akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

struct dijkstra {

	ll N;
	vector<vector<edge>> g;
	ll s;

	vector<ll> ans;

	dijkstra(ll N0, ll s, vector<vector<edge>> g0) {//頂点数、始点、グラフ
		N = N0;
		g = g0;

		ans.assign(N + 1, INF);


		priority_queue<pair<ll, ll>> q;//(-キョリ、頂点)

		ans[s] = 0;
		q.push({ 0,s });

		while (!q.empty()) {
			auto x = q.top();
			q.pop();

			ll dis = -x.first;
			ll v = x.second;

			if (dis > ans[v]) { continue; }


			for (edge e : g[v]) {
				ll w = e.to;
				if (dis + e.d < ans[w]) {
					ans[w] = dis + e.d;
					q.push({ -ans[w], w });
				}
			}


		}
	}

	ll d(ll t) {//sからtまでの最短距離を出力
		return ans[t];
	}


};


int main() {

	ll H, W;
	cin >> H >> W;

	vector<vector<edge>> g(10);

	rep(i, 10) {
		rep(j, 10) {
			ll c;
			cin >> c;
			g[j].push_back({0, i,c });
		}
	}

	dijkstra dij(10, 1, g);

	ll ans = 0;

	repn(i, H)repn(j, W) {
		ll a;
		cin >> a;
		if (a >= 0) { ans += dij.d(a); }
	}


	cout << ans;
	

	system("PAUSE");

	

}


Measured memory_bytes: 504
import java.util.*;
import static java.lang.Math.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[M];
		int[] d = new int[M];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int j = 0; j < M; j++) {
			c[j] = sc.nextInt();
			d[j] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			int min = 0, man = 0,minIndex=0;
			for(int j = 0; j < M; j++) {
				man = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				if(man < min || j == 0) {
					min = man;
					minIndex = j;
				}
				man = 0;
			}
			System.out.println(minIndex + 1);
		}
	}

}

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

typedef long long ll;
int n,w;
pair<ll,ll> a[105];
ll dp[100005][105];

int main()
{
    cin>>n>>w;
    for(int i=1;i<=n;i++){
        cin>>a[i].first;
        cin>>a[i].second;
    }
    memset(dp,-1,sizeof(dp));
    dp[w][1]=0;
    if(w>=a[1].first){
    dp[w-a[1].first][1]=a[1].second;
    }
    ll res=0;
    for(int c=1;c<n;c++){
        for(int r=0;r<=w;r++){
            if(dp[r][c]!=-1){
                if(r>=a[c+1].first){
                    dp[r-a[c+1].first][c+1]=max(dp[r-a[c+1].first][c+1],(dp[r][c]+a[c+1].second));
                    res=max(res,dp[r-a[c+1].first][c+1]);
                }
                dp[r][c+1]=max(dp[r][c+1],dp[r][c]);
                res=max(res,dp[r][c+1]);

            }
        }
    }
    cout<<max(res,dp[w-a[1].first][1]);
    return 0;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

    int num=0,sum=0;
    rep(i,n){
        num = max(num,p[i]);
        sum += p[i];
    }

    cout << sum -num/2 << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
int A[110];

signed main(){
	cin>>N>>M;
	int sum=0;
	REP(i,N){
		cin>>A[i];
		sum+=A[i];
	}
	int cnt=0;
	REP(i,N){
		double d=(double)sum*(1.0/(4.0*(double)M));
		if((double)A[i]>=d){
			cnt++;
			DEB(d)END
		}
	}
	DEB(cnt)END
	if(cnt>=M){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	int k;
	cin >> k;
	if (k <= 12) {
		cout << k << endl;
		return 0;
	}
	vector<vector<int>> dp(100000, vector<int>(10, 0));
	for (int i = 0; i <= 9; i++) {
		dp[0][i] = 1;
	}
	int i = 0;
	int sum = 9;
	while (true) {
		for (int j = 1; j <= 8; j++) {
			dp[i + 1][j] = dp[i][j] + dp[i][j - 1] + dp[i][j + 1];
		}
		dp[i + 1][0] = dp[i][0] + dp[i][1];
		dp[i + 1][9] = dp[i][9] + dp[i][8];
		for (int j = 1; j <= 9; j++) {
			sum += dp[i + 1][j];
		}
		i++;
		if (sum >= k) {
			break;
		}
	}
	//cout << i << endl;;
	int j = 9;
	for (; j >= 0; j--) {
		sum -= dp[i][j];
		if (k > sum) {
			break;
		}
	}
	sum += dp[i][j];

	i--;
	cout << j;
	//cout << sum << endl;
	while (i >= 0) {
		if (j == 9) {
			for (j = 9; j >= 8; j--) {
				sum -= dp[i][j];
				if (k > sum) {
					break;
				}
			
			}
			sum += dp[i][j];
			i--;
			cout << j;
		}
		else if (j == 0) {
			for (j = 1; j >= 0; j--) {
				sum -= dp[i][j];
				if (k > sum) {
					break;
				}
				
			}
			sum += dp[i][j];
			i--;
			cout << j;
		}
		else {
			int a = j;
			for (j = a + 1; j >= a - 1; j--) {
				sum -= dp[i][j];
				//cout << "a"<<j << "," << sum << endl;
				if (k > sum) {
					break;
				}

			}
			sum += dp[i][j];
			i--;
			cout << j;
		}
	}
	cout << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for(ll i = K; i <= N+1; i++){
		ll x = (0LL + i - 1LL) * i / 2LL; // 0~K-1
		ll y = (N - i + 1LL + N) * i / 2LL; //N-K+1 ~ N
		ans += y - x + 1LL;
		ans %= MOD;
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
  int N, M, Q; cin >> N >> M >> Q;

  // int L[M], R[M];
  // for (int i = 0; i < M; i++) {
  //   cin >> L[i] >> R[i];
  // }

  int grid[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      grid[i][j] = 0;
    }
  }

  for (int i = 0; i < M; i++) {
    int l, r; cin >> l >> r;
    grid[l - 1][r - 1]++;
  }

  int p[Q], q[Q];
  for (int i = 0; i < Q; i++) {
    cin >> p[i] >> q[i];
    p[i]--;
  }

  // sort(L, L + M);
  // sort(R, R + M);

  // int left[N + 2]; // Trains that are entirely left of the point
  // int right[N + 2]; // Trains that are entirely right of the point
  // left[0] = 0;
  // right[N + 1] = 0;

  // // The index of the next train to be accounted for in sorted L and R
  // int left_i = 0;
  // int right_i = M - 1;

  // for (int i = 0; i < N + 1; i++) {
  //   int add = 0;
  //   while (left_i < M) {
  //     if (R[left_i] > i + 1) break;
  //     left_i++;
  //     add++;
  //   }
  //   left[i + 1] = left[i] + add;
  // }
  // for (int i = N + 1; i > 0; i--) {
  //   int add = 0; 
  //   while (right_i >= 0) {
  //     if (L[right_i] < i - 1) break;
  //     right_i--;
  //     add++;
  //   }
  //   right[i - 1] = right[i] + add;
  // }

  // for (int i = 0; i < Q; i++) {
  //   cout << right[p[i]] + left[q[i]] - M << endl;
  // }

  // When two numbers are involved, simply making 2 1D cumsums will not work 
  // The results of those cumsums often cannot be combined to obtain the result we want
  // Even if they can be, it is extremely difficult to figure the right combination out

  int table[N + 1][N + 1];
  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < N + 1; j++) {
      table[i][j] = 0;
    }
  }
  for (int i = 1; i < N + 1; i++) {
    for (int j = 1; j < N + 1; j++) {
      table[i][j] = table[i - 1][j] + table[i][j - 1] - table[i - 1][j - 1] + grid[i - 1][j - 1];
    }
  }

  for (int i = 0; i < Q; i++) {
    cout << table[q[i]][q[i]] - table[q[i]][p[i]] - table[p[i]][q[i]] + table[p[i]][p[i]] << endl;
  }
}

Measured memory_bytes: 6376
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int A, B, K;
	cin >> A >> B >> K;
	if (B - A +1<= 2 * K) {
		for (int i = A; i <= B; ++i) {
			cout << i << endl;
		}
	}
	else {
		for (int i = A; i < A + K; ++i) {
			cout << i << endl;
		}
		for (int i = B - K + 1; i <= B; ++i) {
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
//2016
#include<iostream>
using namespace std;
int main(void){
	int a,b,c,d,e,t=0;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>e;
	if(a<0){
		while(a<0){
			t+=c;
			a++;
		}
		if(a==0){
			t+=d;
		}
		while(a<b){
			t+=e;
			a++;
		}
	}
	else{
		while(a<b){
			t+=e;
			a++;
		}
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N,A,B;
    cin >> N >> A >> B;

    if((B - A -1) % 2 != 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,A = inpl()
aa = inpl()

dp = [[[0]*(50*N+5) for j in range(N+1)] for i in range(N)]
# dp[i][j][k] : i 枚目まで見て，j枚選んで，合計がk の通り

for i in range(N):
    dp[i][0][0] = 1


for i in range(N):
    a = aa[i]
    for j in range(1,i+2):
        for k in range(50*j+5):
            dp[i][j][k] = dp[i-1][j][k]
            if k >= a:
                dp[i][j][k] += dp[i-1][j-1][k-a]

ans = 0
for j in range(N+1):
    ans += dp[-1][j][j*A]

print(ans-1)


Measured memory_bytes: 63080
while True:
    h, w = map(int, input().split())
    if w+h == 0:
        break
    for y in range(h):
        line = ""
        for x in range(w):
            if (y+x) % 2 == 0:
                line += "#"
            else:
                line += "."
        print(line)
    print()



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

int main() {
    int N;
    cin >> N;
    set<int> D;
    for(int i = 0; i < N; i++) {
        int d;
        cin >>d;
        D.insert(d);
    }
    cout << D.size() << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll sum = 0, last = 0;
    for(ll i=1; i<=n; i++){
        sum += i;
        last = i;
        if(sum >= n) break;
    }
    ll excess = sum - n;
    for(ll i=1; i<=last; i++){
        if(i == excess) continue;
        cout << i << endl;
    }
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  ll ans = 1;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    if((ll)1e18 / ans < a[i]){
      cout << -1 << endl;
      return 0;
    }
    ans = ans * a[i];
    if(ans > (ll)1e18){
      cout << -1 << endl;
    }
    if(ans == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int N,x,A,y[NMAX+1];
ll  dp[NMAX+1][5005];
void solve1(){
    memset(dp,0,sizeof(dp));
    dp[0][N*NMAX]=1;
    
    for(int j=1;j<=N;j++){
        for(int t=0;t<=2*N*NMAX;t++){
            if(t-y[j]>=0&&t-y[j]<=2*N*NMAX)
                dp[j][t]=dp[j-1][t]+dp[j-1][t-y[j]];
            else
                dp[j][t]=dp[j-1][t];
        }
    }
}



int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N>>A;
    for(int i=1;i<=N;i++){
        cin>>x;
        y[i]=x-A;
    }
    
    solve1();
    
    
    cout<<dp[N][N*NMAX]-1<<"\n";
    
    return 0;
}


Measured memory_bytes: 2304
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll H,W;cin>>H>>W;
    ll a[H][W];WREP(i,H,j,W)cin>>a[i][j];
    ll s=0;
    WREP(i,H,j,W)s+=a[i][j];

    ll cnt=0;
    ostringstream oss;
    REP(i,H){
        REP(j,W){
            if(i==H-1&&j==W-1)break;
            if(a[i][j]%2==1){
                cnt++;
                a[i][j]--;
                if(j!=W-1){
                    a[i][j+1]++;
                    oss<<i+1<<" "<<j+1<<" "<<i+1<<" "<<j+1+1<<"\n";
                }
                else{
                    a[i+1][j]++;
                    oss<<i+1<<" "<<j+1<<" "<<i+1+1<<" "<<j+1<<"\n";
                }
            }
        }
    }
    cout<<cnt<<"\n"<<oss.str();
}

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

int main() {
    int N , M ;
    cin >> N >> M ; 
    int A[M];
    int sum = 0;
    for (int i ; i < M ; i++){
        cin >> A[i];
        sum += A[i];
    }
    if (N >= sum) cout << N - sum << endl ;
    else cout << "-1" <<endl;
	return 0;
}

Measured memory_bytes: 3608
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

#define NMAX 100000
int K = 1;
struct Edge{ int id, c; };
vector<Edge> Edges[NMAX];
int colors[NMAX];

void dfs(int p, int p_color){
	int color = 1;
	for(auto e:Edges[p]){
		K = max(K, colors[e.id] = color==p_color? ++color: color);
		dfs(e.c, color++);
	}
}

int main(){
	int N; cin>>N;
	rp(id, 0, N-1){
		int p,c; scanf("%d%d",&p,&c); p--,c--;
		Edges[p].push_back({id, c});
	}
	dfs(0, 0);
	printf("%d\n", K);
	rp(i, 0, N-1) printf("%d\n", colors[i]);
}

Measured memory_bytes: 7424
#include <iostream>
#include <queue>
#include <map>
#include <bitset>
#include <string>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <stack>
#include <cstdlib>
#include <numeric>
#include <cassert>
#include <complex>
#include <iterator>
//#include <unordered_map>
using namespace std;
#define maxn 500007
#define maxm 400007
#define maxq 1000007
#define maxl 1234
#define modn 998244353 
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define scanl2(a,b) scanf("%lld%lld",&a,&b)
#define scans(a) scanf("%s",a)
#define scans2(a,b) scanf("%s%s",a,b)
#define scand(a) scanf("%lf",&a)
#define scan2(a,b) scanf("%d%d",&a,&b)
#define scand2(a,b) scanf("%lf%lf",&a,&b)
#define scan3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scan5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define print(a) printf("%d\n",a);
#define printl(a) printf("%lld\n",a);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>= b;i--)
#define fscan(a) fscanf(stream,"%d", &a);
#define mp      make_pair	
#define pb      push_back
#define eb      emplace_back
#define mm(a,b) memset(a,b,sizeof a)
#define log2(n) (double)(log(n) / log(2.0))
#define _crt_disable_perfcrit_locks
#define bll __int128
#pragma warning(disable:4996)
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef pair <char, int> pci;
typedef complex<double> cd;
typedef vector<complex<double> > vcd;
const double eps = 1e-8;
const double PI = 2 * acos(0.0);

int cc, bb; char ch; inline int F() {
	while (ch = getchar(), (ch < 48 || ch> 57) && ch != '-'); ch == '-' ? cc = bb = 0 : (cc = ch - '0', bb = 1);
	while (ch = getchar(), ch > 47 && ch < 58)cc = (cc << 1) + (cc << 3) + (ch ^ 48); return bb ? cc : -cc;
}
void write(int x) {
	int y = 10, len = 1;
	while (y <= x) { y *= 10; len++; }
	while (len--) { y /= 10; putchar(x / y + 48); x %= y; }
}
ll pow2(ll a, ll b, ll mod) {
	ll r = 1, base = a;
	while (b) {
		if (b & 1) r = r * base % mod;
		base = base * base % mod;
		b >>= 1;
	}
	return r;
}
ll inv(ll a, ll n) {
	return pow2(a, n - 2, n);
	//return pow2(a, oula(n) - 1, n);
}
int n;

int main() {
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	//FILE* stream = fopen("L:/20.in", "rb+")
	cin >> n;
	if (n % 10 == 7 || n / 100 == 7 || n / 10 % 10 == 7)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll r, g, b;
    r = g = b = 0;
    rep(0, i, N)
    {
        if (S[i] == 'R')
            r++;
        if (S[i] == 'G')
            g++;
        if (S[i] == 'B')
            b++;
    }
    ll ex = 0;
    rep(0, i, N)
    {
        char n = S[i];
        rep(i, j, N)
        {
            char nn = S[j];
            if ((n != nn) && (2 * j - i < N))
            {
                char nnn = S[2 * j - i];
                if ((n != nnn) && (nn != nnn))
                    ex++;
            }
        }
    }
    cout << r * g * b - ex << endl;
}


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

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

int a[100001];
ll l[100002];
ll r[100002];

int main() {
    int n, i;
    ll x = 1, ans = 0;
    cin >> n; 
    for (i = 0; i <= n; i++) cin >> a[i];
    l[n] = r[n] = a[n];
    for (i = n - 1; i >= 0; i--) {
        l[i] = a[i] + (l[i + 1] + 1) / 2;
        r[i] = a[i] + r[i + 1];
    }
    for (i = 0; i <= n; i++) {
        if (l[i] > x) {
            cout << -1 << "\n";
            return 0;
        }
        if (x > r[i]) x = r[i];
        ans += x;
        x = min((x - a[i]) * 2, r[i + 1]);
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define dfor(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
#define ull unsigned long long

int main() {
	int n;
	cin>>n;
	int a[n];
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	float sum = a[0];
	FOR(i,1,n){
		sum = (sum+a[i])/2;
	}
	cout<<sum;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sumA = 0
sumB = 0

for i in range(len(a)):
    if i % 2 == 0:
        sumA += a[i]
    else:
        sumB += a[i]

print(sumA-sumB)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int N;
  scanf("%d", &N);
  char S[2*N];
  scanf("%s", S);
  int left[N], right[N];
  left[0] = 0;
  right[N-1] = 0;
  for(int i = 1; i < N; i++){
    left[i] = left[i-1];
    if(S[i-1] == 'W')
      left[i]++;
  }
  for(int i = N-2; i >= 0; i--){
    right[i] = right[i+1];
    if(S[i+1] == 'E')
      right[i]++;
  }
  int min = N;
  for(int i = 0; i < N; i++){
    int count = left[i] + right[i];
    if(count < min)
      min = count;
  }
  printf("%d\n", min);
}


Measured memory_bytes: 2816
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	while(1){
		int x,y,s; cin >> x >> y >> s; if(x==0&&y==0) return 0;
		int v[1005];
		for(int i=1;i<s;i++){
			double j = (double)i;
			j *= (100.0+(double)x)/100.0;
			v[i] = floor(j+1e-7);
		}
		int ret = 0;
		for(int i=1;i<s;i++){
			for(int j=1;j<s;j++){
				if(v[i]+v[j] != s) continue;
				double k = (double)i;
				k *= (100.0+(double)y)/100.0;
				int K = floor(k+1e-7);
				double l = (double)j;
				l *= (100.0+(double)y)/100.0;
				int L = floor(l+1e-7);
				ret = max(ret,K+L);
			}
		}
		cout << ret << endl;
	}
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  char A = a.at(0);
  char B = b.at(0);
  char C = c.at(0);
  
  cout << A << B << C << endl;
  
  return 0;
}

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

int main () {
    unsigned long long x;
    cin >> x;
    unsigned long long moves = 0;
    unsigned long long y = 0;
    if (x < 11) {
        if (x > 6) {
            cout << "2";
        } else {
            cout << "1";
        }
        return 0;
    }
    if (x % 11 != 0) {
        if (x % 11 > 6) {
            cout << (x/11)*2+2;
        } else {
            cout << (x/11)*2+1;
        }
    } else {
        cout << (x/11)*2;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
int isP(char str[]) 
{ 
  	int count=0;
    int l = 0; 
    int h = strlen(str) - 1; 
    while (h > l) { 
        if (str[l++] != str[h--]) count++;
    } 
  return count;
} 
int main(){
  char s[100];
  cin>>s;
  int ans = isP(s);
  cout<<ans<<endl;
}

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

const int maxn = 2e5 + 5;
int h[maxn];
ll dp[maxn];
int tree[4*maxn];
int trstp = 1;
int n;
ll c;

ll eval(int f, int x) {
  if (f == 0) return 1e18;
  return dp[f] + ll(h[x] - h[f])*(h[x] - h[f]) + c;
}

void update(int f, int root = 1, int s = 1, int e = n) {
  int mid = (s + e)/2;
  bool lless = eval(f, s) < eval(tree[root], s);
  bool rless = eval(f, mid) < eval(tree[root], mid);
  if (rless) {
    swap(f, tree[root]);
  }
  if (s == e) {
    return;
  } else if (lless != rless) {
    update(f, 2*root, s, mid);
  } else {
    update(f, 2*root + 1, mid + 1, e);
  }
}

ll query(int x, int root = 1, int s = 1, int e = n) {
  int mid = (s + e)/2;
  ll ans = eval(tree[root], x);
  if (s == e) {
    return ans;
  } else if (x <= mid) {
    return min(query(x, 2*root, s, mid), ans);
  } else {
    return min(query(x, 2*root + 1, mid + 1, e), ans);
  }
}

int main() {
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }

  dp[n] = 0;
  update(n);
  for (int i = n - 1; i >= 1; i--) {
    dp[i] = query(i);
    update(i);
  }

  cout << dp[1] << '\n';

  return 0;
}


Measured memory_bytes: 5760
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 200005

int b[MAXN], a[MAXN];

int main()
{
    _io
    int n; cin >> n;
    REP(i, 1, n)
        cin >> b[i];
    FOR(i, 1, n)    a[i] = INT_MAX;
    FOR(i, 1, n-1)
    {
        a[i] = min(a[i], b[i]);
        a[i+1] = min(a[i+1], b[i]);
    }
    int res = 0;
    FOR(i, 1, n)    res += a[i];
    cout << res;
}


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

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

  if (N / 10 % 111 == 0 || N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long A[200000];
long long cum_sumA[200000];
int main(){
  int N;
  long long K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  cum_sumA[0] = A[0];
  for(int i = 1; i < N; i++){
    cum_sumA[i] = A[i] + cum_sumA[i - 1];
  }

  map <long long, int> mod_count;
  long long ans = 0;
  for(int i = 0; i < N; i++){
    long long cur_mod = ((cum_sumA[i]- (i + 1)) % K + K) % K;
    if(cur_mod == 0 && i < K - 1){
      ans ++;
    }
    if(mod_count.find(cur_mod) != mod_count.end()){
      ans += mod_count[cur_mod];
    }

    if(mod_count.find(cur_mod) != mod_count.end()){
      mod_count[cur_mod] ++;
    } else {
      mod_count[cur_mod] = 1;
    }
    if(i - (K - 1) >= 0){
      int remove_mod = ((cum_sumA[i - (K - 1)] - (i - (K - 1) + 1)) % K + K) % K;
      mod_count[remove_mod] --;
      if(mod_count[remove_mod] == 0){
        mod_count.erase(remove_mod);
      }
    }

    /*
    for(auto it = mod_count.begin(); it != mod_count.end(); it++){
      cout << it->first << ":" << it->second << " ";
    }
    cout << endl;
    */
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
#include <string>
#include <iostream>

using namespace std;

class B {
	string O, E;

public:
	void solve()
	{
		cin >> O >> E;

		for (size_t i{ 0 }; i < E.length(); i++)
		{
			cout << O[i] << E[i];
		}

		if (E.length() != O.length())
			cout << O.back();

		cout << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
     
    #define ll long long
    #define pb push_back
    #define mp make_pair
    #define f first
    #define s second
    #define sz(x) (int)x.size()
    #define all(x) x.begin(), x.end()
     
    using namespace std;
    using namespace __gnu_pbds;
     
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
    template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
    template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    
    double dp[301][301][301];
    int p[301];
    int n;

    double nadji(int a, int b, int c)
    {
     
        //cout << "e";
        if(dp[a][b][c] != 0)
        {
            //cout << "A" << endl;
            return dp[a][b][c];
        }
        if(a == 1 && b == 0 && c==0)
        {
            //cout << "B" << endl;
            dp[a][b][c] = n;
            return n;
        }
     
        double pom=0;
        pom+= n*1.0/(a+b+c);
        
        if(a!=0)
        pom+=(a*1.0/(a+b+c))*nadji(a-1,b,c);
        
        if(b!=0)
        pom+=(b*1.0/(a+b+c))*nadji(a+1,b-1,c);  
        
         if(c!=0)
        pom+=(c*1.0/(a+b+c))*nadji(a,b+1,c-1);  
        
        dp[a][b][c] = pom;
        
        return dp[a][b][c];

    }

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


      int a=0,b=0,c=0;
        
        
        cin >> n;
        for(int i =0; i<n; i++)
        {
            cin >> p[i];
            if(p[i]==1)
            a++;
            if(p[i]==2)
            b++;
            if(p[i]==3)
            c++;
         }
   
   
   
       
           

        printf("%.10f\n",nadji(a,b,c));                      

        return 0;
    }


Measured memory_bytes: 213376
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int time[2500]={0};
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        time[x*100+y]=1;
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        time[x*100+y]=1;
    }
    int p=0;
    for(int i=0;i<2400;i++){
        if(time[i]==1){
            if(p==1){
                printf(" ");
            }
            printf("%d:%02d",i/100,i%100);
            p=1;
        }
    }
    /*
    printf("%c",8);
    */
    puts("");
    return 0;
}

Measured memory_bytes: 1224
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	for(ll i=0;i<k;i++){
		if(a>=b){
			b*=2;
			continue;
		}
		if(b>=c){
			c*=2;
			continue;
		}
	}
	if(a<b && b<c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;

   vector<int>a(n);
   for(int i=0;i<n;i++)
    cin >> a[i];

    int best=INT_MAX;

    for(int i=-100;i<=100;i++){
        int cur=0;
        for(int j=0;j<n;j++){
            cur+=(a[j]-i)*(a[j]-i);
        }
        best=min(best,cur);
    }

    cout << best << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    string st;
    cin>>st;
    int a=0,b=0;
    REP(i,st.size()){
        if(st[i]=='R'){
            a++;
        }else{
            b++;
        }
    }
    if(a>b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X, Y;
    cin >> X >> Y;
    int A = Y - 4 * X;
    int B = Y - 2 * X;
    if (A % 2 == 0 && B % 2 == 0 && -A >= 0 && B >= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int sum = 0;
    rep(i, n) {
        sum += min(abs(x[i]), abs(x[i] - k));
    }
    sum *= 2;
    cout << sum << endl;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x :: y :: chars = sc.next().toList
  val z = chars.last
  val validates = Seq(
    x == 'A',
    chars.length == chars.count(_ != 'C') + 1,
    (y :: z :: chars.filter(_ != 'C')).forall(_.isLower)
  )
  println(if (validates.forall(identity)) "AC" else "WA")
}


Measured memory_bytes: 55632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[101][10001];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    int weight[N], value[N];

    rep(i, N) cin >> value[i] >> weight[i];


    rep(i, N) {
        rep(j, W+1) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i+1][j] = max(dp[i+1][j], dp[i+1][max(0, j-1)]);
            if (weight[i] <= j) 
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]]+value[i]);
            //else if (weight[i] <= j && weight[i] <= W)
            //    dp[i+1][j] = max(dp[i+1][j], value[i]); 
        }
    }
    cout << dp[N][W] << endl;
    /*
    for(int i = 0; i <= 6; i++) {
        for(int j = 0; j <= W; j += 1) {
            cout << i << ":" << j << "=" << dp[i][j] << endl;
        }
    }
    //*/




    return 0;
}



Measured memory_bytes: 7096
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, pair<string, int>> SP;
#define mp(a, b) make_pair(a, b)

bool comp(SP lhs, SP rhs) {
  if (lhs.second.first != rhs.second.first) {
    // return lhs.second.first.compare(rhs.second.first);
    return lhs.second.first <= rhs.second.first;
  } else {
    //    return lhs.second.first.compare(rhs.second.first);
    return lhs.second.second > rhs.second.second;
  }
}

int main(int argc, char const *argv[]) {
  int n;

  cin >> n;

  int wi;
  vector<int> wv;
  for (int i = 0; i < n; i++) {
    cin >> wi;
    wv.push_back(wi);
  }

  int s1, s2, abs_diff, ans = 1000000000;
  for (int t = 0; t < n; t++) {
    s1 = 0;
    s2 = 0;
    for (int i = 0; i < t; i++) {
      s1 += wv[i];
    }
    for (int j = t; j < n; j++) {
      s2 += wv[j];
    }
    abs_diff = abs(s1 - s2);
    if(abs_diff < ans){ ans = abs_diff; }
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

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

    auto current = new int[N];

    int cnt = 0;
    while (true) {
        if (current == goal) break;
        auto idxList = zip(current,goal).enumerate.filter!(a => a.value[0] != a.value[1]).map!(a => a.index);

        size_t before = size_t.max-1;
        foreach (idx; idxList) {
            if (idx != before+1) cnt++;
            current[idx]++;
            before = idx;
        }
    }
    writeln(cnt);
}



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

using namespace std;

using ll = long long;


vector <pair<ll, ll>> primes(ll n){
	vector <pair<ll, ll>> res;

	for(ll i = 2; i * i <= n; ++i){
		if(n % i != 0) continue;
		
		ll exp = 0;
		while(n % i == 0){
			++exp;
			n /= i;	
		}

		res.push_back({i, exp});
	}

	if(n != 1) res.push_back({n, 1});
	return res;

}	


int main()
{
	ll n, p;
	cin >> n >> p;

	const auto &pf = primes(p);

	ll ans = 1;
	for(auto item : pf) {
		for(int i = 0; i < item.second/n; ++i) ans *= item.first;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if((x-r >= 0) && (x+r <= w) && (y-r >= 0) && (y+r <= h)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2120
x,y=map(int,input().split())
if abs(x)==abs(y):
  print((x*y<0)+0)
elif x*y==0:
    print(abs(x-y)+(x>0 or y<0)*1)
elif x<y:
  if x*y>0:
    print(abs(x-y))
  else:
    print(1+abs(abs(x)-abs(y)))
else:
  if x*y>0:
    print(2+abs(abs(x)-abs(y)))
  else:
    print(1+abs(abs(x)-abs(y)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string s, t;
    cin >> N >> s >> t;
    int p = 0;
    bool match;
    for(int i = 0; i < N; i++){
    	match = true;
    	for(int j = 0; j < N-i; j++){
    		if(s[i+j] != t[j]) match = false;
    	}
    	if(match){
    		p = i;
    		break;
    	}
    }
    if(match) cout << N+p << endl;
    else cout << N+N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000;

signed main()
{
    int n; cin >> n;
    string s; cin >> s;
    int sum = 1;
    rep (i, s.size()-1) {
        if (s[i] != s[i+1]) {
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
	int k, n, a[200000],max=0;
	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i + 1] - a[i] > max) {
			max = a[i + 1] - a[i];
		}
	}
	if (a[0] + k - a[n - 1] > max) {
		max = a[0] + k - a[n - 1];
	}
	cout << k - max << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			C[i] = sc.nextInt();
		}
		solve(N, A, B, C);
	}

	static void solve(int N, int[] A, int[] B, int[] C) {

		//0→A,　1→B,　2→C
		int[][] dp = new int[N][3];
		dp[0][0] = A[0];
		dp[0][1] = B[0];
		dp[0][2] = C[0];

		for (int i = 1; i < N; i++) {
			dp[i][0] = Math.max(dp[i-1][1], dp[i-1][2]) + A[i];
			dp[i][1] = Math.max(dp[i-1][0], dp[i-1][2]) + B[i];
			dp[i][2] = Math.max(dp[i-1][0], dp[i-1][1]) + C[i];
		}

		int answer = Math.max(dp[N-1][0],Math.max(dp[N-1][1], dp[N-1][2]));

		System.out.println(answer);
	}

}






Measured memory_bytes: 93704
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vll vector<ll>
#define vec vector
#define pb push_back
#define pop pop_back
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define FF first
#define SS second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<ll,ll>
#define vecin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define vecout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define FASTio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//ll mod = 1000000007;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FASTio
	// START FROM HERE :)
	int x;
	cin>>x;
	if(x==0)cout<<"1";
	if(x==1)cout<<"0";
	
}





Measured memory_bytes: 3596
from collections import defaultdict

n = int(input())
A = list(map(int, input().split()))
goukei = 0
jisho = defaultdict(int)
for i in range(n):
    goukei += A[i]
    jisho[A[i]] += 1

q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    num1 = jisho[b]
    goukei += num1 * (c - b)
    jisho[c] += num1
    jisho[b] = 0
    print(goukei)


Measured memory_bytes: 88368
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(T) __typeof((T).begin())
#define each(T, it) for(ITER(T) it =(T).begin(); it!=(T).end(); it++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 4001;
const int B = (int)1e6;

int main(void){
    for(int n, f; cin >> n, n; cout << (f?"":"NA\n")){
        vector<ll> in(N);
        vi p;

        while(f = n --){
            int id; ll v, m; cin >> id >> v >> m;
            
            if((in[id] += (ll)v * m) >= B) in[id] = B;
            if(find(ALL(p), id) == p.end()) p.pb(id);
        }
        each(p, it) if(in[*it] == B) cout << *it << endl, f = 1;
    }
 
    return 0;
}

Measured memory_bytes: 1264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int x = Integer.parseInt(br.readLine());
    System.out.println((int) Math.pow(x, 3));
  }
}

Measured memory_bytes: 24184