akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<functional>
#include<fstream>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define f first
#define s second

int dist[100][100];
int qt[1000];
int qp[1000];

class Matching{
  typedef vector<vector<int> > G;

  vector<bool> visited;

  const G &g; //g[i][j] = k <==> i is connected to k
  int n; //number of node
  int m; //number of left node

  bool augment(int left) {
    if (left < 0)
      return true;
    if (visited[left])
      return false;
    visited[left] = true;
    REP(i, g[left].size()) {
      int right = g[left][i];
      if (augment(matching[right])) {
        matching[right] = left;
        return true;
      }
    }
    return false;
  }

public:
  vector<int> matching;

  explicit Matching(const G &graph, int mm)
    : g(graph), m(mm){
    n = graph.size();
  }

  int solve() {
    int matches = 0;
    matching = vector<int>(n,-1);
    visited = vector<bool>(n);
    REP(left, n) {
      visited.assign(n, false);
      if (augment(left))
        matches++;
    }
    return matches;
  }
};


typedef vector<vector<int> > G;

G g;

int main(){
  int n,m,l;
#define MAX 100000
  while(cin>>n>>m>>l, n+m+l){
    g = G(l+l);

    REP(i,n) REP(j,n) dist[i][j] = (i==j ? 0 : MAX);

    REP(i,m){
      int a,b,d;
      cin>>a>>b>>d;
      dist[a][b] = dist[b][a] = d;
    }
    REP(i,l) cin>>qp[i]>>qt[i];

    REP(k,n) REP(i,n) REP(j,n)
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    REP(i,l) REP(j,l) if(i!=j){
      int pos1 = qp[i];
      int pos2 = qp[j];
      int t1 = qt[i];
      int t2 = qt[j];

      if(dist[pos1][pos2] != MAX && t1 + dist[pos1][pos2] <= t2)
        g[i].push_back(j+l);
    }

    int ret = Matching(g, g.size()/2).solve();
    printf("%d\n",l-ret);
  }

  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    double L;
    cin >> L;
    double ans = L / 3;
    double ans2 = pow(ans, 3);
    printf("%.10f\n", ans2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,h,e=0;
    scanf("%d",&n);
    int p[n];
    for(int i=0;i<n;i++)scanf("%d",&p[i]);
    h=0;
    e=0;
    for(int i=0;i<n;i++){
        if(p[i]!=i+1){
            if(h==0){
                for(int j=0;j<n;j++){
                    if(j!=i){
                        if(p[j]==i+1){
                            e=p[i];
                            p[i]=p[j];
                            p[j]=e;
                            h=1;
                        }
                    }
                }
            }else{
                h=2;
                break;
            }
        }
    }
    if(h==0||h==1){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int sum,minus_sum,tmp;

	while(true){
		scanf("%d",&sum);
		if(sum == 0)break;

		minus_sum = 0;

		for(int i = 0; i < 9; i++){
			scanf("%d",&tmp);
			minus_sum += tmp;
		}

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

	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  ll l, t;
  cin >> n >> l >> t;
  ll x[n];
  int w[n];
  REP(i, n) {
    cin >> x[i] >> w[i];
    w[i]--;
  }
  vector<ll> vec;
  REP(i, n) {
    if (w[0] != w[i]) {
      vec.push_back(x[i]);
    }
  }
  ll cnt = 0;
  REP(i, vec.size()) {
    if (w[0] == 0) {
      cnt += (2 * t) / l;
      cnt += ((2 * t) % l >= (vec[i] - x[0]));
    } else {
      cnt -= (2 * t) / l;
      cnt -= ((2 * t) % l >= (l - vec[i] + x[0]));
    }
  }
  cnt = ((cnt % n) + n) % n;
  vector<P> ans;
  REP(i, n) {
    ll val = (x[i] + (w[i] == 0 ? t : -t) % l + l) % l;
    ans.push_back(P(-1, val));
  }
  sort(ALL(ans));
  int pos = (w[0] == 0 ? -1 : n);
  REP(i, n) {
    if (w[0] == 0 && ans[i].second == (x[0] + t) % l) {
      pos = max(pos, i);
    } else if (w[0] == 1 && ans[i].second == (x[0] + (-t % l) + l) % l) {
      pos = min(pos, i);
    }
  }
  for (int i = pos, j = 0; i >= 0; --i, ++j) {
    ans[i].first = (cnt - j + n) % n;
  }
  for (int i = pos, j = 0; i < n; ++i, ++j) {
    ans[i].first = (cnt + j) % n;
  }
  sort(ALL(ans));
  REP(i, n) cout << ans[i].second << endl;
  return 0;
};


Measured memory_bytes: 4464
n,k = gets.split.map(&:to_i)
r,s,p = gets.split.map(&:to_i)
score = Array.new(n){[]*3}
R,S,P = 0,1,2
ans = 0

gets.chomp.split("").each_with_index do |t,i|
  sr, ss, sp = 0,0,0
  sr = r if t == "s"
  ss = s if t == "p"
  sp = p if t == "r"
  if i-k >= 0
    sr = 0 if score[i-k][R] != 0
    ss = 0 if score[i-k][S] != 0
    sp = 0 if score[i-k][P] != 0
  end
  score[i][R] = sr
  score[i][S] = ss
  score[i][P] = sp
  ans += sr + ss + sp
end
p ans


Measured memory_bytes: 30232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define cps(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
#define cps2(x, y) sort(all(x), y), (x).erase(unique(all(x)), end(x))
#define mem(x, y) memset(& x, y, sizeof(x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 1e5 + 123;
ll n, x, m, used[n0], p[n0], val[n0];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	cin >> n >> x >> m;
	memset(& used, -1, sizeof(used));
	ll cur = x;
	p[0] = cur, used[cur] = 0, val[0] = cur;
	for (ll i = 1; i < n; i++) {
		cur = cur * cur % m;
		val[i] = cur;
		p[i] = p[i - 1] + val[i];
		if (used[cur] != -1) {
			ll j = used[cur];
			ll len = i - j, res = 0, bef = 0;
			if (j) bef = p[j - 1];
			res = bef;
			n -= j;
			res += (n / len) * (p[i - 1] - bef);
			n %= len;
			for (ll k = j; k < j + n; k++) res += val[k];
			cout << res;
			return 0;
		}
		used[cur] = i;
	}
	cout << p[n - 1];
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 (b<a) { a=b; return 1; } return 0; }

int main(){
    int n;cin>>n;
    string s,t;
    cin>>s>>t;

    for(int i=0;i<n;i++){
        bool f=true;
        for(int j=0;j+i<n;j++){
            if(t[j]!=s[i+j]){
                f=false;
            }
        }
        if(f){
            cout<<(n-i+i*2)<<endl;return 0;
        }
    }
    cout<<2*n<<endl;
    return 0;
}


Measured memory_bytes: 256
S = list(input())
Slist = list()

def split_list(S):
  Slist.append(int(''.join(S)))
  N = len(S)
  if N == 1:
    return
  for n in range(1, N):
    S1 = ''.join(S[:n])
    r = 2**(N-n-1)
    
    for i in range(r):
    	Slist.append(int(S1))
    
    split_list(S[n:])
    
  

split_list(S)
ans = sum(Slist)
print(ans)

Measured memory_bytes: 3064
n,m = gets.chomp.split(" ").map(&:to_i)
l = []
r = []
m.times do |i|
  l[i],r[i] = gets.chomp.split(" ").map(&:to_i)
end
from = 1
to = n
m.times do |i|
  if l[i] > from
    from = l[i]
  end
  if r[i] < to
    to = r[i]
  end
end
if from <= to
  puts to-from+1
else
  puts 0
end

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

int main(void){
  int n, i, ans;
  int alst[1001];
  while(1){
    cin >> n;
    if(n == 0) break;
    for(i=0;i<n;i++) cin >> alst[i];
    sort(alst, alst + n);
    ans = 1000000;
    for(i=0;i<n - 1;i++) ans = min(ans, alst[i + 1] - alst[i]);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3152
#include <stdio.h>
#include <string.h>
int main(void){
char a[26];
int  len, i,j;
scanf("%s",a);
len = strlen(a);
for(i=0;i+1<len;i++){
for(j=i+1;j<len;j++){
if(a[i]==a[j]){
printf("no");
return 0;
}
}
}
printf("yes");
return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int a[100010];
int main(){
	int n,i,j,x,d=0,s=0;
	cin >> n ;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=1;i<n;i++){
		if(a[i]>a[i-1]){
			d=0;			
		}
		else{
			d++;
			if(d>s)
				s=d;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
#define IINF INT_MAX
#define LLINF LLONG_MAX
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD 1000000007
#define DEBUG true

int main(){
  int e,y;cin >> e >> y;
  int Y[] = {1868,1912,1926,1989,2016};
  switch(e){
    case 0:
      if(y >= Y[0] && y < Y[1]){
        cout << "M" << y - Y[0] + 1;
      }else if(y >= Y[1] && y < Y[2]){
        cout << "T" << y - Y[1] + 1;
      }else if(y >= Y[2] && y < Y[3]){
        cout << "S" << y - Y[2] + 1;
      }else if(y >= Y[3] && y <= Y[4]){
        cout << "H" << y - Y[3] + 1;
      }
    break;
    case 1:
      cout << y + Y[0] - 1;
      break;
    case 2:
      cout << y + Y[1] - 1;
      break;
    case 3:
      cout << y + Y[2] - 1;
      break;
    case 4:
      cout << y + Y[3] - 1;
      break;
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>

using namespace std;

map<string, int> mp;
vector<string> v;
int main(void)

{
    int i,a,n;
    string s;
    cin>>n;
    map<string, int>::iterator it;
    int counter = 1;
    for(i = 0; i < n; i++){
        cin>>s;
        if(mp[s]){
            mp[s]++;
            if(mp[s] > counter)
                counter = mp[s];
        }
        else{
            mp[s]++;
        }
    }
    for(it = mp.begin(); it != mp.end(); it++){
        if(it->second == counter){
            cout<<it->first<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 25216
#include<stdio.h>
int main(){
	int x,y;
	
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)return 0;
		if(x>=y) printf("%d %d\n",y,x);
		else printf("%d %d\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 2044
from collections import defaultdict
import sys

input = lambda: sys.stdin.readline().rstrip()

M = 998244353 # < (1 << 30)

def mod_inv(a, M=M):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, M
  while abs(z1) != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1*z1%M

R_bits = 30
R = 1 << R_bits
R_dec = R - 1
R2 = pow(R, 2, M)
M_neg_inv = mod_inv(-M, R)

def MR(x):
  b = (x * M_neg_inv) & R_dec
  t = x + b * M
  c = t >> R_bits
  d = c - M
  return d if 0 <= d else c

def Montgomery(x):
  return MR(x*R2)

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(edge):
  grundy = [{} for i in range(3)]
  sum_g = [defaultdict(int, {0:M_W_sum}) for i in range(3)]
  M_W = M_W_last
  for i in range(N, 0, -1):
    for g, s, e in zip(grundy, sum_g, edge):
      if i in e:
        m = mex({g.get(j, 0) for j in e[i]})
        if m:
          g[i] = m
          s[g[i]] +=  M_W
          s[0] -=  M_W
    M_W = MR(M_W * M_B_inv)
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

N = int(input())
B = pow(10, 18, M)
M_B_inv = Montgomery(mod_inv(B))
M_W_last = Montgomery(pow(B, N, M))
M_W_sum = MR((M_W_last - Montgomery(1)) * MR(Montgomery(B) * Montgomery(mod_inv(B-1))))

edge = [read_edge() for i in range(3)]
sum_g = calc_grundy(edge)
ans = 0
for gx, sx in sum_g[0].items():
  for gy, sy in sum_g[1].items():
    gz = gx^gy
    sz = sum_g[2][gz]
    if sz:
      ans += MR(MR(sx*sy)*sz)
print(MR(ans)%M)


Measured memory_bytes: 68568
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 0; i < q; i++) {
		    arr[sc.nextInt()]++;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
		    if (arr[i] > q - k) {
		        sb.append("Yes");
		    } else {
		        sb.append("No");
		    }
		    sb.append("\n");
		}
		System.out.println(sb);
   }
}


Measured memory_bytes: 49200
<?php
fscanf(STDIN, "%d %d", $a, $b);

$count = 0;

if($a >= $b) {
  $count = $a;
  $a = $a - 1;
} else {
  $count = $b;
  $b = $b -1;
}

if($a > $b) {
  $count += $a;
} else {
  $count += $b;
}

echo $count;

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
const int inf = 1<<30;

int main() {
  string s; cin >> s;
  int ans = inf;
  for(char c = 'a'; c <= 'z'; ++c) {
    int maxItr = 0;
    int cnt = 0;
    for(int i = 0; i < s.size(); ++i) {
      if(s[i] == c) maxItr = max(maxItr, cnt), cnt = 0;
      else cnt++;
    }
    maxItr = max(maxItr, cnt);
    ans = min(ans, maxItr);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;
typedef long long int lli;

bool deco(int x)
{
	int count = 0;
	rep(i, 1, (sqrt(x)+1)) {
		if (x%i == 0)count++;
	}
	if (count == 4)return true;
	else return false;
}

int main(void)
{
	int N; cin >> N;
	int count = 0;
	for(int i=1;i<=N;i+=2) {
		if (deco(i))count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{
  int A,B;
  scanf("%d %d",&A,&B);
  if(A+B==3)
  {
      printf("3\n");
  }
  else if(A+B==4)
  {
      printf("2\n");
  }
  else
  {
      printf("1\n");
  }
  return 0;
}


Measured memory_bytes: 1572
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;


void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split;

    auto dp = new long[][](N, 3);
    dp[0][0] = A[0].to!long;
    dp[0][1] = dp[0][2] = - (10L^^15);


    foreach (i; 1..N) {
        auto sign = A[i*2-1];
        auto num  = A[i*2].to!long;
        if (sign == "+") {
            dp[i][0] = max(dp[i-1][0] + num, dp[i-1][1] - num, dp[i-1][2] + num);
            dp[i][1] = max(dp[i-1][1] - num, dp[i-1][2] + num);
            dp[i][2] = dp[i-1][2] + num;
        }
        else {
            dp[i][0] = max(dp[i-1][0] - num, dp[i-1][1] + num, dp[i-1][2] - num);
            dp[i][1] = max(dp[i-1][0] - num, dp[i-1][1] + num, dp[i-1][2] - num);
            dp[i][2] = max(dp[i-1][1] + num, dp[i-1][2] - num);
        }
    }

    dp[N-1].reduce!(max).writeln;
    
}


Measured memory_bytes: 15984
#include<stdio.h>
#define N 100

int main(){
  
  int i,j,A[N],count=0,n,tmp,flag;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  flag=1;
  while(flag){
    flag = 0;
    for(j=n-1;j>0;j--){
      if(A[j]<A[j-1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	count++;
	flag=1;
      }
    }
  }


  
  for(i=0;i<n;i++){
    if(i>0){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n");


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




Measured memory_bytes: 2128
N = int(input())
a  = []
for  i  in range(N):
	a.append(int(input()))

ans = 1
while a[0] !=  2:
	n = a[0]
	a[0] = a[n-1]
	ans += 1
	if  ans > N:
		ans = -1
		break

print(ans)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp  make_pair
#define pb  push_back
#define  sz(x)   (int)x.size()
#define  all(x)  x.begin(), x.end()
#define	 allr(x)  x.rbegin(), x.rend()
#define  bit(x)  __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
int mul (int x, int y) { return ((ll)x * y) % mod; } 
int sub (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 3e5;
 
int a[maxn], b[maxn];

void solve () {
	string s; cin >> s; s += 'R'; s = '$' + s;
	int n = sz (s);
	int cntL, cntR, c;
	cntL = cntR = 0;
	vector <pii> v;
	for (int i = 0; i < n; i ++) {
		if (s[i] == 'R' && s[i-1] == 'L') {
			if ((cntL + cntR) % 2 == 0) {
				v.pb (mp (c-1, (cntL + cntR) / 2));				
				v.pb (mp (c, (cntL + cntR) / 2));				
			} else {
				if (cntR > cntL && cntR % 2 == 1) {
					v.pb (mp (c-1, (cntL + cntR) / 2 + 1));
					v.pb (mp (c, (cntL + cntR) / 2));
				} else if (cntR > cntL && cntR % 2 == 0) {
					v.pb (mp (c-1, (cntL + cntR) / 2));
					v.pb (mp (c, (cntL + cntR) / 2 + 1));				
				}	

				if (cntR < cntL && cntL % 2 == 0) {
					v.pb (mp (c-1, (cntL + cntR) / 2 + 1));
					v.pb (mp (c, (cntL + cntR) / 2));
				} else if (cntR < cntL && cntL % 2 == 1) {
					v.pb (mp (c-1, (cntL + cntR) / 2));
					v.pb (mp (c, (cntL + cntR) / 2 + 1));				
				}	
			}
			cntL = 0, cntR = 1;
		} else if (s[i] == 'R') {
			cntR ++;
		} else if (s[i] == 'L' && s[i - 1] == 'R') {
			c = i;
			cntL ++;
		} else if (s[i] == 'L') {
			cntL ++;
		}

		//cout << cntL << ' ' << cntR << endl;
	}

	for (auto to: v) {
		a[to.first] = to.second;
	}

	for (int i = 1; i < n-1; i ++)
		cout << a[i] << ' ';
}

main () { fast_in;
    int t = 1; //cin >> t;
    while (t --) {
    	solve ();    
    }
	return 0;
}

Measured memory_bytes: 4436
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int gcd(int a,int b){
    int temp;
    while(b!=0){
        temp=b;
        b=a%b;
        a=temp;
    }
    return a;
}

int main(){
    int n,x; cin>>n>>x;
    int xi,ans; cin>>xi;
    ans=abs(x-xi);
    rep(i,n-1){
        cin>>xi;
        ans=gcd(ans,abs(x-xi));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
#define rep(i, c) for( int i = 0; i < c; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, ans;
    ans = INT_MAX;
    cin >> N;
    vector<int> X(N);
    rep(i,N) cin >> X.at(i);
    for ( int i = 1; i <= 100; i++ ){
        int cost = 0;
        rep(j,N)  cost += ( i - X.at(j) ) * ( i - X.at(j) );
        ans = min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
char s[maxn];
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	cin>>s;
	int len=strlen(s);
	int ans=0;
	rep(i,0,len)
	{
		if(i&1)
		{
			if(s[i]=='0')
			{
				ans++;
			}
		}else
		{
			if(s[i]=='1')
			{
				ans++;
			}
		}
	}
	int fans=0;
	rep(i,0,len)
	{
		if(i&1)
		{
			if(s[i]=='1')
			{
				fans++;
			}
		}else
		{
			if(s[i]=='0')
			{
				fans++;
			}
		}
	}
	
	cout<<min(fans,ans)<<endl;
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 384
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * E - ∙ (Bullet)
 * https://atcoder.jp/contests/abc168/tasks/abc168_e
 */
public class Main {
  static int MOD = 1000000007;
  public static void main(String[] args) {
    long answer = 1;
    int zero = 0;
    int xzero = 0;
    int yzero = 0;
    Map<String, Tuple> map = new HashMap<>();
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    long[] p2 = new long[n + 1];
    p2[0] = 1;
    for(int i = 1; i <= n; i++){
      p2[i] = p2[i-1] * 2 % MOD;
    }

    for(int i = 0; i < n; i++){
      String[] ab = sc.nextLine().split(" ");
      long x = Long.parseLong(ab[0]);
      long y = Long.parseLong(ab[1]);
      if(x == 0 && y == 0){
        zero++;
        continue;
      } else if (x == 0){
        xzero++;
      } else if (y == 0){
        yzero++;
      } else {
        if(y < 0){
          x = -x;
          y = -y;
        }
        long g = gcd(Math.abs(x),Math.abs(y));
        x /= g;
        y /= g;
        String key;
        if(x < 0){
          key = String.valueOf(y) + "/" + String.valueOf(-x) ;
        } else {
          key = String.valueOf(x) + "/" + String.valueOf(y) ;
        }
        if(map.containsKey(key)){
          Tuple tuple = map.get(key);
          if(x < 0){
            tuple.b += 1;
          } else {
            tuple.a += 1;
          }
        } else {
          Tuple tuple = new Tuple();
          if(x < 0){
            tuple.b += 1;
          } else {
            tuple.a += 1;
          }
          map.put(key, tuple);
        }
      }
    }
    answer = answer * (p2[xzero] + p2[yzero] -1) % MOD;
    Collection<Tuple> valueList = map.values();
    for(Tuple tuple : valueList){
      long tmp = p2[tuple.a] + p2[tuple.b] - 1;
      answer = answer * tmp % MOD;
    }
    answer = (answer + zero + MOD - 1) % MOD;
    System.out.print(answer);
  }
  static long gcd(long a, long b){
    return b > 0 ? gcd(b, a % b) : a;
  }
  static class Tuple {
    int a = 0;
    int b = 0;
  }

}

Measured memory_bytes: 97044
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define sz(a) int(a.size())
#define pb(x) push_back(x);
#define ll long long
#define ii pair<ll,ll>
#define Long long long
#define MAX_N 3
#define MOD 1000000007

int main() {
    int n;cin>>n;
    string a;cin>>a;
    if(n%2){
        cout<<"No";
    }
    else{
        int x = n/2;
        for(int i = 0;i < n/2;i++){
            if(a[i]!=a[i+(n/2)]){
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  vector<int> v = {105, 104, 103, 102, 101, 100};
  int n;
  cin >> n;
  for (auto &i : v) {
    while (n >= i && n % 100 >= i % 100) n -= i;
  }
  cout << (n == 0) << '\n';
}


Measured memory_bytes: 3648
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    if(A >= 13) cout << B;
    else if (6 <= A && A <= 12) cout << B / 2;
    else cout << 0;
    cout << endl;
    return 0;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    int ans=0;
    for(int i=1; i<n-1; i++){
        if(p[i]<p[i-1] && p[i]>p[i+1]){
            ans ++;
        }
        else if(p[i]>p[i-1] && p[i]<p[i+1]){
            ans ++;
        }
    }
    cout << ans << endl;

}

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

const int MAXN = 100000 + 10;

struct Edge {
	int next, to;
};

int n;
Edge e[MAXN << 1];
int tot, head[MAXN];
int dis1[MAXN], dis2[MAXN];
int sum1, sum2;

void Add_edge(int u, int v) {
	
	e[++tot].next = head[u]; e[tot].to = v; head[u] = tot;
	
}

void Pre() {
	
	for (int i = 0; i <= MAXN - 10; i++) {
		dis1[i] = -1; dis2[i] = -1;
	}
	
}

void dfs_1(int u, int dep) {
	
	dis1[u] = dep;
	
	for (int i = head[u]; i; i = e[i].next) {
		int v = e[i].to;
		if (dis1[v] == -1)
			dfs_1(v, dep + 1);
	}
	
}

void dfs_2(int u, int dep) {
	
	dis2[u] = dep;
	
	for (int i = head[u]; i; i = e[i].next) {
		int v = e[i].to;
		if (dis2[v] == -1)
			dfs_2(v, dep + 1);
	}
	
}

int main() {
	
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		Add_edge(a, b); Add_edge(b, a);
	}
	
	Pre();
	
	dfs_1(1, 0);
	dfs_2(n, 0);
	
	for (int i = 1; i <= n; i++) {
		if (dis1[i] <= dis2[i])
			sum1++;
		else
			sum2++;
	}
	
//	printf("%d %d\n", sum1, sum2);
	
	if (sum1 > sum2)
		puts("Fennec");
	else
		puts("Snuke");
	
	return 0;
	
}

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

int main(){
    int n;
    cin>>n;
    ll ans=0;
    vector<int> d(n+1);
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i) d[j]++;
    }
    for (int i=1;i<=n;i++) ans+=ll(i)*d[i];
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 42324
#include <stdio.h>
#include <math.h>

int main(void){
	double q , x1 , x2;
	while(1){
		scanf("%lf" , &q);
		if(q == -1) break;
		x1 = q / 2;
		while(1){
			x2 = x1 - (pow(x1 , 3) - q) / (3 * pow(x1 , 2));
			if(fabs(pow(x2 , 3) - q) < (q * 0.00001)) break;
			x1 = x2;
		}
		printf("%f\n" , x2);
	}
	return 0;
}

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


  
int main(){
  

  string s;
  cin>>s;
  
  int n;
  n=int(s.size());
  

  int answer=0;
  
  for (int i=0;i<n;i++){
    int tmp=n-1;
    for (int j=i;j<n;j++){
      if (s.at(j)!='A' and s.at(j)!='T' and s.at(j)!='G' and s.at(j)!='C'){
        tmp=j-1;
        break;
      }
    }
    answer=max(answer,tmp-i+1);
    
  }
  
  cout<<answer<<endl;
  
   
  
}

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

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

    while (1) {
        int n, m, c, s, t;
        cin >> n >> m >> c >> s >> t;
        if (n == 0) break;
        vector<vector<vector<int>>> dist(c, vector<vector<int>>(n, vector<int>(n, 1e9)));
        for (int i = 0; i < m; i++) {
            int a, b, d, type;
            cin >> a >> b >> d >> type;
            a--, b--, type--;
            dist[type][a][b] = min(dist[type][a][b], d);
            dist[type][b][a] = min(dist[type][b][a], d);
        }
        for (int type = 0; type < c; type++) {
            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        dist[type][i][j] = min(dist[type][i][j], dist[type][i][k] + dist[type][k][j]);
                    }
                }
            }
        }
        vector<int> segs(c);
        for (int i = 0; i < c; i++) cin >> segs[i];
        vector<vector<int>> da(c), dd(c);
        for (int i = 0; i < c; i++) {
            int prev = 0;
            for (int j = 0; j < segs[i] - 1; j++) {
                int a;
                cin >> a;
                if (j > 0) {
                    da[i].push_back(a - prev);
                } else {
                    da[i].push_back(a);
                }
                prev = a;
            }
            da[i].push_back(1e9);
            for (int j = 0; j < segs[i]; j++) {
                int a;
                cin >> a;
                dd[i].push_back(a);
            }
        }
        function<int(int, int, int, int)> find_cost = [&](int type, int d, int acc, int idx) -> int {
            if (d <= da[type][idx]) return acc + dd[type][idx] * d;
            return find_cost(type, d - da[type][idx], acc + dd[type][idx] * da[type][idx], idx + 1);
        };

        vector<vector<int>> cost(n, vector<int>(n, 1e9));
        for (int type = 0; type < c; type++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (dist[type][i][j] != 1e9) {
                        cost[i][j] = min(cost[i][j], find_cost(type, dist[type][i][j], 0, 0));
                    }
                }
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }
        s--, t--;
        if (cost[s][t] == 1e9) {
            cout << -1 << endl;
            continue;
        }
        cout << cost[s][t] << endl;
    }
}


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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    ll ans = 0;
    rep(i, n-1) {
        ans += min((x[i+1]-x[i])*a, b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define ll long long
#define repeat(i,a,b) \
	for(int i=(a),i##end=(b);i<i##end;i++)
int n,m,a,b;
int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m>>a>>b;
	{ 
	    repeat(i,0,b){
	    	repeat(j,0,a)cout<<"0";
	    	repeat(j,0,m-a)cout<<"1";
	    	cout<<endl;
	    }
	    repeat(i,0,n-b){
	    	repeat(j,0,a)cout<<"1";
	    	repeat(j,0,m-a)cout<<"0";
	    	cout<<endl;
	    }
	}
	return 0;
}

Measured memory_bytes: 1280
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, K;
	
	cin >> N >> K;

	ll a[N];
	ll vr[N+1];
	ll v[N+1];
	v[0] = vr[0] = 0;
	rep(i, N)
	{
		cin >> a[i];
		v[i+1] = v[i] + a[i];
		if (a[i] >= 0)
		{
			vr[i+1] = vr[i] + a[i];
		}
		else
		{
			vr[i+1] = vr[i];
		}
	}

	ll ans = 0;

	rep(i, N - K + 1)
	{
		//ans = max(ans, vr[i] + vr[N] - vr[i+K]);
		ans = max(ans, max(v[i+K]- v[i], 0ll) + vr[i] + vr[N] - vr[i+K]);
	}

	cout << ans << endl;



	
	return 0;
}


Measured memory_bytes: 2560
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];

    let mut a: Vec<Vec<i64>> = vec![];

    for _ in 0..n{
        a.push(read_as_vec());
    }
    let mut floid = a.clone();
    for i in 0..n{
        for j in 0..n{
            for k in 0..n{
                floid[j][k] = cmp::min(floid[j][k], floid[j][i] + floid[i][k]);
            }
        }
    }

    //compare
    for i in 0..n{
        for j in 0..n{
            if a[i][j] != floid[i][j]{
                println!("-1");
                return;
            }
        }
    }


    let mut delete_memo: Vec<Vec<bool>> = vec![vec![false;n];n];
    for i in 0..n{
        for j in 0..n{
            for k in 0..n{
                if (i == j) || (k == i) || (k == j){
                    continue;
                }
                if a[i][j] == a[i][k] + a[k][j]{
                    delete_memo[i][j] = true;
                }
            }
        }
    }
    for i in 0..n{
        for j in 0..n{
            if delete_memo[i][j]{
                a[i][j] = 0;
            }
        }
    }

    let mut ans = 0;
    for i in 0..n{
        for j in 0..i{
            ans += a[i][j];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <fstream>
#include <climits>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <list>

#define FOR(i,n)    for(int i = 0 ; i < n ; i++)
#define FORrev(i,n) for(int i = n - 1 ; i >= 0 ; i--)
#define ALL(a)      a.begin(),a.end()

typedef long long int ll; 

using namespace std;

int main() {
	int a , b;
	cin>>a>>b;
	int level = 1 , sockets = a;
	while(sockets <= b) {
		sockets = sockets * a;
		level++;
	}
	level--;
	sockets /= a;
	int count = 0;
	while(sockets < b) {
		sockets = sockets - 1 + a;
		count++;
	}
	int temp = 1;
	for(int i = 0 ; i < level ; i++) {
		count += temp; 
		temp *= a;
	}
	cout<<count;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

int dx[4]={1, -1, 0, 0};
int dy[4]={0, 0, 1, -1};

int k, s, ans;
int main(void) {
    cin >>k >>s;
    REP(x, k+1){
        REP(y, k+1){
            if(s-(x+y)>=0 && s-(x+y)<=k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import random

n = int(input())
a = [list(input()) for _ in range(n)]

e = [0 for _ in range(n)]
kachi = [0 for _ in range(n)]
hikiwake = [0 for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i][j] == 'o':
            e[i] += 3 / n
            kachi[i] += 1
        elif a[i][j] == '-':
            e[i] += 1 / n
            hikiwake[i] += 1

me = -1
idx = -1
for i in range(n):
    if me < e[i]:
        me = e[i]
        idx = i

ls = []
for i in range(n):
    if a[i][idx] == 'o':
        ls.append(i + 1)

if len(ls) == 0:
    ls.append(idx + 1)

for i in range(1000):
    print(ls[i % len(ls)])
    s = input()



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

using namespace std;

#define endl '\n'

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

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100010;

vi adj[ maxn ];
bool vis[ maxn ][ 11 ];
int col[ maxn ];

void paint(int s, int d, int c){
    if ( d == -1 || vis[s][d] ) return;

    for (int i = d; i >= 0 && !vis[s][i]; --i)
        vis[s][i] = true;

    if (!col[ s ])
        col[s] = c;

    for (auto u : adj[s])
        paint(u, d - 1, c);
}

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

#ifdef MARX
    freopen("test.in", "r", stdin);
#endif

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int q; cin >> q;

    vector<int> U(q), D(q), C(q);

    for (int i = 0; i < q; ++i){
        cin >> U[i] >> D[i] >> C[i];
    }

    for (int i = q - 1; i >= 0; --i){
        paint(U[i], D[i], C[i]);
    }

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

    return 0;
}

Measured memory_bytes: 9208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
          char ch = fr.next().charAt(0);
          if(ch>=65 && ch<=90){
            System.out.println("A");
        }
        else{
            System.out.println("a");
        }
    }
}

Measured memory_bytes: 32804
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int ans = 700;
	for (int i = 0; i < 3; i++) {
		char a;
		cin >> a;
		if (a == 'o') ans += 100;
	}
	cout << ans << endl;
    return 0;
}

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

class SegmentTree{
private:
    int n;
    vector<int> t;
    
    int combine(int a, int b){
        return a + b;
    }
public:
    SegmentTree(int N){          // build tree
        n = N;
        t.assign(n << 1, 0);
        
        //for (int i = 0; i < n; i++) t[n+i] = v[i];
        //for (int i = n-1; i > 0; i--) t[i] = combine(t[i<<1], t[i<<1|1]);
    }
    void modify(int p, int val){          // set v[p] = val
        for (t[p+=n] += val; p >>= 1; ) t[p] = combine(t[p<<1],t[p<<1|1]);
    }
    int query(int l, int r){              // query in range v[l,r)
        int res = 0;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1){
            if (l&1) res = combine(res,t[l++]);
            if (r&1) res = combine(res,t[--r]);
        }
        return res;
    }
    int ncquery(int l, int r){            // query for non-commutative combine function
        int resl, resr;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1){
            if (l&1) resl = combine(resl, t[l++]);
            if (r&1) resr = combine(t[--r], resr);
        }
        return combine(resl, resr);
    }
};

int N, M;

int main() {

    scanf("%d%d",&N,&M); SegmentTree st(N+1);
    for (int i = 0, op, a, b; i < M; i++) {
        scanf("%d%d%d",&op,&a,&b);

        if (op)
            printf("%d\n", st.query(a,b+1));
        else
            st.modify(a,b);
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()

int main(void){
    string s[3];
    rep(i,3){
        cin>>s[i];
        reverse(all(s[i]));
    }
    int man = 0;
    while(s[man]!=""){
        int next = s[man].back()-'a';
        s[man].pop_back();
        man = next;
    }
    cout<<char('A'+man)<<endl;
    return 0;
}


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

int main()
{
	int arr[3][3];
	bool mark[3][3] = {0};

	int a;
	for(int i=0; i<3; i++)
	{
		for(int j=0; j<3; j++)
		{
			cin>>arr[i][j];
		}
	}


	int n;
	cin>>n;
	int p;
	for(int i =0 ; i<n; i++)
	{
		cin>>p;


		for(int i=0; i<3; i++)
		{
			for(int j=0; j<3; j++)
				if( p == arr[i][j])mark[i][j] = true;
        }
	}

	bool flag = false;
	if(mark[0][0] == true and mark[0][1] == true and mark[0][2] == true) flag = true;
	if(mark[1][0] == true and mark[1][1] == true and mark[1][2] == true) flag = true;
	if(mark[2][0] == true and mark[2][1] == true and mark[2][2] == true) flag = true;

	if(mark[0][0] == true and mark[1][0] == true and mark[2][0] == true) flag = true;
    if(mark[0][1] == true and mark[1][1] == true and mark[2][1] == true) flag = true;
    if(mark[0][2] == true and mark[1][2] == true and mark[2][2] == true) flag = true;

    if(mark[0][0] == true and mark[1][1] == true and mark[2][2] == true) flag = true;
    if(mark[0][2] == true and mark[1][1] == true and mark[2][0] == true) flag = true;


    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n,k; cin>>n>>k;
    VI h(n);
    REP(i, n) cin >> h[i];

    sort(ALL(h), greater<int>());

    LL result = 0;

    FOR(i,k,n){
        result += h[i];
    }

    cout << result << endl;
    
    

	return;
}

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

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

long long int n,m,h[200010],i,a,b;
bool tr[100010];

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	for (i=1;i<n+1;i++) cin>>h[i];
	for (i=1;i<n+1;i++) tr[i]=true;
	for (i=1;i<m+1;i++)
	{
		cin>>a>>b;
		if (h[a]<=h[b]) tr[a]=false;
		if (h[b]<=h[a]) tr[b]=false;
	}
	a=0;
	for (i=1;i<n+1;i++) if (tr[i]) a++;
	cout<<a;
}


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


def solve(N: int, A: int, B: int):
    print(min(B, A*N))
    return


# Generated by 1.1.4 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()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import           Control.Monad
import           Data.Maybe                     ( fromJust )
import qualified Data.Vector.Unboxed           as V
import qualified Data.ByteString.Char8    as BC

main = do
    n  <- readLn
    as <-
        V.fromList
        .   map (pred . fst . fromJust . BC.readInt)
        .   BC.lines
        <$> BC.getContents
    print $ solve as 0 0 n

solve as 1 i _ = i
solve as k i n | i == n    = -1
               | otherwise = solve as (as V.! k) (succ i) n


Measured memory_bytes: 5116
#include <cstdio>
#include <cstring>

int n;
char s[200010];

int main() {
	scanf("%s", s);
	n = strlen(s);
	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans = (ans + s[i] - '0') % 9;
	puts(ans ? "No" : "Yes");
	return 0;
}



Measured memory_bytes: 1804
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int a[1000];
    while(cin>>n)
    {
        int sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];            
        }
        sum=(sum+n-1)/n;
        int ans1=0,ans2=0;
        for(int i=0;i<n;i++)
        {
            ans1+=(a[i]-sum)*(a[i]-sum);
            ans2+=(a[i]-sum+1)*(a[i]-sum+1);
        }
        cout<<min(ans1,ans2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  string s;
  cin >> n >> s;

  int ans = 0, c = 0;
  rep(i, 0, n) {
    if (s[i] == 'I')
      c++;
    else
      c--;
    chmax(ans, c);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)cin>>a[i];
	sort(a,a+n);
    int res=0;
    for(int i=0;i<n;++i)res+=a[i];
    if(res%10==0){
         for(int i=0;i<n;++i){
         	res-=a[i];
         	if(res%10==0){
         		res+=a[i];
         	} else {
         		cout<<res<<endl;
         		return 0;
         	}
         }
         cout<<0<<endl;
         return 0;
    }
    cout<<res<<endl;
    return 0;



}

Measured memory_bytes: 256