akhauriyash/Code-Regression huggingface dataset:
import java.util.*

object MainKt {
	val mod = 1000000007

	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val l = scanner.next()
		val cs = l.toCharArray()
		var ans: Long = 0
		var mul=0
		for (i in 0..cs.size-1){
			if (i!=cs.size-1){
				if (cs[i]=='1'){
					ans = (ans+(pow(2, mul)*pow(3, cs.size-1-i)))%mod
					mul++
				}
			}else{
				ans = (ans+pow(2, mul)*( if(cs[i]=='0') 1 else 3 ))%mod
			}
		}
		println(ans)
	}

	fun pow(base: Int, exp: Int): Long{
		var e = exp
		var p= base.toLong()
		var ans: Long = 1
		while(e>0){
			if (e%2==1){
				ans = (ans*p)%mod
			}
			p = (p*p)%mod
			e/=2
		}
		return ans
	}

}

Measured memory_bytes: 32432
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
ll fac[55], ifac[55];
//tot c+ c-
int dp[55][55][55];
bool check(int a, int b, int c, int d)
{
	if (c<d) return d-c<=b;
	else return c-d<=a;
}
void upd(int &x, ll v)
{
	x = (x+v)%mod;
}
int main()
{
	fac[0] = 1;
	for (int i=1; i<=50; i++) fac[i] = fac[i-1]*i%mod;
	for (int i=0; i<=50; i++) ifac[i] = qpow(fac[i], mod-2);
	cin>>n;
	dp[1][0][0] = 1;
	dp[1][1][0] = 1;
	for (int i=1; i<n; i++)
	{
		for (int cp=0; cp<=i; cp++)
		{
			for (int cn=0; cn+cp<=i; cn++)
			{
				if (cp>0&&cn>0) continue;
				int &cur = dp[i][cp][cn];
				for (int ex=0; cp+cn+ex+ex+i<=n; ex++)
				{
					if (cp==0&&cn==0&&ex==0) continue;
					for (int x=0; x<=cp+ex; x++)
					{
						for (int y=0; y<=cn+ex; y++)
						{
							upd(dp[i+cp+cn+ex+ex][x][y], 1ll*cur*ifac[cp+ex-x+y]%mod*ifac[cn+ex-y+x]%mod);
						}
					}
				}
			}
		}
	}
	ll ans = dp[n][0][0];
	cout<<1ll*ans*fac[n]%mod<<endl;
	return 0;
}


Measured memory_bytes: 640
from collections import OrderedDict
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
#初期データ、構造
N,Q = (int(x) for x in input().split())
connection ={i:set() for i in range(1,N+1)}
for i in range(N-1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)
#point =OrderedDict({i:0 for i in range(1,N+1)})
point ={i:0 for i in range(1,N+1)}
for i in range(Q):
    p,x = (int(x) for x in input().split())
    point[p] +=x

def DFS(now,prev = -1):
    for next in connection[now]:
        if next == prev:
            continue
        point[next] +=point[now] 
        DFS(next,now)

DFS(1)
print(*point.values())


Measured memory_bytes: 350484
#include <cstdio>
#include <algorithm>
#include <cstring>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i != -1; i = edge[i].next)
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 524288;

int x[N], ll[20][N], rr[20][N], f[N], g[N], sg[N];

bool vv[N];

int main()
{
	//freopen("snake7.in", "r", stdin);
	//freopen("s.out", "w", stdout);
	
	int n, v;
	scanf("%d%d", &n, &v);
	Rep(i, n) scanf("%d", &x[i]);
	
	int k = 0;
	while (true) {
		rr[k][n + 1] = rr[k][n] = n;
		for (int i = n - 1; i; i --) {
			if (x[i] + v >= x[i + 1]) rr[k][i] = rr[k][i + 1];
			else rr[k][i] = i;
		}
		ll[k][0] = ll[k][1] = 1;
		for (int i = 2; i <= n; i ++) {
			if (x[i - 1] + v >= x[i]) ll[k][i] = ll[k][i - 1];
			else ll[k][i] = i;
		}
		k ++;
		if (!v) break;
		v /= 2;
	}
	
	Rep0(s, (1 << k) - 1) f[s] = 0;
	Rep0(s, (1 << k) - 1) g[s] = n + 1;
	
	Rep0(s, (1 << k) - 1){
		//printf("%d %d %d\n", s, f[s], g[s]);
		Rep0(i, k - 1) if (!(s & (1 << i))) {	
			f[s ^ (1 << i)] = max(f[s ^ (1 << i)], rr[i][f[s] + 1]);
			g[s ^ (1 << i)] = min(g[s ^ (1 << i)], ll[i][g[s] - 1]);
		}
	}
	
	Rep0(s, (1 << k) - 1) {
		sg[s] = g[s];
		Rep0(i, k - 1) if (s & (1 << i)) sg[s] = min(sg[s], sg[s ^ (1 << i)]);
	}
	bool flag = false;
	Rep0(s, (1 << k) - 1) if (!(s & 1)) {
		int ss = (((1 << k) - 1) ^ 1) ^ s;
		//printf("%d %d %d %d\n", s, ss, f[s], sg[ss]);
		if (sg[ss] <= f[s] + 1){ flag = true; break;}
		else if (ll[0][f[s] + 1] == ll[0][sg[ss] - 1]){ vv[ll[0][f[s] + 1]] = true; }
	}
	
	if (flag) Rep(i, n) printf("Possible\n");
	else Rep(i, n){
		if (vv[ll[0][i]]) printf("Possible\n");
		else printf("Impossible\n");
	}
	
	return 0;
}


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

using namespace std ;

char s[ 100010 ] ;

int main() {
	scanf( "%s" , s + 1 ) ;
	int n = strlen( s + 1 ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		if( s[ i ] == s[ i + 2 ] ) {
			printf( "%d %d\n" , i , i + 2 ) ;
			return 0 ;
		}
		if( s[ i ] == s[ i + 1 ] ) {
			printf( "%d %d\n" , i , i + 1 ) ;
			return 0 ;
		}
	}
	puts( "-1 -1" ) ;
	return 0 ;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }
                         
int main() {
    SS(int,n);
    int x[8],y[8];
    rep(i,n)cin>>x[i]>>y[i];

    vector<int> ord(n);
    rep(i, n) ord[i] = i;

    int kai=1;

    rep(i,n){
        kai*=i+1;
    }
    double res=0;
    do {
        rep(i, n) {
            if(i == 0) continue;
            res += sqrt((x[ord[i-1]] - x[ord[i]])*(x[ord[i - 1]] - x[ord[i]]) + (y[ord[i - 1]] - y[ord[i]])*(y[ord[i - 1]] - y[ord[i]]));
        }
    }
    while(next_permutation(ord.begin(), ord.end()));
    p(res/kai);
}

Measured memory_bytes: 256
MOD = 10**9+7
MAX = 1000010
finv = [0] * MAX
inv = [0] * MAX
def COMinit():
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD
def COM(n, k):
    res = 1
    for i in range(k):
        res = res * (n-i) % MOD
    return res * finv[k] % MOD

x, y = map(int, input().split())
if (x+y)%3 != 0:
    ans = 0
else:
    s, t = (-x+2*y)//3, (2*x-y)//3
    if s < 0 or t < 0:
        ans = 0
    else:
        COMinit()
        ans = COM((s+t), s)

print(ans)

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


int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    if(A.size()==n+1){
        int now=0;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]){
                now+=d[i];
            }
        }
        ans=max(now,ans);
        return;
    }

    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
    return;
}

int main() {
    cin>>n>>m>>q;
    a=b=c=d=vector<int> (q);
    ans=0;
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(vector<int> (1,1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

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

        int n = sc.nextInt();
        int d = sc.nextInt();
        int[][] x = new int[n][d];
        int count = 0;
        int total = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                x[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = 1 + i; j < n; j++) {
                for (int k = 0; k < d; k++) {
                    total += Math.abs((x[i][k] - x[j][k]) * (x[i][k] - x[j][k]));
                }
                double distance = Math.sqrt(total);
                if (distance == (int) distance) {
                    count++;
                }
                total = 0;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*
願はくは花の下にて春死なんそのきさらぎの望月のころ（西行 1118-1190）
--This is old Japanese poem expressing the desire to die under tree on the full moon night.(written by Saigyo)
In my research, there is possibility that the tree may be seg-tree.
*/

/*Coding Space*/
set<string> cnt;
int main(){
  string s; cin >> s;
  int k; cin >> k;
  rep(i,s.size()){
    for(int j = 1; j + i <= (int)s.size() && j <= 5; j++)
      cnt.insert(s.substr(i,j));
  }
  auto itr = cnt.begin();
  rep(i,k-1)  itr++;
  cout << *itr << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
string a;
  cin >> a;
  bool ax=false,ay=true;
  int count=0,xy;
  if (a[0]=='A')ax=true;
  for (int i=2;i<a.size()-1;i++){
  	if (a[i]=='C') {count++;
                   xy=i;
                   }
  }
  for (int i=1;i<a.size();i++){
  	if (i!=xy && !(a[i]>='a' && a[i]<='z')) ay=false;
  }
  if (ax&&ay&&count==1)cout << "AC" <<endl;
  else cout <<"WA"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long int N,i,fillness = 0,latestEat = 999;
    cin >> N;
    int A[N],B[N],C[N-1];
    for(i = 0; i < N; i++){
        cin >> A[i];
    }
    for(i = 0; i < N; i++){
        cin >> B[i];
    }
    for(i = 0; i < N - 1; i++){
        cin >> C[i];
    }
   
    for(i = 0; i < N; i ++){
        fillness += B[A[i] - 1];
        if(latestEat + 1 == A[i]){
            fillness += C[latestEat - 1];
        }
        latestEat = A[i];
    }
    cout << fillness << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
int main(int argc,char** argv){ fastio; myio;
  map<ll,int> m;
  int n;
  cin>>n;
  rep(i,n){
    ll a;
    cin>>a;
    if(m[a]) m[a]=0;
    else m[a]=1;
  }
  int ans = 0;
  for(auto i:m){
    ans+=i.se;
  }
  cout<<ans;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<int> a(n);
    int ans = 0;
    rep(i,n) {
        cin >> a[i];
        ans+=(a[i]-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
int x, y;
signed main() {
	cin >> x >> y;
	for (int i = 0; i <= x; i++) {
		if (2 * i + 4 * (x - i) == y) {
			puts("Yes");
			ggr
		}
	}
	puts("No");
	ggr
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    vll A(5);
    rep(i,5) cin >> A[i];
    rep(i,5) if(A[i] == 0)cout << i+1 << endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3624
import sys
from fractions import gcd

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    N, M, *A = map(int, read().split())
    A = list({a // 2 for a in A})

    power = 1
    while all(a % 2 == 0 for a in A):
        A = [a // 2 for a in A]
        power *= 2

    if any(a % 2 == 0 for a in A):
        print(0)
        return

    l = 1
    for a in A:
        l = lcm(l, a)

    l *= power
    ans = (M + l) // (2 * l)
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 16108
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < 3; i++) {
        string s;
        cin >> s;
        cout << (char)('A' + (s[0] - 'a'));
    }
    cout << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
/*与えられた期間の間のうるう年をすべて出力*/
void leap_year(int year1, int year2);

int main(void)
{
    while (1){
        int a, b; /*a は year1　, b は year2*/
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0){
            break;
        }else {
            leap_year(a, b);
        }
    }
    return 0;
}

void leap_year(int year1, int year2)
{   
    static int c = 0;/*二回目のデータ以降空行を開けるようにする*/
    ++c;
    if (c != 1){
        printf("\n");
    }
    int limit = 0; /*もしも、うるう年がなかった時に使う*/
    for (int i = year1; i <= year2; ++i){ /*i は年を表す*/     
        if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){
            printf("%d\n", i);
        }else{
            ++limit;
        }
    }
    if (limit == (year2 - year1 + 1)){/*うるう年がない場合*/
        printf("NA\n");
    }
} 

Measured memory_bytes: 1044
#include <iostream>
#include <vector>
const int Maxn=1e5+5;
#define rep(i,n) for (int i=0;i<n;++i)
#define int long long
int n,mx;
std::vector <int> v[Maxn];
int dp[Maxn];
void dfs(int k,int p=-1)
{
	int s=0,ss=0;
	std::vector <int> t;
	for (auto &x:v[k])
	{
		if (x==p) continue;
		ss++;
		t.push_back(x);
		dfs(x,k);
		if (dp[x]) s++;
		dp[k]+=dp[x];
	}
	dp[k]+=std::max(ss-s-1,0ll);
}
signed main()
{
	std::cin>>n;
	for (int i=1;i<n;++i)
	{
		int x,y;
		std::cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	rep(i,n) if (v[i].size()>v[mx].size()) mx=i;
	dfs(mx);
	std::cout<<std::max(1ll,dp[mx])<<std::endl;
	return 0;
}


Measured memory_bytes: 18816
N = int(input())

R = []
for i in range(N):
  x, l = map(int, input().split(" "))
  R.append([x-l, x+l])
R.sort(key=lambda x: x[1])
ans = 1
length = R[0][1]
for r in R:
  if length <= r[0]:
    ans += 1
    length = r[1]

print(ans)

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

//int main(void)
//{
//    long long a;
//    cin >> a;
//    if(a%2 == 0)
//        cout << a << endl;
//    else
//        cout << a*2 <<endl;
//    return 0;
//}
int main(void)
{
    int maxa = 0;
    int mina = 1000000008;
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        if(x > maxa)
            maxa = x;
        if(x < mina)
            mina = x;
    }
    cout << maxa - mina << endl;
    return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		200000									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最大公約数 - 取得
int
fGetGcd(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	int liWork;

	// ユークリッドの互除法
	if (piVal1 < piVal2) {
		liWork = piVal1;
		piVal1 = piVal2;
		piVal2 = liWork;
	}
	while (piVal2 > 0) {
		liWork = piVal1 % piVal2;
		piVal1 = piVal2;
		piVal2 = liWork;
	}

	return piVal1;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fscanf(szpFpI, "%d", &si1Array[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 最大公約数 - 取得
	int liGcd = si1Array[0];
	for (i = 1; i < siACnt; i++) {
		liGcd = fGetGcd(liGcd, si1Array[i]);
	}

	return liGcd;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;

const LL M = 1e9 + 7;

LL powmod(LL x, int n) {
	LL r = 1;
	while (n) {
		if (n & 1) r = r * x % M;
		n >>= 1;   x = x * x % M;
	}
	return r;
}

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	std::cin >> n;
	LL r = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n);
	r %= M;
	if (r < 0) r += M;
	print(r);
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
D=dict()
for i in range(n):
	s= input()
	s=sorted(s)
	S=''.join(s)
	if S in D:
		D[S]+=1
	else:
		D[S]=1

cnt=0
for s in D:
	cnt+=D[s]*(D[s]-1)//2
print(cnt)

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

int main() {
	int h, w;
	cin >> h >> w;
	while (h != 0) {
		int i, j;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
					cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 1000000007


int n;
vector<pair<int, int>> v;
int dp[10001];
int fun(int h){
    if(h<=0)
        return 0;
        if(dp[h]!=-1)
            return dp[h];
    int ans = 1e9;
    fo(i,n){
        ans = min(ans, fun(h - v[i].first) + v[i].second);
    }
    return dp[h] = ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int h;
    cin >> h >> n;
    memset(dp, -1, sizeof(dp));
    v.resize(n);
    fo(i,n){
        int x, y;
        cin >> x >> y;
        v[i] = {x, y};
    }
    cout << fun(h);
}
  

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,H;cin>>N>>H;
    vector<pair<int,int>> Katana(N);
    int MaxA=0;
    REP(i,N){
        cin>>Katana[i].second>>Katana[i].first;
        MaxA=max(MaxA,Katana[i].second);
    }
    sort(rAll(Katana));
    int ans=0;
    REP(i,N) if(Katana[i].first>=MaxA){
        ans++;
        H-=Katana[i].first;
        if(H<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    ans+=(H-1)/MaxA+1;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    char s;
    ll ans = 0;
    rep(i, 4){
        cin >> s;
        if(s == '+'){
            ans++;
        }else{
            ans--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		int r=Integer.parseInt(scan.next());
    		int g=Integer.parseInt(scan.next());

    	
    		System.out.print(g+(g-r));
    		
    	
  
    				
 
     
    }
    }
// end 

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (int i = 0; i <= N - 3; i++) {
		string t = S.substr(i, 3);
		if (t == "ABC") ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>


int main() {
    long a, b, c, x, y;

    std::cin >> a >> b >> c >> x >> y;

    long maxI = std::max(x, y);
    long minPrice = NULL;

    for (long i = 0; i < maxI+1; ++i) {
        long price = i*2*c + std::max((long)0, x-i) *a + std::max((long)0, y-i)*b;

        minPrice = minPrice == NULL or minPrice > price ? price : minPrice;
    }

    std::cout << minPrice << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
    string x;cin>>x;
    x[0]++;
    cout<<x[0]<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &slice[i])
	}

	num := slice[0]
	min := 2
	cnt := 0

	for (num % min) == 0 {
		min *= 2
		cnt++
	}

	min /= 2

	for _, num := range slice[1:] {
		for (num % min) != 0 {
			min /= 2
			cnt--
		}
	}
	fmt.Println(cnt)
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll K;
    cin >> K;
    string S;
    cin >> S;
    if (S.size() <= K) {
        cout << S << '\n';
    }else {
        rep(i, K) {
            cout << S[i];
        }
        cout << "..." << '\n';
    }
}

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


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

map<char,int> m1;
int32_t main(){
	int n;
	cin>>n;
	set<char> se;
	se.insert({'M','A','R','C','H'});
	string s;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(se.count(s[0])){
			m1[s[0]]++;
		}
	}
	int m=m1['M'];
	int a=m1['A'];
	int r=m1['R'];
	int c=m1['C'];
	int h=m1['H'];
	int ans=0;
	ans += m*a*r;
	ans += m*a*c;
	ans += m*a*h;
	ans += m*r*c;
	ans += m*r*h;
	ans += m*c*h;
	ans += a*r*c;
	ans += a*r*h;
	ans += a*c*h;
	ans += r*c*h;
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int h, w;
  cin >> h >> w;
  char c[100][100];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < w+2; i++) cout << "#";
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << "#";
    for (int j = 0; j < w; j++) cout << c[i][j];
    cout << "#" << endl;
  }
  for (int i = 0; i < w+2; i++) cout << "#";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
 
int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    vector<vector<int>> bk(n,vector<int>(m+1));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m+1; j++)
        {
            cin >> bk[i][j];
        }
        
    }
    int min = 1e9;
    for (int i = 0; i < pow(2,n); i++)
    {
        int bit = 0;
        vector<int> A(m+1);
        for (int bit = 0; bit < n; bit++)
        {
            if (i&(1<<bit))
            {
                for (int k = 0; k < m+1; k++)
                {
                    A[k] += bk[bit][k];
                }
                
            }
        }
        int cnt = 0;
        for (int i = 1; i < m+1; i++)
        {
            if (A[i] >= x)
            {
                cnt++;
            }
            
        }
        if (cnt == m && min > A[0])
        {
            min = A[0];
        }
        
    }
    if (min == 1e9)
    {
        cout << "-1" << endl;
    }else{
        cout << min << endl;
    }
    
}

Measured memory_bytes: 3980
#include <iostream>
using namespace std;
inline int selectionSort(int a[], int n) {
	int sw = 0;
	for (int i = 0; i < n - 1; i++) {
		int minj = i;
		for (int j = i +1; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(a[i], a[minj]);
			sw++;
		}
	}
	return sw;
}
int main() {
	const int n = 100000;
	int ar[n];
	int num;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> ar[i];
	}
	int sum = selectionSort(ar, num);
	cout << ar[0];
	for (int i = 1; i < num; i++) {
		cout << ' ' << ar[i];
	}
	cout << endl << sum << endl;
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main(void) {
	int N;
	scanf("%d",&N);
	int a[100000];
	
	// input array
	for (int i=0; i<N; i++) {
		scanf("%d",&a[i]);
	}
	
	//check friends
	int pairs=0;
	for (int i=0; i<N;i++) {
		if (a[a[i]-1]==i+1) {
			pairs++;
		}
	}
	pairs=pairs/2; // Counted each pair twice
	printf("%d",pairs);
	return 0;
}


Measured memory_bytes: 512
# coding: utf-8

# https://atcoder.jp/contests/abc088/tasks/abc088_d
# 19:01-20:04 chudan
# 20:17-20:53 done


def main():
    H, W = map(int, input().split())

    INF = 10**10
    n_white = 0
    s = [[-1] * (W+2) for _ in range(H+2)]
    for i in range(H):
        for j, x in enumerate(input()):
            # white => 1, black => -1
            s[i+1][j+1] = INF if x == "." else -1
            n_white += 1 if x == "." else 0
    s[1][1] = 0

    queue = [(1, 1)]
    queue_size = 1
    queue_idx = 0
    while True:
        # 最短から貪欲に伸ばして行く
        if queue_idx == queue_size:
            # cannot arrive
            return -1
        
        x, y = queue[queue_idx]
        queue_idx += 1
        
        if x == H and y == W:
            shortest = s[x][y]
            break

        if s[x][y-1] != -1 and s[x][y-1] > s[x][y]+1:
            s[x][y-1] = s[x][y]+1
            queue.append((x, y-1))
            queue_size += 1
        if s[x][y+1] != -1 and s[x][y+1] > s[x][y]+1:
            s[x][y+1] = s[x][y]+1
            queue.append((x, y+1))
            queue_size += 1
        if s[x-1][y] != -1 and s[x-1][y] > s[x][y]+1:
            s[x-1][y] = s[x][y]+1
            queue.append((x-1, y))
            queue_size += 1
        if s[x+1][y] != -1 and s[x+1][y] > s[x][y]+1:
            s[x+1][y] = s[x][y]+1
            queue.append((x+1, y))
            queue_size += 1
    
    return n_white - (shortest + 1)


print(main())


Measured memory_bytes: 3188
// 動的計画法

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

// コイン両替問題：
//     額面が d1, ..., dm のコインで n 支払う
//     各コインの使用枚数は無制限
int coin_changing(vector<int> coin, const int sum) {
    static const int INF = 1000000000;
    sort(coin.begin(), coin.end());
    vector<int> dp(sum + 1, INF);
    dp[0] = 0;
    for(const auto& d: coin)
        for(int s = d; s <= sum; ++s)
//      for(int s = n; s - d >= 0; --s) // 1 枚制限
            dp[sum] = min(dp[s], dp[sum - d] + 1);
    return dp[sum];
}

// ナップサック問題
struct Goods {int value, weight;};
int knapsack(const vector<Goods>& goods, const int capacity) {
    vector<int> dp(capacity + 1, 0);
    for(const auto& g: goods)
        for(int w = g.weight; w <= capacity; ++w)
//      for(int w = W; w - g.weight >= 0; --w)  // 1 個制限
            dp[w] = max(dp[w], dp[w - g.weight] + g.value);
    return *max_element(dp.begin(), dp.end());
}

// 最長増加部分列：O(n ^ 2)
// int longest_increasing_subsequence(const vector<int>& sequence) {
//     vector<int> dp(sequence.size(), 1);
//     for(int i = 1; i < dp.size(); ++i)
//         for(int j = i - 1; j >= 0; --j)
//             if(sequence[j] < sequence[i]) dp[i] = max(dp[i], dp[j] + 1);
//     return *max_element(dp.begin(), dp.end());
// }
// 最長増加部分列：O(n log n)
//       dp[i]: 長さ i の増加部分列を作ったとき、最後の要素の最小値
//       dp は昇順になるので
int longest_increasing_subsequence(const vector<int>& sequence) {
    vector<int> dp;
    dp.push_back(sequence[0]);
    for(const auto& i: sequence) {
        if(dp.back() < i)   dp.push_back(i);
        else                *lower_bound(dp.begin(), dp.end(), i) = i;
    }
    return dp.size();
}

// 編集距離：O(n * m)
//     挿入・削除・置換の回数
//     dp[i][j]: s1 の前方 i と、s2 の前方 j 文字との間のレーベンシュタイン距離
int Levenshtein_distance(string s1, string s2) {
    static const int INF = 1000000000;
    vector<vector<int>> dp(s1.size() + 1, vector<int>(s2.size() + 1, INF));
    for(int i = 0; i <= s1.size(); ++i) dp[i][0] = i;
    for(int j = 0; j <= s2.size(); ++j) dp[0][j] = j;
    for(int i = 1; i <= s1.size(); ++i) for(int j = 1; j <= s2.size(); ++j) {
        dp[i][j] = min({
            dp[i - 1][j] + 1,
            dp[i][j - 1] + 1,
            dp[i - 1][j - 1] + (s1[i - 1] == s2[j - 1] ? 0 : 1),
        });
    }
    return dp[s1.size()][s2.size()];
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    cout << Levenshtein_distance(s1, s2) << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if (a < b){
    /* code */
    cout << "a < b" << endl;
  }else if(a > b){
    cout << "a > b" << endl;
  }else{
    cout << "a == b" << endl;
  }
}


Measured memory_bytes: 3084
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	sort.Ints(a)

	m := (n + 1) / 2
	x := a[m]
	if n%2 == 0 {
		x -= a[m-1]
	} else {
		x += a[m-1]
	}
	for i := 0; i < m-1; i++ {
		x -= a[i] * 2
	}
	for i := m + 1; i < n; i++ {
		x += a[i] * 2
	}
	if n%2 == 0 {
		fmt.Println(x)
		return
	}

	m = (n - 1) / 2
	y := -a[m] - a[m-1]
	for i := 0; i < m-1; i++ {
		y -= a[i] * 2
	}
	for i := m + 1; i < n; i++ {
		y += a[i] * 2
	}
	fmt.Println(max(x, y))
}


Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        int c = nextInt();
        int k = nextInt();
        int[] t = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = nextInt();
        }
        Arrays.sort(t);
        int res = 0;
        int j = 0;
        for (int i = 0; i < n; i++) {
            if (t[i] > t[j] + k || i >= j + c) {
                res++;
                j = i;
            }
        }
        res++;
        out.println(res);
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 35256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    int A[N];
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    
    int ans = 0;
    bool result = true;
    while (result) {
        for (int i=0; i<N; i++) {
            if (A[i] % 2 == 0) {
                A[i] /= 2;
            } else {
                result = false;
                break;
            }
        }
        if (result) {
            ans += 1;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  char A;
  int a,b,t[50][50],dp[50][50];
  cin>>a>>b;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>A;
      t[i][j]=A-'0';
      dp[i][j]=0;
    }
  }
  for(int i=1;i<b;i++){
    dp[0][i]=t[0][i]+dp[0][i-1];
  }
  for(int i=1;i<a;i++){
    dp[i][0]=t[i][0]+dp[i-1][0];
  }
  for(int i=1;i<a;i++){
    for(int j=1;j<b;j++){
      dp[i][j]=min(dp[i][j-1],dp[i-1][j])+t[i][j];
    }
  }
  /*
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      printf("%4d ",dp[i][j]);
    }
    cout<<endl;
    }*/

  cout<<dp[a-1][b-1]<<endl;
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#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=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> dp(k+1, 0);
    FOR(i, 1, k+1){
        rep(j,n){
            if(i-a[j] >= 0) dp[i] |= !dp[i-a[j]];
        }
    }
    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    string C1[2];
    string C2[2];

    cin >> C1[0];
    cin >> C1[1];

    C2[0] = C1[0];
    C2[1] = C1[1];

    C2[1][2] = C1[0][0];
    C2[1][1] = C1[0][1];
    C2[1][0] = C1[0][2];
    C2[0][2] = C1[1][0];
    C2[0][1] = C1[1][1];
    C2[0][0] = C1[1][2];

    if(C1[0] == C2[0] && C1[1] == C2[1]) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }


    return 0;
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
if 2*x <= a**2*b: #45度以上
    h = 2*x/(a*b)
    tan = b/h
    sita = math.atan(tan)
    print(360*sita/(2*math.pi))
else: #ちょっと傾けたらこぼれる
    tan = (b-(x/a**2))*2/a
    sita = math.atan(tan)
    print(360*sita/(2*math.pi))

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 2e18;

typedef long long ll;

int n, m, a, b;
ll ans = 0;
vector<int> adjList[9];


void dfs(int x, int visited, int k){
    visited |= (1<<x);
    if(k == n){
        bool pos = 1;
        for(int i = 1; i <= n; i++){
            if(!(visited&(1<<i))){
                pos = 0;
            }
        }
        if(pos){
            ans++;
        }
    }
    else{
        for(int i = 0; i < adjList[x].size(); i++){

            if(!(visited&(1<<adjList[x][i]))){
                dfs(adjList[x][i], visited, k+1);
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    while(m--){
        cin >> a >> b;
        adjList[a].pb(b);
        adjList[b].pb(a);
    }
    dfs(1, 0, 1);
    cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		long n = sc.nextLong();
		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum += sc.nextLong() - 1;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 25968
r, c = map(int, input().split())
l = [list(map(int, input().split())) for _  in range(r)]

tmp = [0] * c
for i in range(r):
    print(' '.join(map(str, l[i])) + f' {sum(l[i])}')
    tmp = [a + b for a, b in zip(tmp, l[i])]

print(' '.join(map(str, tmp)) + f' {sum(tmp)}')



Measured memory_bytes: 5712
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;

int main()
{
    fastio;
    long long n,i,j,k;
    cin>>n>>k;
    long long a[n],dp[n];
    memset(dp,63,sizeof(dp));
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<=i+k  && j<n; j++)
        {
            dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792