akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

const int m = 1e6, M = 1e9+7;
ll inverse[3*m], fact[3*m], invfact[3*m];

ll nCr(ll n, ll r){
    ll ans = fact[n]*invfact[r]%M;
    return (ans*invfact[n-r]%M); 
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int h, a;
    cin>>h>>a;
    if(h%a) cout<<1 +h/a<<"\n";
    else cout<<h/a<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<vector<int>> g(n);
  vector<int> colors(n, -1);
  colors[0] = 1;
  colors[colors.size() - 1] = 0;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  stack<pair<int, int>> st;
  vector<int> vp(n, -1);
  st.push({0, 0});
  while (!st.empty()) {
    auto [idx, p] = st.top();
    st.pop();
    if (vp[idx] >= 0) {
      continue;
    }

    vp[idx] = p;
    for (auto ch : g[idx]) {
      st.push({ch, idx});
    }
  }

  // パスをたどる
  int cur = n - 1;
  vector<int> vpath;
  while (cur != 0) {
    cur = vp[cur];
    if (cur != 0) {
      vpath.push_back(cur);
    }
  }

  int turn_f = vpath.size() / 2 + vpath.size() % 2, turn_s = vpath.size() / 2;
  for (int i = 0; i < vpath.size(); ++i) {
    colors[vpath[i]] = i >= turn_s;
  }

  auto dfs = [&](int c, int init) {
    stack<int> st;
    vector<bool> seen(n, false);
    st.push(init);
    int ans = 0;
    while (!st.empty()) {
      auto idx = st.top();
      st.pop();
      if (colors[idx] != -1 && colors[idx] != c) {
        continue;
      }

      if (seen[idx]) {
        continue;
      }

      seen[idx] = true;
      ans += colors[idx] == -1;
      colors[idx] = c;
      for (auto ch : g[idx]) {
        st.push(ch);
      }
    }

    return ans;
  };

  turn_f += dfs(1, 0);
  turn_s += dfs(0, n - 1);

  if (turn_f == turn_s) {
    turn_s++;
  }

  cout << (turn_s < turn_f ? "Fennec" : "Snuke") << '\n';
  return 0;
}

Measured memory_bytes: 10864
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()
# +からのstart
S = [0]*N
tmp = max(0, 1 - A[0])
S[0] = max(1, A[0])
for i in range(1, N):
    if i%2:
        x = 1 + S[i-1] + A[i]
        if x > 0:
            tmp += x
            S[i] = -1
        else:
            S[i] = S[i-1] + A[i]
    else:
        x = 1 - S[i-1] - A[i]
        if x > 0:
            tmp += x
            S[i] = 1
        else:
            S[i] = S[i-1] + A[i]
ans = tmp*1

# -スタート
S = [0]*N
tmp = max(0, 1 + A[0])
S[0] = min(-1, A[0])
for i in range(1, N):
    if i%2 == 0:
        x = 1 + S[i-1] + A[i]
        if x > 0:
            tmp += x
            S[i] = -1
        else:
            S[i] = S[i-1] + A[i]
    else:
        x = 1 - S[i-1] - A[i]
        if x > 0:
            tmp += x
            S[i] = 1
        else:
            S[i] = S[i-1] + A[i]
ans = min(tmp, ans)
print(ans)

Measured memory_bytes: 14332
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
*/

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int dp[100010];

int main(){
  int n,d,x;
  int p[11][11];
  cin>>n>>d>>x;
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      cin>>p[i][j];
    }
  }

  // 日付
  for(int i=0;i<d-1;i++){
    // 初期化
    for(int j=0;j<x;j++)dp[j]=j;
    // j番目の株式を買った時
    int maxi=x;
    for(int j=0;j<n;j++){
      for(int k=p[i][j];k<x+1;k++){
	dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]);
	maxi=max(maxi,dp[k]);
      }
    }
     x=maxi;
  }
  
  cout<<x<<endl;
  return 0;
}



Measured memory_bytes: 3176
#include<cstdio>
#include<algorithm>
using namespace std;
int A,B,p[101][101],cnt,o[101][101],tot,t[101],mp[101][101];
bool b;
int main(void){
	register int i,j,num,x,y;
	scanf("%d%d",&A,&B);
	printf("%d %d\n",100,100);
	if(A<B)swap(A,B),b=1;
	for(i=1;i<=25;++i){
		if(tot==A)break;
		for(j=1;j<=25;++j){
			++tot;
			for(x=1;x<=3;++x)
				for(y=1;y<=3;++y)
					mp[(i-1)*4+x][(j-1)*4+y]=1;
			if(tot==A)break;
		}
		if(tot==A)break;
	}
	num=B-1;
	for(i=1;i<=25;++i){
		if(cnt==num)break;
		for(j=1;j<=25;++j){
			++cnt;
			mp[(i-1)*4+2][(j-1)*4+2]=0;
			if(cnt==num)break;
		}
		if(cnt==num)break;
	}
	for(i=1;i<=100;++i,putchar('\n'))
		for(j=1;j<=100;++j)
			if(mp[i][j]==1){
				if(b)putchar('#');
				else putchar('.');
			}else{
				if(b)putchar('.');
				else putchar('#');
			}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 

string s[10000];

bool compare( string a, string b)
{
	return a+b < b+a ;
}


int main()
{
	int n,l; cin>>n>>l;

	
	for(int i=0;i<n;i++)
	cin>>s[i];
	
	//sort( s, s+n ,compare);
sort(s, s+n) ;
	
	string ans="";
	
	for( int i=0;i<n;i++) 
	ans= ans + s[i];
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>

using namespace std;

int main() {
  std::array<int, 3> as;
  for (auto& a : as) {
    std::cin >> a;
  }
  std::sort(as.begin(), as.end());
  int ret = 0;
  int previous = as[0];
  for (auto&& a : as) {
    ret += abs(a - previous);
    previous = a;
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

def dfs(s):
  if int(s) > N:
    return 0
  if all(s.count(c) > 0 for c in '753'):
    ret = 1
  else:
    ret = 0
  for c in '753':
    ret += dfs(s + c)
  return ret
print(dfs('0'))

Measured memory_bytes: 9088
#include<bits/stdc++.h>

using namespace std;

int main(){
    char c[2][3];
    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    if(c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


}

Measured memory_bytes: 256
n,nn=map(int,input().split())
l=[list(map(int,input().split()))for i in range(nn)]
l.reverse()
m=[[1,i] for i in range(n)]
ans=[]
ans.append(n*(n-1)//2)
for a,b in l:  #10^5
  #print(m)
  a-=1
  b-=1
   
  while a!=m[a][1]:
    a=m[a][1]
  
  while b!=m[b][1]:
    b=m[b][1]
    
  if a==b:
    ans.append(ans[len(ans)-1])
    continue
  #a=b
  
  ans.append(ans[len(ans)-1]-m[a][0]*m[b][0])
  if a<b:
    a,b=b,a
  #a>=b
  m[a][0]+=m[b][0]
  m[b][0]=0
  m[b][1]=a
ans.reverse()
for a in ans[1:]:
  print(a)

Measured memory_bytes: 42428
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[0]-h[1])

for i in range(2, n):
  dp[i] = min([dp[j] + abs(h[i]-h[j]) for j in range(max(0, i-k), i)])

print(dp[-1])


Measured memory_bytes: 55264
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z;
    return 0;
}


Measured memory_bytes: 256
// author - shreyanshjn (Shreyansh Jain)
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
/* #define input 1 */
#define INF 100000000000000000
#define endl '\n'
#define debug(x) cout<<#x<<": "<<x<<endl
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define rep(a,b,c) for(int a=b; a<c; a++)
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
const int mod = 1e9 + 7;
int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
string trim(const string& str) {
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}
int main() { 
    #ifdef input
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(15);
    int n; cin >> n;
    int arr[n];
    fori(0, n) cin >> arr[i];
    int dp[n];
    dp[0] = 0; dp[1] = abs(arr[1] - arr[0]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 2] + abs(arr[i] - arr[i - 2]), dp[i - 1] + abs(arr[i] - arr[i - 1]));
    }
    cout << dp[n - 1] << endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


Measured memory_bytes: 4448
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;
struct UnionFind {
  vector<int> d;
  UnionFind(int n){
    d.resize(n,-1);
  }
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    --x; --y;
    uf.unite(x,y);
  }
  int ans = 0;
  rep(i,n) ans = max(ans,uf.size(i));
  cout << ans << endl;
  return 0;
  
}


Measured memory_bytes: 4040
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	 Scanner reader  =new Scanner(System.in);	
	 int r=reader.nextInt();
	 int g=reader.nextInt();
	 int b=reader.nextInt();
	 int c=r*100+g*10+b*1;
	 if(c%4==0) {
		 System.out.println("YES");
		 
	 }
	 else {
		 System.out.println("NO");
	 }
	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
	float a;
	float b;
	float x;
	
	scanf("%f %f", &a, &b);
	
	x = (a + b) / 2;
	
	if (x != (int)x){
		printf("%d", (int)x + 1);
	}
	else {
		printf("%d", (int)x);
	}
	return 0;
}

Measured memory_bytes: 128
from math import sqrt
import itertools

N = int(input())
coordinate = []
for _ in range(N):
    x, y = map(int, input().split())
    coordinate.append((x, y))

def minR(x1, y1, x2, y2, x3, y3):
    """
    3点(x1, y1), (x2, y2), (x3, y3)を通る円の半径を返す
    """
    # 3点が同一直線状にある場合は先に処理
    if (x3 - x1) * (y2 - y1) == (y3 - y1) * (x2 - x1):
        C = [(x1, y1), (x2, y2), (x3, y3)]
        C.sort()
        m = (C[0][0] + C[2][0]) / 2
        n = (C[0][1] + C[2][1]) / 2
        return m, n, sqrt((m - C[0][0]) ** 2 + (n - C[0][1]) ** 2)
    else:
        # middle point
        m12 = (x1 + x2) / 2
        n12 = (y1 + y2) / 2
        m13 = (x1 + x3) / 2
        n13 = (y1 + y3) / 2
        m23 = (x2 + x3) / 2
        n23 = (y2 + y3) / 2

        if y1 == y2:
            x0 = m12
            y0 = n13 - (x3 - x1) * (x0 - m13) / (y3 - y1)
        elif y1 == y3:
            x0 = m13
            y0 = n12 - (x2 - x1) * (x0 - m12) / (y2 - y1)
        elif y2 == y3:
            x0 = m23
            y0 = n12 - (x2 - x1) * (x0 - m12) / (y2 - y1)
        else:
            r12 = (x2 - x1) / (y2 - y1)
            r13 = (x3 - x1) / (y3 - y1)
            x0 = (n12 - n13 + m12 * r12 - m13 * r13) / (r12 - r13)
            y0 = n12 - (x2 - x1) * (x0 - m12) / (y2 - y1)

        return x0, y0, sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2)


if N == 2:
    m = 0
    n = 0
    x = 0
    y = 0
    for c in coordinate:
        x = c[0]
        y = c[1]
        m += c[0] / 2
        n += c[1] / 2
    print(sqrt((x - m) ** 2 + (y - n) ** 2))
else:
    ans = float("inf")
    L = [i for i in range(N)]
    for pair in list(itertools.combinations(L, 3)):
        x1, y1 = coordinate[pair[0]]
        x2, y2 = coordinate[pair[1]]
        x3, y3 = coordinate[pair[2]]

        m12 = (x1 + x2) / 2
        n12 = (y1 + y2) / 2
        m13 = (x1 + x3) / 2
        n13 = (y1 + y3) / 2
        m23 = (x2 + x3) / 2
        n23 = (y2 + y3) / 2

        x0, y0, r = minR(x1, y1, x2, y2, x3, y3)
        # 2点の中点を中心に持つ円が最適の場合もある!!!!!!!!!!（尖った菱形とか）
        x12, y12, r12 = m12, n12, sqrt((x1 - m12) ** 2 + (y1 - n12) ** 2)
        x13, y13, r13 = m13, n13, sqrt((x1 - m13) ** 2 + (y1 - n13) ** 2)
        x23, y23, r23 = m23, n23, sqrt((x2 - m23) ** 2 + (y2 - n23) ** 2)

        # 全ての点が含まれるかチェック
        for x, y in coordinate:
            r = max(r, sqrt((x - x0) ** 2 + (y - y0) ** 2))
            r12 = max(r12, sqrt((x - x12) ** 2 + (y - y12) ** 2))
            r13 = max(r13, sqrt((x - x13) ** 2 + (y - y13) ** 2))
            r23 = max(r23, sqrt((x - x23) ** 2 + (y - y23) ** 2))

        ans = min(ans, r, r12, r13, r23)

    print(ans)


Measured memory_bytes: 66920
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

struct abc { ll a, b, c; };

bool comp(abc a, abc b) {
  if (a.a != b.a) {
    return a.a > b.a;
  } else {
    return a.c < b.c;
  }
}

int main() {
  int n;
  cin >> n;

  vector<ll> vec(n);
  ll ans = 0;

  for (int i = 0; i < n; i++) {
    ll aa, bb;
    cin >> aa >> bb;
    ans -= bb;
    vec[i] = aa+bb;
  }

  sort(vec.begin(), vec.end(), greater<ll>() );

  for (int i = 0; i < n; i++) {
    if ( !(i & 1) ) {
      ans += vec[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

num = [2, 5, 5, 4, 5, 6, 3, 7, 6]

N, M = getNM()
A = getList()

digit = []
for i in A:
    digit.append([i, num[i - 1]])
digit.sort(key = lambda i: i[1])

dp = [-float('inf')] * (N + 1)
dp[0] = 0

# 桁数を調べる
for i in range(1, N + 1):
    for j in range(M):
        if i >= digit[j][1]:
            dp[i] = max(dp[i], dp[i - digit[j][1]] + 1)

# 数字を組み上げる
ans = ''
now = N
digit.sort(reverse = True)
while now > 0:
    for j in range(M):
        if now - digit[j][1] >= 0 and dp[now] == dp[now - digit[j][1]] + 1:
            now -= digit[j][1]
            ans += str(digit[j][0])
            break
print(ans)

Measured memory_bytes: 78868
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }

  sort(b.begin(), b.end(), greater<int>());

  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    if (a[i] == b[0]) {
      cout << b[1] << endl;
    } else {
      cout << b[0] << endl;
    }
  }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;

int main() {
  long int n;
  long int k;
  long int h[200001];
  long int sum_a = 0;
  long int sum_k = 0;
  cin >> n >> k ;
  if ( n <= k ) {
    cout << 0 << endl;
    return 0; 
  }
  // cout << h << " " << n << " " << sum_a << " ";
  for ( int i=0 ; i < n ; ++i ) {
    cin >> h[i] ;
    sum_a = sum_a + h[i]; 
  }
  sort(h , h + n , greater<long int>());
  for ( int i=0 ; i < k ; ++i ) {
    sum_k = sum_k + h[i];
  }
  // cout << a << " " << sum_a ;
  cout << sum_a - sum_k << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

ll dp[2020][2020]; // dp[i][j] := checked S[0]~S[i], T[0]~T[j]
ll sum[2020][2020];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> S(N),T(M);
    REP(i,N) cin >> S[i];
    REP(i,M) cin >> T[i];

    REP(i,N) sum[i][0] = 1;
    REP(i,M) sum[0][i] = 1;
    ll ans = 1;
    REP(i,N){
        REP(j,M){
            if(S[i]==T[j]) dp[i+1][j+1] = sum[i][j], ans = (ans + dp[i+1][j+1])%MOD;
            else dp[i][j] = 0;
            sum[i+1][j+1] = (sum[i][j+1] + sum[i+1][j] + MOD - sum[i][j] + dp[i+1][j+1])%MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 63744
#include<bits/stdc++.h>

using namespace std;


int main(){
	
	int a,b;
	cin >> a >> b;
	if(a >= 6 && a <= 12){
		cout << b/2;
	}else if(a >= 13){
		cout << b;
	}
	else
		cout << 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>

# define pb push_back
# define ll long long

using namespace std;

ll z , o ;

	
int main() {

	string s ;
	cin >> s ;
	if( ( s[0] == s[1] && s[0] != s[2] ) || ( s[0] == s[2] && s[0] != s[1] ) || ( s[1] == s[2] && s[0] != s[1]) ){
		cout << "Yes" << endl ;
	}
	else{
		cout << "No" << endl ;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        
        if(a<=c&&a+b>=c)
        {
            cout<<"YES"<<endl;
        }
        else 
        {
            cout<<"NO"<<endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};


int main()
{
    int N, M;
    cin >> N >> M;
    if (abs(N - M) > 1)
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    REP(i,1,N+1){
        ans *= i;
        ans %= MOD;
    }
    REP(i,1,M+1){
        ans *= i;
        ans %= MOD;
    }
    if(N==M){
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  	long int N, summ, i;
  	i = 1;
  	summ = 0;
  
  	scanf("%ld", &N);
  
  	while(i <= N){
    	if (i%3!=0&&i%5!=0){
          summ += i;
        }
      	i++;
    }
  
  	printf("%ld", summ);
  return 0;
}

Measured memory_bytes: 1732
import scala.io.Source

object Main extends App {
  val src = Source.stdin.getLines
  val org_dice = src.next.split(" ").map(_.toInt).toList
  val directions = src.next

  def sDirection(dice: List[Int]) = List(dice(4), dice(0), dice(2), dice(3), dice(5), dice(1))
  def nDirection(dice: List[Int]) = List(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
  def wDirection(dice: List[Int]) = List(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  def eDirection(dice: List[Int]) = List(dice(3), dice(1), dice(0), dice(5), dice(4), dice(2))

  def roll(dice: List[Int], direction: Char): List[Int] = direction match {
    case 'N' => nDirection(dice)
    case 'S' => sDirection(dice)
    case 'E' => eDirection(dice)
    case 'W' => wDirection(dice)
  }

  println(directions.foldLeft(org_dice)(roll).head)
}

Measured memory_bytes: 44256
#include <bits/stdc++.h>
using namespace std;
int d,g,ans=1000000,sum,rest,num;
int main(){
    scanf("%d %d",&d,&g);
    int p[d],c[d];
    for(int i=0;i<d;i++) scanf("%d %d",&p[i],&c[i]);
    for(int bit=0;bit < (1<<d);bit++){
        sum=rest=num=0;
        for(int i=0;i<d;i++){
            if(bit & (1<<i)){
                sum+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }
            else rest=i;
        }
		if(sum>=g)
            ans=min(ans,num);
		else if(sum<g){
            int sh = g-sum;
            int sum2=0;
            int num2=0;
            for(int j=0;j<p[rest];j++){
                sum2=100*(rest+1)*(j+1);
                num2++;
                if(j==p[rest]-1) sum2+=c[rest];
				if(sum2>=sh){
                    ans=min(ans, num+num2);
                    break;
                }
            }
        }
    }
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  
  string abc = "ABC";
  int count = 0;
  
  for (int i = 0; i < n;){
    if (s.substr(i, 3) == abc) {
      count += 1;
      i += 3;
    } else {
      i += 1;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import itertools

N,M,Q=map(int,input().split())
abcd = [tuple(int(v2) for v2 in input().split()) for _ in range(Q)]
#print(abcd)
def getScore(ary):
  score = 0
  for a,b,c,d in abcd:
    #print(a,b,ary)
    if ary[b-1]-ary[a-1] == c:
      score+=d
  return score
C=[i for i in range(M+N-1)]
As =[]
for c in itertools.combinations(C,N):
  #print(c)
  tmp = [0 if i in c else 1 for i,v in enumerate(C) ]
  l = [sum(tmp[:i]) for i,v in enumerate(tmp) if v == 0]
  As.append(l)
#print(As)
scores = [getScore(a) for a in As]
#print(scores)
print(max(scores))

Measured memory_bytes: 31124
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

const int N = 1e5 + 1;
vector<int > graph[N];

void bfs(int n, int s, int ans[]) {
    ans[s] = 1;
    queue<int> q;
    q.push(s);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        // cout<<v<<" source\n";
        for(int b: graph[v]) {
            if(ans[b] == 0) {
                ans[b] = 1;
                q.push(b);
            }
        }
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i) {
        int u,v,w;
        cin>>u>>v>>w;
        graph[u-1].push_back(v-1);
        graph[v-1].push_back(u-1);
    }

    int ans[n] = {0};

    int count = 0;
    for(int i=0;i<n;++i) {
        if(ans[i] == 0) {
            // cout<<i<<"\n";
            ++count;
            bfs(n,i,ans);
        }
    }

    cout<<count;

    return 0;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
typedef long long l;
int main()
{
    l X,N,p;
    cin>>X>>N;
    l A[101]={0};
    for(l i=0;i<N;i++)
    {
        cin>>p;
        A[p]=1;
    }
    if(A[X]==0)
    {
        cout<<X;
        exit(0);
    }
    l ans,cnt=1;
    while(true)
    {
        if(X-cnt>=0)
        {
            if(A[X-cnt]==0)
            {
                ans=(X-cnt);
                break;
            }
            if(X+cnt>100)
            {
                ans=(X+cnt);
                break;
            }
            if(A[X+cnt]==0)
            {
                ans=(X+cnt);
                break;
            }
        }
        else{
            ans=(X-cnt);
            break;
        }
        cnt++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3628
h, w = map(int, input().split())
s = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        flag = 1
        if s[i][j] == "#":
            if i > 0:
                if s[i - 1][j] == "#":
                    flag = 0
            if i < h - 1:
                if s[i + 1][j] == "#":
                    flag = 0
            if j > 0:
                if s[i][j - 1] == "#":
                    flag = 0
            if j < w - 1:
                if s[i][j + 1] == "#":
                    flag = 0
            if flag == 1:
                print("No")
                exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
vector<string> s(3);
queue<char>a;
queue<char>b;
queue<char>c;
int main(int argc,char const* argv[])
{
  cin >> s[0] >> s[1] >> s[2];
  for(int i=0;i<3;i++)
    {
      for(int j=0;j<s[i].size();j++)
	{
	  if(i==0) a.push(s[i][j]);
	  else if(i==1) b.push(s[i][j]);
	  else if(i==2) c.push(s[i][j]);
	}
    }
  char turn=a.front();a.pop();
  while(1)
    {
      if(turn=='a')
	{
	  if(a.empty())
	    {
	      cout << 'A' << endl;
	      return 0;
	    }
	  turn=a.front();
	  a.pop();
	}
      else if(turn=='b')
	{
	  if(b.empty())
	    {
	      cout << 'B' << endl;
	      return 0;
	    }
	  turn=b.front();
	  b.pop();
	}
      else if(turn=='c')
	{
	  if(c.empty())
	    {
	      cout << 'C' << endl;
	      return 0;
	    }
	  turn=c.front();
	  c.pop();
	}
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define llu unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction


#define inf 99999999
#define MX 1000006
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int e1,e2,e3;
    data() {}
    data(int a,int b,int c)
    {
        e1=a,e2=b,e3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.e1> b.e1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;

int a[55],b[55],c[55],d[55];
int main()
{
    int t,tc=1;
	sf2(n,m);
	for(int i=1;i<=n;i++){
		sf2(a[i],b[i]);
	}
	for(int i=1;i<=m;i++){
		sf2(c[i],d[i]);
	}
	for(int i=1;i<=n;i++){
		int tmp=0;
		ll dis=100000000000000;
		for(int j=1;j<=m;j++){
			//if(c[j]=-9999999999) continue;
			ll x=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(x<dis){
				tmp=j;
				dis=x;
			}
		}
		//c[tmp]=-9999999999;
		pfi(tmp);
		NL;
	}

    return 0;
}

/*




*/


Measured memory_bytes: 256
import itertools

while True:
    n, x = map(int,input().split())
    if n == 0 and x == 0 :
        break
    N = list(range(1,n+1))
    k = 0
    for i in itertools.combinations(N, 3):
        if sum(i) == x:
            k += 1
    print(k)


Measured memory_bytes: 5632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int judge(string s){
	for(int i=0;i<s.length();i++){
		if(s[i]!=s[s.length()-1-i]){
			return 0;
		}
	}
	return 1;
}
ll num[maxn];
ll a[maxn];
int main() {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) num[a[i]]++;
	ll sum = 0;
	for(int i=1;i<=n;i++){
		if(num[i]>=2) sum+=((num[i]*(num[i]-1LL))/2LL);
	//	cout<<sum<<endl;
	}
	for(int i=1;i<=n;i++){
		ll t = sum;
		//cout<<num[a[i]]<<endl;
		t-=((num[a[i]]*(num[a[i]]-1LL))/2LL);
		//cout<<t<<endl;
		t+=((num[a[i]]-1)*(num[a[i]]-2LL))/2;
		cout<<t<<endl;
	}
    return 0;
}



Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,a,b,ans,max=0;
    scanf("%d",&n);
    for (int i=0; i<n; i++){
        scanf("%d%d",&a,&b);
        if (a>max){
            max=a;
            ans=a+b;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;

const int N = 400003;
int n, a[N], b[N];

vector <int> ans;

signed main(void)
{
	//后面影像前面 
	scanf("%d", &n);
	for(int i=1; i<=n; ++i)
		scanf("%d", &a[i]);
	for(int i=n; i>=1; --i)
	{
		int res = 0;
		for(int j=i+i; j<=n; j+=i)
			res+=b[j];
		if(res %2 != a[i]){
		 b[i] = 1;
	ans.push_back(i);
	}
	}	
	printf("%d\n", ans.size());
	for(int i=0; i<ans.size(); ++i)
	printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 2936
#include <iostream>
using namespace std ;
int main()
{
  int num1 , num2 , num3 ;
  
  cin >> num1 >> num2 >> num3 ;
  
  int num4 = num3 - num1 + num2 ;
  
  if(num4 >=0){
    cout << num4 <<endl ;
  }
  else if(num4 < 0){
    cout << 0 <<endl ;
  }
  return 0 ;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;


#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 961748941;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2505 + 5;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

struct edge
{
  int u,v,c;
  edge(int u, int v, int c) : u(u), v(v), c(c) {}
  edge(){}
};
vector<edge>edges;

ll dist[maxn];

int vis[2][maxn];
vector<int>graph[maxn];
vector<int>rev[maxn];

void dfs(int u, int p)
{
  vis[p][u] = 1;
  for(const auto &v : p == 0 ? graph[u] : rev[u])
  {
    if(!vis[p][v])
      dfs(v, p);
  }
}

int main()
{
  int n,m,p;
  cin >> n >> m >> p;
  for(int i = 0 ; i < m ; i++)
  {
    int u,v,c;
    cin >> u >> v >> c;
    edges.push_back(edge(u, v, p - c));
    graph[u].push_back(v);
    rev[v].push_back(u);
  }
  MSET(dist, INF);
  dfs(1, 0);
  dfs(n, 1);
  dist[1] = 0;
  for(int i = 1; i <= n; i++)
  {
    for(int j = 0 ; j < edges.size(); j++)
    {
      int u = edges[j].u;
      int v = edges[j].v;
      int c = edges[j].c;
      if(!vis[1][v] || !vis[0][u])
        continue;
      if(!vis[0][v] || !vis[1][u])
        continue;
      if(dist[u] != INF && dist[v] > dist[u] + c)
      {
        dist[v] = dist[u] + c;
      }
    }
  }

  for(int i = 0 ; i < m; i++)
  {
    int u = edges[i].u;
    int v = edges[i].v;
    int c = edges[i].c;
    if(!vis[1][v] || !vis[0][u])
      continue;
    if(!vis[0][v] || !vis[1][u])
      continue;
    
    if(dist[u] != INF && dist[u] + c < dist[v])
    {
      cout << "-1\n";
      return 0;
    }
  }

  cout << max(0LL,-dist[n]) << endl;

  return 0;
}

Measured memory_bytes: 3952
s = list(map(int,list(str(input()))))
if len(s)==1:
    print(0)
    exit()
sum_odd = sum(s[0::2])
sum_even = sum(s[1::2])
if_odd = len(s[0::2])-sum_odd +sum_even
if_even = len(s[1::2])-sum_even +sum_odd
print(min([if_odd,if_even]))

Measured memory_bytes: 4652
#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b;
  cin >> a >> b;

  if (a < 9 && b < 9)
    cout << "Yay!\n";
  else
    cout << ":(\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<int> city(n, 0);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    city[a-1]++;
    city[b-1]++;
  }
  for(int i = 0; i < n; i++)
    cout << city[i] << endl;
  return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A -=1
        tmp = A // 2
        A -= tmp
        B += tmp

    else:
        if B % 2 != 0:
            B -=1
        tmp = B // 2
        B -= tmp
        A += tmp
print(A, B)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;

int main() {
  int K, X;
  cin >> K >> X;
  
  int a = max(X - (K - 1), -1000000);
  int b = min(X + (K - 1), 1000000);
  
  for (int i = a; i <= b; i++) {
    cout << i << " ";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int main(){
    int n,t,e,x,f=1;
    cin>>n>>t>>e;
    LP(i,n){
        cin>>x;
        int j=1;
        while(x*j<=t+e){
            if(x*j>=t-e&&f==1){
                cout<<i+1<<endl;
                f=0;
            }
            j++;
        }
    }
    if(f) cout<<-1<<endl;
    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int res[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int last = 0;
	for (int i = 0; i < s.length(); ++i)
		if (s[i] == 'R')
			last = i;
		else {
			if ((i - last) & 1)
				++res[last + 1];
			else
				++res[last];
		}
	last = 0;
	for (int i = s.length() - 1; i >= 0; --i)
		if (s[i] == 'L')
			last = i;
		else {
			if ((last - i) & 1)
				++res[last - 1];
			else
				++res[last];
		}
	for (int i = 0; i < s.length(); ++i)
		cout << res[i] << ' ';
	cout << '\n';
	return 0;
}

Measured memory_bytes: 1104
#include <cstdio>

int a, b;

int main(){
    scanf("%d %d", &a, &b);

    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    printf("Possible\n");
    else
    printf("Impossible\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int cn) {
    int a,b,c,d,e;
    string s,t,u;
    cin>>a;

    cout<<((a>=30)?"Yes":"No")<<endl;


}


#define SINGLE
int main() {
#ifdef SINGLE
    solve(1);
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve(i);
    }
#endif
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
#define MAX 10100

int prime[MAX];

void is_prime(){
  for(int i = 0 ; i < MAX ; i++) prime[i] = 0;
  prime[0] = prime[1] = 1;

  for(int i = 2 ; i*i < MAX ; i++)
    if(!prime[i])
      for(int j = 2*i ; j < MAX ; j += i)
	prime[j] = 1;
}

int main(){
  int n;

  is_prime();
  while(cin >> n){
    int cnt = 0;
    for(int i = 1, j = n ; i <= n && j >= 1 ; i++,j--)
      if(!prime[i]&&!prime[j]) cnt++;

    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    s = input()
    if s[-1] == "s":
        print(s+"es")
    else:
        print(s+"s")






if __name__=="__main__":
    main()


Measured memory_bytes: 66944
#include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum[ohara],pos,k,sei[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);

      
      cin>>n>>k;
      rep(i,n){
        cin>>a;
        sum[i]=a;
        if(a>0)sei[i]=a;
      }
      rep(i,n-1){
        sum[i+1]+=sum[i];
        sei[i+1]+=sei[i];
      }
      //黒(スコアin)
      rep(i,n-k+1){
        if(i==0)cnt=sum[i+k-1];
        else cnt=sum[i+k-1]-sum[i-1];
        if(i!=0)cnt+=sei[i-1];
        cnt+=sei[n-1]-sei[min(i+k-1,n-1)];
        ans=max(ans,cnt);
      }
      //白(スコアout)
      rep(i,n-k+1){
        cnt=0;
        if(i!=0)cnt+=sei[i-1];
        cnt+=sei[n-1]-sei[min(i+k-1,n-1)];
        ans=max(ans,cnt);
      }
      Cout(ans);

       
return 0;
}


Measured memory_bytes: 5120
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
#define R register
#define MAXN 5010
#define mo 10000007
#define base 137
using namespace std;
int l,r,mid,n;
char S[MAXN]; int pow[MAXN],hash[MAXN];
int poww[MAXN],hashh[MAXN];
inline int get(int l,int r)
{
	return (hash[r] - hash[l - 1] * pow[r - l + 1] % mo + mo) % mo;
}
inline int gett(int l,int r)
{
	return (hashh[r] - hashh[l - 1] * poww[r - l + 1] % mo + mo) % mo;
}
inline bool check()
{
	for(R int i = 1; i + mid - 1 <= n; i++)
		for(R int j = i + mid; j + mid - 1 <= n; j++)
			{ //printf("%d %d   %d %d\n",i,i+mid-1,j,j+mid-1);
			if(get(i,i+mid-1) == get(j,j+mid-1) && gett(i,i+mid-1) == gett(j,j+mid-1)) return true;
		} return false;
}
main()
{
	scanf("%lld%s",&n,S+1); pow[0] = poww[0] = 1;
	for(R int i = 1; i <= n; i++)
		pow[i] = (pow[i-1] * base) % mo,
		hash[i] = (hash[i-1] * base % mo + S[i] - '0') % mo,
		poww[i] = (poww[i-1] * 107) % mo,
		hashh[i] = (hashh[i-1] * 107 % mo + S[i]) % mo;
	//	printf("%d %d\n",pow[i],hash[i]);
	l = 1, r = n; int ans = 0;
	while(l <= r){
		mid = l + r >> 1;
		if(check()) ans = mid,l = mid + 1;
		else r = mid - 1;
	} printf("%lld",ans); //printf("%d %d",gett(1,2),gett(3,4));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;


void solve(long long N, long long L){
    ll a=N*L+N*(N+1)/2-N;
    ll b=L+N-1;
    rep(i,N){
        b=min(abs(b),abs(L+i));
    }
    if(a==0){
        cout<<b<<endl;
        return;
    }
    else{
    cout<<a*(abs(a)-abs(b))/abs(a)<<endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    solve(N, L);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

void trace(int A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i != N-1)
		{
			printf("%d ", A[i]);
		}
		else
		{
			printf("%d\n", A[i]);
		}
	}
}

int sort(int A[], int N)
{
	int sw = 0;
	bool flg = true;
	while (flg)
	{
		for (int i = 0; flg; i++) 
		{
			flg = false;
			for (int j = N - 1; j >= i + 1; j--)
			{
				if (A[j] < A[j - 1])
				{
					std::swap(A[j], A[j - 1]);
					flg = true;
					sw++;
				}
			}

		}
	}
	trace(A, N);
	return sw;
}

int main(void)
{
	int N;
	scanf("%d", &N);

	int A[100];
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}
	printf("%d\n", sort(A, N));
}



Measured memory_bytes: 3216