akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#include <iomanip>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 100000
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
double PI = atan2(0, -1);

int N, Q;
vector< vector<int> > edges(200005);
vector<ll> cnt(200005,0), delta(200005,0);
vector<bool> visited(200005,false);

void dfs(int i) {
	cnt[i] += delta[i];
	visited[i] = true;
	for (auto const& chld : edges[i]) {
		if (visited[chld])
			continue;
		delta[chld] += delta[i];
		dfs(chld);
	}
}
 
int main () {
	cin >> N >> Q;
	int a, b;
	rep(i,N-1) {
		cin >> a >> b;
		--a, --b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	int p, x;
	rep(q,Q) {
		cin >> p >> x;
		--p;
		delta[p] += x;
	}
	dfs(0);
	rep(i,N) cout << cnt[i] << " ";
	cout << endl;
    return 0;
}

Measured memory_bytes: 22784
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }











void solve() {
    string s,t;
    cin>>s>>t;
    ll n=s.size(),m=t.size();
    ll ans = LLINF;
    rep(i,n){
        ll cnt = 0;
        if(i + m-1>=n) break;
        rep(j,m){
            if(s[i+j] != t[j]) cnt++;
        }
        chmin(ans,cnt);
    }
    cout<<ans<<endl;




}







signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    double v[111];
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n - 1; i++) {
        sort(v + i, v + n);
        v[i + 1] = (v[i + 1] + v[i]) / 2;
    }
    cout << v[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt(), B = scn.nextInt(), C = scn.nextInt(), D = scn.nextInt(), E = scn.nextInt(), F = scn.nextInt();

		double ans  = -1;
		int water = 0, sugar = 0;
		
		
		for(int a = 0;a <= F/(A*100);a++) {
			for(int b = 0;b <= (F-100 * A * a)/(100 * B);b++) {
				for(int c = 0;c <= (F - 100 * A * a - 100 * B * b)/(C);c++) {
					for(int d = 0;d <= (F - 100 * A * a - 100 * B * b - C * c)/D;d++) {
						if(C*c+D*d > (A*a+B*b)*E || a+b==0)continue;
						double buf = (double)(C*c+D*d)/(double)(100 * (A*a+B*b) + C*c+D*d);
						if(buf > ans) {
							ans = buf;
							water = (A*a+B*b)*100;
							sugar = C*c+D*d;
						}
					}
				}
			}
		}

		System.out.println(water+sugar + " " + sugar);

	}

}


Measured memory_bytes: 21972
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a+b>=c)
cout<<"Yes";
else cout<<"No";
system("pause");
return 0;
}

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

int main()
{
    int n,i;
    cin >> n;
    vector<int> h(n);
    for(i = 0;i < n;++i){
        cin >> h.at(i);
    }
    int temp = 0;
    int max = 0;
    for(i = 0;i < n-1;++i){
        if(h.at(i) >= h.at(i+1)){
            ++temp;
        }else{
            if(max < temp){
                max = temp;
            }
            temp = 0;
        }
    }
    if(max < temp){
        max = temp;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 768
import math


def main():
    h = [int(input()) for count in range(5)]
    total_time = 0
    while len(h) > 0:
        dlist = []
        for i in range(len(h)):
            time = h[i]
            del_time = abs((math.ceil(time / 10) * 10) - time)
            dlist.append(del_time)
        min_d = dlist.index(min(dlist))
        total_time += h[min_d]
        if len(h) > 1:
            total_time = math.ceil(total_time / 10) * 10
        h.pop(min_d)

    print(total_time)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5],i;
    for(i=0;i<5;i++) cin>>a[i];
    for(i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
void op(vector<int>&v, int yes) {
    if(yes)
        reverse(begin(v), end(v));
}
vector<int>solve(int n, int a, int b) {
    if(n < 1)
        return {};
    bool rev = 0;
    if(a > b)
        swap(a, b), rev = 1;
    if(n == 1) {
        vector<int>c = {a, b};
        op(c, rev);
        return c;
    }
    if(b < (1 << (n - 1))) {
        vector<int>v = solve(n - 1, a, b);
        assert(v[v.size() - 2] != b);
        vector<int>u = solve(n - 1, v[v.size() - 2], b);
        v.pop_back();
        for(int x : u)
            v.push_back(x ^ (1 << (n - 1)));
        v.push_back(b);
        op(v,rev);
        return v;
    } else if(a >= (1 << (n - 1))) {
        vector<int>v = solve(n - 1, a - (1 << (n - 1)), b - (1 << (n - 1)));
        vector<int>u = solve(n - 1, v[v.size() - 2], b - (1 << (n - 1)));
        v.pop_back();
        for(int &val : v)
            val ^= (1 << (n - 1));
        assert(!v.empty());
        for(int x : u)
            v.push_back(x);
        v.push_back(b);
        op(v,rev);
        return v;
    }
 
    for(int p = 0; p <= 20; p++) {
        int interm = a ^ (1 << p);
        if(interm < (1 << (n - 1)) && interm != b) {
            vector<int>v = solve(n - 1, a, interm);
            vector<int>u = solve(n - 1, interm, b - (1 << (n - 1)));
            for(int& val : u) {
                val ^= (1 << (n - 1));
                v.push_back(val);
            }
 
            op(v,rev);
            return v;
        }
    }
    assert(5 == 3);
    return {};
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if(__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2) {
        cout << "NO";
        return 0;
    }cout<<"YES\n";
    auto res = solve(n, a, b);
    for(auto it : res)
        cout << it << ' ';
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	int H,W; cin>>H>>W;
	string a[H]; rep(i ,H) cin>>a[i];

	rep(j , W + 2)cout<<'#';
	cout<<endl;
	rep(q , H){
		cout<<'#';
		cout<<a[q];
		cout<<'#'<<endl;
	}
	rep(t , W + 2)cout<<'#';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const int N=5e3+20;
int h,w,n,a[20000];
int b[N][N];
int main()
{
	while(cin>>h>>w)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
			cin>>a[i];
		int x=1,y=1;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=a[i];j++)
			{
				b[x][y]=i;
				if(x%2)
					y++;
				else
					y--;
				if(y==w+1)
					x++,y=w;
				if(y==0)
					x++,y=1;
			}
		}
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)
				printf("%d%c",b[i][j],j==w?'\n':' ');
	}
	return 0;
 
} 

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

int main()
{
    string s1 = "ABC";
    string s2 = "ARC";

    string s;
    cin>>s;

    if(s==s1)
    {
        cout<<s2;
    }
    else
        cout<<s1;

    return 0;
}


Measured memory_bytes: 3628
n = int(input())
# n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
data = [0] + a + [0]
total = 0
for i in range(n+1):
    total += abs(data[i]-data[i+1])

ans = 0
for i in range(1, n+1):
    ans = total+abs(data[i-1]-data[i+1]) - \
        abs(data[i]-data[i+1])-abs(data[i-1]-data[i])
    print(ans)



Measured memory_bytes: 65132
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		int S = in.nextInt();
		int W = in.nextInt();

		System.out.println(W >= S ? "unsafe" : "safe");

	}



	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 35704
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> l(n),d(n);
    for(int i=0;i<n;i++) cin >> l[i];
    int count=0;
    d[0]=0;
    int i,j=0;
    for(i=1;i<=n;i++){
        d[i]=d[i-1]+l[i-1];
        if(d[i]<=x) j++;
    }
    cout << j+1 << endl;
    }



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			ll s = a[i - 1] - a[i];
			ans += s;
			a[i] += s;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;


void solve(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	rep(i,n-1){
		if(a[i]<=a[i+1])continue;
		else if(a[i]-a[i+1]==1){
			a[i+1]++;
		}
		else{
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 640
n,m = list(map(int, input().split()))
isla=[0 for i in range(n+1)]
bri=[]
crus=[[] for i in range(n)]
num=[0 for i in range(n)]
score=[]
crusmax=0

plusnum=-1
minusnum=-1
newnum=-1
plusval=[0,0]
minusval=[0,0]


for i in range(m):
    a,b = list(map(int, input().split()))
    bri.append([a,b])

bri.reverse()
#print(bri)

for i in range(m):
    a=bri[i][0]
    b=bri[i][1]
    if(isla[a]==0 and isla[b]==0):
        crusmax+=1
        crus[crusmax].append(a)
        crus[crusmax].append(b)
        isla[a]=crusmax
        isla[b]=crusmax
        num[crusmax]=2
        [plusnum,minusnum,newnum]=[0,0,crusmax]
    elif(isla[a]==0):
        isla[a]=isla[b]
        crus[isla[b]].append(a)
        num[isla[b]]+=1
        [plusnum,minusnum,newnum]=[isla[b],0,0]
        plusval=[num[isla[b]]-1,num[isla[b]]]
    elif(isla[b]==0):
        isla[b]=isla[a]
        crus[isla[a]].append(b)
        num[isla[a]]+=1
        [plusnum,minusnum,newnum]=[isla[a],0,0]
        plusval=[num[isla[a]]-1,num[isla[a]]]
    elif(isla[a]<isla[b]):
        color=isla[b]
        dif=len(crus[isla[b]])
        for j in range(len(crus[isla[b]])):
            isla[crus[color][j]]=isla[a]
            crus[isla[a]].append(crus[color][j])
        crus[color]=[]
        num[isla[a]]+=num[color]
        num[color]=0
        [plusnum,minusnum,newnum]=[isla[a],color,0]
        plusval=[num[isla[a]]-dif,num[isla[a]]]
        minusval=[dif,0]
    elif(isla[a]>isla[b]):
        color=isla[a]
        dif=len(crus[isla[a]])
        for j in range(len(crus[isla[a]])):
            isla[crus[color][j]]=isla[b]
            crus[isla[b]].append(crus[color][j])
        crus[color]=[]
        num[isla[b]]+=num[color]
        num[color]=0
        [plusnum,minusnum,newnum]=[isla[b],color,0]
        plusval=[num[isla[b]]-dif,num[isla[b]]]
        minusval=[dif,0]
    else:
        [plusnum,minusnum,newnum]=[0,0,0]
    #print("bri[i]",bri[i])
    #print("isla",isla)
    #print("crus",crus)
    #print("num",num)
    
    if(i==0):
        total=0
    else:
        total=score[-1]
    if(newnum!=0):
        total+=1
    if(plusnum!=0):
        total+=(plusval[1]*(plusval[1]-1))//2
        total-=(plusval[0]*(plusval[0]-1))//2
    if(minusnum!=0):
        total+=(minusval[1]*(minusval[1]-1))//2
        total-=(minusval[0]*(minusval[0]-1))//2
    score.append(total)
    #print("total",total)
    #print()
            

score.reverse()
for i in range(len(score)):
    score[i]=(n*(n-1))//2 - score[i]
score.append((n*(n-1))//2)
score=score[1:]
for i in range(len(score)):
    print(score[i])

Measured memory_bytes: 35212
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    int x;
    cin >> a >> b >> c >> x;
    int ans=0;
    for(int i = 0; i <= a; ++i){
        for(int j = 0; j <= b; ++j){
            for(int k = 0; k <= c; ++k){
                int tmp = i * 500 + j * 100 + k * 50;
                if(tmp == x) ans++;
            } 
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,l,t,a[100100],w[100100],cnt;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d%d",&n,&l,&t);
    repu(i,0,n-1)
    {
        a[i]=getint(),w[i]=getint();
        if (w[i]==1)
        {
            if (t>=l-a[i])
                (cnt+=(t-l+a[i])/l+1)%=n;
            (a[i]+=t)%=l;
        }
        else
        {
            if (t>a[i])
                cnt=((cnt-(t-a[i]-1)/l-1)%n+n)%n;
            a[i]=((a[i]-t)%l+l)%l;
        }
    }
    sort(a,a+n);
    repu(i,cnt,n-1)
        printf("%d\n",a[i]);
    repu(i,0,cnt-1)
        printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int a, b, sum1, sum2, sum3; double ave; char t;
int main() {
	while (cin >> a >> t >> b) {
		sum1 += a*b;
		sum2 += b;
		sum3++;
	}
	ave = 1.0*sum2 / sum3;
	cout << sum1 << endl;
	cout << (int)(ave + 0.5) << endl;
}

Measured memory_bytes: 1160
//累積和が使えそう

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long plas[n+2];
  plas[0]=0L;
  int sum=0;
  for(int i=0;i<n;i++){
    cin >>sum;
    plas[i+1]=plas[i]+sum;
  }
  map<long,long> a{};//umb,cpunt
  long ans=0L;
  for(int i=0;i<=n;i++){
    ans+=a[plas[i]];
    a[plas[i]]++;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MAX = 1e5 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ll h,w;
	cin>>h>>w;
	char grid[h][w];
	ll dp[h][w];
	For(i,0,h){
	    For(j,0,w)cin>>grid[i][j];
	}
	dp[0][0]=1;
	For(j,1,w){
	    if(grid[0][j]=='.')dp[0][j]=dp[0][j-1];
	    else dp[0][j]=0;
	}
	
	For(i,1,h){
	    if(grid[i][0]=='.')dp[i][0]=dp[i-1][0];
	    else dp[i][0]=0;
	}
	For(i,1,h){
	    For(j,1,w){
	        if(grid[i][j]=='#')dp[i][j]=0;
	        else
	        dp[i][j] = dp[i-1][j]+dp[i][j-1];
	        dp[i][j]%=MOD;
	    }
	}
	
	cout<<dp[h-1][w-1];
	return 0;
}
 /*           *          *******        *       *    *
             * *            *          * *       *  *
            *****           *         *****        *
           *     *      *   *        *     *       *
          *       *      * *        *       *      *
*/


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

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

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

    int64_t r[2] = {};
    for (int j = 0; j < 2; j++) {
        int64_t m = 0;
        int s = j == 0 ? 1 : -1;
        for (int i = 0; i < n; i++) {
            m += a[i];
            int64_t t = m * s;
            if (t <= 0) {
                r[j] += -t + 1;
                m = s;
            }
            s *= -1;
        }
    }

    cout << min(r[0], r[1]) << endl;

    return 0;
}

Measured memory_bytes: 640
import Data.List

sortedCount :: Integer -> [Integer] -> [Integer] -> [Integer]
sortedCount 0 _ acc = acc
sortedCount j [] acc = sortedCount (j-1) [] (0:acc)
sortedCount j (i:a) (x:acc) | i == j = sortedCount j a ((x+1):acc)
                            | otherwise = sortedCount (j-1) (i:a) (0:x:acc)

main = do
  n:k:q:_ <- map read . words <$> getLine :: IO [Integer]
  a <- map read . words <$> getContents :: IO [Integer]
  mapM (putStrLn . (\x -> if 0 < x then "Yes" else "No")) $ map (\x -> x + k - q) $ tail $ sortedCount n (reverse (sort a)) [0]


Measured memory_bytes: 18044
N, M = map(int, input().split())
A = [input().split() for _ in range(M)]

c = [0]*N
w = [0]*N

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)

Measured memory_bytes: 33696
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s:Vec<char> = buf.trim().chars().collect();
	let mut flag = false;
	let mut p = 0;
	for i in 1..(s.len()+1) {
		let mut j = 0;
		while j + i <= s.len() {
			let ps = &s[j..(j+i)];
			for k in ps {
				if !(*k == 'A' || *k == 'T' || *k == 'G' || *k == 'C') {
					flag = true;
					break;	
				}
			}
			if flag {
				flag = false;
			}else{
				p = i;
				break;
			}
			j += 1;
		}
		flag = false;
	}
	println!("{}", p);
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cmath>
int yaksu(int a){
        if (a==1) return 1;
        int res=a;
        for(int i=sqrt(a);i>0;i--){
                if(a%i==0){
                        res-=i;
                        if(i!=a/i&&i!=1) res=res-a/i;
                }
                if(res<0) break;
        }
        return res;
}

int main(){
        int a,tk;
        while(1){
        scanf("%d",&a);
        if(a==0) return 0;
        tk=yaksu(a);
        if(tk>0) printf("deficient number\n");
        else if(tk==0) printf("perfect number\n");
        else printf("abundant number\n");
        }
}

Measured memory_bytes: 0
// Problem : C - Ubiquity
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 1000003, M = N << 1, mod = 1000000007;

int n;
int dp[N];

inline int qpow(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = res * a % mod;
		a = a * a % mod, b >>= 1;
	}
	return res;
}

signed main()
{
	//File("");
    n = gi <int> ();
    if (n == 1) {puts("0"); return 0;}
    int ans = qpow(10, n);
    int tmp = 2 * qpow(9, n) % mod;
    int tmp2 = qpow(8, n) % mod;
    cout << ((ans - tmp + tmp2) % mod + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename Monoid>
class BIT {
public:
	size_t len;
	Monoid* arr;
	Monoid* tree;
	uint32 i;
	//配列確保
	BIT(size_t length) {
		len = length;
		tree = (Monoid *)calloc(length + 1, sizeof(Monoid));
	}
	//単位元初期化
	void set() {
		for (i = 0; i <= len; ++i) tree[i] = 0;
	}
	//初期化
	void set(Monoid* array) {
		--array;
		for (i = 1; i <= len; ++i) tree[i] = array[i] + range(i);
		++array;
	}
	//区間取得
	Monoid range(size_t a) {
		Monoid ret = tree[a];
		a &= a - 1;
		while (a) {
			ret = ret + tree[a];
			a &= a - 1;
		}
		return ret;
	}
	//更新
	void update(size_t end, Monoid data) {
		int32 a = int32(end);
		++a;
		++len;
		while (a <= len) {
			tree[a] = tree[a] + data;
			a += a&(-a);
		}
		--len;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::string s;
	std::cin >> s;
	std::vector<uint32> c(s.length());
	BIT<int32> t(s.length());
	t.set();
	std::stack<uint32> st[26];
	uint32 cou[26] = {};
	rep(i, 0, s.length()) {
		++cou[s[i] - 'a'];
	}
	bool flag = 0;
	uint32 o = 26;
	rep(i, 0, 26) {
		if (cou[i] & 1) {
			if (flag) {
				std::cout << -1 << "\n";
				return 0;
			}
			else {
				o = i;
				flag = 1;
			}
		}
	}
	uint32 oe = 0;
	uint32 oh = 0;
	uint32 temp;
	uint32 ans = 0;
	uint32 cou2[26] = {};
	flag = 0;
	rep(i, 0, s.length()) {
		temp = s[i] - 'a';
		if (temp == o&&cou2[temp]==cou[temp]/2) {
			ans += oe;
			++oe;
			++cou2[temp];
			flag = 1;
			continue;
		}
		if (cou2[temp] >= cou[temp] / 2) {
			t.update(st[temp].top(), -1);
			ans += t.range(i) - t.range(st[temp].top());
			st[temp].pop();
			++oe;
			++cou2[temp];
		}
		else {
			st[temp].push(i);
			t.update(i, 1);
			ans += oe * 2;
			if (flag) --ans;
			++cou2[temp];
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4500
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string S;
	cin>>S;
	if(S.length()%2==1){cout<<"No";return 0;}
	for(int i=0;i<S.length();i+=2){
		if(S[i]!='h'||S[i+1]!='i'){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) std::cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back

struct Node {
    bool flag;
    vector<Int> adjacentNodes;
};

int main() {
    Int n, m;
    cin >> n >> m;
    auto g = vector<Node>(n, Node{false, vector<Int>()});

    rep(i, m) {
        Int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].adjacentNodes.PB(b);
        g[b].adjacentNodes.PB(a);
    }

    function<Int(Int)> dfs = [&](Int i) -> Int {
        if (g[i].flag) {
            return 0;
        }
        auto v = 1LL;
        g[i].flag = true;
        for (auto &j : g[i].adjacentNodes) {
            v += dfs(j);
        }
        return v;
    };
    auto ans = 0LL;
    rep(i, n) {
        ans = max(ans, dfs(i));
    }
    PUTS(ans)
}

Measured memory_bytes: 28216
//url:
//problem name:

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

void print_vec(vector<ll> vec,int n) {
    rep(i,n) cout << vec.at(i) << " ";
    cout << endl;
}

int N;
vecl H(100010);
int main() {
    cin >> N;
    rep(i,N) cin >> H[i];
    bool ok = true;
    for(int i = N-1; i > 0; i--) {
        //print_vec(H,N);
        if(H.at(i) >= H.at(i-1)) continue;
        else {
            H.at(i-1)--;
            if(H.at(i) < H.at(i-1)) ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.size = [1]*n

    def find(self,a):
        if self.parent[a] == a:
            return a
        else:
            return self.find(self.parent[a])

    def unite(self,a,b):
        a_root = self.find(a)
        b_root = self.find(b)
        if a_root == b_root:
            return
        else:
            if self.size_of(b_root) > self.size_of(a_root): 
                self.parent[a_root] = self.parent[b_root]
                self.size[b_root] += self.size[a_root]
            else:
                self.parent[b_root] = self.parent[a_root]
                self.size[a_root] += self.size[b_root]
                
    def size_of(self,a):
        return self.size[self.find(a)]
    
    def is_same(self,a,b):
        return self.find(a) == self.find(b)

N,M = map(int,input().split())
tree = UnionFind(N)
for i in range(M):
    X, Y = map(int,input().split())
    tree.unite(X-1,Y-1)

print(max([tree.size_of(x) for x in range(N)]))

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

int main(){
    int N, R; cin >> N >> R;
    int ans;

    if(N>=10){
        ans = R;
    }else{
        ans = R+100*(10-N);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int v, e;
const int MAX_N=100010;

vector<int> g[MAX_N];
vector<int> h[MAX_N];
bool used[MAX_N];

vector<int> ans;

int dp[MAX_N];

void dfs(int u) {
  if(used[u]) return;
  used[u] = true;
  for(int i=0;i<g[u].size();i++)dfs(g[u][i]);
  ans.push_back(u);
}

void tsort() {
  for(int i=1;i<=v;i++)dfs(i);
  reverse(ans.begin(), ans.end());
}

int main(){
  cin >> v >> e;
  for(int i=0;i<e;i++) {
    int s, t;
    cin >> s >> t;
    g[s].push_back(t);
    h[t].push_back(s);
  }

  tsort();
  int lp=0;
  for(int i=0;i<ans.size();i++){
    for(int j=0;j<h[ans[i]].size();j++){
      int x=h[ans[i]][j];
      dp[ans[i]]=max(dp[ans[i]],dp[x]+1);
    }
    lp=max(lp, dp[ans[i]]);
  }
  cout << lp << endl;
  return 0;
}


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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define fastio    ios::sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

ll iv(ll a, ll b) {
  return a > 1 ? b - iv(b % a, a) * b / a : 1;
}

int32_t main() {
  fastio;
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int n;
  cin >> n;
  vi a1(n);
  rep(i, n) cin >> a1[i];
  vi a2(a1);

  ll lcm = 1;
  for (int i = 2; i <= 1000; i++) {
    int mx = 1;
    rep(j, n) {
      int cur = 1;
      while (a2[j] % i == 0) {
        cur *= i;
        a2[j] /= i;
      }
      mx = max(cur, mx);
    }
    lcm = lcm * mx % mod;
  }

  set<int> s;
  rep(i, n) s.insert(a2[i]);

  for (int i : s) lcm = lcm * i % mod;

  ll tot = 0;
  rep(i, n) tot = (tot + lcm * iv(a1[i], mod)) % mod;

  cout << tot;

  return 0;
}


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

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

  int left, right, count = 0;
  for (int i = a; i <= b; i++) {
    left = i / 1000;
    right = i % 10;
    right *= 10;
    right += i / 10 % 10;
    if (left == right) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

vector<ll> factorize(ll val) {
    vector<ll> res;
    for (ll i = 1; i * i <= val; ++i) {
        if (val % i) {
            continue;
        }
        res.push_back(i);
        if (i * i != val) {
            res.push_back(val / i);
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> factors1 = factorize(N - 1);
    ll ans = (ll)factors1.size() - 1;
    vector<ll> factors2 = factorize(N);
    for (auto f : factors2) {
        if (f == 1) {
            continue;
        }
        ll tmp = N;
        while (tmp > 0) {
            if (tmp % f) {
                if (tmp > f) {
                    tmp %= f;
                }
                else {
                    tmp -= f;
                }
            }
            else {
                tmp /= f;
            }
            if (tmp == 1) {
                ++ans;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
#define V 1001001
lint mo=998244353;
lint num[V+10],dp[V+10],inv[V+10];
vector<int> ya[V+10];
int main()
{
	inv[1]=1;REP(i,2,V) inv[i] = inv[mo%i] * (mo - mo/i) % mo;
	memset(num,0,sizeof(num));
	int n,a;cin>>n;
	rep(i,n){
		cin>>a;num[a]++;
	}
	/*REP(i,1,V){
		for(int j=i+i;j<V;j+=i) ya[j].pb(i);
	}*/
	REP(i,1,V) dp[i]=inv[i];
	REP(i,1,V){
		for(int j=i+i;j<V;j+=i){
			dp[j]+=mo-dp[i];
			if(dp[j]>=mo) dp[j]-=mo;
		}
	}
	//REP(i,1,7) cout<<i<<' '<<dp[i]<<endl;
	lint out=0;
	REP(i,1,V){
		lint sum=0;
		for(int j=i;j<V;j+=i){
			if(num[j]<1) continue;
			lint t=(num[j]*(num[j]-1)/2)%mo;
			out+=((t*j)%mo*j)%mo*dp[i];out%=mo;
			out+=((sum*j)%mo*num[j])%mo*dp[i];out%=mo;
			sum+=num[j]*j;sum%=mo;
			//cout<<i<<' '<<j<<' '<<out<<' '<<sum<<endl;
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int N, X, Y; cin >>N >> X >> Y; X--; Y--;

    vector<int> cnt(N, 0);

    int d, d1, d2;
    for (int i = 0; i < N-1; i++) {
        for (int j = i + 1; j < N; j++) {
            d1 = abs(X - i) + abs(Y - j);
            d2 = abs(Y - i) + abs(X - j);
            d = min(d1, d2) + 1;
            d = min(d, j - i);
            cnt[d]++;
        }
    }

    for (int i = 1; i < N; i++) {
        cout << cnt[i] << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]){
		// Nを入力
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();

		// ABCDEを入力
		long A;
		long min = (long)1e18;
		for(int i = 0; i < 5; i++){
			A = scan.nextLong();
			// ボトルネック箇所のキャパを算出
			if(A < min){
				min = A;
			}
		}
		scan.close();
        
		// 答えを計算し出力
		long ans = (N + min - 1) / min + 4;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }



int main()
{
    long long int n,ans=0;
    cin >>n;
    ans=(n/500)*1000+((n%500)/5)*5;
    cout<<ans<<"\n";
    return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
const string ok = "Yes";
const string ng = "No";

const int inf=1145141919;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int bit=0;
    unordered_map<int,int> x;
    x[bit]=0;
    REP(i,n){
        int t=s[i]-'a';
        bit^=(1<<t);
        REP(c,26){
            if(x.count(bit^(1<<c))){
                if(x.count(bit)==0)
                    x[bit]=inf;
                chmin(x[bit],x[bit^(1<<c)]+1);
            }
        }
    }
    
    cout<<max(x[bit],1)<<endl;
    
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n,a[maxn],b[maxn],c[maxn];


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

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

    int res=0;
    for (int i=0; i<n; i++) {
	res+=b[a[i]];
	if (i && a[i-1]+1==a[i]) {
	    res+=c[a[i-1]];
	}
    }
    out(res);
    
    
    return 0;
}


Measured memory_bytes: 3620
icase=0
if icase==0:
    import sys
    n=int(input())
    a=list(map(int,input().split()))
    for i in range(40):
        for ii in range(n):
            aii=a[ii]
            a[ii]=aii//2
            if aii%2==1:
                print(i)
                sys.exit()

Measured memory_bytes: 3060
import Control.Monad
main = do
  n <- readLn
  xs <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  let ds = zipWith (zipWith subtract) ([0,0,0] : xs) xs
      ok = all (\[t,x,y] -> t>=x+y && even (t-x-y)) ds
  putStrLn $ if ok then "Yes" else "No"

Measured memory_bytes: 83324
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        
        if(A + B >= 10){
            Console.WriteLine("error");
        }else{
            Console.WriteLine(A + B);
        }
    }
    
}

Measured memory_bytes: 11092
import bisect
# listのpopを使う
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# 純粋に小さい方を読んでいく
ans = 0
# 1番上しか読めない
# while K >= A[0] or K >= B[0]:
#     if A[0]
cumulative_sum_of_A = [0]
cumulative_sum_of_B = [0]
for i in range(N):
    cumulative_sum_of_A.append(cumulative_sum_of_A[-1]+A[i])

for i in range(M):
    cumulative_sum_of_B.append(cumulative_sum_of_B[-1]+B[i])

# print(cumulative_sum_of_A)
# print(cumulative_sum_of_B)

ans = 0
for i in range(N+1):
    # print(ans)
    if cumulative_sum_of_A[i] > K:  # それ以上Aを読めないならアウト
        break
    tmp = i  # A側の本をi冊読む  # 0の場合もあり
    remaining = K - cumulative_sum_of_A[i]  # 残り時間
    upper_bound = bisect.bisect_right(cumulative_sum_of_B, remaining)-1
    tmp += upper_bound
    ans = max(tmp, ans)
print(ans)


Measured memory_bytes: 47344
isPrint = False

while True:

    inputCount = int(input())

    if inputCount == 0:
        break

    if isPrint:
        print()
    else:
        isPrint = True

    matchList = []

    for lp in range(inputCount):

        name, win, lose, draw = [item for item in input().split(" ")]
        score = int(win) * 3 + int(draw)

        matchList.append([name, score])

    matchList.sort(key=lambda item: -item[1])

    for name, score in matchList:
        print(name + "," + str(score))



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve(){
    ll n, q;
    queue<pair<string, ll>> qu;
    cin >> n >> q;
    rep(i, 0, n){
        string name; ll t;
        cin >> name >> t;
        qu.push(make_pair(name, t));
    }

    ll elapsed = 0, a; // elapsed time
    pair<string, ll> u;
    while(!qu.empty()){
        u = qu.front(); qu.pop();
        a = min(q, u.second);
        elapsed += a;
        u.second -= q;
        if(u.second > 0){
            qu.push(u);
        }else{ 
            cout << u.first << " " << elapsed << "\n";
        }
    }
}


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

    solve();
    return 0;
}



Measured memory_bytes: 6188
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	int ans = 0;
	for(int i=n;i<m+1;i++){
		if(i%k==0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    int n ;
    cin >> n ;
    vector<int> a(100001,0) ;
    ll sum = 0 ;
    for (int i = 0; i < n; i++){
         int tmp ;
         cin >> tmp ;
         sum+=tmp ;
         a[tmp]++ ;
    }

    int q ;
    cin >> q ;
    int b[q],c[q] ;
    for (int i = 0; i < q; i++) cin >> b[i] >> c[i] ;

    for (int i = 0; i < q; i++)
    {
        if(a[b[i]]==0){
            cout << sum << endl ;
            continue ;
        }else{
            int tmp = a[b[i]]*b[i]-a[b[i]]*c[i] ;
            a[c[i]]+=a[b[i]] ;
            a[b[i]] = 0 ;
            if(tmp<0){
                sum += (-1)*tmp ;
            }else{
                sum -= tmp ;
            }
                cout << sum << endl ;
        }
    }
    
        return 0; 
}

Measured memory_bytes: 4384
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func run() {
	n := nextInt()
	as := make([][]int, n)
	for i := 0; i < n; i++ {
		as[i] = nextInts(n - 1)
		for j := 0; j < n-1; j++ {
			as[i][j]--
		}
	}
	waiting := make(map[int]int)
	cursor := make([]int, n)
	queue := make([]int, n)
	for i := 0; i < n; i++ {
		queue[i] = i
	}
	waitFor := func(me int, you int) bool {
		waiting[me] = you
		if they, ok := waiting[you]; ok {
			if they == me {
				delete(waiting, you)
				delete(waiting, me)
				cursor[you]++
				cursor[me]++
				return true
			}
		}
		return false
	}
	answer := 0
	for len(queue) > 0 {
		nextQueue := make([]int, 0)
		for _, x := range queue {
			you := as[x][cursor[x]]
			if waitFor(x, you) {
				if cursor[x] < n-1 {
					nextQueue = append(nextQueue, x)
				}
				if cursor[you] < n-1 {
					nextQueue = append(nextQueue, you)
				}
			}
		}
		queue = nextQueue
		answer++
	}
	for i := 0; i < n; i++ {
		if cursor[i] != n-1 {
			answer = -1
		}
	}
	Println(answer)
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024

func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}

func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}

func nextFloats(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = nextFloat()
	}
	return res
}

func nextStrings(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = next()
	}
	return res
}

func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c)
{
    if (c - a - b > 0)
    {
        if (4 * a * b < (c - a - b) * (c - a - b))
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long c;
    scanf("%lld", &c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;

int main(){
    int a,w;
    cin>>a>>w;
    if(w>=a){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
}

Measured memory_bytes: 3636