akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define travel(x, y, i) for (int i = fir[x], y = e[i].to; i; i = e[i].nxt, y = e[i].to)
using namespace std;

const int N = 1e5 + 5;

struct edge {
  int nxt, to;
} e[N << 1];
int fir[N], cnt = 0;
int n, dp[N];

inline void addedge(int x, int y) {
  e[++ cnt] = (edge) { fir[x], y }; fir[x] = cnt;
}

inline int Log(int x) {
  int res = 0;
  if (x >= (1 << 16)) x >>= 16, res += 16;
  if (x >= (1 << 8)) x >>= 8, res += 8;
  if (x >= (1 << 4)) x >>= 4, res += 4;
  if (x >= (1 << 2)) x >>= 2, res += 2;
  if (x >= (1 << 1)) x >>= 1, res += 1;
  return res;
}

inline void Dfs(int x, int f) {
  int msk = 0, t = 0;
  travel(x, y, i) {
    if (y == f) continue;
    Dfs(y, x);
    int tmp = dp[y];
    for (int j = 17; j > t; j --)
      if ((msk & tmp) & (1 << j)) t = j;
    msk |= tmp;
  }
  while (msk & (1 << t)) t ++;
  msk |= (1 << t) - 1;
  msk ^= (1 << t) - 1;
  msk |= (1 << t);
  dp[x] = msk;
}

int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; i ++) {
    scanf("%d%d", &x, &y);
    addedge(x, y); addedge(y, x);
  }
  Dfs(1, 0);
  printf("%d\n", Log(dp[1]));
  return 0;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint N;
	cin >> N;
	
	
	
	//SOLVE
	llint ans=0;
	
	bool fla= true;
	ans = (double)(N) / 1.08;
	
	if (((double)(ans) * 1.08) != N) {
		if ((llint)((double)(ans+1) * 1.08) != N) {
			fla = false;
		} else {
			ans += 1;
		}
	}
	
	//OUTPUT
	if (fla) {
		cout << ans << endl;
	} else {
		put(":(");
	}
	
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	bool ans=false;
	cin >>s;
	rep(i,s.size()-1){
		if(s[i]=='A' and s[i+1]=='C'){
			ans=true;
		}
	}
	cout<<solve(ans)<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
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)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#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する


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
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 main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    A, B, H, M = map(int, input().split())
    #A = 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(N)) #改行行列


    t=M/60*2*math.pi
    s=2*math.pi*(M/12/60+H/12)
    x1=A*math.cos(s)
    y1=A*math.sin(s)
    x2=B*math.cos(t)
    y2=B*math.sin(t)
    ans=(x1-x2)**2+(y1-y2)**2
    print(ans**0.5)




if __name__ == "__main__":
    main()

Measured memory_bytes: 69632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
	  REP(i, b) {
		cout << a;
	  }
	  cout << endl;
	} else {
	  REP(i, a) {
		cout << b;
	  }
	  cout << endl;
	}
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  for(int i=a; i<a+k && i <= b; i++)cout << i << endl;

  for(int i=max(b-k+1,a+k); i <=b; i++)cout << i << endl;

}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int t;
	int a,b,c;
while(	scanf("%d%d%d",&a,&b,&c)!=EOF){
	

    if(a>b)
	{
		t=a;a=b;b=t;
    }
    if(a>c)
    {
    	t=a;a=c;c=t;
    }
    if(b>c)
    {
    	t=b;b=c;c=t;
    }
    
	printf("%d\n",c-a);	
	
}}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int H1, M1, H2, M2; cin >> H1 >> M1 >> H2 >> M2;
  int K; cin >> K;
  
  while(K >= 60) {
    H2--;
    K -= 60;
  }
  if(K <= M2) M2 -= K;
  else {
    H2--;
    M2 += 60-K;
  }
  
  cout << 60*(H2-H1) + M2 - M1 << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int k,n;
char s[100100];

int main() {
	scanf("%s %d", s, &k);
	for (n = 0; s[n]; n++) {
		if (s[n] != 'a' && s[n]+k > 'z') {
			k -= 'z'+1-s[n];
			s[n] = 'a';
		}
	}
	s[n-1] = 'a' + (s[n-1]-'a'+k)%26;
	printf("%s\n", s);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];
  int m = N+1;
  int count = 0;
  rep(i,N){
    if(m > v[i]){
      ++count;
      m = v[i];
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
AB = sorted(AB, key=lambda x: x[1])

ans = 0
m = 0
for ab in AB:
    if not ab[0] < m <= ab[1]:
        m = ab[1]
        ans += 1
print(ans)


Measured memory_bytes: 29852
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55

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


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

    cout << (1 << int(log2(n))) << "\n";


}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<queue>

using namespace std;
priority_queue<int> pq;

int main(void)

{
    int N, i, a, j, p, sum = 0, n;
    cin>>N;
    n = (N*(N-1))/2;
    int ara[N+4];
    for(i = 0; i < N; i++){
        cin>>a;
        if(i == 0){
            ara[i] = a;
        }
        else{
            for(j = 0; j < i; j++){
                p = a*ara[j];
                pq.push(p);
            }
            ara[i] = a;
        }
    }
    while(!pq.empty() && n--){
        a = pq.top();
        pq.pop();
        sum += a;
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 最長共通部分列
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C&lang=ja">ALDS1_10_C</a>
 */
public class Main {

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

		for (int i = 0; i < n; i++) {
			String X[] = sc.next().split("");
			String Y[] = sc.next().split("");
			System.out.println(lcs(X, Y));
		}

		sc.close();
	}

	private static int lcs(String X[], String Y[]) {
		int m = X.length;
		int n = Y.length;
		int c[][] = new int[m + 1][n + 1];
		for (int i = 0; i <= m; i++) c[i][0] = 0;
		for (int i = 0; i <= n; i++) c[0][i] = 0;

		int maxl = 0;

		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= n; j++) {
				if (X[i - 1] .equals(Y[j - 1])) {
					c[i][j] = c[i - 1][j - 1] + 1;
				} else {
					c[i][j] = Math.max(c[i - 1][j], c[i][j - 1]);
				}
				maxl = Math.max(maxl, c[i][j]);
			}
		}
		return maxl;
	}

}



Measured memory_bytes: 62740
import numpy as np

N = int(input())
D = input()
D =  D.split(' ')
D = [int(d) for d in D]
D_sort = np.sort(D)

k = int(N/2)
count = 0

low_d = D_sort[k-1]
hight_D = D_sort[k]
dis = hight_D - (low_d+1) + 1

print(dis)
    

Measured memory_bytes: 23416
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int N, K;
int A[2048];

int kaunto[2048];
int one[2048];

int main(void) {
	int i;
	int mult;
	int kitaeri = 0;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int mofu = 0;
		int j;
		for (j = 0; j < i; j++) {
			if (A[j] > A[i]) mofu++;
		}
		one[i] = mofu;
		kaunto[A[i]]++;
	}
	for (i = 2000 - 1; i > 0; i--) kaunto[i] += kaunto[i + 1];
	mult = K % 2 == 0 ? mul(K - 1, K / 2) : mul((K - 1) / 2, K);
	for (i = 0; i < N; i++) {
		kitaeri = add(kitaeri, mul(mult, kaunto[A[i] + 1]));
		kitaeri = add(kitaeri, mul(K, one[i]));
	}
	printf("%d\n", kitaeri);
	return 0;
}


Measured memory_bytes: 1728
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

from collections import defaultdict
dd = defaultdict(int)

N=I()
a=LI()

a.sort()

for i in range(N):
    dd[a[i]]+=1
    
ans=0
for k,v in dd.items():
    if v>k:
        ans+=v-k
    if v<k:
        ans+=v
        
print(ans)
    




Measured memory_bytes: 68776
<?php

// 標準入力を一行ずつ配列に代入します
fscanf(STDIN, '%d %d %d', $n, $a, $b);


$total = 0;
for ($i = 1; $i <= $n; $i++) {
	$str_i = (string)$i;
	$byte_len = strlen($str_i);

	$keta_total = 0;
	for ($b_i = 0; $b_i < $byte_len; $b_i++) {
		$keta_total += $str_i[$b_i];
	}
	if ($keta_total <= $b && $keta_total >= $a ) {
		$total += $i;
	}
}

echo $total;

Measured memory_bytes: 4856
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstdio>
using namespace std;

#define INF 1e9

int main(void){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

    // ??????????????¨??´??????
    int s, g;
    cin >> s >> g;
    --s; --g;

    // ???????????±???????????????
    int x, y, d, c;
    vector<vector<pair<int, pair<int, int> > > > adjlist(n);
    for(int i = 0; i < m; i++){
      cin >> x >> y >> d >> c;
      --x; --y;
      adjlist[x].push_back(make_pair(y, make_pair(d, c)));
      adjlist[y].push_back(make_pair(x, make_pair(d, c)));
    }

    
    // ????????????????????????
    const int MAX_SPEED = 30;
    const int acc[3] = {-1, 0, 1};
    vector<vector<vector<double> > > result(n, vector<vector<double> >(n, vector<double>(MAX_SPEED + 1, INF)));

    // U??????????????¢????????????????????????????????????????????????????????????????????????
    // (-cost, ((speed, nextpoint), nextnextindex))
    priority_queue<pair<double, pair<pair<int, int>, int> > > wait;
    for(int i = 0; i < adjlist[s].size(); i++){
      result[s][adjlist[s][i].first][0] = 0;
      wait.push(make_pair(0, make_pair(make_pair(0, s), i)));
    }

    while(!wait.empty()){
      double nowcost = -wait.top().first;
      int nowspeed = wait.top().second.first.first;
      int nowpoint = wait.top().second.first.second;
      int nextindex = wait.top().second.second;
      wait.pop();
      int nextpoint = adjlist[nowpoint][nextindex].first;      
      if(result[nowpoint][nextpoint][nowspeed] < nowcost){ continue; }

      int speedlimit = adjlist[nowpoint][nextindex].second.second;
      for(int j = 0; j < 3; j++){
        int nextspeed = nowspeed + acc[j];
        // ??¢??????????????¢?????¶????????????????????¢
        if(nextspeed <= 0 || speedlimit < nextspeed){ continue; }
        double nextcost = nowcost + ((double)adjlist[nowpoint][nextindex].second.first / nextspeed);
        for(int i = 0; i < adjlist[nextpoint].size(); i++){
          int nextnextpoint = adjlist[nextpoint][i].first;
          // U??????????????¢
          if(nextnextpoint == nowpoint){ continue; }
          if(result[nextpoint][nextnextpoint][nextspeed] > nextcost){
            result[nextpoint][nextnextpoint][nextspeed] = nextcost;
            wait.push(make_pair(-nextcost, make_pair(make_pair(nextspeed, nextpoint), i)));
          }
        }
        // ????????????????????????????????¨?????????????????¢
        if(result[nextpoint][nextpoint][nextspeed] > nextcost){ result[nextpoint][nextpoint][nextspeed] = nextcost; }
      }
    }
    
    // ??????????¨????????????????
    double mincost = INF;
    for(int i = 0; i < n; i++){
      if(mincost > result[g][i][1]){ mincost = result[g][i][1]; }
    }
    if(mincost == INF){ cout << "unreachable" << endl; }
    else{ printf("%.5f\n", mincost); } 
  }
  
  return 0;
}

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

int main(){

cout<<fixed<<setprecision(12);
double a,b,c,d;
cin>>a>>b>>c>>d;
double X=pow(c-a,2);
double Y=pow(d-b,2);
cout<<sqrt(X+Y)<<endl;


return 0;
}


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

int main(){
  int N;
  double T,A;cin>>N>>T>>A;
  double H[1010];
  for(int i=0;i<N;i++)cin>>H[i];
  double ans=100000;
  int tmp=0;
  for(int i=0;i<N;i++){
    double x=T-(H[i]*0.006);
    double y=A-x;
    if(y<0)y*=-1;
    ans=min(y,ans);
    if(ans==y)tmp=i+1;
  }
  cout<<tmp<<endl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())

if (A == 1 and B == 2) or (A == 2 and B == 1):
    print(3)
elif (A == 1 and B == 3) or (A == 3 and B == 1):
    print(2)
elif (A == 2 and B == 3) or (A == 3 and B == 2):
    print(1)

Measured memory_bytes: 8856
#include <iostream>
#include <vector>
using namespace std;
vector<int> G[200010];
int cnt[200010] = {};
void dfs(int s, int p){
	for(auto v:G[s]){
		if(v==p) continue;
		cnt[v] += cnt[s];
		dfs(v,s);
	}
}

int main(){
	int i,n,q;
	cin >> n >> q;
	for(i=0;i<n - 1;i++){
		int a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	for(i=0;i<q;i++){
		int a,b; cin >> a >> b; a--; cnt[a] += b;
	}
	dfs(0,-1);
	for(i=0;i<n;i++){
		cout << cnt[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 23424
/*input
YAK
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	string s;
	cin>>s;
	if(s.size()>3 && s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
		cout<<"Yes";
	else cout<<"No";
}

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

using namespace std;

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

const ll maxn =5e5+5;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

char a;

int main(){
    migmig
    cin >> a;
    a++;
    cout << a;


    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for (ll i = 0; i < H; i++)
  {
    cin >> S.at(i);
  }

  const string blank = string(W, '.');
  vector<ll> last(H, -1);
  for (ll i = 0; i < H; i++)
  {
    for (ll j = 0; j < W; j++)
    {
      if (S.at(i).at(j) == '#')
        last.at(i) = j;
    }
  }
  
  vector<vector<ll>> A(H, vector<ll>(W, 0));
  vector<bool> done(H, false);
  ll cnt = 1;
  for (ll i = 0; i < H; i++)
  {
    if (S.at(i) == blank)
      continue;
    
    for (ll j = 0; j < W; j++)
    {
      A.at(i).at(j) = cnt;
      if (S.at(i).at(j) == '#' && last.at(i) != j)
        cnt++;
    }
    cnt++;
    done.at(i) = true;
  }

  for (ll i = H - 2; i >= 0; i--)
  {
    if (!done.at(i) && done.at(i + 1))
    {
      for (ll j = 0; j < W; j++)
      {
        A.at(i).at(j) = A.at(i + 1).at(j);
      }
      done.at(i) = true;
    }
  }

  for (ll i = 0; i < H - 1; i++)
  {
    if (!done.at(i + 1) && done.at(i))
    {
      for (ll j = 0; j < W; j++)
      {
        A.at(i + 1).at(j) = A.at(i).at(j);
      }
      done.at(i + 1) = true;
    }
  }
  
  for (ll i = 0; i < H; i++)
  {
    for (ll j = 0; j < W; j++)
    {
      cout << A.at(i).at(j) << ((j == W - 1) ? '\n' : ' ');
    }
  }
}

Measured memory_bytes: 1664
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
H = np.array(lr())
Hdiff = np.diff(H)
Hdiff = Hdiff[Hdiff>0]
answer = H[0] + Hdiff.sum()
print(answer)


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

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;

int main() {
    int n,d;
    cin >> n >> d;

    int ans = 0;
    for (int i=0; i<n; i++) {
        int x,y;
        cin >> x >> y;
        if (hypot(x,y) <= d) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3228
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static List<Long> aList = new ArrayList<Long>();

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

        int k = Integer.parseInt(scan.next());

        scan.close();

        aList.add((long) 0);
        aList.add((long) 1);
        aList.add((long) 2);
        aList.add((long) 3);
        aList.add((long) 4);
        aList.add((long) 5);
        aList.add((long) 6);
        aList.add((long) 7);
        aList.add((long) 8);
        aList.add((long) 9);

        long i = 1;
        while (aList.size() < 100001) {
            i *= 10;
            addA(i);
        }

        System.out.println(aList.get(k));
    }

    private static void addA(long keta) {
        List<Long> addList = new ArrayList<Long>();
        long curKeta = keta / 10;

        addList.add(keta);

        for (long a : aList) {
            if (a < curKeta) {
                String aStr = String.valueOf(a);
                if (aStr.startsWith("1")) {
                    addList.add(keta + a);
                }

                continue;
            }

            long headNum = a / curKeta;
            if (headNum == 1) {
                addList.add(keta + a);
                addList.add(keta * 2 + a);
            } else if (headNum == 9) {
                addList.add(keta * 8 + a);
                addList.add(keta * 9 + a);
            } else {
                addList.add(keta * (headNum - 1) + a);
                addList.add(keta * headNum + a);
                addList.add(keta * (headNum + 1) + a);
            }
        }

        Collections.sort(addList);
        for (long addNum : addList) {
            aList.add(addNum);
        }
    }

}


Measured memory_bytes: 50084
from itertools import accumulate


n, k = map(int, input().split())
p = list(map(int, input().split()))
max_sum_k = 0
cum_sum = [0] + list(accumulate(p))
for i in range(k-1, n + 1):
    sum_p = cum_sum[i] - cum_sum[i-k]
    if sum_p > max_sum_k:
        max_sum_k = sum_p

max_ex = (k + max_sum_k) / 2
print(max_ex)


Measured memory_bytes: 25152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

int main(){
    int H,W;

while(!(H==0 && W==0)){
    cin>>H;
    cin>>W;
    for(int i=0;i<H;i++){
       for(int j=0;j<W;j++){
         if(i==0 || i==H-1){
           cout<<"#";
         }else if(j==0 || j==W-1){
           cout<<"#";
         }else{
           cout<<".";
         }
       }
      cout<<"\n";
    }
    if(!(H==0 && W==0))
    cout<<endl; 
}

    }


Measured memory_bytes: 3084
from sys import stdin

def main():
    N,M=[int(x) for x in stdin.readline().split()]
    D=dict()
    AC=0
    WA=0
    for _ in range(M):
        p,a=stdin.readline().split()
        p=int(p)
        if not p in D:
            D[p]=0
        if a=='WA' and D[p]!=-1:
            D[p]+=1
        if a=='AC' and D[p]!=-1:
            WA+=D[p]
            AC+=1
            D[p]=-1
    print(AC,WA)
main()


Measured memory_bytes: 15032
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
#pragma GCC optimize("O3,Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC target("arch=ivybridge")
using namespace std;
using VI = vector<long>;

int main() {
    int a;
    cin >> a;
    if (a < 1200) {
        cout << "ABC" << endl;
        return 0;
    }
    if (a < 2800) {
        cout << "ARC" << endl;
        return 0;
    }
    cout << "AGC" << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

const long long MOD = 1000000007;
const double PI = 3.1415926535;

int main(void) {
	int k;
	string s;
	cin >> k >> s;
	
	if(s.length() <= k)cout << s << endl;
	else {
		string ans = s.substr(0,k);
		ans += "...";
		cout << ans << endl;
	}			

	return 0;
}


Measured memory_bytes: 3600
#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())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    cout << (n * (n - 1) / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{

    class ABC170
    {
        static int N;
        static int K;

        static void Main(String[] args)
        {
            var arr = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();

            N = arr[0];
            K = arr[1];

            var p = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToList<int>();

            p.Sort();
            var arrP = p.ToArray();
            var result = 0;

            for (int i = 0; i < K; i++)
            {
                result += arrP[i];
            }
            Console.WriteLine(result);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 28672
#include <stdio.h>

int main(void)
{
        int i;
        char c[4][4];

        for (i=0;i<3;i++)
                scanf("%s",c[i]);

        for (i=0;i<3;i++)
                printf("%c",c[i][i]);

        printf("\n");

        return 0;
}

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

int main(void){
  const int INF = 1e6;
  vector<int> A(3);
  for(int i = 0; i < 3; i++) cin >> A[i];
  int ans = INF;
  do{
    ans = min(ans, abs(A[1] - A[0]) + abs(A[2] - A[1]));
  }while(next_permutation(A.begin(), A.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void isDoublePalindrome(string str, int n)
{
   //int length = string.length();
    // if length is not even, then it is not a double palindrome
    
    int start = 0, f=0;
    int end = n - 1;
    int middle = ((n-1) / 2)-1;
    while (middle>=0) {
      // if characters are same, move the pointers, otherwise break and
      // return false
      if ((str.at(start) == str.at(middle))
          && (str.at(start) == str.at(end))) {
        start++;
        middle--;
        end--;
      } else {
          f=1;
          break;
        //cout<<"No\n";
      }
    }
    if(f==0)
    cout<<"Yes\n";
    else
    cout<<"No\n";
 
}
 
int main()
{
    string str;
    cin>>str;
    int n=str.size();
    if (n % 2 == 0 || n<3||n>99) {
      cout<<"No\n";
    }
    else
    isDoublePalindrome(str, n);
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

vector<vector<int>> dp;

int n, k;
vector<int> arr;

int solve(int left = k, int chance = 0) {
    if(dp[chance][left] != -1) {
        return dp[chance][left];
    }
    int ans = chance;
    for(int i = 0; i < n; i ++) {
        int temp = left - arr[i];
        if(temp >= 0 && temp < arr[0]) {
            dp[chance][left] = chance;
            return chance;
        }
    }
    for(int i = 0; i < n; i ++) {
        if(left >= arr[i] && (solve(left - arr[i], !chance) == chance)) {
            dp[chance][left] = chance;
        }
    }
    if(dp[chance][left] == -1) {
        dp[chance][left] = !chance;
    }
    return dp[chance][left];
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    dp.assign(2, vector<int>(k+1, -1));
    arr.assign(n+1, 0);
    for(int i = 0; i < n; i ++) cin >> arr[i];
    int ans = solve();
    // cout << dp << endl;
    cout << (ans ? "Second" : "First") << endl;
    return 0;
}

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

#define INF 1010101010

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a;
	for (int i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			a.emplace_back(i);
			a.emplace_back(m / i);
		}
	}

	int mx = 1;
	for (auto& i : a) {
		if (i >= n) {
			mx = max(mx, m / i);
		}
	}
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
int a[maxn], b[maxn], a1[maxn], b1[maxn];
int  v[maxn], match[maxn];
int n;
vector < int > g[maxn];
bool dfs(int x)
{
	int y;
	for(int i = 0; i < g[x].size(); i++){
		y = g[x][i];
		if(!v[y]){
			v[y] = 1;
			if(!match[y] || dfs(match[y])){
				match[y] = x;
				return true;
			}
		}
	}
	return false;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d %d", a + i, b + i);
	}
	for(int i = 1; i <= n; i++){
		scanf("%d %d", a1 + i, b1 + i);
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(a[i] < a1[j] && b[i] < b1[j]){
				g[i].push_back(j);
			}
		}
	}
	int ans = 0;
	for(int i  = 1; i <= n; i++){
		memset(v, 0, sizeof(v));
		if(dfs(i))ans++;
	}
	printf("%d", ans);
	return 0;
}

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

using namespace std;

int main(){
    int N,W,cnt=1;
    int v[1001],w[1001];

    while(cin>>W){
        if(W==0) break;

        cin>>N;
        int dp[N+1][W+1];

        for(int i=0;i<=W;i++){
            dp[0][i]=0;
        }

        for(int i=0;i<N;i++){
            scanf("%d,%d",v+i,w+i);
        }

        for(int i=0;i<N;i++){
            for(int j=0;j<=W;j++){
                if(j<w[i]){
                    dp[i+1][j]=dp[i][j];
                }else{
                    dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
                }
            }
        }

        cout<<"Case "<<cnt++<<":\n"<<dp[N][W]<<endl;

        int max_w=W;
        while(dp[N][W]==dp[N][max_w]) max_w--;

        cout<<max_w+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 5164
a, b = map(int, input().split())
c = input()
d = [0] * a
e = 0
for i in range(1, a):
    if c[i] == "C" and c[i-1] == "A":
        e += 1
    d[i] = e
for i in range(b):
    f, g = map(int, input().split())
    print(d[g-1]-d[f-1])


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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF int(1e9)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

// vector<int> dx = {-1, 0, 0, 1};
// vector<int> dy = {0, 1, -1, 0};

void solve() {
    int h, w;
    cin >> h >> w;

    int ch, cw;
    cin >> ch >> cw;
    ch--, cw--;

    int dh, dw;
    cin >> dh >> dw;
    dh--, dw--;

    vector<string> mat(h);
    for (string &s: mat)
        cin >> s;
    // trace(mat);
    deque<pair<int, int>> q;
    vector<vector<int>> d(h, vector<int>(w, INF));

    d[ch][cw] = 0;
    q.push_back({ch, cw});

    while (!q.empty()) {
        int x = q.front().first, y = q.front().second;
        // trace(x, y);
        q.pop_front();

        for (int dx = -2; dx <= 2; dx++) {
            for (int dy = -2; dy <= 2; dy++) {
                int w1 = 1;
                if (dx * dx + dy * dy == 1)
                    w1 = 0;

                int nx = x + dx;
                int ny = y + dy;

                if (nx < h && ny < w && nx >= 0 && ny >= 0 && mat[nx][ny] == '.') {
                    if (d[nx][ny] > w1 + d[x][y]) {
                        d[nx][ny] = w1 + d[x][y];
                        if (w1 == 0) {
                            q.push_front({nx, ny});
                        } else {
                            q.push_back({nx, ny});
                        }
                    }
                }
            }
        }
    }

    if (d[dh][dw] >= INF) {
        cout << -1;
    } else {
        cout << d[dh][dw];
    }

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 8780
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int M = 10000;
static const int NMAX = 100;

main(){
  int N, K, A, B;
  int dp[NMAX+1][3][2], T[NMAX+1];

  cin >> N >> K;

  rep(i, N+1) rep(j, 3) rep(k, 2) dp[i][j][k] = 0;
  rep(i, N+1) T[i] = -1;

  rep(i, K){
    cin >> A >> B;
    B--; // 0, 1, 2
    T[A] = B;
  }
  
  // init
  if ( T[1] >= 0 ){
    dp[1][T[1]][1] = 1;
  } else {
    rep(j, 3) dp[1][j][0] = 1;
  }

  for ( int i = 2; i <= N; i++ ){
    rep(s, 3){
      rep(j, 3){
	if ( T[i] >= 0 && j != T[i] ) continue;
	
	if ( s != j ){
	  dp[i][j][0] = (dp[i][j][0] + dp[i-1][s][0])%M;
	  dp[i][j][0] = (dp[i][j][0] + dp[i-1][s][1])%M;
	} else {
	  dp[i][j][1] = (dp[i][j][1] + dp[i-1][s][0])%M;
	}
      }
    }
  }

  int sum = 0;
  rep(j, 3) rep(k, 2) sum = (sum + dp[N][j][k])%M;

  cout << sum << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,K;
	cin >> N >> K;
	int num = (N-1)*(N-2)/2 - K;
	if(num<0){
		cout << -1 << endl;
		return 0;
	}
	cout << N-1 + num << endl;
	rep1(i,N-1) cout << 1 << " " << i+1 << endl;
	for(int i=2;i<=N;i++) for(int j=i+1;j<=N;j++){
		if(num == 0) return 0;
		cout << i << " " << j << endl;
		num--;
	}
}


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

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int H = Cin(), N = Cin();
    vector<int> As(N), Bs(N);
    for (int i = 0; i < N; ++i) cin >> As[i] >> Bs[i];

    // dp[i] = HPをiだけ削るのに必要な最小MP
    int dp[11000];
    dp[0] = 0;
    for (int i = 1; i <= H; ++i)
    {
        int minMP = 200000000;
        for (int j = 0; j < N; ++j)
        {
            int k = max(0, i - As[j]);
            minMP = min(minMP, dp[k] + Bs[j]);
            //for (int k = max(0, i - As[j]); k < i; ++k)
            //{
            //    minMP = min(minMP, dp[k] + Bs[j]);
            //}
        }
        dp[i] = minMP;
    }
    cout << dp[H] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=150;
char s[N][N];
int t[N*2];
int main(){
	int n=rd(),m=rd();
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,n)rep(j,1,m){
		t[s[i][j]]++;
	}
	int tot1=0,tot2=0,tot3=0;
	rep(i,'a','z'){
		t[i]%=4;
		tot1+=(t[i]==1);
		tot2+=t[i]==2;
		tot3+=t[i]==3;
	}
	//cout<<tot1<<endl;
	tot2+=tot3,tot1+=tot3;
	bool flag=1;
	if(tot1>1||((tot1==1)&&(n%2==0||m%2==0)))flag=0;
	if(n&1)tot2-=m/2;
	if(m&1)tot2-=n/2;
	if(tot2>0)flag=0;
	puts(flag?"Yes":"No");
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, ans = 0;
    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        if (i % 2 == 1) continue;
        if (a % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

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


void solve(long long N, std::vector<long long> d){
    int ans = 0;
    for (int i = 0; i < N-1; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

def solve():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        if V[i]-C[i] >= 0:
            ans += V[i]-C[i]
    
    print(ans)

if __name__ == "__main__":
    solve()



Measured memory_bytes: 3060
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n, x, y;
	cin >> n >>x >> y;
	x--, y--;
	unordered_map<int, int> ans;
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			ans[min(j-i, abs(i-x)+abs(j-y)+1)]++;
		}
	}
	for(int i = 1; i <= n-1; i++) {
		cout << ans[i] << '\n';
	}


	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
int cnt = 0;
char exc[100011];
char buf[100011];
int p;
int M;
 
int kakko();
int number();
int multidiv();
int operation();
 
 
int pl(int a,int b){
  int n = a+b;
  // cout << a << " + " << b << " = " << n << endl;
  return n % p;
}
 
int mina(int a,int b){
  int n = a-b + p;
  // cout << a << " - " << b << " = " << n << endl;
  return n % p;
}
 
int kake(int a,int b){
  int n = a*b;
  // cout << a << " * " << b << " = " << n << endl;
  return n%p;
}
 
int doubli(int b){
  if( b == 1 ) return 1;
  long long  m = p-2;
  long long x = 1;
  long long k = b;
  while( m ){
    if( m&1 ){
      x *= k;
      x %= (long long)p;
    }
    m>>=1;
    k*=k;
    k%=(long long)p;
  }
  //  cout << "doubli " << p << " " <<b << " " << x << " " << b*x << " " << (b*x)%p << endl;
  return (int)x;
}
 
int zyo(int a,int b){
  if( b == 0 ) return -1;
  b = doubli(b);
  int n = a * b;
  // cout << a << " /  " << b << " = " << n << endl;
  //cout << a << " * " << b << " = " << n << " " << n%p<< endl;
  return n % p;
}
 
 
int number(){
  int ret = 0;
  if(!('0' <= exc[cnt] && exc[cnt] <= '9') ) return -1;
  while( '0' <= exc[cnt] && exc[cnt] <= '9' ){
    ret *= 10;
    ret += exc[cnt]-'0';
    cnt++;
  }
  return ret;
}

int kakko(){
  int ret = number();
  if( ret == -1 ){
    if( exc[cnt] == '(' ){
      cnt++;
      ret = operation();
      if( exc[cnt] == ')' ){
	cnt++;
      }
    }
  }
  return ret;
}


int multidiv(){
  int ret = kakko();
  char c = exc[cnt];
  while( c == '*' || c == '/' ){
    if( ret == -1 ) return -1;
    cnt++;
    int b = kakko();
    if( b == -1 ) return -1;
    if( c == '*' ){
      ret = kake(ret,b);
    } else {
      ret = zyo(ret,b);
    }
    c = exc[cnt];
  }
  return ret;
}

int  operation(){
  int ret = multidiv();
  char c = exc[cnt];
  while( c=='+' || c=='-' ){
    if( ret == -1 ) return -1;
    cnt++;
    int b = multidiv();
    if( b == -1 ) return -1;
    if( c == '+' ){
      ret = pl(ret,b);
    } else {
      ret = mina(ret,b);
    }
    c = exc[cnt];
  }
  return ret;
}

int parse(){
  return  operation();
}

 
int main(){
  while( cin >> p ){
    fgets(buf,sizeof(buf),stdin);
    if( p == 0 ) break;
    cnt = 0;
    int n = strlen(buf);
    memset(exc,0,sizeof(exc));
    for(int i=0;i<n;i++){
      if( buf[i] != ' ' && buf[i] != ':' && buf[i] != '\n' ) exc[cnt++] = buf[i];
    }
    M = cnt;
    exc[M] = '\0';
    // cout << p << " " << exc << " " << M << endl;
    cnt = 0;
    int res = parse();
    if( res!=-1 ){
      cout << exc << " = " << res << " (mod " << p << ")"<<endl;
    } else {
      cout <<"NG" << endl;
    }
  }
}

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

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

int main(){
	int n;
	cin >> n;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	int ans = 0;
	int k = 1;
	for(int i=0;i<n;i++){
		if(v[i]%2==0){
			int x = 1;
			for(int j=i+1;j<n;j++){
				x *= 3;
			}
			ans += k*x;
			k *= 2;
		}else{
			int x = 1;
			for(int j=i+1;j<n;j++){
				x *= 3;
			}
			ans += 2*k*x;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

    int n;
    cin >> n;

    vector<int64_t> a(n);
    repeat (i, n) {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int64_t>());

    int ans = 0;
    unordered_map<int64_t, int> counter;
    repeat (i, n) {
        bool flag = false;
        for (int j = 31; j >= 1; j--) {
            int64_t sum = (1LL << j);

            if (2 * a[i] > sum) break;

            if (counter[sum - a[i]] > 0) {
                counter[sum - a[i]]--;
                ans++;
                flag = true;
                break;
            }
        }
        if (!flag) counter[a[i]]++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 32272