akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

llint N;
vector<int> G[205];
bool used[205];
llint root;

llint dp[205][205][205];

llint fact[205], fact_i[205];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 205; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 205; i++){
		fact_i[i] = pow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_i[k], ret %= mod;
	ret *= fact_i[n-k], ret %= mod;
	return ret;
}

void merge(vector<llint> &v1, vector<llint> v2)
{
	llint tmp[205];
	llint a = v1.size()-1, b = v2.size()-1;
	for(int i = 0; i <= a+b; i++) tmp[i] = 0;
	
	for(int i = 1; i <= a; i++){
		for(int j = 1; j <= b; j++){
			llint n = v1[i] * v2[j] % mod;
			for(int k = 0; k <= i+j; k++){
				tmp[k] += dp[i][j][k] * n % mod;
				tmp[k] %= mod;
			}
		}
	}
	
	v1.clear();
	for(int i = 0; i <= a+b; i++) v1.push_back(tmp[i]);
}

vector<llint> dfs(int v)
{
	vector<llint> ret;
	if(G[v].size() == 0){
		ret.push_back(0);
		ret.push_back(1);
		return ret;
	}
	
	ret = dfs(G[v][0]);
	for(int i = 1; i < G[v].size(); i++){
		merge(ret, dfs(G[v][i]));
	}
	ret.insert(ret.begin(), 0);
	return ret;
}

int main(void)
{
	make_fact();
	
	cin >> N;
	int a, b;
	for(int i = 0; i < N-1; i++){
		cin >> a >> b;
		G[a].push_back(b);
		used[b] = true;
	}
	if(N == 1){
		cout << 1 << endl;
		return 0;
	}
	
	for(int i = 0; i < N; i++){
		if(!used[i]){
			root = i;
			break;
		}
	}
	
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			for(int k = 0; k <= min(i, j); k++){
				dp[i][j][i+j-k] = comb(i, k) * comb(i+j-k, i) % mod;
				dp[i][j][i+j-k] %= mod;
			}
		}
	}
	
	vector<llint> avec = dfs(root);
	llint ans = 0;
	for(int i = 0; i < avec.size(); i++) ans += avec[i], ans %= mod;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 68016
from collections import deque
from typing import List, Optional, Tuple


def cycle_detectable_topological_sort(
    graph: List[List[int]], in_degrees: List[int], first_index: int = 0
) -> Tuple[Optional[List[int]], Optional[List[int]]]:
    """Topological sort that uses Kahn's algorithm and detects a loop (DAG or not).
    Returns:
        if the given graph is DAG, a list of sorted vertices and a list of depths of
        each vertex is returned.
        Otherwise, (None, None) is returned.
    """
    V = len(graph) + first_index
    order = []
    depths = [-1] * V  # depths[i] := the length of the longest path to V_i
    for i in range(first_index, V):
        if not in_degrees[i]:
            order.append(i)
            depths[i] = 0

    queue = deque(order)
    while queue:
        u = queue.popleft()
        cur_depth = depths[u]
        for v in graph[u]:
            in_degrees[v] -= 1
            if not in_degrees[v]:
                depths[v] = max(depths[v], cur_depth + 1)
                queue.append(v), order.append(v)
    return (order, depths) if len(order) + first_index == V else (None, None)


def abc139_e():
    N, *A = map(int, open(0).read().split())

    ids = [[-1] * (N + 1) for _ in range(N + 1)]
    cur_id = 0
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            ids[i][j] = ids[j][i] = cur_id
            cur_id += 1

    graph = [[] for _ in range(N * (N - 1) // 2)]
    in_degrees = [0] * (N * (N - 1) // 2)
    for i, a in enumerate(zip(*[iter(A)] * (N - 1)), 1):
        prev_id = -1
        for j in a:
            cur_id = ids[i][j]
            if prev_id != -1:
                graph[prev_id].append(cur_id)
                in_degrees[cur_id] += 1
            prev_id = cur_id

    _, depths = cycle_detectable_topological_sort(graph, in_degrees)
    print(max(depths) + 1 if depths is not None else -1)


if __name__ == "__main__":
    abc139_e()


Measured memory_bytes: 144092
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, q = MI()
    S = input()
    ats = [0]
    cnt = 0
    for i in range(n-1):
        j = i + 2
        s = S[i:j]
        # print(s)
        if s == 'AC':
            cnt += 1
        ats.append(cnt)
    # print(ats)
    for _ in range(q):
        l, r = MI1()
        # print(S[l:r+1])
        print(ats[r] - ats[l])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 53068
a,b,ab,x,y=map(int,input().split())
ans=0
if ab<(a+b)/2:
    m=min(x,y)
    ans+=ab*2*m
    x-=m
    y-=m
    if x==y==0:
        print(ans)
        exit()
    if y==0:
        if ab*2<a:
            ans+=x*2*ab
        else:
            ans+=x*a
    else:
        if ab*2<b:
            ans+=y*2*ab
        else:
            ans+=y*b

else:
    ans+=x*a+y*b

print(ans)

Measured memory_bytes: 9120
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll ans = 0;
    if (k <= a) {
        cout << k << endl;
        return 0; 
    } else {
        k -= a;
        ans += a;
    }
    if (k <= b) {
        cout << ans << endl;
        return 0;
    } else {
        k -= b;
    }
    ans -= k;
    cout << ans << endl;
    return 0;
}



















Measured memory_bytes: 3632
import sys
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x = 0
y = 0
t = 0
for i in range(n):
    if abs(a[i][1] - x) + abs(a[i][2] - y) > abs(a[i][0] - t) or (a[i][1] - x + a[i][2] - y) % 2 != (a[i][0] - t) % 2:
        print('No')
        sys.exit()
    else:
        x = a[i][1]
        y = a[i][2]
        t = a[i][0]
print('Yes')

Measured memory_bytes: 60632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
int ch[30];

bool judge(string s) {
	int len = s.size();
	for(int i = 0; i < len; i++) {
		if(ch[s[i] - 'a']) {
			return false;
		}
		else {
			ch[s[i] - 'a']++;
		}
	}
	return true;
}

int main() {
	string s;
	while(cin >> s) {
		memset(ch, 0, sizeof(ch));
		if(judge(s)) {
			puts("yes");
		}
		else {
			puts("no");
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        vector<bool> used(2000,false);
        deque<char> deq;
        
        bool f=false;
        int pos = 1000;
        for(int i=0;i<s.size();i+=3){
            if(used[pos]==false){
                if(f==false || used[pos+1]==true){
                    f=true;
                    deq.push_front(s[i]);
                }else{
                    deq.push_back(s[i]);
                }
                used[pos]=true;
            }
            if(i+1>=s.size())continue;
            assert(s[i+1]=='<' || s[i+2]=='>');
            if(s[i+1]=='<')pos--;
            else if(s[i+2]=='>')pos++;
        }
        for(auto e:deq)cout<<e;
        cout<<endl;
    }
}

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
  cin >> vec.at(i);
  }
  long long s = 0, k =0;
  for(int i = 0; i < N; i++){
  for(int j = i; j < N; j++){
  if(vec.at(i) > vec.at(j)){
  s += 1;
  }
  }
  }
  for(int i = 0; i < N; i++){
  for(int j = 0; j < N; j++){
  if(vec.at(i) > vec.at(j)){
  k += 1;
  }
  }
  }
  if(K == 1){
  cout << s;
  }else{
  K = K % 1000000007;
    long long T,M;
   T = K * s % 1000000007;
    M = (K-1) * K % 1000000007;
    M = k * M % 1000000007;
    M = M * modinv(2,1000000007) % 1000000007;
    cout << (T + M) % 1000000007;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif
ll dp[2020];
int32_t main() 
{
	IAMSPEED
	string str; cin >> str;
	ll times = 1;
	ll sum = 0;
	ll ans = 0;
	dp[0]=1;
	DEC(i,str.size()-1,0) {
		//~ db(i);
		sum += ((str[i]-'0') * times) % 2019;
		sum %= 2019;
		times *= 10;
		times %= 2019;
		//~ db(sum);
		ans += dp[sum];
		dp[sum]+=1;
	}
	cout<<ans;
	
}



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

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

  int x; cin >> x;
  if (x < 1200) cout << "ABC" << '\n';
  else cout << "ARC" << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll arr[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,g=0;
    cin>>n>>m;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        arr[i]/=2;
    }
    ll p=arr[0];
    for(ll i=1;i<n;i++){
        ll g=__gcd(p,arr[i]);
        if(p/g>1.0*m/arr[i]){
            cout<<0;
            exit(0);
        }
        p*=arr[i]/g;
    }
    for(ll i=0;i<n;i++){
        ll k=p/arr[i];
        if(k%2==0){
            cout<<0;
            exit(0);
        }
    }
    m/=p;
    m=ceil(m/2.0);
    cout<<m;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();

            // 整数Aiの数を数える
            var countTable = new Dictionary<int, long>();
            foreach (var i in Enumerable.Range(0, N))
            {
                countTable[A[i]] = countTable.ContainsKey(A[i]) ? countTable[A[i]] + 1 : 1;
            }

            // 全体の2つのボールを選び出す組み合わせ数を数える
            var allCount = 0L;
            foreach (var count in countTable.Values)
            {
                allCount += (count * (count - 1)) / 2;
            }

            // 各kに対して、全体の組み合わせ数 - (kの整数の個数 - 1)が答えとなる
            foreach (var k in Enumerable.Range(0, N))
            {
                var count = countTable[A[k]] - 1;
                Console.WriteLine(allCount - count);
            }
        }
    }
}


Measured memory_bytes: 44916
import sys
input = sys.stdin.readline

n = int(input())
xys = []
for _ in range(n):
    a = int(input())
    xy = [list(map(int, input().split())) for _ in range(a)]
    xys.append(xy)


def bc(x):
    return bin(x).count("1")

ans = 0
for i in range(2**n):
    is_ok = True
    for j in range(n):
        if (i>>j) & 1:
            for x, y in xys[j]:
                if ((i>>(x-1)) & 1) != y :
                    is_ok = False
                    break
    if is_ok:
        cnt = bc(i)
        if ans < cnt:
            ans = cnt
print(ans)

Measured memory_bytes: 3064
S = input()

ans = 0
for s in range(len(S)):
    for e in range(1,len(S) - s + 1):
        c = 0
        str = S[s:s+e]
        c += str.count('A')
        c += str.count('C')
        c += str.count('G')
        c += str.count('T')
        if c == len(str):
            ans = max(ans,len(str))
            # print(str)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll x, y;

    cin >> x >> y;

    ll sum = 0;
    if(x == 1 && y == 1) sum = 1000000;
    else{
        if(x == 1){
            sum += 300000;
        }
        if(x == 2){
            sum += 200000;
        }
        if(x == 3){
            sum += 100000;
        }
        if(y == 1){
            sum += 300000;
        }
        if(y == 2){
            sum += 200000;
        }
        if(y == 3){
            sum += 100000;
        }
    }

    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000007)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;


ll sum[200010];

int main(void){
    int a[5];
    for(int i=0;i<5;i++)cin>>a[i];
    for(int i=0;i<5;i++){
        if(a[i]!=i+1){
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class StonesOnATree
{
    public:
int minStones(vector <int> p, vector <int> w)
{

}
};

int main()
{
int a;
while(cin>>a){
    int A[200005]={};
    int B[200005]={};
    for(int i=0;i<a;i++){
        cin>>A[i];
    }
    for(int i=0;i<a;i++){
        cin>>B[i];
    }
    
    int ans=0;
    for(int i=(1<<28);i;i>>=1){
        
        for(int r=0;r<a;r++){
            A[r]%= (i*2);
            B[r]%= (i*2);
        }
        
        sort(A,A+a);
        sort(B,B+a);
        int t1=0,t2=0,t3=0;
        int t=0;
        for(int j=a-1;j>=0;j--){
            
            while(t1<a&&A[j]+B[t1]<i)
                t1++;
            while(t2<a&&A[j]+B[t2]<i*2)
                t2++;
            while(t3<a&&A[j]+B[t3]<i*3)
                t3++;
            
            t+=t2-t1+a-t3;
            t%=2;
        }
        if(t==1)
            ans+=i;
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
}



    return 0;
}


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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  int A[N][M];
  int B[M];
  for(int i = 0; i < M; i++){
    cin >> B[i];
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    int ans = 0;
    for(int j = 0; j < M; j++){
      ans += A[i][j]*B[j];
    }
    if(ans + C > 0) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 100000000000000000

int n, m ;
vector<int> c ;
vector<vector<int>> dp ;
int find (int i, int j){
    if(dp[i][j] >= 0){
        return dp[i][j] ;
    }
    int res ;
    if(i == m){
        if (j == 0){
            return 0 ;
        }
        else {
            return 100000 ;
        }
    }
    else if (j < c[i]) {
        res = find(i + 1, j) ;
    }
    else {
        res = min((find(i, j - c[i]) + 1) ,min (find(i + 1, j), find(i + 1, j - c[i]) + 1)) ;
    }
    return dp[i][j] = res ;
}
int main (){
    cin >> n >> m ;
    c.resize(m) ;
    dp = vector<vector<int>> (m + 1, vector<int>(n + 1, -1)) ;
    rep(i, m){
        cin >> c[i] ;
    } 
    cout << find (0, n) << endl; 

}


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

int main(void){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  cout << (a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000) << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll ans = 0;
    exrep(i, 1, n) {
        if(i%3 != 0 && i%5 != 0) {
            ans += i;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll N =3e3+5;
ll dp[N][N];
string s,ss,ans;
ll solve(int i,int j);

int main(){
ll i,j,k,m;
memset(dp,-1,sizeof(dp));
cin>>s>>ss;
k=solve((int)s.size()-1,(int)ss.size()-1);
i=(int)s.size()-1,j=(int)ss.size()-1;
while(k){//k is number of char in LCS
    if(s[i]==ss[j]){
        ans+=s[i];
        i-=1,j-=1;
        k--;
    }
    else if(i && dp[i-1][j]==k)
        i--;
    else j--;
}
reverse(ans.begin(), ans.end());
cout<<ans<<"\n";
    return 0;
}

ll solve(int i,int j){
    if(i<0 || j<0)return 0;
    else if(dp[i][j]!=-1)return dp[i][j];
    else if(s[i]==ss[j])
        return dp[i][j]=1+solve(i-1,j-1);
    return dp[i][j]=max(solve(i-1,j),solve(i,j-1));
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
using ll = long long;
using p = pair <int, int>;

int		main(void){
	int		n, m;
	cin >> n >> m;
	vector<p>	given(m);
	int		i = 0;
	while (i < m){
		cin >> given[i].second >> given[i].first;
		i++;
	}
	sort(given.begin(), given.end());
	int		ans;
	int		tmp;
	ans = 1;
	tmp = given[0].first;
	i = 1;
	while (i < m){
		if (given[i].second >= tmp){
			tmp = given[i].first;
			ans++;
		}
		i++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ***********************************/
/******* Main ****************************************/
void Main() {
  int H, W;
  // 奇数行は ＃ 偶数列は . ではじめる
  while (cin >> H >> W) {
    if (H == 0 && W == 0) break;
    rep(i, 0, H) {
      if (i % 2 != 0) {
        rep(j, 0, W) {
          if (j % 2 != 0)
            cout << '#';
          else
            cout << '.';
        }
        cout << '\n';
      } else {
        rep(j, 0, W) {
          if (j % 2 != 0)
            cout << '.';
          else
            cout << '#';
        }
        cout << '\n';
      }
    }
    cout << '\n';
  }
}

/*********************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

************************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  int n;
  while(cin>>s){
    for(string::iterator it=s.begin();it!=s.end();++it){
      n=1;
      if(*it=='@'){
	++it;
	n=*it-'0';
	++it;
      }
      while(n--) cout<<*it;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String input	 = in.readLine();
		String S	 = in.readLine();

		int N = Integer.parseInt(input.split(" ")[0]);

		long[] s = new long[N];
		long R=0;
		long G=0;
		long B=0;

		for(int i = 0;i<N;i++) {
			if(S.charAt(i)=='R') {
				s[i]=0;
				R++;
			}else if(S.charAt(i)=='G') {
				s[i]=1;
				G++;
			}else {
				s[i]=2;
				B++;
			}
		}
		long ans=R*G*B;

		for(int i = 0; i<N; i++) {
			for(int j=1;i+2*j<N;j++) {
				if(s[i]!=s[i+j] && s[i+j]!=s[i+2*j] && s[i]!=s[i+2*j]) {
					ans--;
				}
			}
		}

		System.out.println(ans);





//		int N = scanner.nextInt();
//		String S = scanner.next();
//
//		List<Integer> R = new ArrayList<>();
//		List<Integer> G = new ArrayList<>();
//		List<Integer> B = new ArrayList<>();
//
//		for(int i=0;i<N;i++){
//			char c = S.charAt(i);
//			if(c=='R') {
//				R.add(i);
//			}else if(c=='G') {
//				G.add(i);
//			}else {
//				B.add(i);
//			}
//		}

		//愚直にSに対してFor文で良かったな…

//		int minus=0;
//		for(int rIndex=0;rIndex<R.size();rIndex++) {
//			for(int gIndex =0;gIndex<G.size();gIndex++) {
//				int r = R.get(rIndex);
//				int g =G.get(gIndex);
//				int num =0;
//				if((r+g)%2==0 && B.contains((r+g)/2)) {
//						minus++;
//				}if(r<g) {
//					num=g-r;
//					if(B.contains(r-num)||B.contains(g+num)) {
//						minus++;
//					}
//				}else{
//					num = r-g;
//					if(B.contains(g-num)||B.contains(r+num)) {
//					}
//					minus++;
//				}
//			}
//		}

		//		int minus=0;
		//		for(int rIndex=0;rIndex<=N/2-1;rIndex++) {
		//			for(int gIndex =G.get(tansaku(R.get(rIndex),G));gIndex<=G.size()/2;gIndex++) {
		//				int num = G.get(gIndex)-R.get(rIndex);
		//				if(B.contains(G.get(gIndex)+num)) {
		//					minus++;
		//				}
		//			}
		//		}

//		System.out.println(R.size()*G.size()*B.size()-minus/2);

		//		for(int r :R){
		//			int gTarget = tansaku(r,G);
		//			if(gTarget == G.size()) {
		//				break;
		//			}
		//			int gNum = G.size()-gTarget;
		//
		//			int bTarget = tansaku(G.get(gTarget),B);
		//			if(bTarget == B.size()) {
		//				break;
		//			}
		//			if(b) {
		//
		//			}
		//
		//		}


	}

	static int tansaku(int target, List<Integer> list ) {
		int R=list.size();
		while (target < R) {
			int M = (target+R)/2;
			if (list.get(M) == target) {
				return M;
			}
			else if (list.get(M) > target) {R = M;}
			else if (list.get(M) < target) {target = M+1;}
		}
		return 0;
	}
}


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

int main() {
  int N;
  cin >> N;
  
  bool P, W, G, Y = false;
  
  for (int i = 0; i < N; i++) {
    string color;
    cin >> color;
    if (color == "P") {
      P = true;
    }
    else if (color == "W") {
      W = true;
    }
    else if (color == "G") {
      G = true;
    }
    else if (color == "Y") {
      Y = true;
    }
  }
  
  if (P && W && G && Y) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 500002

void BuildMaxHeap(int *);
void MaxHeapify(int *, int);

int h;

int main(){
  int a[N];
  int i;

  scanf("%d", &h);
  for(i = 1; i < h + 1; i++) scanf("%d", &a[i]);

  BuildMaxHeap(a);

  for(i = 1; i < h + 1; i++) printf(" %d", a[i]);
  printf("\n");

  return 0;
}

void BuildMaxHeap(int *a){
  int i;

  for(i = h / 2; i > 0; i--) MaxHeapify(a, i);
}

void MaxHeapify(int *a, int i){
  int left, right, large, change;

  if(i * 2 <= h) left = i * 2;
  else left = i;
  if(i * 2 + 1 <= h) right = i * 2 + 1;
  else right = i;


  if(left < h + 1 && a[left] > a[i]) large = left;
  else large = i;
  if(right < h + 1 && a[right] > a[large]) large = right;
  
  if(large != i){
    change = a[i];
    a[i] = a[large];
    a[large] = change;
    MaxHeapify(a, large);
  }
}

Measured memory_bytes: 2552
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int h=nextInt();
		int w=nextInt();
		if(h==1 || w==1)
		{
			out.println(1);
			return;
		}
		long p=1l*h*w;
		out.println((p+1)/2);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23124
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int main(void) {
	// in = fopen("A.in", "rt");
	
	int n, a, b;
	fscanf(in, "%d %d %d", &n, &a, &b);
	fprintf(out, "%d %d\n", min(a, b), max(0, a + b - n));
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int main()
{
  string s;
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

int main(){
	ll n,m;
	cin >> n >> m;
	ll t = 1900;
	ll k=1;
	for(ll i=0;i<m;i++){
		k *= 2;
	}
	cout << k*(100*(n-m)+t*m)  << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  cout << ((n-1)/1000+1)*1000-n << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = 51;
const int M =  50 * 50 + 1;
const int mod = int(1e9) + 7;

ll f[N][N][M], n, oddness;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> oddness;
    f[0][0][0] = 1;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= i; ++j) {
            for(int k = 0; k <= oddness; ++k) {
                if(k < 2 * j) continue;
                if(j) f[i][j][k] = f[i - 1][j][k - 2 * j] * (2 * j + 1) + f[i - 1][j + 1][k - 2 * j] * (j + 1) * (j + 1) + f[i - 1][j - 1][k - 2 * j];
                else f[i][j][k] = f[i - 1][j][k - 2 * j] * (2 * j + 1) + f[i - 1][j + 1][k - 2 * j] * (j + 1) * (j + 1);
                if(f[i][j][k] >= mod) f[i][j][k] %= mod;
            }
        }
    }
    cout << f[n][0][oddness];
}


Measured memory_bytes: 49152
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b&&b>=c)
	{
		cout<<(a*10+b)+c;
		return 0;
	}
	if(a>=c&&c>=b)
	{
		cout<<(a*10+c)+b;
		return 0;
	}
	if(b>=a&&b>=c)
	{
		cout<<(b*10+a)+c;
		return 0;
	}
	if(b>=c&&c>=a)
	{
		cout<<(b*10+c)+a;
		return 0;
	}
	if(c>=a&&a>=b)
	{
		cout<<(c*10+a)+b;
		return 0;
	}
	if(c>=b&&b>=a)
	{
		cout<<(c*10+b)+a;
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    System.out.printf("%d %d %d",c,a,b);

  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int z[20];
int gc(){
  char ch=getchar();
  while(ch!='Y'&&ch!='N') ch=getchar();
  return ch=='Y';
}
int main(){
  int d=0;
  for (ll i=1; i<=1e10; i*=10){
    cout<<"? "<<i<<endl;
    z[++d]=gc();
  }
  if (z[d]==1){
    for (ll s=10; ; s*=10){
      cout<<"? "<<s-1<<endl;
      if (gc()){
	cout<<"! "<<s/10;
	return 0;
      }
    }
  }
  for (int i=1; i<=d; ++i)
    if (z[i]==0){
      --i;
      ll l=1,r=1,mid,ans;
      for (int j=1; j<=i; ++j)
	l*=10;
      r=l,l/=10;
      while(l<=r){
	mid=(l+r)>>1;
	cout<<"? "<<mid*10<<endl;
	if (gc()) ans=mid,r=mid-1;
	else l=mid+1;
      }
      cout<<"! "<<ans;
      return 0;
    }
  return 0;
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 100002;
ll n,m,ans=0;
vector<ll> p;
ll par[N];
void init(ll n){
	FOR(i,1,n+1)par[i]=i;
}

ll root(ll x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=root(par[x]);
	}
}

void unite(ll x,ll y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	init(n);
	FOR(i,0,n){
		ll k;cin>>k;
		p.pb(k);
	}
	FOR(i,0,m){
		ll x,y;
		cin>>x>>y;
		unite(x,y);
	}
	FOR(i,1,n+1){
		if(root(i)==root(p[i-1]))ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 2168
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

s_unique = list(set(s))
# t_unique = list(set(t))

rieki = 0
son = 0
cnt = 0
res = 0
for i in s_unique:
    rieki = s.count(i)
    son = t.count(i)
    res = max(res, rieki - son)

print(res)


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

int main(){
    string str;
    int win = 0;
    
    cin >> str;
    
    for(int i=0; i<str.length(); i++){
        if (str[i] == 'o'){
            win++;
        }
    }
    
    if (15-str.length()+win >= 8) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    
    return 0;
}

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

int N, a[200001];

int main(){
    cin >> N;
    unordered_set<int> ans;
    for(int i = 1; i <= N; i++){
        cin >> a[i];
    }
    for(int i = N; i >= 1; i--){
        int a_acc = a[i];
        for(int j = 1; i * j <= N; j++){
            if(ans.count(i * j) == 1){
                a_acc++;
            }
        }
        if(a_acc % 2){
            ans.insert(i);
        }
    }

    cout << ans.size() << endl;
    for(auto itr = ans.begin(); itr != ans.end(); itr++){
        if(itr != ans.begin()){
            cout << " ";
        }
        cout << *itr;
    }
    cout << endl;
}
            


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

int main(){
    char s[200005];
    scanf("%s",s);
    long int n;
    n=strlen(s);
    long int i,j;
    i=0;
    j=n-1;
    while(s[i]!='A')i++;
    while(s[j]!='Z')j--;
    printf("%ld",j-i+1);
    
    
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll A(N);
    REP(i, N) cin >> A[i];

    ll b = 0;
    REP(i, N) {
        b ^= A[i];
    }

    REP(i, N) {
        cout << (A[i] ^ b) << ' ';
    }

    cout << endl;
    
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

int main() 
{
	#ifdef gupta_samarth
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	fastio();

	int k;
	cin>>k;
	while(k--)
		cout<<"ACL";
	

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> data(n);
  REP(i, n) { cin >> data[i]; }
  ll ans = 0;
  REP(d, 60) {
    ll one_cnt = 0;
    REP(i, n) {
      if (data[i] >> d & 1) one_cnt++;
    }
    ll now = one_cnt * (n - one_cnt) % MOD;
    REP(j, d) {
      now *= 2;
      now %= MOD;
    }
    ans += now;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5616
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int a[110],b[110];
int main(){
	int m,n,x,y;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	if(x>=y){
		printf("War");
		return 0;
	}
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<m;i++) scanf("%d",&b[i]);
	sort(a,a+n);sort(b,b+m);
	if(a[n-1]>=b[0]||max(a[n-1],x)>=min(b[0],y)){
		printf("War");
		return 0;
	}
	printf("No War");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int D, G;
    cin >> D >> G, G /= 100;
    vector <int> p(D), c(D);
    int sum = 0;
    rep (i, D) cin >> p[i] >> c[i], c[i] /= 100, sum += p[i] * (i + 1) + c[i];

    const int INF = 1e9;
    vector <int> dp(sum + 1, INF);
    dp[0] = 0;

    rep (i, D) {
        for (int j = sum; j >= 0; j--) if (dp[j] != INF) rep (k, p[i]) {
            if (k != p[i] - 1 && j + (k + 1) * (i + 1) <= sum) {
                dp[j + (k + 1) * (i + 1)] = min(dp[j + (k + 1) * (i + 1)], dp[j] + k + 1);
            }
            if (k == p[i] - 1 && j + k * (i + 1) + c[i] <= sum) {
                dp[j + (k + 1) * (i + 1) + c[i]] = min(dp[j + (k + 1) * (i + 1) + c[i]], dp[j] + k + 1);
            }
        }
    }

    int ans = 1e9;
    range (i, G, sum + 1) ans = min(ans, dp[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a%b);
}
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = b-a+1;
  ll cc = b/c - (a-1)/c;
  ll cd = b/d - (a-1)/d;
  ll bg = c*d/gcd(c,d);
  ll ccd = b/bg - (a-1)/bg;
  cout << ans-cc-cd+ccd << el;
  return 0;
}

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i=1; i<=n; i++){
        string s = to_string(i);
        int num = 0;
        for(int j=0; j<s.size(); j++){
            int tmp = s[j] - '0';
            num += tmp;
        }
        if(num <= b && a <= num) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    t,a = LI()
    h = LI()
    mi = -1
    ms = inf
    for i in range(n):
        s = abs(a-(t - h[i] * 0.006))
        if ms > s:
            ms = s
            mi = i

    return mi + 1


print(main())


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

int main(){
    int k,n;
    cin >> k >>n;
    int a[n+1];
    for(int i=0; i<n;i++){
        cin >> a[i];
    }
    int max=0;
    for(int i=0; i<n-1;i++){
        if((a[i+1]-a[i])>max){
            max=a[i+1]-a[i];
        }
    }
    if((k-a[n-1]+a[0])>max){
        max=k-a[n-1]+a[0];
    }

    cout <<k- max <<endl;
    return 0;
}

Measured memory_bytes: 1024
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

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

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    bool ok = false;
    rep(i,0,n)ok |= (a[i] & 1);
    cout << (ok ? "first" : "second") << "\n";
}

Measured memory_bytes: 3980
#include<iostream>

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

using namespace std;

ll N, X, S[55], P[55];

void foo() {
  S[1] = 5;
  P[1] = 3;
  rep2c(i, N) {
    S[i]=S[i-1]*2+3;
    P[i]=P[i-1]*2+1;
  }
  return;
}

ll bar(ll level, ll pos) {
  if(level==1) {
    if(pos==5) return pos-2;
    else return pos-1;
  }
  ll mid = S[level]/2+1;
  if(pos == S[level]) return P[level];
  else if(pos == 1)   return 0;
  else if(pos == mid) return P[level-1]+1;
  else if(pos < mid)  return bar(level-1, pos-1);
  else                return P[level-1]+1+bar(level-1, pos-mid);
}

void solve() {
  foo();
  cout << bar(N, X) << endl;
  return;
}

int main() {
  cin >> N >> X;
  solve();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

cnt = 0
ans = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

if cnt:
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string w;
    int alphabet = 0x61;
    cin>>w;
    for(int i='a';i<='z';i++){
        int count = 0;
        for(int j=0;j<w.size();j++){
            if(w[j]==i){
                count++;
            }
        }
        if(count%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256