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

int main(){
    int N,Q;
    scanf("%d %d",&N,&Q);
    string S;
    cin>>S;
    int l[Q],r[Q];
    rep(i,Q)scanf("%d %d",&l[i],&r[i]);

    vector<int>acs;
    for(int i=0;i<N-1;i++)
        if(S[i]=='A'&&S[i+1]=='C')acs.push_back(i);
    
    int ir,il;
    rep(i,Q){
        il=lower_bound(acs.begin(),acs.end(),l[i]-1)-acs.begin();
        ir=upper_bound(acs.begin(),acs.end(),r[i]-2)-acs.begin();
        if(ir-il<0){
            printf("%d\n",0);
        }else{
            printf("%d\n",ir-il);
        }
    }
}

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define scnf scanf
#define scnaf scanf
#define CRLF <<'\n';
#define ALL(v) v.begin,v.end()
#define SIZE(v) (int)v.size()
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    ll c=7;
    rep(i,1,n+1){
        if (c %n ==0){
            cout << i;
            return 0;
        }else{
            c= (c%n)*10+7;
        }
    }
    cout << -1;

}


Measured memory_bytes: 3744
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
A = [0] + list(map(int, readline().split()))
for i in range(1, N):
    A[i] += A[i-1]

INF = 10**9+7
B = [list(map(int, readline().split())) for _ in range(N)] + [[INF]*M] + [[0]*M]
right = [[0]*M for _ in range(N)]

for m in range(M):
    L = list(range(N))
    L.sort(key = lambda x: B[x][m])
    RR = list(range(1, N+3))
    LL = list(range(-1, N+1))
    for vn in L:
        vn += 1
        right[vn-1][m] = RR[vn]-1
        RR[LL[vn]] = RR[vn]
        LL[RR[vn]] = LL[vn]

diff = [0]*(N+1)
for m in range(M):
    diff[0] += B[0][m]
    pre = B[0][m]
    for i in range(1, N):
        if B[i][m] > pre:
            diff[i] += B[i][m]-pre
            pre = B[i][m]

offset = 0
ans = 0
for l in range(N):
    offset += diff[l]
    for m in range(M):
        if B[l][m] < B[l-1][m]:
            oldr = right[l-1][m]
            diff[oldr] -= B[oldr][m] - B[l-1][m]
            offset += B[l][m] - B[l-1][m]
            cnt = l
            while cnt < N and right[cnt][m] <= oldr:
                rcm = right[cnt][m]
                diff[rcm] += B[rcm][m] - B[cnt][m]
                cnt = rcm
    ans = max(ans, offset)
    roff = offset
    for r in range(l+1, N):
        roff += diff[r]
        ans = max(ans, roff - (A[r]-A[l]))
        #print(l, r, roff - (A[r] - A[l]))

print(ans)

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

int main () {
  map<string, int> s; 
  string skey[102], tkey[102];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> skey[i];
    s[skey[i]]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> tkey[i];
    s[tkey[i]]--;
  }
  int ans;
  for (int i = 0; i < n; i++) {
    ans = max(ans, s[skey[i]]);
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys

a=[int(i)-1 for i in sys.stdin]
N=a[0]+1
a=a[1:]

done=[False]*N

ans=0
i=0

while True:
  if done[i]==False:
    done[i]=True
    ans+=1
    if a[i]==1:
      break
    i=a[i]

  
  else:
    ans=-1
    break
    
print(ans)
    

Measured memory_bytes: 7840
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  int[] x = new int[5];
  while (in.hasNext()) {
	for (int i = 0; i < x.length; i++) {
	  x[i] = in.nextInt();
	}
	swap(x, 0, 1);
	swap(x, 3, 4);
	swap(x, 0, 3);
	swap(x, 1, 4);
	swap(x, 0, 2);
	swap(x, 2, 4);
	swap(x, 1, 3);
	swap(x, 2, 3);
	swap(x, 1, 2);

	for (int i = 0; i < 4; i++) {
	  System.out.print(x[i]);
	  System.out.print(' ');
	}
	System.out.println(x[4]);
  }
}

private static void swap(int x[], int a, int b) {
  if (x[a] < x[b]) {
	int t = x[a];
	x[a] = x[b];
	x[b] = t;
  }
}
}

Measured memory_bytes: 0
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => {

  const sec = parseInt(input);
  const hour = parseInt(sec / 3600);
  const minute = parseInt(sec / 60 % 60);
  const second = parseInt(sec % 60)

  output = hour + ':' + minute + ':' + second;
  console.log(output)
})



Measured memory_bytes: 15296
# coding: utf-8


def main():
    s, c = map(int, input().split())

    result = s - int(c / 2)

    if result < 0:
        r = result * -2
        r = int(r / 4)
        print(s + r)
    else:
        print(s - result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define oo (int)1e9
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e3 + 5, M = 2 * N + 5;

int a[N];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);
    sort(a, a + n);
    int ans = 0;
    for(int i = 0 ; i < n ; ++i){
        for(int j = i + 1 ; j < n ; ++j){
            int tani = lower_bound(a, a + n, a[i] + a[j]) - a - 1;
            ans += (tani - j);
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1e9+7	// int 1000000007
const int inf{int(1e9)};	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;


int main(void) {
	int W, a, b;
	cin >> W >> a >> b;

	if (a + W <= b) cout << b - (a + W) << endl;
	else if (a <= b) cout << 0 << endl;
	else if (b + W <= a) cout << a - (b + W) << endl;
	else cout << 0 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    sort(a.begin(),a.end());
    int ans = a[N-1] - a[0];
    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
v = [0 for i in range(N)]
ab = []
for i in range(M):
  l = list(map(int, input().split()))
  ab.append(l)
  
for val in ab:
  if H[val[0] - 1] == H[val[1] - 1]:
    v[val[0] - 1] = 1
    v[val[1] - 1] = 1
  elif H[val[0] - 1] < H[val[1] - 1]:
    v[val[0] - 1] = 1
  else:
    v[val[1] - 1] = 1
    
ans = v.count(0)
print(ans)

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

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

using namespace std;
typedef pair<int,int> pii;

const int INF = 0x3fffffff;

class Flow{
	public:
	int N, en;
	vector<int> C, F;
	vector< vector<pii> > edge;
	Flow(int n, int e): C(e+1), F(e+1), N(n), edge(n){ en=0; }
	void addEdge(int f, int t, int c){
		en++;
		edge[f].emplace_back(t,  en);
		edge[t].emplace_back(f, -en);
		C[en] = c;
	}
	int flow(int n, int c, int T, vector<bool> &bf){
		if( n == T ) return c;
		bf[n] = true;
		for(auto to: edge[n]){
			int i = to.second;
			int cc = ( i>0 ? C[i]-F[i] : F[-i] );
			if( bf[to.first] || cc == 0 ) continue;
			int f = flow(to.first, min(c, cc), T, bf); 
			if( f > 0 ){
				F[ abs(i) ] += f * (i/abs(i));
				return f;
			}
		}
		return 0;
	}
	int maxFlow(int S, int T){
		for(int ret=0;;){
			vector<bool> bf(N);
			int add = flow(0, INF, T, bf);
			ret += add;
			if( add==0 ) return ret;
		}
	}
	void clear(){
		fill( F.begin(), F.end(), 0 );
	}
};

int V, E;
int C[1005];
int F[1005];
vector<pii> e[105];
int solve(int n, int c, bool bf[105]){
	if( n == V-1 ) return c;
	bf[n] = true;
	for(auto to: e[n]){
		int i = to.second;
		int cc = ( i>0 ? C[i]-F[i] : F[-i] );
		if( bf[to.first] || cc == 0 ) continue;
		int flow = solve(to.first, min(c, cc), bf); 
		if( flow > 0 ){
			F[ abs(i) ] += flow * (i/abs(i));
			return flow;
		}
	}
	return 0;
}

int main(){
	cin >> V >> E;
	Flow fl(V,E);
	for(int i=1; i<=E; i++){
		int u, v, c;
		cin >> u >> v >> c;
//		e[u].emplace_back(v,  i);
//		e[v].emplace_back(u, -i);
//		C[i] = c;
		fl.addEdge( u, v, c );
	}
//	int ans = 0;
//	while(1){
//		bool bf[105] = {};
//		int add = solve(0, INF, bf);
//		ans += add;
//		if( add == 0 ) break;
//	}

	cout << fl.maxFlow(0, V-1) << endl;

	return 0;
}

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

using namespace std;

int N, ans;

int main() {
    cin >> N;
    ans = N % 10;
    if (ans == 3) {
        cout << "bon";
    }
    else if (ans == 0 or ans == 1 or ans == 6 or ans == 8) {
        cout << "pon";
    }
    else {
        cout << "hon";
    }
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {

    public static void main(String[] args) {

        try {
            //?¨????????????????1?????\??????????????????????????°??????????????????????????¨??\???????????????????????§???
            //?????????????????§"3 8 1" ??¨??\????????¨??????????????????
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String inputData;
            //??\????????????????????????inputData?????????????????????
            inputData = reader.readLine();
            String[] strArray = inputData.split(" ");

            //???????????¨???List???????´?
            List<Integer> list = new ArrayList<Integer>();
            for(int i=0;i<strArray.length;i++){
                list.add(Integer.valueOf(strArray[i]));
            }
            //???????????????
            Collections.sort(list);

            //??????
            System.out.println(list.get(0) + " " + list.get(1) + " " + list.get(2));

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}

Measured memory_bytes: 24228
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<algorithm>
#include <cstring>
#include<set>
#include<cmath>
# define ll long long 
using namespace std;

int main()
{
	ll k,a,b;
	cin>>k>>a>>b;
	int flag=0;
	for(int i=a;i<=b;++i)
	{
		if(i%k==0)
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout<<"OK\n";
	else
		cout<<"NG\n";
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
//Z function is the greatest number of character starting from position i that coincide with first character of s
//eg. "aaaaa" = [0,4,3,2,1] the first element of the array is immaterial
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);

    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
        {
            z[i] = min (r - i + 1, z[i - l]);
        }
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
        {
            ++z[i];
        }
        if (i + z[i] - 1 > r)
        {
            l = i, r = i + z[i] - 1;
        }
    }
    return z;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;

    string s;
    cin>>s;

    int len = 0;
    int ans = 0;
    while( len < s.length() )
    {
        string str = s.substr(len,s.length()-len);
        vector<int> z_val = z_function(str);

        rep(i,0,z_val.size())
        {
            if ( i >= z_val[i] )
            {
                ans = max(ans,z_val[i]);
            }
        }
        len++;
    }

    cout<<ans<<endl;

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

using namespace std;

class DSU {
private:
	int n;
	vector<int> parent;
	vector<int> rank;

public:
	DSU(int n) : n(n) {
		for (int i = 0; i <= n; i++)
			parent.push_back(i);
		rank.resize(n+1, 0);
	}
	
	int find(int a) {
		if (parent[a] != a)
			parent[a] = find(parent[a]);
		return parent[a];
	}
	
	bool merge(int a, int b) {
		int ap = find(a);
		int bp = find(b);
		if (ap == bp)
			return true;
		
		if (rank[ap] < rank[bp]) {
			parent[ap] = bp;
		} else if (rank[ap] > rank[bp]) {
			parent[bp] = ap;
		} else {
			parent[bp] = ap;
			rank[ap]++;
		}
		return false;
	}
};

int main() {
	int n, m, ans = 0;
	unordered_map<int, int> count;
	
	cin >> n >> m;
	DSU dsu(n+1);
	
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		dsu.merge(u, v);
	}
	
	for (int i = 1; i <= n; i++) {
		count[dsu.find(i)]++;
	}
	
	for (auto& e : count) {
		ans = max(ans, e.second);
	}
	
	cout << ans;
	return 0;
}



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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	int n; cin >> n;

	vector < vector < int > > DP;
	DP.assign(n, vector < int > (3));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> DP[i][j];
		}
	}

	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < 3; ++j) {
			int val = DP[i][j];
			for (int k = 0; k < 3; ++k) {
				if (j == k) continue;
				DP[i][j] = max(DP[i][j], val + DP[i - 1][k]);
			}
		}
	}

	cout << max({DP[n - 1][0], DP[n - 1][1], DP[n - 1][2]});
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;++i)
typedef long long int ll;

int main(){

    int n,k;
    string s;
    cin >> n >> s >> k;

    rep(i,n){
        if(s[i]!=s[k-1]){
            s[i]='*';
        }
    }

    cout << s << endl;

    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

const int N = 1e5 + 5;
map<pii, int> m;
vector<int> e[N];
int M;

void dfs(int u, int p=-1){
    int bl = 0;
    for(int i = 0; i < int(e[u].size()); i++){
        int v = e[u][i];
        if(m.count(make_pair(u, v))){
            bl = m[make_pair(u, v)]; 
        } else if(m.count(make_pair(v,u))){
            bl = m[make_pair(v, u)];
        }
    }

    int t = 1;
    for(int i = 0; i < int(e[u].size()); i++){
        int v = e[u][i];
        if(!m.count(make_pair(u, v))){
            if(t == bl) t++;
            m[make_pair(u, v)] = m[make_pair(v, u)] = t++;
        }
    }

    for(int v : e[u]){
        if(v == p) continue;
        dfs(v, u);
    }
}

int main(){
    fcin;
    int n;
    cin >> n;
    vector<pii> edges;
    for(int i = 0; i < n-1; i++){
        int u, v;
        cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
        edges.eb(u, v);
    }
    for(int i = 1; i <= n; i++) M = max(M, int(e[i].size()));

    dfs(1);

    cout << M << endl;
    for(pii p : edges){
        int u = p.fi, v = p.se;
        cout << m[make_pair(u, v)] << endl;
    }
    return 0;
}



Measured memory_bytes: 22268
#include<iostream>
using namespace std;
int main() {
	int ans = 0;
	string s;
	cin >> s;
	char tmp = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != tmp) {
			ans++;
			tmp = s[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}

/* main */

signed main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N);
    FOR(i,0,N)cin >> a[i];
    vector<ll> b(N,0),c(N,0);
    FOR(i,1,N)b[i] = max((ll)0,a[i-1])+b[i-1];
    REP(i,0,N-1)c[i] = max((ll)0,a[i+1])+c[i+1];
    FOR(i,1,N)a[i] += a[i-1];
    ll ans = 0;
    FOR(i,0,N-K+1){
        chmax(ans,b[i] + max((ll)0,a[i+K-1]-(i ? a[i-1] : 0)) + c[i+K-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

struct po{int y,x,type;};
bool operator==(const po &a, const po &b){
  return a.y==b.y && a.x==b.x && a.type==b.type;
}

vector<po> dfs(int rest, vector<vi> mp, int y, int x){
  vector<po> err(1);
  err[0] = (po){-1,-1,-1};
  if(rest==0){
    // check it is ok
    bool flag = true;
    // REP(i,10){
    //   REP(j,10)printf("%04d ",mp[i][j]);
    //   cout<<endl;
    // }
    // cout<<endl;
    REP(i,10)REP(j,10){
      if(mp[i][j]!=0)flag=false;
    }
    if(flag){
      return vector<po>();
    }else{
      return err;
    }
  }else{
    while(true){
      if(y>9)return err;
      if(mp[y][x]>0){
        vector<vi> nmp;
        if(y<=7 && x>0 && x<9){
          // ?°?
          nmp = mp;
          REP(o,3)REP(p,3)if(abs(o-1)+abs(p-1)<=1)nmp[y+o][x-1+p]--;
          vector<po> s = dfs(rest-1,nmp,y,x);
          if(s!=err){
            s.push_back((po){y+1,x,1});
            return s;
          }
        }
        if(y<=7 && x<=7){
          // ??¨
          nmp = mp;
          REP(o,3)REP(p,3)nmp[y+o][x+p]--;
          vector<po> s = dfs(rest-1,nmp,y,x);
          if(s!=err){
            s.push_back((po){y+1,x+1,2});
            return s;
          }
        }
        if(y<=5 && x>=2 && x<=7){
          // ??§
          nmp = mp;
          REP(o,5)REP(p,5)if(abs(o-2)+abs(p-2)<=2)nmp[y+o][x-2+p]--;
          vector<po> s = dfs(rest-1,nmp,y,x);
          if(s!=err){
            s.push_back((po){y+2,x,3});
            return s;
          }
        }
        return err;
      }
      ++x;
      if(x>9){
        x=0;
        ++y;
      }
    }
  }
}

int main(){
  int n;
  cin>>n;
  vector<vi> mp(10,vi(10));
  REP(i,10)REP(j,10)cin>>mp[i][j];
  vector<po> res = dfs(n,mp,0,0);
  REP(i,res.size()){
    cout<< res[i].x << " " << res[i].y << " " << res[i].type << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

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

  deque<int> b;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      b.emplace_back(a[i]);
    } else {
      b.emplace_front(a[i]);
    }
  }

  if(n % 2 != 0) {
    reverse(b.begin(), b.end());
  }

  for (int i = 0; i < b.size(); i++) {
    cout << (i ? " " : "") << b[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define MAX 200009
#define PI 3.141592653589793238
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
#define Q 50
int n, m, q;
int a[Q+1], b[Q+1], c[Q+1], d[Q+1];
int maxi = 0;
void fun(vector<int>& v, int i, int curr){
	/*i is length of currently generated sequence
	curr is the value above or = each element must be*/
	if(i == n){ // we have a sequence of length n in v
		int this_subs_score = 0;
		for(int j = 0; j < q; j++){
			if(v[b[j]] - v[a[j]] == c[j]){
				this_subs_score += d[j];
			}
		}
		maxi = max(maxi, this_subs_score);
	}
	else{
		for(int j = curr; j <= m; j++){
			v.pb(j);
			fun(v, i+1, j);
			v.pop_back();
		}
	}
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in2.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		cin >> n >> m >> q;
		FOR(i, q) {
			cin >> a[i] >> b[i] >> c[i] >> d[i];
			a[i]--; b[i]--;
		}
		vector<int> v;
		fun(v, 0, 1);
		cout << maxi;
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		if (r < 1200)	{
			System.out.println("ABC");
		} else if (r < 2800)	{
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 25172
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char X,Y;
    scanf("%s%s",&X,&Y);
    int I,J;
    if(X=='A'){I=1;}
    if(Y=='A'){J=1;}
    if(X=='B'){I=2;}
    if(Y=='B'){J=2;}
    if(X=='C'){I=3;}
    if(Y=='C'){J=3;}
    if(X=='D'){I=4;}
    if(Y=='D'){J=4;}
    if(X=='E'){I=5;}
    if(Y=='E'){J=5;}
    if(X=='F'){I=6;}
    if(Y=='F'){J=6;}
    if(I>J){cout<<">"<<endl;}
    else if(I<J){cout<<"<"<<endl;}
    else if(I==J){cout<<"="<<endl;}
    return 0;
}


Measured memory_bytes: 256
class WordCount
  def sentence(array)
    result = array.each_with_object(Hash.new(0)) { |w, h| h[w] += 1 }
    mode_word = result.max_by { |_, v| v }[0].to_s
    max_length_word = result.max_by { |k, _| k.length }[0].to_s
    [mode_word, max_length_word]
  end
end

result = WordCount.new.sentence(STDIN.gets.split)
printf "%s %s\n", result[0], result[1]

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

int r[3333];
int main() {
	int p;
	cin >> p;
	for (int i = 0; i < p; i++) {
		int a;
		cin >> a;
		if (!i) (r[0] += a) %= p;
		a = p - a;
		for (int d = 1; d < p; d++) {
			(r[p - d] += a) %= p;
			(a *= i) %= p;
		}
	}
	for (int i = 0; i < p; i++)
		cout << r[i] << ' ';
	cout << endl;
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

// コンビネーションを計算する関数
ll modpow(ll a, ll n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    map<ll, ll> M;

    REP(i, N){
        ll a;
        cin >> a;
        M[a]++;
    }

    if(N%2 == 0){
        ll k = N/2;
        for(ll i=1; i<=N-1; i=i+2){
            if(M[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    else{
        ll k = N/2;
        if(M[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        for(ll i=2; i<=N-1; i=i+2){
            if(M[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    ll k=N/2;
    cout << modpow(2, k) << endl;
    return 0;
}

Measured memory_bytes: 7548
#include <iostream>
using namespace std;

int main() {
	int n;
	int ave=0;
	cin >> n;
	int a[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
		ave=ave+a[i];
	}
	ave=ave/n;
	
	int sum1=0;
	for(int i=0;i<n;i++){
		sum1 = sum1 + (a[i]-ave)*(a[i]-ave);
	}
	
	int sum2=0;
	for(int i=0;i<n;i++){
		sum2= sum2+(a[i]-ave-1)*(a[i]-ave-1);	
	}
	
	if(sum1<sum2)
	cout << sum1 << endl;
	
	else
	cout << sum2 << endl;
	
	
	return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, m, c;

vi b;

void read() {
  cin >> n >> m >> c;

  for(int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    b.pb(x);
  }
}


void solve() {
  int sol = 0;
  for(int i = 0; i < n; ++i) {
    ll sum = 0;
    for(int j = 0; j < m; ++j) {
      ll nr;
      cin >> nr;
      sum += nr * b[j];
    }
    if (sum + c > 0)
      ++sol;
  }
  cout << sol;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
//  cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, raw_input().split());
i = 0
ar = [0] * n
vc = [0] * m
while i < n:
	ar[i] = map(int, raw_input().split());
	i += 1
i = 0
while i < m:
	vc[i] = input();
	i += 1
for el in ar:
	ans = 0
	for el2, el3 in zip(vc, el):
		ans += el2 * el3
	print ans

Measured memory_bytes: 4564
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * 3 for _ in range(N + 1)]

for i in range(N):
    for y in range(3):
        for t in range(3):
            if y != t:
                dp[i + 1][t] = max(dp[i + 1][t], dp[i][y] + abc[i][t])

print(max(dp[N][:]))


Measured memory_bytes: 47328
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

int query(vi &pos){
	cout << "?";
	rep(i,0,pos.size()){
		cout << ' ' << pos[i] + 1;
	}
	cout << endl;
	string s;
	cin >> s;
	if(s == "-1")assert(false);
	return s[0] == 'R' ? 0 : 1;
}

void ans(vi &res){
	cout << "! ";
	rep(i,0,res.size()){
		cout << (res[i] ? 'B' : 'R');
	}
	cout << endl;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vi v(n);
	iota(all(v), 0);
	int val = query(v);
	if(n == 1){
		vi res = {val, val?0:1};
		ans(res);
		return 0;
	}
	int l = 0, r = n;
	while(l < r-1){
		int m = (r+l)/2; 
		vi t(n);
		iota(all(t), m);
		int res = query(t);
		if(res == val)l = m;
		else r = m;
	}
	vi eq1,eq2;
	rep(i,0,2*n){
		if(i > l && i < r + n - 1)eq1.emplace_back(i);
		else if(i != l && i != r + n - 1)eq2.emplace_back(i);
	}
	vi ANS(2*n);
	ANS[l] = val;
	ANS[r+n-1] = val ? 0 : 1;
	for(int x:eq1){
		eq2.push_back(x);
		ANS[x] = query(eq2);
		eq2.pop_back();
	}
	for(int x:eq2){
		eq1.push_back(x);
		ANS[x] = query(eq1);
		eq1.pop_back();
	}
	ans(ANS);
}


Measured memory_bytes: 3828
using System;

class Program
{
	static void Main()
	{
		int D = int.Parse(Console.ReadLine());
		for (int i = 1; i <= D; i++)
		{
			int x = i;
			if (x % 3 == 0)
			{
				Console.Write(" " + i);
			}
			else
			{
				while (x != 0)
				{
					if (x % 10 == 3)
					{
						Console.Write(" " + i);
						break;
					}
					x /= 10;
				}
			}
		}
		Console.WriteLine();
	}
}

Measured memory_bytes: 5820
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;

//자동 정렬은 ctrl k f
//주석은 ctrl k c
//주석 해제는 ctrl k u
// int gcd(int a, int b){
// 	while(b!=0){
// 		int r= a%b;
// 		a=b;
// 		b=r;
// 	}
// 	return a;
// }
// int lcm(int a, int b){
// 	return a*b/gcd(a,b);
// }
long long int arr[200001];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string a, b;
	cin >> a >> b;
	//cabacc
	//abc
	int sum = INF;
	int min_sum = 0;
	

	for (int j = 0; j < a.length()-b.length()+1; j++) {
		int cnt = 0;
		for (int i = 0; i < b.length(); i++) {
			if (b[i] != a[j+i]) {
				cnt++;
			}
		}
		min_sum = min(cnt, sum);
		sum = min_sum;
	}

	cout << min_sum;
	/*int n;
	cin >> n;
	long long int total = 0;
	for (int i = 0; i < n-1; i++) {
		cin >> arr[i];
		total += arr[i] % 1000000007;
		total %=1000000007;
	}
	long long int sum = 0;
	long long int m_sum = 0;
	for (int i = 0; i < n; i++) {
		m_sum += arr[i];
		m_sum = m_sum  % 1000000007;
		sum = sum + arr[i] * (total - m_sum);
		sum = sum % 1000000007;

	}
	cout << sum % 1000000007;*/
	return 0;
}



Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    int N = 5;
    vector<int> vec(N);
    REP(i, N) cin >> vec[i];

    vector<int> d(N);
    int total = 0;
    REP(i, N) {
        total += vec[i];
        int b = vec[i] % 10;
        int a = 10 - b;
        if (a != 10) {
            d[i] = a;
        } else {
            d[i] = 0;
        }
    }
    sort(d.begin(), d.end());
    REP(i, N-1) total += d[i];
    print(total);
}

int main() {

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define NMAX 100
#define SQMAX 10

struct S{
	double x, y, r;
};

/*点と円 true->点は円の内部*/
bool po_cr(double cx, double cy, double cr, double px, double py){
    return pow((cx - px), 2.0) + pow((cy - py), 2.0) <= pow(cr, 2.0);
}


int main(){

	int n;
	int cnt, ans;
	S seal[NMAX];
	char gav;

	while(1){

		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; i++){
			cin >> seal[i].x >> gav >> seal[i].y;
			seal[i].r = 1.0;
		}

		ans = 0;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				cnt = 0;
				for(int k = 0; k < n; k++){
					if(po_cr(seal[k].x, seal[k].y, seal[k].r, (double)SQMAX*i/100, (double)SQMAX*j/100)){
						cnt++;
					}
				}
				ans = max(ans, cnt);
			}
		}

		cout << ans << endl;

	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define vvi         vector<vector<ll>>
#define mpi         map<pi,ll>
#define pipi        pair<ll,pair<ll,ll> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define ef          else if
#define yes       cout<<"YES"<<'\n';
#define no        cout<<"NO"<<'\n';
#define C         continue;
#define wa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define debugp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>     
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>     
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll N = 350;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); } 
/*
ll power(ll x, ll y) 
{ 
    ll res = 1;  
	x=x%M; 
    while (y > 0) 
    { 
        if (y & 1) 
        res = (res*x)%M; 
        y = y>>1; 
        x = (x*x)%M;  
    } 
    return res; 
}
*/
signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		ll n=s.length();
		if(s[s.length()-1]=='s')
		cout<<s<<"es"<<u;
		else
		cout<<s<<"s"<<u;
	}
	return 0;
} 

Measured memory_bytes: 3620
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A > 12) {
            System.out.println(B);
        } else if (6 <= A && A <= 12) {
            System.out.println(B/2);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21332
N,L = (int(i) for i in input().split())

min = 10000
min_raw = 100000
ans = 0

for i in range(1,N+1):
    temp = L + i - 1
    if abs(temp) < min:
        min = abs(temp)
        min_raw = temp

for i in range(1,N+1):
    ans += L + i - 1

print(ans-min_raw)


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
ll cnt=0;
bool flag=false;
for(int i=1;i<4;i++){
    if(s.at(i)==s.at(i-1)){
        cnt++;
        if(cnt==2){
            flag=true;
        }
    }else{
        cnt=0;
    }
}
if(flag){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}









Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{ 
  long long int n;
  char s[20];
  cin>>n;
  int i=0;
  
 while(n>0)
 { 
   n--;
   s[i]=(n%26)+'a';
   n=n/26;
   i++;
 }
  n=i;
  for(i=0;i<n;i++)
  {
    cout<<s[n-i-1];
  }
  cout<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 20000000000000000
#define mod 998244353
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 2000005

//ll a[ma],b[ma],c[ma],d[ma],max1=0,n,m,q;
//ll pr[ma];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll i,j,x,y,a,b,n;
    while(cin>>a>>b>>n)
    {
        ll max1=0;

        ll r=min(b-1,n);
        ll max2=(a*r)/b-a*(r/b);
        cout<<max2<<endl;

        /*for(i=1;i<=n;i++)
        {
            ll p=(a*i)/b-a*(i/b);
            max1=max(max1,p);
            cout<<i<<" "<<p<<endl;
        }*/
       // cout<<max1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,int>p;
int ans;
int n,m;
int a[20],b[20];
string f[12001];
int gcd(int x,int y){
	if(x%y==0)return y;
	return gcd(y,x%y);
}
bool find(int x,int y){
	int n=f[x].length();
	int m=f[y].length();
	if(n!=m)return n>m;
	for(int i=0;i<n;i++)if(f[x][i]!=f[y][i])return f[x][i]>f[y][i];
}
int main(){
	b[1]=2;
	b[7]=3;
	b[4]=4;
	b[5]=5;
	b[2]=5;
	b[3]=5;
	b[6]=6;
	b[9]=6;
	b[8]=7;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	for(int i=0;i<=n;i++){
		if(f[i].length()==0&&i!=0)continue;
		for(int j=1;j<=m;j++){
			f[12000].clear();
			f[12000]=f[i]+(char)('0'+a[j]);
			if(find(12000,i+b[a[j]]))f[i+b[a[j]]]=f[12000];
		}
//	for(int i=1;i<=n;i++)cout<<f[i]<<endl;
	}
	cout<<f[n]<<endl;
}

Measured memory_bytes: 38528
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> time(N);
  vector<string> title(N);
  string end;
  for (int i = 0; i < N; i++) {
    cin >> title[i] >> time[i];
  }
  cin >> end;
  int index;
  for (int i = 0; i < N; i++) {
    if (title[i] == end) {
      index = i;
      break;
    }
  }
  ll total = 0;
  for (int i = index+1; i < N; i++) {
     total += time[i];
  }
  cout << total << endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>

using namespace std;


int W, H;
vector<string> map;

string maxstr(string s1, string s2) {
	if ((int)s1.size() >(int)s2.size()) return s1;
	if ((int)s2.size() > (int)s1.size()) return s2;
	return max(s1, s2);
}

string solver() {
	vector< vector<string> > dp(H, vector<string>(W, ""));
	
	string res = "";
	
	for (int i = 0; i<H; i++) {
		
		for (int j=0; j<W; j++) {
			
			if ('0' <= map[i][j] && map[i][j] <= '9') {
				if (i > 0) {
					if (j > 0) dp[i][j] = maxstr(dp[i-1][j], dp[i][j-1]) + map[i][j];
					else dp[i][j] = dp[i-1][j] + map[i][j];
				} else {
					if (j > 0) dp[i][j] = dp[i][j - 1] + map[i][j];
					else dp[i][j] = map[i][j];
				}
			}
			if (dp[i][j] == "0") dp[i][j] = "";
			res = maxstr(res, dp[i][j]);
		}
	}
	
	return res;
}

int main() {
	while (1) {
		cin >> W >> H; if (W==0 && H==0) break;
		
		map.clear();
		map.assign(H, "");
		for (int i=0; i<H; i++) cin >> map[i];
		
		 cout << solver() << endl;
	}
	
	return 0;
}

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

int main() {
  int A,B;
  cin>> A >> B;
  if((A*B*1)%2==1||(A*B*2)%2==1||(A*B*3)%2==1) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
typedef pair<ll, ll> P;
int main() {
    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll>t(n);
    rep(i, 0, n) {
        ll tmp = 0;
        cin >> tmp;
        t[i] = tmp;
    }
    sort(t.begin(), t.end());
    int bus = 0;
    for (int i = 0; i < n;) {
      ++bus;
      int starti = i;
      while (i < n && t.at(i) - t.at(starti) <= k && i - starti < c) ++i;
    }
    cout << bus << endl;
   return 0;
}


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

using ll = long long;

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

    ll a,b,c;
    cin>>a>>b>>c;

    ll ans=(a%2==0||b%2==0||c%2==0?0:min(min(a*b,b*c),c*a));

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3524
#input
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])
#print(S)
L = len(S)
fugou = []

#bit zentansaku
for i in range(2**(L-1)):
    total = S[0]
    #bin_i = bin(i)
    moji = format(i,'b').zfill(4)
    #print(moji)
    for k in range(1,L):
        #print(moji[k])
        if int(moji[k]) == 1:
            total = total + S[k]
        else:
            total = total - S[k]
        #print(total)
    if total == 7:
        moji_answer = moji
#print(moji_answer)
#print
for i in range(1,L):
    if int(moji_answer[i]) == 1:
        fugou_tandoku = "+"
    else:
        fugou_tandoku = "-"
    fugou.append(fugou_tandoku)
print(S[0],fugou[0],S[1],fugou[1],S[2],fugou[2],S[3],'=7',sep='')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int v[n], c[n];
  rep(i,n) {
    cin>>v[i];
  }
  rep(i,n) {
    cin>>c[i];
  }
  int cost = 0;
  rep(i,n) {
    if(v[i] >= c[i]) {
      cost += v[i] - c[i];
    }
  }
  cout << cost << endl;

  return 0;
}


Measured memory_bytes: 256