akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(x):print(x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    D = int(input())
    #N, K = map(int, input().split())
    cs = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(D)) #改行行列
    ls=[0]*26
    for i in range(D):
        s=S[i]
        if i==0:
            msc=-1000000
            ans=-1
            for j in range(26):
                sc=s[j]+cs[j]
                if msc<sc:
                    ans=j
                msc=sc
            ls[ans]=1

            print(ans+1)
            continue
        msc=0
        ans=-1
        dec=[-cs[j]*(i+1-ls[j]) for j in range(26)]
        msc=-10000000
        ans=-1
        for j in range(26):
            sc=s[j]-dec[j]
            if msc<sc:
                ans=j
            msc=sc
        ls[ans]=i+1
        print(ans+1)



            
                    
            






if __name__ == "__main__":
    main()

Measured memory_bytes: 73096
import java.util.ArrayList;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int map[][] = new int[h][w];
        ArrayList<Operate> op = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                map[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) {
                // 偶数行目 左 => 右
                for (int j = 0; j < w - 1; j++) {
                    if (map[i][j] % 2 == 0) {
                        continue;
                    } else {
                        // [[i][j]はあまりがある
                        op.add(new Operate(i, j, i, j + 1));
                        map[i][j + 1]++;
                    }
                }
                // 最下段でない
                if (i != h - 1) {
                    if (map[i][w - 1] % 2 == 0) {
                        continue;
                    } else {
                        // [[i][j]はあまりがある
                        op.add(new Operate(i, w - 1, i + 1, w - 1));
                        map[i + 1][w - 1]++;
                    }
                }
            } else {
                for (int j = w - 1; j > 0; j--) {
                    if (map[i][j] % 2 == 0) {
                        continue;
                    } else {
                        // [[i][j]はあまりがある
                        op.add(new Operate(i, j, i, j - 1));
                        map[i][j - 1]++;
                    }
                }
                // 最下段でない
                if (i != h - 1) {
                    if (map[i][0] % 2 == 0) {
                        continue;
                    } else {
                        // [[i][j]はあまりがある
                        op.add(new Operate(i, 0, i + 1, 0));
                        map[i + 1][0]++;
                    }
                }
            }
        }
        System.out.println(op.size());
        for (Operate operate : op) {
            operate.show();
        }

        sc.close();
    }
}

class Operate {

    int i, j, ni, nj;

    Operate(int i, int j, int ni, int nj) {
        this.i = i + 1;
        this.j = j + 1;
        this.ni = ni + 1;
        this.nj = nj + 1;
    }

    public void show() {
        System.out.println(i + " " + j + " " + ni + " " + nj);
    }
}


Measured memory_bytes: 103260
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 200000;
multiset < int > s[N];
vector < int > g[N];
int used[N], a[N];
int dp[N], ans, v0;
void dfs(int v, int p = -1){
    int x = 0;
    int y = 0;
    int z = 0;
    for (auto u: g[v]){
        if (u == p) continue;
        dfs(u, v);
        if (dp[u] == 0) x++;
        if (dp[u] == 1) y++;
        if (dp[u] == 2) z++;
    }
    if (x <= 1 && y == 0 && z == 0){
        dp[v] = 0;
        return;
    }
    if (y > 1 || z > 0){
        z += y;
        y = 0;
    }
    if (y == 0){
        if (x == 0){
            dp[v] = 2;
        } else{
            ans += x - 1;
            dp[v] = 1;
        }
        return;
    }
    if (y == 1){
        if (x > 0) ans += x - 1;
        dp[v] = 1;
        if (v == v0 && x <= 1) ans++;
    }
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int res = 1e9;
    for (int i = 0; i < min(50, n); i++){
        memset(dp, 0, sizeof(dp));
        v0 = rand() % n;
        ans = 0;
        dfs(v0);
        if (dp[v0] == 0) ans++;
        //cout << ans << " " << v0 << endl;
        res = max(res, ans);
    }
    cout << ans;
}


Measured memory_bytes: 26368
import java.util.*;

public class Main {
	void solve() {
		try (final Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			String c = sc.next();
			System.out.println(a.charAt(0) + "" + b.charAt(0) + "" + c.charAt(0));
		}
	}

	public static void main(String[] args) {
		new Main().solve();
	}

}


Measured memory_bytes: 9556
import fractions

a,b,c,d = map(int,input().split()) 

cd = (c * d) // fractions.gcd(c, d)
b_c = b // c
b_d = b // d
b_cd = b // cd
a_c = (a-1) // c
a_d = (a-1) // d
a_cd = (a-1) // cd

ans = b - b_c - b_d + b_cd - (a-1) + a_c + a_d - a_cd

print(ans)

Measured memory_bytes: 5076
import collections
n = int(input())
li = [input() for _ in range(n)] #n行に１つずつ入力されるmojiretu
ans = 'Yes'
lw = li[0][0]
for s in li:
    if lw != s[0]:
        ans = 'No'
        break
    else:
        lw = s[-1]

c = collections.Counter(li)
if c.most_common()[0][1] != 1:
    ans = 'No'
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,f=0;
	cin>>n;
	int a[n];
	priority_queue<int>q1,q2;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		q1.push(a[i]);
		q2.push(a[n-i-1]);
		while(!q1.empty()&&q1.top()==q2.top())q1.pop(),q2.pop();
		if(q1.empty()){
			if(f++)cout<<' ';
			cout<<i+1;
		}
	}cout<<endl;
}


Measured memory_bytes: 4112
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    priority_queue<char, vector<char>, greater<char>> que1;
    priority_queue<char> que2;
    
    for(int i = 0; i < s.length(); i++){
        que1.push(s[i]);
    }
    for(int i = 0; i < t.length(); i++){
        que2.push(t[i]);
    }
    
    string S, T, temp;
    while(!que1.empty()){
        temp = que1.top();
        que1.pop();
        S += temp;
    }
    while(!que2.empty()){
        temp = que2.top();
        que2.pop();
        T += temp;
    }
    
    if(S < T){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

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

int main()
{   
    int h,w;
    cin>>h>>w;
    string c[105];
    
    for(int i=0;i<h;i++){
         cin>>c[i];
         cout<<c[i]<<endl<<c[i]<<endl;
    }
    
        
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    conditions = []
    for _ in range(M):
        s, c = input().rstrip("\r\n").split()
        conditions.append((int(s)-1, c))
    ans = -1
    if N > 1:
        start = 10**(N-1)
    else:
        start = 0
    for i in range(start, 10**N):
        i_str = str(i)
        matched = True
        for s, c in conditions:
            if len(i_str) > s:
                matched = matched and i_str[s] == c
            else:
                matched = False
        if matched:
            ans = i
            break
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38896
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    cnt = 0
    ans = 0
    for _ in range(n):
        a, b = input_int_list()
        if a == b:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    else:
        ans = max(ans, cnt)

    if ans >= 3:
        print("Yes")
    else:
        print("No")
    return


if __name__ == "__main__":
    main()


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

using namespace std;

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

  long A[n][m];
  long B[m][l];
  long C[n][l]; 

  fill(&C[0][0], &C[n+1][0], 0);

  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      cin >> A[i][j];
  
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < l; ++j)
      cin >> B[i][j];

  for (int i = 0; i < n; ++i)
    for (int k = 0; k < m; ++k)
      for (int j = 0; j < l; ++j)
        C[i][j] += A[i][k] * B[k][j];

  for (int i = 0; i < n; ++i) {
    cout << C[i][0];
    for (int j = 1; j < l; ++j)
      cout << " " << C[i][j];
    cout << endl;
  }
}


Measured memory_bytes: 3248
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
int main(){
  int n;
  cin>>n;
  vector<int>t(n),x(n),y(n);
  rep(i,n)cin>>t[i]>>x[i]>>y[i];
  bool ans=true;
  rep(i,n-1){
    int dx=x[i+1]-x[i],dy=y[i+1]-y[i];
    if((t[i+1]-t[i])%2!=(abs(dx+dy))%2)ans=false;
    if(abs(dx)+abs(dy)>t[i+1]-t[i])ans=false;
  }
  if(t[0]%2!=abs(x[0]+y[0])%2)ans=false;
  if(abs(x[0])+abs(y[0])>t[0])ans=false;
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1408
//
//  ALDS1_3_B.cpp
//  
//
//  Created by mk on 2015/12/02.
//
//

#include <stdio.h>
#include <string.h>
#include <iostream>
#define LEN 100005

using namespace::std;

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int main(int argc, const char * argv[]) {
    int elaps = 0, c;
    int q;
    P u;
    scanf("%d %d", &n, &q);
    for (int i=1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n+1;
    
    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t >0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }

    return 0;
}

Measured memory_bytes: 11348
import java.util.*;

class Main {
    public static void main(final String[] args) {
        final Scanner scan = new Scanner(System.in);
        int a = scan.nextInt(); // Takahasi HP
        final int b = scan.nextInt();
        int c = scan.nextInt(); // Aoki HP
        final int d = scan.nextInt();
        scan. close();
        
        while(true){
            c -= b;
            if(c <= 0){
                System.out.print("Yes"); 
                break;
            }
            a -= d;
            if(a <= 0){
                System.out.println("No");
                break;
            }
        }
    }
}

Measured memory_bytes: 35756
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <cstdio>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int,int>;
using TP = tuple<int,int,int>;

int main() {
    int h,w,ch,cw,dh,dw;
    scanf("%d %d %d %d %d %d",&h, &w,&ch,&cw,&dh,&dw);

    char s[h+1][w+1];
    for (int i=0; i<h; i++) {
        scanf("%s",s[i]);
    }

    vector num(h, vector(w,-1));

    const vector dx = {-1,0,+1,0};
    const vector dy = {0,+1,0,-1};

    priority_queue<TP, vector<TP>, greater<>> q;
    q.emplace(0, ch-1,cw-1);
    while(!q.empty()) {
        const auto [c,y,x] = q.top(); q.pop();
        if (x<0 || w<=x) continue;
        if (y<0 || h<=y) continue;
        if (s[y][x] == '#') continue;
        if (num[y][x]>=0 && num[y][x]<=c) continue;
        num[y][x] = c;
        if (y+1 == dh && x+1 == dw) break;


        for (short i=0; i<4; i++) {
            const int xi = x + dx[i];
            const int yi = y + dy[i];
            if (xi<0 || w<=xi) continue;
            if (yi<0 || h<=yi) continue;
            if (s[yi][xi] == '#') continue;
            q.emplace(c,yi,xi);
        }

        for (short i=-2; i <=2; i++) {
            const int yi = y + i;
            if (yi<0 || h<=yi) continue;
            for (short j=-2; j<=2; j++) {
                const int xi = x + j;
                if (xi<0 || w<=xi) continue;
                if (s[yi][xi] == '#') continue;
                if (num[yi][xi]>=0 && num[yi][xi]<=c) continue;
                q.emplace(c+1,yi, xi);
            }
        }
    }


    cout << num[dh-1][dw-1] << endl;
}


Measured memory_bytes: 9792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int N = scan.nextInt();
		Integer p[] = new Integer[N];
		//int min = Math.abs(100 - X);
		int min = 100;
        int result = X;

		for (int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}

		for (int i = 0; i <= 200; i++) {
			if (Math.abs(X - i) < min && !Arrays.asList(p).contains(i)) {
				min = Math.abs(X - i);
				result = i;
			}
		}

		System.out.println(result);

	}

}

Measured memory_bytes: 35876
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int n;
	scanf("%d", &n);
	int m = n / 10;
	int l = n / 100;
	
	if(n - 10 * m == 7) printf("Yes");
	else if(l == 7) printf("Yes");
	else if(10 * m - l * 100 == 70) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 1728
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

int main(){
	string s;
	cin>>s;
	int n=s.size();
	ll ans=0;
	ll pos=0;
	rep0(i,n){
		if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'){
			pos++;
		}
		else{
			ans=max(ans,pos);
			pos=0;
		}
	}
	ans=max(ans,pos);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  long long t;
  cin >> n >> t;
  long long ans = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
	cin >> a[i];
  }
  for (int i = 0; i < n -1; i++) {
	if (a[i + 1] - a[i] > t) {
	  ans += t;
	}
	else {
	  ans += a[i + 1] - a[i];
	}
  }
  cout << ans + t << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
#define ll long long

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define pb emplace_back
#define mp make_pair


using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<ll, ll> P;

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

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

ll R, C, N, M, K, Q;

vector<int> v[200005];
vector<int> res;

void dfs(int node, int p = 0){
    PRINT(node)
    PRINT(res[node])
    rep(i,v[node].size()){
        if(v[node][i] == p) continue;
        res[v[node][i]] += res[node];
        dfs(v[node][i], node);
    }
    return;
}

signed main() {
    //cout << fixed << setprecision(10);
    cin >> N >> Q;

    rep(i, N-1){
        int from,to; cin >> from >> to;
        from --;
        to --;
        v[from].pb(to);
        v[to].pb(from);
    }
    res.assign(N,0); 
    rep(i,Q){
        int node, val; cin >> node >> val;
        res[--node] += val;
    }
    dfs(0);

    rep(i, N){
        cout << res[i] << endl;
    }

    //cout << max << endl;
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int r,g,b;
	cin>>r>>g>>b;
	int ans = r*100 + g*10 + b;
	if (ans % 4 == 0)
	{
		cout<<"YES"<<endl;
	}
	else {
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int input(int*, int*,int );
void sort(int *,int );
void reset(int*, int*, int);
int compare_int(const void* a, const void* b);


int main()
{
	int sum = 0;
	int n, k;
	int *data;
	int *m;

	scanf("%d %d", &n, &k);

	data = (int*)malloc(n * sizeof(int));
	m = (int*)malloc(n * sizeof(int));

	reset(data, m, n);
	n = input(data, m, n);

	for (int i = k; i < n; i++)
		sum += m[i];

	printf("%d\n", sum);

	free(data);
	free(m);

	return 0;
}

void reset(int* data, int* m, int n)
{
	for (int i = 0; i < n; i++)
		data[i] = m[i] = 0;
}

int input(int *data, int *m,int n)
{
	int a;

	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		data[a - 1]++;
	}

	a = 0;
	for (int i = 0; i < n; i++) {
		if (data[i] != 0) {
			m[a] = data[i];
			a++;
		}
	}

	qsort(m, a, sizeof(int), compare_int);

	return a;
}

int compare_int(const void* a, const void* b)
{
	return *(int*)b - *(int*)a;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  double ans = 0;
  for(int i = 0; i < n; i++){
    double x; string u; cin >> x >> u;
    if(u == "JPY") ans += x;
    else ans += x * 380000;
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  map<int, int> A;
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    auto itr = A.find(tmp);
    if (itr != A.end()) {
      A[tmp] += 1;
    } else {
      A[tmp] = 1;
    }
  }

  int num_2 = 0;
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    if (itr->second % 2 == 0) {
      num_2 += 1;
    }
  }
  if (num_2 % 2 == 0) {
    cout << A.size() << endl;
  } else {
    cout << A.size() - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) -= (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int n, a, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    if (n == 1)
        cout << "Hello World";
    else
        cin >> a >> b,
        cout << a + b;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    VI a(n);
    REP(i,n) cin >> a[i];
    for ( int i=k; i<n; i++ ) {
        if ( a[i]>a[i-k] ) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3988
A = input()
B = input()
C = input()
state = [list(A), list(B), list(C)]

player = 0
player_name = ["A", "B", "C"]
get_player = {"a": 0, "b":1, "c": 2}
while True:
    if len(state[player]) == 0:
        print(player_name[player])
        exit()
    next_player_name = state[player].pop(0)
    player = get_player[next_player_name]


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main( void ){
    int a,b;
    int n;
    cin >> a >> b;
    if (b < 10) n = a*10 + b;
    else if (b == 100) n = a*1000 + b;
    else n = a*100 + b;
    int f = 1;

    for(int i = 1;i<1+sqrt(n);i++){
        if( i ==  n/i && (double) (n%i) == 0){
          f = 0;  
          break;
        }
       // cout << i << " ";
    }

    if(f == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<int> E(N, 0), W(N, 0);

	for(int i = 0; i < N; i++) {
		int b = i == 0 ? 0 : W[i - 1];
		W[i] = S[i] == 'W' ? b + 1 : b;
		b = i == 0 ? 0 : E[N - i];
		E[N - i - 1] = S[N - i - 1] == 'E' ? b + 1 : b;
	}

	int m = INT_MAX;
	for(int i = 0; i < N; i++) {
		int n = W[i] + E[i];
		if(W[i] > 0 && S[i] == 'W') n--;
		else if(E[i] > 0 && S[i] == 'E') n--;

		m = min(m, n);
	}
	cout << m << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, m;
  cin >> n >> m;

  vll x(m);
  rep(i, m) {
    cin >> x[i];
  }
  sort(all(x));

  vll d(m - 1);
  rep(i, m - 1) {
    d[i] = x[i + 1] - x[i];
  }

  sort(all(d));

  ll ans;
  if (n >= m) {
    ans = 0;
  } else {
    ans = accumulate(d.begin(), next(d.begin(), m - n), 0ll);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    string S;
    cin >> S;

    int ans = 700;
    for (int i = 0; i < 3; ++i) {
        if (S[i] == 'o') {
            ans += 100;
        }
    }

    cout << ans << endl;

    return 0;
}


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


map<char,int>st;
int data[3]={0};
int main(){
	data[0]=1;
	st['A']=0;
	st['B']=1;
	st['C']=2;
	
	char cha,ch,chb;
	while(cin>>cha>>ch>>chb){
		int tmp=data[st[cha]];
		data[st[cha]]=data[st[chb]];
		data[st[chb]]=tmp;
	}
	
	for(int i=0;i<3;i++){
		if(data[i]==1){
			char ans='A'+i;
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 1168
#include <iostream>

using namespace std;
int main(){
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    h1 = h1*60 + m1; h2 = h2*60 + m2;
    cout << h2 - h1 - k << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main(){
	string s;
	cin >> s;
	string t;
	cin >> t;
	int n = s.size();
	int m = t.size();
	for (int i = n - m; i >= 0; i--) {
		bool cor = true;
		for (int j = 0; j < m; j++) {
			if (s[i + j] != '?' && s[i + j] != t[j]) cor = false;
		}
		if (cor) {
			for (int k = 0; k < i; k++) {
				char ans = s[k] == '?' ? 'a' : s[k];
				cout << ans;
			}
			cout << t;
			for (int l = i + t.size(); l < s.size(); l++) {
				char ans = s[l] == '?' ? 'a' : s[l];
				cout << ans;
			}
			return 0;
		}
	}
	cout << "UNRESTORABLE";
	return(0);
}

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

using namespace std;

int a[100005];
int n;
const int INF = 1e9 + 7;
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  int m = a[n-1];
  double t = a[n-1] / 2.0;
  double MIN = INF;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(abs(t - a[i]) < MIN) {
      MIN = abs(t - a[i]);
      ans = a[i];
    }
  }
  cout << m << " " << ans << endl;
}
  


Measured memory_bytes: 640
<?php
fscanf(STDIN,"%d",$n);

$arr=explode(' ',trim(fgets(STDIN)));
asort($arr);

$k_arr=array_keys($arr);

for($i=0;$i<$n;$i++){
	echo ($k_arr[$i]+1);
	if($i<>$n){
		echo " ";
	}
}

?>

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

const int N = 5000+9;
const int M = 200+9;

int n,m,que[M][N],cnt[M],mat[M][N],bst[M];
LL delta[N],x[N],vout,cur,dis,len;

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

int main() {
	//freopen("11input.in","r",stdin);
	n = read(); m = read();
	for (int i=1;i<n;i++) 
		x[i] = read();
	for (int j=1;j<=n;j++) {
		for (int i=1;i<=m;i++) {
			mat[i][j] = read();
		}
	}
	for (int r=1;r<=n;r++) {
		cur = 0; len = (dis += x[r-1]);
		for (int i=1;i<=m;i++) {
			while (cnt[i] && mat[i][que[i][cnt[i]]] <= mat[i][r]) {
				if (cnt[i] > 1) 
					delta[que[i][cnt[i]-1]] += mat[i][que[i][cnt[i]-1]] - mat[i][que[i][cnt[i]]];
				cnt[i]--;
			}
			que[i][++cnt[i]] = r;
			if (cnt[i] > 1) delta[que[i][cnt[i]-1]] += mat[i][r] - mat[i][que[i][cnt[i]-1]];
			bst[i] = max(bst[i], mat[i][r]);
			cur += bst[i];
		}
		for (int l=1;l<=r;l++) {
			vout = max(vout, cur - len);
			cur += delta[l];
			len -= x[l];
		}
	}
	printf("%lld\n",vout);
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    map<ll, ll> M;
    ll res = 0;
    REP(i, N) {
        ll x;
        cin >> x;
        res += M[i-x];
        M[i+x]++;
    }
    cout << res << "\n";
}


Measured memory_bytes: 26188
import math

if __name__ == '__main__':
    s = input()
    count = 0
    for i in range(math.ceil(len(s) / 2)):
        if s[i] != s[len(s) - i - 1]:
            # print(i)
            # print(s[i], s[len(s) - i - 1])
            count += 1

    print(count)

Measured memory_bytes: 3060
def reverseStr(s):
    return s[::-1]

n = int(input())
for i in range(n):
    s = input()
    d = set([])
    for j in range(1,len(s)):
        a = s[:j]
        b = s[j:]
        d.add(a+b)
        d.add(b+a)
        d.add(a + reverseStr(b))
        d.add(b + reverseStr(a))
        d.add(reverseStr(a) + b)
        d.add(reverseStr(b) + a)
        d.add(reverseStr(a) + reverseStr(b))
        d.add(reverseStr(b) + reverseStr(a))
    print(len(d))

Measured memory_bytes: 7648
s = input().strip()

ok = s[0] == 'A' and s[2:-1].count('C') == 1
if ok:
    for i, c in enumerate(s):
        if i == 0:
            continue
        if 2 <= i < len(s) - 1 and c == 'C':
            continue
        if c != c.lower():
            ok = False

if ok:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
n = gets.to_i
l = {}
max = 0
n.times do
  s = gets.chop
  l[s] = l[s].to_i + 1
  max = l[s] if l[s] > max
end
o = []
l.each do |k, v|
  o << k if v == max
end
o.sort.each do |v|
  puts v
end


Measured memory_bytes: 34780
#include<iostream>
using namespace std;
long long dp[60][60][3000];
int main(){
	int n,a,x[50];
	cin>>n>>a;
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<=2500;k++){
				dp[i+1][j][k]+=dp[i][j][k];
				dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
			}
		}
	}
	long long ans=0;
	for(int j=1;j<=n;j++){
		ans+=dp[n][j][a*j];
	}
	cout<<ans<<endl;
	return 0;
}


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

#define  vt            vector
#define  db            long double
#define  int           long long
#define  pb            push_back
#define  inf           (int)1e18
#define  mxn           (int)2e5+5
#define  pii           pair<int,int>

#define  si(x)         (int)x.size()
#define  all(x)        x.begin(),x.end()
#define  mem(a,x)      memset(a,x,sizeof(a))
#define  forr(i,n)     for(int i=0;i<n;i++)

#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}

int mainx()
{
    int n;
    cin >> n;
    vt<int> a(n , 0);
    for (int i = 0 ; i < n ; i++)
        cin >> a[i];
    int sum = 0;
    forr(i , n)
    {
        if (i == 0)continue;
        else
        {
            if (a[i] < a[i - 1])
            {
                sum += (a[i - 1] - a[i]);
                a[i] = a[i - 1];
            }
            else
                continue ;
        }

    }
    cout << sum << endl;
    return 0;
}


inline void include() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
#endif
}
int32_t main() {
    //include();
    ios::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    //cout << fixed << setprecision(20);

    int tt = 1;
    //cin>>tt;
    for (int t = 1 ; t <= tt ; t++ )
    {
        mainx();
    }
    return 0 ;
}


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

int main(){
	long long a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if(a[2] % 2 == 0) 
		cout << "0" << endl;
	else
		cout << a[0] * a[1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************

int N,T,A;

double mse=100000;
int min_i;
double abs_mse;

int main(void){
    cin >> N;
    cin >> T >> A;

    vector<int> height(N+100,0);
    vector<double> temperture(N+100,0);

    for(int i=0;i<N;i++) cin >> height[i] ;

    for(int i=0;i<N;i++){
        temperture[i]=(T-height[i]*0.006);
        //cout << temperture[i] << endl;

    }

    for(int i=0;i<N;i++){
        abs_mse=abs(temperture[i]-A);
        if(mse>=abs_mse){
            
            mse=abs_mse;
            min_i=i+1;
        }
        //cout << abs_mse << endl;
    }

    cout << min_i<< endl;

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define REV(x) (reverse(x.begin(),x.end()))

class UnionFind{
public:
	vector<int> par;
	//0-indexed
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		else par[x] = y;
	}
};

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

	int N,M;
	cin >> N >> M;
	vector<int> l[M+1];
	FOR(i,1,N+1){
		int K;
		cin >> K;
		FOR(j,0,K){
			int L;
			cin >> L;
			l[L].push_back(i);
		} 
	}
	UnionFind uf;
	uf.init(N+1);
	FOR(i,1,M+1){
		FOR(j,0,l[i].size()-1){
			uf.unite(l[i][j],l[i][j+1]);
		}
	}

	set<int> se;
	FOR(i,1,N+1){
		se.insert(uf.root(i));
	}
	if(se.size()==1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//

Measured memory_bytes: 4608
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

ll euclid(ll a, ll b)
{
    int nr = 0;
    while (b != 0)
    {
        int c = b;
        b = a % b;
        a = c;
        nr++;
    }
    return nr;
}


int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int nr = 0;
    for (int i = min(a, b); i >= 1; i--)
    {
        if (a % i == 0 && b % i == 0)
        {
            nr++;
        }
        if (nr == k)
        {
            cout << i;
            break;
        }
    }
    return 0;
}


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

int main() {
  int N;
  double T, A;
  cin >> N >> T >> A;
  vector<double> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  double mini = 10000;
  int ans = 0;

  for (int i = 0; i < N; i++) {
    double t = T - H[i] * 0.006;
    if (abs(A - t) < mini) {
      mini = abs(A - t);
      ans = i;
    }
  }

  cout << ans + 1 << endl;
}

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

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i{}; i < N; ++i) cin >> A[i];
  for (int i{}; i < N; ++i) cin >> B[i];
  for (int i{}; i < N; ++i) cin >> C[i];
  sort(A.begin(), A.end());
//  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  ll ans{};
  for (int j{}; j < N; ++j) {
    int i = lower_bound(A.begin(), A.end(), B[j]) - A.begin();
//    if (!i) continue;
    int k = upper_bound(C.begin(), C.end(), B[j]) - C.begin();
    ans += static_cast<ll>(i) * (N - k);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4576
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	int N; cin >> N;
	vector<int> table(1000001,0);
	vector<int> A(N,0);
	
	int M = 0;	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		M = max(M, A[i]);
	}

	for (int i = 0; i < N; i++) {
		int a = A[i];
		while(a <= M) {
			table[a] += 1;	
			a += A[i];
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (table[A[i]] <= 1) {
			ans++;	
		}
	}

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 8012
#!/usr/bin/env python3
import sys


def solve(x: "List[int]"):
    for i, v in enumerate(x):
        if v == 0:
            print(i + 1)
            return
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = [int(next(tokens)) for _ in range(5)]  # type: "List[int]"
    solve(x)

if __name__ == '__main__':
    main()


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

int main(){
    int s,s1,s2,s3;
    cin >> s;
    s1=s/100;
    s2=(s-s1*100)/10;
    s3=(s-s1*100-s2*10);
    cout << s1+s2+s3;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
  int n, w[101];
  scanf("%d", &n);

  int i;
  int sum[101] = {0};
  for (i = 1; i <= n; i++)
  {
    scanf("%d", &w[i]);
    sum[i] = sum[i - 1] + w[i];
  }

  int ans = sum[n];
  for (i = 1; i <= n; i++)
  {
    if (abs(sum[n] - sum[i] - sum[i]) < ans)
    {
      ans = abs(sum[i] - (sum[n] - sum[i]));
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&a[i]);
	}
	int max=0;
	int count=0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i]>=max)
		{
			count++;
			max=a[i];
		}
	}
	printf("%d\n",count);
}

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

template<class T>
struct SegmentTree {
private:
    int n;
    vector<T> node;
    T def;
    function<T(T,T)> lop;
    function<T(T,T)> out;
    
public:
    SegmentTree() {}
    SegmentTree(const vector<T> &v, T _def, function<T(T,T)> _lop, function<T(T,T)> _out) {
        int vl = (int)v.size();
        n = 1;
        while(n < vl) n *= 2;
        def = _def; lop = _lop; out = _out;
        node = vector<T>(2 * n - 1, def);
        for(int i = 0; i < vl; i++) node[i + n - 1] = v[i];
        for(int i = n - 2; i >= 0; i--) node[i] = out(node[i * 2 + 1], node[i * 2 + 2]);
    }
    
    void update(int idx, T val) {
        idx += (n - 1);
        node[idx] = lop(node[idx], val);
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = out(node[idx * 2 + 1], node[idx * 2 + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if ((r <= a) || (b <= l)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        return out(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    auto lop = [](ll a, ll b){ return a + b; };
    auto out = [](ll a, ll b){ return a + b; };
    SegmentTree<ll> st(vector<ll>(n, 0), 0, lop, out);
    rep(i, q) {
        ll com;
        cin >> com;
        if (com == 0) {
            ll x, y;
            cin >> x >> y;
            x--;
            st.update(x, y);
        }
        else {
            ll x, y;
            cin >> x >> y;
            x--; y--;
            cout << st.query(x, y + 1) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

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

	ll n; cin >> n;
	vector<pair<ll,ll> > edges;
	for(int i = 1; i < n; i++){
		ll a,b; cin >> a >> b;
		edges.push_back({a,b});
	}
	ll res = 0;
	for(ll i = 1; i <= n; i++) res += i * (n-i+1);
	for(auto it : edges){
		ll a = min(it.ST,it.ND);
		ll b = max(it.ST,it.ND);
		res -= a * (n-b+1);
	}
	cout << res;
	
	
	
	
	
	
	

}

Measured memory_bytes: 7380
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        int count = 0;
        for (int i = 0 ; i < c.length ; i++) {
            if (c[i] == 'D' ||c[i]  ==  '?') {
                count++;
                c[i] = 'D';
            }
            System.out.print(c[i]);
        }
        System.out.print("\n");

    }

}

Measured memory_bytes: 56088
#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>;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
from collections import deque

def string_formation(s, q_list):
    ans = deque()
    for x in s:
        ans.append(x)
    count = 0
    for query in q_list:
        if query[0] == '1':
            count += 1
        else:
            if count % 2 == 0:
                if query[1] == '1':
                    ans.appendleft(query[2])
                else:
                    ans.append(query[2])
            else:
                if query[1] == '1':
                    ans.append(query[2])
                else:
                    ans.appendleft(query[2])
    if count % 2 == 1:
        ans.reverse()
    print(''.join(ans))

s = input()
q = int(input())
q_list = []
for _ in range(q):
    tmp = input().split()
    q_list.append(tmp)

string_formation(s, q_list)

Measured memory_bytes: 119256
#include<iostream>
#include<string>
#include<algorithm>
#include <map>  
#include <string.h>
#include <math.h>

using namespace std;

int x, y, z;

int main()
{	
	cin >> x >> y >> z;

	x -= (y + z * 2);

	int tmp=0;

	while (x >= 0) {
		tmp++;
		x -= (y + z);
	}

	cout << tmp << endl;

	return 0;
}

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

//typedef long long ll;

int main(){
    int N;
    string S;
    cin>>N;
    cin>>S;
    int cnt=1;
    for(int i=1;i<N;i++){
        if(S.at(i)!=S.at(i-1)){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ANumberOfMultiples {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int L, R, D;
        in>>L>>R>>D;
        out<<R/D-(L-1)/D<<'\n';
    }
};


int main() {
	ANumberOfMultiples solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3636