akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> B(N-1);
    for(int i=0; i<N-1; i++) cin >> B.at(i);

    int ans = B[0] + B[N-2];
    for(int i=1; i<N-1; i++)
    {
        ans += min(B[i], B[i-1]);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

void printYes(){
	cout<<"Yay!"<<endl;
}
void printNo(){
	cout<<":("<<endl;
}


lli data[310][310];
lli ans[310][310];
lli sum[310][310];

lli q(lli x1,lli x2,lli y1,lli y2){
	return sum[y2][x2]-sum[y1][x2]-sum[y2][x1]+sum[y1][x1];
}

signed main(){

	lli h,w,k;

	cin>>h>>w>>k;
	REP(i,0,310)REP(j,0,310){
		data[i][j]=0;
		ans[i][j]=0;
		sum[i][j]=0;
	}

	REP(i,0,h)REP(j,0,w){
		char tmp;
		cin>>tmp;
		if(tmp=='#'){
			data[i][j]=1;
			//sum[i][j]=1;
		}
	}

	/*

	REP(i,0,h)REP(j,0,w){
		sum[i+1][j+1] = sum[i][j+1]+sum[i+1][j]-sum[i][j]+data[i][j];
	}

	*/

	lli num=1;

	REP(y,0,h)REP(x,0,w){
		if(ans[y][x]!=0)continue;
		if(data[y][x]==0)continue;
		//何もないところから上下に伸ばしてとりあえず埋める
		//埋まってないところはあとでうめることを考える
		ans[y][x]=num;
		for(lli y2=y-1;y2>=0;y2--){
			if(ans[y2][x]!=0 || data[y2][x]!=0)break;
			ans[y2][x]=num;
		}
		for(lli y2=y+1;y2<h;y2++){
			if(ans[y2][x]!=0 || data[y2][x]!=0)break;
			ans[y2][x]=num;
		}
		num++;
	}

	REP(y,0,h)REP(x,0,w){
		if(ans[y][x]==0)continue;
		//if(data[y][x]==0)continue;

		lli tmp = ans[y][x];
		for(lli x2=x-1;x2>=0;x2--){
			if(ans[y][x2]!=0)break;
			ans[y][x2]=tmp;
		}
		for(lli x2=x+1;x2<w;x2++){
			if(ans[y][x2]!=0)break;
			ans[y][x2]=tmp;
		}
	
	}

	REP(y,0,h){
		REP(x,0,w){
			cout<<ans[y][x]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner  stdin = new Scanner(System.in);
	int t = stdin.nextInt();
	int h = t/3600;
	int m = (t-h*3600)/60;
	int s = (t-h*3600)%60;
	System.out.println(h+":"+m+":"+s);
    }
}

Measured memory_bytes: 26248
<?php
// Your code here!
$S = fgets(STDIN);
$T = fgets(STDIN);

$arrS = str_split($S);
$arrT = str_split($T);

$str_diff = array_diff_assoc($arrS, $arrT);

$diff_count = count($str_diff);
echo $diff_count;
?>

  

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

char s[1005][1005];
int d[1005][1005];
bool is[1005][1005];

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

int main() {
	make2(n, m);
	FOR(i,0,n) {
		scanf("%s", s[i]);
	}
	FOR(i,0,n) FOR(j,0,m) {
		is[i][j] = false;
		d[i][j] = 1e9;
	}
	vector<PII> que;
	FOR(i,0,n) {
		FOR(j,0,m) {
			if (s[i][j] == '#') {
				is[i][j] = true;
				d[i][j] = 0;
				que.pb({i,j});
			}
		}
	}
	int pos = 0;
	while (pos < que.size()) {
		PII ja = que[pos];
		pos++;
		FOR(j,0,4) {
			int x = ja.st + dx[j];
			int y = ja.nd + dy[j];
			if (x >= 0 && x < n && y >= 0 && y < m) {
				if (is[x][y] == false) {
					is[x][y] = true;
					d[x][y] = d[ja.st][ja.nd] + 1;
					que.pb({x,y});
				}
			}
		}
	}
	int ans = 0;
	FOR(i,0,n) FOR(j,0,m) ans = max(ans, d[i][j]);
	
	printf("%d\n", ans);

}





Measured memory_bytes: 15980
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  string S;
  cin >> S;
  if (S[S.size()-1]=='s') cout << S << "es" << endl;
  else cout << S << 's' << endl;
  return 0;
}

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

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

	unordered_map <string, int> mp;
	mp["AC"] = 0;
	mp["WA"] = 0, mp["TLE"] = 0, mp["RE"] = 0;

	string s;
	while (n--){
		cin >> s;
		mp[s]++;
	}

	
	cout << "AC" << " x " << mp["AC"] << endl;
	cout << "WA" << " x " << mp["WA"] << endl;
	cout << "TLE" << " x " << mp["TLE"] << endl;
	cout << "RE" << " x " << mp["RE"] << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define ll long long

int main() {
    int r;
    cin >> r;
    cout << M_PI*2*r << endl;
    return 0;
}

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

mod = 10**9+7

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m=mod):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


N = int(input())
A = list(map(int, input().split()))

NN = [1]
for n in range(1, N+1):
    NN.append(NN[-1]*n%mod)

div = 0
ans = 0
for i in range(N-1):
    div = (div + NN[N-1]*mod_inv(i+1) % mod) % mod
    ans = (ans + div*(A[i+1]-A[i])%mod) % mod

print(ans)

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

#define ll long long
#define ull unsigned long long
#define openfiles ifstream cin("input.txt"); ofstream cout("output.txt");

using namespace std;

ll a[5000], dp[5000][5000][2];

ll solve(int l, int r, int hod)
{
    if(l == r)
        return a[l];
    if(!dp[l][r][hod])
        return dp[l][r][hod] = max(-solve(l + 1, r, 1 - hod) + a[l], -solve(l, r - 1, 1 - hod) + a[r]);
    return dp[l][r][hod];
}
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    cout << solve(0, n - 1, 0);
}
//10 20 30 40
//30 50 70
//90 140


Measured memory_bytes: 235264
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char ch[15];
int main()
{
  scanf("%s",ch+1);
  int a=0;
  for(int i=1;i<=4;i++)
    a=a*10+ch[i]-'0';
  if(a<2019){puts("Heisei");return 0;}
  if(a>2019){puts("TBD");return 0;}
  a=(ch[6]-'0')*10+ch[7]-'0';
  if(a<4){puts("Heisei");return 0;}
  if(a>4){puts("TBD");return 0;}
  a=(ch[9]-'0')*10+ch[10]-'0';
  if(a<=30){puts("Heisei");return 0;}
  else {puts("TBD");return 0;}
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}


int pow_mod(ll a, int b) {
	ll pow = 1;
	while (b > 0) {
		if (b & 1) pow = pow * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return pow;
}

ll inv_mod(ll n) {
	return pow_mod(n, MOD - 2);
}

int fact_mod(int n) {
	ll fact = 1;
	for (int i = n; i > 0; --i) fact = (fact * i) % MOD;
	return (int)fact;
}

ll comb_mod(ll n, ll r) {
	ll comb = 1;
	if (n / 2 < r) return comb_mod(n, n - r);
	else {
		for (ll i = 0; i < r; ++i)
			comb = (comb * (n - i)) % MOD;
		return (comb * inv_mod(fact_mod(r))) % MOD;
	}
	}

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

	ll ans = pow_mod(2,n);
	ans -= (comb_mod(n,a) + comb_mod(n,b)) %MOD;


  cout << (ans - 1 < 0 ? ans -1 +MOD : (ans - 1) % MOD) << endl;
	
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<LL, LL> P;

struct UnionFindTree {
  std::vector<int> data;

  UnionFindTree(int size) : data(size, -1) { }
  bool Unite(int x, int y) {
    x = Root(x); y = Root(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool IsSameRoot(int x, int y) {
    return Root(x) == Root(y);
  }
  int Root(int x) {
    return data[x] < 0 ? x : data[x] = Root(data[x]);
  }
  int Size(int x) { return -data[Root(x)]; }
};

int main() {
  LL N, M; cin >> N >> M;
  vector<P> ps(M);
  for (int i = 0; i < M; ++i) {
    LL A, B; cin >> A >> B;
    --A, --B;
    ps[i] = {A, B};
  }

  UnionFindTree tree(N);
  vector<LL> score(M + 1);
  score[M-1] = N * (N - 1) / 2;
  for (int i = M - 1; i > 0; --i) {
    auto [a, b] = ps[i];
    LL update = tree.Size(a) * tree.Size(b);
    if (tree.IsSameRoot(a, b)) {
      score[i-1] = score[i];
    } else {
      score[i-1] = score[i] - update;
      tree.Unite(a, b);
    }
  }
  for (int i = 0; i < M; ++i) {
    cout << score[i] << endl;
  }
}


Measured memory_bytes: 5876
#include <stdio.h>

int main(void) {
	int x, y, temp;
	scanf("%d %d", &x, &y);
	while (x!=0 || y!=0)
	{
		if (x>y) {
			temp=x;
			x=y;
			y=temp;
		}
		printf("%d %d\n", x, y);
		scanf("%d %d", &x, &y);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
string s, t;

int main() {
	cin>>s;
	cin>>t;

	int result = INT_MAX;
	for(int i=0;i<s.length();i++) {
		if(i >= t.length() - 1) {
			int ti = 0;
			int br = 0;
			for(int j=i-t.length()+1;j<=i;j++) {
				if(s[j] != t[ti]) br++;
				ti++;
			}

			result = min(result, br);
		}
	}

	cout<<result<<"\n";
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

int main(){
 	int k;
 	char a[100];
 	scanf ("%d", &k);
 	scanf ("%s", a);
 	
 	if (strlen(a) <= k) {
  		printf ("%s", a);
	} 
 	else {
  		for(int i = 0; i < k; i++) {
   			printf ("%c", a[i]);
  		}
  		printf ("...");
 	}
	return 0;
}

Measured memory_bytes: 1720
from collections import deque

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))
q = deque([(0, 0)])
s[0][0] = 0
dy = (1, 0, -1, 0)
dx = (0, 1, 0, -1)
blacks = 0
for y in range(h):
    blacks += s[y].count("#")
while q:
    y, x = q.popleft()
    dist = s[y][x]
    if (y, x) == (h - 1, w - 1):
        break
    for k in range(4):
        ny, nx = y + dy[k], x + dx[k]
        if 0 <= ny < h and 0 <= nx < w:
            if s[ny][nx] == ".":
                s[ny][nx] = dist + 1
                q.append((ny, nx))
if s[h - 1][w - 1] == ".":
    print(-1)
else:
    print(h * w - s[h - 1][w - 1] - blacks - 1)


Measured memory_bytes: 40560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int x,a;
    cin >> x >> a;
    if(x >= a)cout << 10 << endl;
    else cout << 0 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;

int field[1024][1024][3];
int main()
{
  char c2i[256] = {};
  c2i['J'] = 0;
  c2i['O'] = 1;
  c2i['I'] = 2;
  int h, w, K;
  cin >> h >> w >> K;
  for (int i = 0; i < h; i++){
    string s;
    cin >> s;
    for (int j = 0; j < w; j++){
      int id = c2i[s[j]];
      field[i + 1][j + 1][id] = 1;
    }
  }
  for (int i = 1; i <= h; i++){
    for (int j = 1; j <= w; j++){
      for (int k = 0; k < 3; k++){
        field[i][j][k] += field[i - 1][j][k] + field[i][j - 1][k] - field[i - 1][j - 1][k];
      }
    }
  }
  for (int i = 0; i < K; i++){
    int sx, sy, ex, ey;
    cin >> sy >> sx >> ey >> ex;
    vector<int> v;
    for (int k = 0; k < 3; k++){
      int x = field[ey][ex][k] - field[sy - 1][ex][k] - field[ey][sx - 1][k] + field[sy - 1][sx - 1][k];
      v.push_back(x);
    }
    show(v, Out<int>);
  }

  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 13504
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=300005;
const int NN=2005;
const ll md=998244353;

vii g[N];
int ans[N];

void bfs(){
    vii ch;
    ch.pb(1);
    for (int i=0;i<ch.size();i++){
        int v=ch[i];
        for (auto x:g[v]){
            if (ans[x]==-1){
                ans[x]=v;
                ch.pb(x);
            }
        }
    }

}

int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    ans[1]=0;
    for (int i=2;i<=n;i++){
        ans[i]=-1;
    }
    for (int i=1;i<=m;i++){
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    bfs();
    str s="Yes";
    for (int i=2;i<=n;i++){
        if (ans[i]==-1){
            s="No";
        }
    }
    cout << s << E;
    if (s=="Yes"){
        for (int i=2;i<=n;i++){
            cout << ans[i] << E;
        }
    }
    r0;
}
/*








*/


Measured memory_bytes: 18088
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
vector < pair<long long,long long>> wow[2000];
long long dijk[300][300] = {};
int main() {
#define int long long
	int n, m,r;
	cin >> n >> m >> r;
	vector<int> geko;
	REP(i, r) {
		int tmp;
		cin >> tmp;
		geko.push_back(tmp);
	}
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		wow[a].push_back(make_pair(b, c));
		wow[b].push_back(make_pair(a, c));
	}
	sort(geko.begin(), geko.end());
	long long final_ans = LONG_INF;
		for (int i = 1;i <= n;++i) {
			for (int q = 0;q < 300;++q) {
				dijk[i][q] = LONG_INF;
			}
			dijk[i][i] = 0;
			priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> woa;
			int visited[300] = {};
			woa.push(make_pair(0,i));
			while (woa.empty() == false) {
				pair<int, int> now = woa.top();
				woa.pop();
				if (visited[now.second] == false) {
					visited[now.second] = true;
					for (int q = 0;q < wow[now.second].size();++q) {
						if (dijk[i][wow[now.second][q].first] > dijk[i][now.second] + wow[now.second][q].second) {
							dijk[i][wow[now.second][q].first] = dijk[i][now.second] + wow[now.second][q].second;
							woa.push(make_pair(dijk[i][wow[now.second][q].first], wow[now.second][q].first));
						}
					}
				}
			}
		}
		do {
			long long now = 0;
			for (int i = 0;i < geko.size() - 1;++i) {
				now += dijk[geko[i]][geko[i + 1]];
			}
			final_ans = min(final_ans, now);
		} while (next_permutation(geko.begin(), geko.end()));
	cout << final_ans << endl;
	return 0;
}

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

int main() {
	int n,m,X,Y;
	cin>>n>>m>>X>>Y;
	vector<int> x(n+1),y(m+1);
	for(int i=0;i<n;++i){
		cin>>x[i];
	}
	x[n]=X;
	sort(x.begin(),x.end());
	for(int i=0;i<m;++i){
		cin>>y[i];
	}
	y[m]=Y;
	sort(y.begin(),y.end());
	
	
	if(x[n]<y[0]){
		cout<<"No War"<<endl;
	}else {
		cout<<"War"<<endl;
	}
}

Measured memory_bytes: 256
ans = 1;

def one_count(data, i, count):
    global ans
    
    count+=1
    
    if data[i+1] == 1:
        one_count(data, i+1, count)
    elif ans <= count:
        ans = count+1
    
N = int(input())
data = list(map(int, input().split()))
data.append(0)

for i in range(N):
    count = 0;
    if data[i] == 1:
        one_count(data, i, count)

print(ans)
        


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
//----------------------------------------------------------------------------------------------------------------------
 
#define MOD 1000000007 
  
void swap(char &a, char & b){
    char temp = a;
    a = b;
    b = temp;
 
}
 
const ll md = 1e9 + 7;
const int MAXN = 2*1e5 + 50;
 
vector< int > graph[MAXN];
int in_degrees[MAXN];
int dist[MAXN];
bool visited[MAXN];
ll inf = 1e18*1LL;



void dfs(int root){
    visited[root] = true;
    for(auto it : graph[root]){
        dist[it] = max(dist[it],dist[root] + 1);
        --in_degrees[it];
        if(in_degrees[it] == 0){
            dfs(it);
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    for(int i = 0;i < m;i++){
        int a,b;
        cin >> a >> b;
        graph[a].pb(b);
        ++in_degrees[b];
    }    
    for(int i = 1; i <= n;i++){
        if(!visited[i] && in_degrees[i] == 0){
            dfs(i);
        }
    }
    int ans = 0;
    for(int i = 1;i <= n;i++) ans = max(ans,dist[i]);

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

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    s = input()
    k = int(input())
    extracted = set()
    s_len = len(s)

    # See:
    # https://beta.atcoder.jp/contests/abc097/submissions/2497319
    for i in range(1, min(k, s_len) + 1):
        for j in range(s_len - i + 1):
            extracted.add(s[j:i + j])

    print(sorted(extracted)[k - 1])


Measured memory_bytes: 4552
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, x;
    cin >> n >> x;
    int st = 0;
    int ans = 1;
    for(int i = 1; i <= n; ++i)
    {
        int nr;
        cin >> nr;
        st += nr;
        if(st <= x)
            ++ans;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    vi a(n);
    ll sum = 0;
    rep (i, n){
      cin >> a[i];
      sum += a[i];
    }
    sort(all(a));
    sum -= a[0] + a.back();
    cout << sum / (n - 2) << endl;
  }
}



Measured memory_bytes: 3124
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


struct UnionFind {
    vector<ll> par;
        
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    ll find(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    
    bool same(ll x, ll y) {
        return find(x) == find(y);
    }
    
    bool unite(ll x, ll y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    ll size(ll x) {
        return -par[find(x)];
    }

    void print(ll x){
        rep(i,x){
            cout<<par[i]<<endl;
        }
        return ;
    }
};


void solve(){
    ll n,m;
    cin>>n>>m;
    ll a[110],b[110];
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    ll ans=0;
    rep(i,m){
        UnionFind uf(n);
        rep(j,m){
            if(i==j) continue;
            uf.unite(a[j],b[j]);
        }
        if(uf.size(0)!=n) ans++;
    }
    cout<<ans<<endl;
}


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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

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

void solve(ll N, string S) {
  string T{S, 0, S.size() / 2};
  bool pred = S == T + T;
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define v  vector<int>
#define pb  push_back

int a,b,c;

int main()
{
    cin>>c>>b>>a;
    cout<<abs(a-b)+abs(b-c)+abs(a-c)-max(max(abs(a-b),abs(b-c)),abs(a-c));
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
struct Magic {
	int damage, mp;
};
int main() {
	int health, n; std::cin >> health >> n;
	std::vector<Magic> magic(n); for (auto& m : magic) std::cin >> m.damage >> m.mp;
	std::vector<long long int> min_mp(health + 1, LLONG_MAX); min_mp[0] = 0;
	for (const auto m : magic) {
		for (auto h = 0; h <= health; ++h) {
			if (min_mp[h] != LLONG_MAX) {
				if (h + m.damage <= health) {
					min_mp[h + m.damage] = std::min(min_mp[h + m.damage], min_mp[h] + m.mp);
				}
				else {
					min_mp.back() = std::min(min_mp.back(), min_mp[h] + m.mp);
				}
			}
		}
	}
	std::cout << min_mp.back() << std::endl;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Main
{
    public static class Program
    {
        static void Main(string[] arg)
        {
            double r = int.Parse(Console.ReadLine());
            //var array = GetIntList(Console.ReadLine());
            double answer = 0;

            answer = Math.Pow(r,2) * 3;

            Console.WriteLine(answer);
            Console.ReadLine();
 
        }
        
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();
 
        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();
 
        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static bool IsOdd(int i)
        {
            return i % 2 == 1 ? true : false;
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=924844033,N=1e5;
int limn,fac[N],f[2][2][N],cnt[2][2],n,K,rev[N],w[N],ifac[N],g[N];
int qpower(int a,int b){int ans=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)ans=1ll*ans*a%mod;return ans;}
void prework(int n)
{
    fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpower(fac[n],mod-2);for(int i=n-1;i>=0;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
    limn=1;while(limn<=n)limn<<=1;
    for(int i=1;i<limn;i++)rev[i]=(rev[i>>1]>>1)|((i&1)?(limn>>1):0);
    for(int i=1;i<limn;i<<=1)
    {
        int omg=qpower(5,(mod-1)/(i<<1));
        w[i]=1;
        for(int j=1;j<i;j++)w[i+j]=1ll*w[i+j-1]*omg%mod;
    }
}
int C(int n,int m){if(n<m)return 0;return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
void NTT(int a[])
{
    for(int i=0;i<limn;i++)
        if(i<rev[i])swap(a[i],a[rev[i]]);
    for(int i=1;i<limn;i<<=1)
        for(int j=0;j<limn;j+=i<<1)
            for(int k=0;k<i;k++)
            {
                int x=1ll*w[i+k]*a[i+j+k]%mod;
                a[i+j+k]=(a[j+k]-x)%mod,a[j+k]=(a[j+k]+x)%mod;
            }
}
int main()
{
    scanf("%d%d",&n,&K);prework(n);f[0][0][0]=f[0][1][0]=f[1][0][0]=f[1][1][0]=1;
    for(int i=1;i<=K;i++)
    {
        int len=0,t=0;
        for(int j=i;j<=n;j+=2*K)
        {
            len++;++t;
            if(j+K<=n)++t;
        }
        if(!cnt[len&1][t&1])
        {
            for(int j=1;j<=len;j++)f[len&1][t&1][j]=C(t-j,j);
        }
        ++cnt[len&1][t&1];
        len=0,t=0;
        for(int j=i;j<=n;j+=2*K)
        {
            ++t;if(j+K<=n)++len,++t;
        }
        if(!cnt[len&1][t&1])
        {
            for(int j=1;j<=len;j++)f[len&1][t&1][j]=C(t-j,j);
        }
        ++cnt[len&1][t&1];
    }
    NTT(f[0][0]),NTT(f[0][1]),NTT(f[1][0]),NTT(f[1][1]);
    for(int i=0;i<limn;i++)g[i]=1ll*qpower(f[0][0][i],cnt[0][0])*qpower(f[0][1][i],cnt[0][1])%mod*qpower(f[1][0][i],cnt[1][0])%mod*qpower(f[1][1][i],cnt[1][1])%mod;
    reverse(g+1,g+limn);NTT(g);
    int iv=mod-(mod-1)/limn;for(int i=0;i<=n;i++)g[i]=1ll*g[i]*iv%mod;
    int ans=0;
    for(int i=0;i<=n;i++)ans=(ans+1ll*fac[n-i]*((i&1)?-1:1)*g[i])%mod;
    cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    string s, t;
    cin >> s >> t;
    int ans = 1010;
    for (i = 0; i + t.size() <= s.size(); i++) {
        int cnt = 0;
        for (j = 0; j < t.size(); j++) {
            cnt += (s[i+j] != t[j]);
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
from sys import stdin


def main():
    N, x = [int(x) for x in stdin.readline().rstrip().split()]
    a = [int(x) for x in stdin.readline().rstrip().split()]
    aa = sorted(a)
    xx = x
    count = 0
    for i in aa:
        if i <= xx:
            xx -= i
            count += 1
        else:
            xx = 0
            break
    if xx != 0:
        count -= 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n=gets.to_i
s=gets.chomp

count=0
0.upto(9) do |i|
    0.upto(9) do |j|
        0.upto(9) do |k|
            a=0
            b=0
            a=s.index(i.to_s)
            break if a.nil?
            b=s.index(j.to_s,a+1)
            break if b.nil?
            if s.index(k.to_s,b+1)
                count+=1
            end
        end
    end
end

puts count


Measured memory_bytes: 14272
#include<iostream>
int main(){
  int n;
  std::cin>>n;
  n%=10;
  switch(n){
    case 3:
      std::cout<<"bon"<<std::endl;
      return 0;
    case 0:
    case 1:
    case 6:
    case 8:
      std::cout<<"pon"<<std::endl;
      return 0;
    default:
      std::cout<<"hon"<<std::endl;
      return 0;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
    int  card[4][13];
    int i,j;
    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            card[i][j] = 0;
        }
    }

    int n;
    scanf("%d", &n);
    int  k;
    char mark,
         ch;
    int  num;
    for (k = 0; k < n; k++) {
        scanf("%c", &ch);
        scanf("%c %d", &mark, &num);
        switch (mark) {
            case 'S':
                card[0][num - 1] = 1;
                break;
            case 'H':
                card[1][num - 1] = 1;
                break;
            case 'C':
                card[2][num - 1] = 1;
                break;
            case 'D':
                card[3][num - 1] = 1;
                break;
            default:
                break;
        }
    }

    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            if (card[i][j] == 0) {
                switch (i) {
                    case 0:
                        printf("%c ", 'S');
                        break;
                    case 1:
                        printf("%c ", 'H');
                        break;
                    case 2:
                        printf("%c ", 'C');
                        break;
                    case 3:
                        printf("%c ", 'D');
                        break;
                    default:
                        break;
                }
                printf("%d", j + 1);
                printf("\n");
            }
        }
    }

    return(0);
}



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

const int N = 100005;

using namespace std;

string s;
int n, l[N], r[N], x[N], root[N], summ[N], sz[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if (s.size() == 1)
    {
        cout << "YES";
        return 0;
    }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }
    if (s.size() % 2 == 1)
    {
        int pos = s.size() / 2;
        for (int i = 0; i < n; i++)
        {
            if (l[i] == pos && r[i] == pos)
            {
                n--;
                swap(l[i], l[n]);
                swap(r[i], r[n]);
                i--;
                continue;
            }
            if (l[i] > pos) l[i]--;
            if (r[i] >= pos) r[i]--;
        }
        string t = "";
        for (int i = 0; i < s.size(); i++) if (i != pos) t += s[i];
        s = t;
    }
    int len = s.size() / 2;
    for (int i = 0; i < n; i++)
    {
        if (l[i] < len && r[i] >= len)
        {
            int p1 = len - l[i], p2 = r[i] - len + 1;
            if (p1 == p2) l[i] = -1, r[i] = -1;
            if (p1 < p2)
            {
                l[i] += 2 * p1;
            }
            if (p1 > p2)
            {
                r[i] -= 2 * p2;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (l[i] >= len)
        {
            int rr = s.size() - 1 - l[i];
            int ll = s.size() - 1 - r[i];
            l[i] = ll, r[i] = rr;
        }
    }
    for (int i = 0; i < len; i++)
    {
        x[i + 1] = (s[s.size() - 1 - i] + 26 - s[i]) % 26;
    }
    for (int i = len + 1; i > 0; i--)
    {
        x[i] = (x[i] - x[i - 1] + 26) % 26;
    }
    for (int i = 0; i < n; i++)
    {
        l[i]++, r[i]++, r[i]++;
    }
    iota(root, root + len + 2, 0);
    fill(sz, sz + len + 2, 1);
    for (int i = 0; i < n; i++)
    {
        int a = l[i], b = r[i];
        while (a != root[a]) a = root[a];
        while (b != root[b]) b = root[b];
        if (a == b) continue;
        if (sz[a] < sz[b])
        {
            sz[b] += sz[a];
            root[a] = b;
        }
        else
        {
            sz[a] += sz[b];
            root[b] = a;
        }
    }
    for (int i = 1; i < len + 2; i++)
    {
        int j = i;
        while (j != root[j]) j = root[j];
        summ[j] += x[i];
    }
    int t = -1;
    for (int i = 0; i < len + 2; i++)
    {
        if (summ[i] % 26 != 0)
        {
            if (t == -1) t = i;
            else cout << "NO", exit(0);
        }
    }
    if (t == -1) cout << "YES", exit(0);
    cout << "YES";
}


Measured memory_bytes: 2128
n,k,*l=map(int,open(0).read().split())
s=sum(l)
L=[]
for i in range(1,30000):L+=[i,s//i]*(s%i<1)
t=1
for d in L:a=sorted([m%d for m in l]);t=max(t,d*(sum(a[:-sum(a)//d])<=k))
print(t)

Measured memory_bytes: 3064
while 1:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break;
    else:
        if m==-1 or f==-1:
            print("F")
        elif m+f>=80:
            print("A")
        elif 65<=m+f<80:
            print("B")
        elif 50<=m+f<65:
            print("C")
        elif 30<=m+f<50:
            if r>=50:
                print("C")
            else:
                print("D")
        else:
           print("F")


Measured memory_bytes: 5596
//I am so vegetable
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2e3;
const int MOD = 998244353;
const double exps = 1e-6;
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	FIO;
	string s;
	int q, t, f;
	char ch;
	bool flag = 0;
	vector<char>b, e;
	cin >> s >> q;
	while (q--) {
		cin >> t;
		if (t == 1)flag = !flag;
		if (t == 2) {
			cin >> f >> ch;
			if (flag) {
				if (f == 1)e.push_back(ch);
				else b.push_back(ch);
			}
			else {
				if (f == 1)b.push_back(ch);
				else e.push_back(ch);
			}
		}
	}
	if (flag) {
		for (int i = e.size() - 1; i >= 0; --i)cout << e[i];
		reverse(s.begin(), s.end());
		cout << s;
		_for(i, 0, b.size())cout << b[i];
	}
	else {
		for (int i = b.size() - 1; i >= 0; --i)cout << b[i];
		cout << s;
		_for(i, 0, e.size())cout << e[i];
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vec vector

typedef long long ll;

const ll inf = 1LL << 60;
const int mod = 1e9 + 7;

using namespace std;

/* Input variables. */
int n;
vec<ll> a;

/* Solve! */
void solve() {
  ll sum = 0;
  int negcnt = 0;
  rep(i, n) {
    if (a[i] < 0) negcnt++;
    sum += a[i] = abs(a[i]);
  }
  if (negcnt % 2 == 1) sum -= *min_element(a.begin(), a.end()) * 2;
  cout << sum << endl;
}

int main() {
  /* Input handling. */
  cin >> n;
  a = vec<ll>(n);
  rep(i, n) cin >> a[i];

  solve();
  return 0;
}

Measured memory_bytes: 1024
// D.

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	cout.precision(10);
	int n, elapsed = 0, speed = 0, x;
	double ans = 0;
	cin >> n;
	vector<int> t(n), v(n);
	for (int i = 0; i < n; ++i) {
		cin >> x;
		elapsed += x;
		t[i] = elapsed;
	}
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	t.push_back(t.back());
	v.push_back(0);
	elapsed = 0;
	for (int i = 0; i <= n; ++i) {
		for (; elapsed < t[i]; ++elapsed) {
			int next = min(speed + 1, v[i]);
			for (int k = i + 1; k <= n; ++k) {
				next = min(next, v[k] + t[k - 1] - elapsed - 1);
			}
			if (speed == next && speed < v[i]) {
				ans += speed + 0.25;
			} else {
				ans += (double)speed + 0.5 * (next - speed) * 0.5 * 0.5;
			}
			speed = next;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int x;
    cin >>x;
    if(x<1200) cout << "ABC"<<endl;
    else cout << "ARC"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n,k;
  cin >> n >> k;
  mint c[k];
  drep(i,k){
    int t = i+1;
    c[i]=mint(k/t).pow(n);
    while(t+i+1<=k){
      t += i+1;
      c[i] -= c[t-1];
    }
  }
  mint ans = 0;
  //rep(i,n)cout << c[i] << endl;
  rep(i,k)ans += c[i]*(i+1);
  cout << ans << endl;
}

Measured memory_bytes: 3944
#include<stdio.h>

int main(){
  int n,i,dp[45];
  scanf("%d",&n);
  dp[0]=1;dp[1]=1;
  for(i=2;i<=45;i++)dp[i]=dp[i-1]+dp[i-2];
  printf("%d\n",dp[n]);

  return 0;
}



Measured memory_bytes: 2100
i,a[10],b[10],h,g,c,x;
main(n)
{ 
  for(scanf("%d",&n);n--;puts(x?"NO":"YES"))
    {
      for(a[0]=b[0]=h=g=i=x=0;i++<10;)
	{
	  scanf("%d",&c);
	  if(x!=0)continue;
	  if(a[h]<c||b[g]<c)
	    if(a[h]<c&&(a[h]>b[g]||b[g]>=c))
	      a[++h]=c;
	    else
	      b[++g]=c;
	  else x=-1;
	}
    }
}

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

vector<int> sieve(int n);

vector<int> sieve(int n){
    vector<int> primes(n);
    for(int i=2; i<n; i++){
        primes[i] = i;
    }
    for(int i=2; i*i<n; i++){
        if(primes[i]){
            for(int j=i*i; j<n; j+=i){
                primes[j] = 0;
            }
        }
    }
    return primes;
}

int main(){
    vector<int> primes = sieve(50022);
    int n;
    while(cin >> n){
       int lower = n-1;
       int upper = n+1;
       while(primes[lower] == 0) lower--;
       while(primes[upper] == 0) upper++;
       cout << primes[lower] << " " << primes[upper] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#82c
import collections

N = int(input())
A_list = [int(e) for e in input().split()]
counted = collections.Counter(A_list)

ans =0

for number,count in counted.items():
    if number != count:
        if number < count:
            ans += count - number
        elif number > count:
            ans += count
            
print(ans)

Measured memory_bytes: 18676