akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    string s,t; cin >> s >> t;
    rep(i,n) cout << s[i] << t[i];

    return 0;
}


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

const int mod = 1000000007;
int N, K;
int a[1000];
long c[1001][1001];
long dp[21][1001];
void pre() {
  for (int n = 0; n <= N; ++n) {
    for (int r = 0; r <= n; ++r) {
      if (r == 0) {
        c[n][r] = 1;
      } else {
        c[n][r] = (c[n - 1][r - 1] + c[n - 1][r]) % mod;
      }
    }
  }
}

long comb(int n, int r) {
  if (n < 0 || r < 0) return 0;
  return c[n][r];
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < K; ++i) {
    cin >> a[i];
  }
  
  pre();
  dp[0][0] = 1;
  for (int k = 1; k <= K; ++k) {
    for (int n = 0; n <= N; ++n) {
      long sum = 0;
      for (int x = 0; x <= n; ++x) {
        long add = dp[k - 1][n - x] * comb(N - n + x, x) % mod * comb(N - x, a[k - 1] - x) % mod;
        sum = (sum + add) % mod;
      }
      dp[k][n] = sum;
    }
  }
  cout << dp[K][N] << endl;
}

Measured memory_bytes: 7552
#include <cstdio>

int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    if (a == 1)
    {
        a = 14;
    }
    
    if (b == 1)
    {
        b = 14;
    }
    
    if (a > b)
    {
        printf("Alice");
    }
    
    else if (b > a)
    {
        printf("Bob");
    }
    
    else if (a == b)
    {
        printf("Draw");
    }
}

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

using namespace std; 

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

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

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

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

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

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

void Main()
{
    int n;cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else{
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
	return;
}

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

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

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

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

    vector<long long> J(N);
    vector<long long> O(N);
    vector<long long> I(N);

    J[0]=O[0]=I[0]=0;
    switch(instr[0]) {
    case 'J' :
        ++J[0]; break;
    case 'O' :
        ++O[0]; break;
    case 'I' :
        ++I[0]; break;
    }

    for(int i=1; i<N; ++i) {
        J[i]=J[i-1]; O[i]=O[i-1]; I[i]=I[i-1];
        switch(instr[i]) {
        case 'J' :
            ++J[i]; break;
        case 'O' :
            ++O[i]; break;
        case 'I' :
            ++I[i]; break;
        }
    }

    long long cnt1=0,cnt2=0,cnt3=0;
    long long mx=-1;

    for(int i=0; i<N; ++i) {
        if(instr[i]!='O') {
            if(instr[i]=='J') mx=MAX(mx,J[i]*(I[N-1]-I[i]));
            else mx=MAX(mx,J[i]*(I[N-1]-I[i]+1));
            continue;
        }
        cnt1+=(J[i]+1)*(I[N-1]-I[i]);
        cnt2+=J[i]*(I[N-1]-I[i]);
        cnt3+=J[i]*(I[N-1]-I[i]+1);
        mx=MAX(mx,J[i]*(I[N-1]-I[i]));
    }

    cnt2+=mx;

    long long ans=cnt1;
    ans=MAX(ans,cnt2);
    ans=MAX(ans,cnt3);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);i++)

using namespace std;

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;
}

char c[3][3];

int main() {
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    printf("%c%c%c\n", c[0][0], c[1][1], c[2][2]);
}



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

#define MOD 1000000007
#define MAX 100005
#define ll long long
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define ss(x) scanf("%s",x)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vpii vector<pii >
#define vll vector<ll>
#define clr(x) memset(x,0,sizeof(x))

#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll power(ll a,ll b,ll m){
	ll x=1%m; a%=m;
	while(b){
		if((1&b)) x = x * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return x;
}

bool can(int t1,int x1,int y1,int t,int x,int y){
	int del = t1-t;
	int diff = abs(x1-x);
	diff%=2;
	int diff2 = abs(y1-y);
	diff2%=2;
	if(abs(x1-x)+abs(y1-y)<=del && (diff^diff2)==del%2) return 1;
	return 0;
}

int main(){
	int n;sd(n);

	int px = 0 , py = 0, t = 0;

	for(int i=1;i<=n;i++){
		int tn,x,y;
		sd(tn);sd(x);sd(y);
		if(!can(tn,x,y,t,px,py)){
			printf("No");
			return 0;
		}
		px = x, py = y, t = tn;
	}

	printf("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, k;
  cin >> n >> k;
  vl p(n);
  rep(i,n) {
    cin >> p[i];
    p[i]++;
  }
  vector<ll> csum(p.size()+1);
  rep(i,p.size()) {
    csum[i+1] = csum[i] + p[i];
  }
  double ans = 0;
  rep(i,n-k+1) {
    double s = csum[i+k] - csum[i];
    ans = max(ans, s);
  }
  ans /= 2;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<ios>
using namespace std;
#include<vector>
#include<queue>
#include<limits>
template<typename T>
vector<T>dijkstra(int s,const vector<vector<pair<int,T> > >&G,T INF=numeric_limits<T>::max())
{
	int n=G.size();
	vector<T>d(n,INF);
	vector<int>parent(n,-1);
	priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > >P;
	d[s]=0;
	P.push(make_pair(d[s],s));
	while(!P.empty())
	{
		pair<T,int>p=P.top();P.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(const pair<int,T>&e:G[v])
		{
			int u=e.first;
			T cost=d[v]+e.second;
			if(d[u]>cost)
			{
				d[u]=cost;
				parent[u]=v;
				P.push(make_pair(d[u],u));
			}
		}
	}
	return d;
}
main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,int> > >G(n);
    for(;m--;)
    {
        int a,b,c,d;scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        a--,b--;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,d));
    }
    int s,t,P,V;
    scanf("%d,%d,%d,%d",&s,&t,&P,&V);
    s--,t--;
    cout<<P-V-dijkstra(s,G)[t]-dijkstra(t,G)[s]<<endl;
}


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

int n,m;
string str[20];
int s[10], id[30];
bool head[10];
vector<int> comb[6];
vector<int> pre[1<<10], suf[1<<10];

string bin(int a){
  string res = "";
  for(int i=0;i<10;i++){
    if((a>>i)&1)res += "1";
    else res += "0";
  }
  return res;
}

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

  int lim = 1<<10;
  for(int i=1;i<6;i++){
    int tmp = (1<<i)-1;
    while(tmp < lim){
      comb[i].push_back(tmp);
      int x = tmp & -tmp, y = tmp + x;
      tmp = ( ( (tmp & ~y) /x ) >> 1) | y;
    }
  }

  while(cin >> n,n){
    vector<char> v;
    for(int i=0;i<n;i++){
      cin >> str[i];
      for(int j=0;j<str[i].size();j++){
	v.push_back(str[i][j]);
      }
    }

    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());

    m = v.size();
    for(int i=0;i<m;i++)id[v[i]-'A'] = i;

    for(int i=0;i<m;i++){
      s[i] = 0; head[i] = false;
    }

    for(int i=0;i<n;i++){
      if(str[i].size()>1)head[id[str[i][0]-'A']] = true;

      int tmp = (i==n-1?-1:1);
      for(int j=str[i].size()-1;j>=0;j--){
	s[id[str[i][j]-'A']] += tmp;
	tmp *= 10;
      }
    }

    if(m==1){
      if(s[0] == 0 && !head[0])cout << 1 << endl;
      else cout << 0 << endl;
      continue;
    }

    int plen = m/2, slen = m-plen;
 
    for(int i=0;i<comb[plen].size();i++){
      int comb1 = comb[plen][i];
      pre[comb1].clear();

      vector<int> tmp;
      for(int j=0;j<10;j++){
	if( (comb1>>j)&1 )tmp.push_back(j);
      }
      
      do{
	int sum = 0;
	bool f = true;
	for(int j=0;j<plen;j++){
	  if(tmp[j] == 0 && head[j]){
	    f = false;
	    break;
	  }
	  sum += s[j]*tmp[j];
	}
	if(f)pre[comb1].push_back(sum);
      }while(next_permutation(tmp.begin(),tmp.end()));
      
      sort(pre[comb1].begin(),pre[comb1].end());
    }
    
    for(int i=0;i<comb[slen].size();i++){
      int comb1 = comb[slen][i];
      suf[comb1].clear();

      vector<int> tmp;
      for(int j=0;j<10;j++){
	if( (comb1>>j)&1 )tmp.push_back(j);
      }
      
      do{
	int sum = 0;
	bool f = true;
	for(int j=0;j<slen;j++){
	  if(tmp[j] == 0 && head[plen+j]){
	    f = false;
	    break;
	  }
	  sum += s[plen+j]*tmp[j];
	}
	if(f)suf[comb1].push_back(sum);
      }while(next_permutation(tmp.begin(),tmp.end()));
      
      sort(suf[comb1].begin(),suf[comb1].end());
    }

    int ans = 0;
    for(int i=0;i<comb[plen].size();i++){
      for(int j=0;j<comb[slen].size();j++){
	int comb1 = comb[plen][i], comb2 = comb[slen][j];
	if(!(comb1&comb2)){
	  for(int k=0;k<pre[comb1].size();k++){
	    int num = upper_bound(suf[comb2].begin(),suf[comb2].end(),-pre[comb1][k])
	      - lower_bound(suf[comb2].begin(),suf[comb2].end(),-pre[comb1][k]);
	    ans += num;
	  }
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1620
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,M;
	while(1){
	int n[100001]={};
	bool Q[100001]={};
	int G=0;
	int H=0;
	cin>>N>>M;if(N==0&&M==0)break;
	for(int i=0;i<M;i++)
	{int t;
		cin>>t;Q[t]=true;
	}
	//sort(n,n+M);
	int max=0,h=0,y=0;int w=0,z=-1;
	int D=2;
	if(Q[0]==false)D=1;
	int P=0,PY=1;
	for(int i=1;i<=N;i++)
	{
		if(Q[i]==true){
			h++;
		y++;}
		else{
		P++;PY++;
		if(Q[0]==true){
			if(P!=D)h++;
			if(PY!=D)y++;}
		if(P==D){
			if(max<h)max=h;
			P=0;h=0;
			}
		if(Q[0]==true&&PY==D){
			if(max<y)max=y;
			PY=0;y=0;
		}
		}
	
	}
	if(max<h)max=h;
	if(Q[0]==true&&max<y)max=y;
	if(max==0){
		if(Q[0]==true)max=2;
		else max=1;}

	cout<<max<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int x=0;
    int ans=0;
    for(int i=0; i<n; i++){
        if(s.at(i)=='I'){
            x++;
            ans=max(ans,x);
        }
        else x--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int n, ma, mb;
	cin >> n >> ma >> mb;
	vector<int> a(n), b(n), c(n);
	rep(i,n){
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(500, vector<int>(500, inf)));
	dp[0][0][0] = 0;
	rep(i,n){
		rep(j,405){
			rep(k,405){
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
			}
		}
	}
	int ans = inf;
	rep2(i,1, 405)
	{
		rep2(j,1,405){
			if (i * mb == j * ma)
				ans = min(ans, dp[n][i][j]);
		}
	}
	if(ans == inf)
		ans = -1;
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 45232
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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;}

int N,W;
ll w[100005],v[100005];

ll dp[105][100005];
ll ans;

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

Measured memory_bytes: 79488
#!python3.8
# -*- coding: utf-8 -*-
# abc177/abc177_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

P = 10**9 + 7

def main():
    N = i2n()
    A = i2nn()
    B = [None] * (N - 1)
    B[-1] = A[-1]
    for i in range(2, N):
        B[-i] = (A[-i] + B[-i+1]) % P
    ans = 0
    for i in range(N - 1):
        ans += (A[i] * B[i]) % P
    print(ans % P)
    return

main()


Measured memory_bytes: 33384
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
using namespace std;
//// NG!!
int main() {
  int H,B,N,M,K,X,Y,Z;
  cin >> N;

  map<string, int> mp;
 
  for(int i=0 ; i < N ; i++){
    string tmp;
    cin >> tmp;
    mp[tmp]++;
  }
  int mx = 0;
  for(auto p : mp){
    mx = max(mx, p.second);
  }
  for(auto p : mp){
    if(p.second != mx){
      continue;
    }
    cout << p.first << endl;
  }
  return(0);
}

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

using namespace std;

int main()
{
    int A, B, K, cnt = 0;
    cin >> A >> B >> K;

    if (A >= B)
    {
        for (int i = B; i > 0; i--)
        {
            if (A % i == 0 && B % i == 0)
            {
                cnt++;
            }
            if (cnt == K)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
    else if (A < B)
    {
        for (int i = A; i > 0; i--)
        {
            if (A % i == 0 && B % i == 0)
            {
                cnt++;
            }
            if (cnt == K)
            {
                cout << i << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")  */
#include <bits/stdc++.h>
 
#define file ""
 
#define all(x) x.begin(), x.end()
 
#define sc second
#define fr first
 
#define pb push_back
#define mp make_pair

#define pss pair<line*, line*>
 
using namespace std;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
                                 
const ll inf = 1e18;
const int MOD = 1e9 + 7;

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

const int N = 1e6 + 5;
           
ll dp[N];

int main() {                
#ifdef Mask                                                         
  freopen(".in", 	"r", stdin);
  freopen(".out", "w", stdout);  
#endif
	ios_base :: sync_with_stdio(false);               
  cin.tie(nullptr); 	
  int n, l;
  cin >> n >> l;
  int a[n + 1];
  for (int i = 1; i <= n; i++)
  	cin >> a[i], dp[i] = 1e18;
  dp[1] = 0;
  for (int i = 1; i <= n; i++) {
  	for (int k = 1; k <= l; k++) 
   		if (i + k <= n) 
   			dp[i + k] = min(dp[i] + abs(a[i] - a[i + k]), dp[i + k]);
  }
  cout << dp[n];
	return 0;   
}



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

void solve()
{
  ll n, k; cin >> n >> k;
  // ll x, y, z; cin >> x >> y >> z;
  // string s; cin >> s;
  vector<ll> a(n); REP(i, n) {cin >> a[i];a[i]--;}
  vector<ll> f(n); REP(i, n) f[i] = -1;
  vector<ll> route;
  ll loops ;
  ll c1 = 0, c2 = 0;
  ll now = 0;
 ll ans = 0;
  // bool ok = false;
  while(f[now] < 0) {
    f[now] = c1;
    now = a[now];
    c1 ++;
    if(c1 == k) {
      cout << now +1 << endl;
      return;
    }
  }
  //  cout << c1 << " " << now << " " << f[now] << endl; 
  
  loops = c1 - f[now];
  ll r = (k - f[now]) % loops;
  REP(i, r) {
    now = a[now];
  }
  
  cout << now + 1 << endl;
  // cout << (ok?"Yes":"No") << endl;}
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;


int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  rep(i, h) {
    rep(j, w) {
      if ((j < a && i < b) || j >= a && i >= b) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
  }


  return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(){
	double a;
	while(~scanf("%lf",&a)){
		double b=a,c=a;
		for(int i=2;i<=10;i++){
			if(i%2)b/=3;
			else b*=2;
			c+=b;
		}
		printf("%.8lf\n",c);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <deque>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;

int n,q;
queue<pair<string,int> > p;

int main()
{
    scanf("%d%d",&n,&q);
    string s;
    int x;
    for(int i = 0; i < n; ++i){
        cin >> s >> x;
        p.push(make_pair(s,x));
    }
    int sum = 0;
    while(!p.empty())
    {
        pair<string,int> cur;
        cur = p.front();
        sum += min(cur.second,q);
        if(cur.second <= q){
            cout << cur.first << " " << sum << endl;
            p.pop();
        }else{
            cur.second -= q;
            p.pop();
            p.push(cur);
        }
    }
    return 0;
}

Measured memory_bytes: 6412
#include<cstdio>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;

typedef long long ll;
const int MAXN=1e5+5;

int n;
ll ans;
ll a[MAXN],b[MAXN];
map<ll,int> mp;

void work(int id,ll x){
    a[id]=b[id]=1;
    for(ll i=2;i*i*i<=x;i++){
        if(x%i) continue;
        int cnt=0;
        while(x%i==0) cnt++,x/=i;
        if(cnt%3==1) a[id]*=i,b[id]*=i*i;
        else if(cnt%3==2) a[id]*=i*i,b[id]*=i;
    }
    if(x!=1){
        ll k=sqrt(x);
        if(k*k==x) a[id]*=k*k,b[id]*=k;
        else a[id]*=x,b[id]*=x*x;
    }
}

int main(){

    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        ll x;
        scanf("%lld",&x);
        work(i,x);
    }
    for(int i=1;i<=n;i++) mp[a[i]]++;
    for(int i=1;i<=n;i++){
        if(!mp[a[i]]) continue;
        if(a[i]==b[i]) ans++,mp[a[i]]=0;
        else ans+=max(mp[a[i]],mp[b[i]]),mp[a[i]]=mp[b[i]]=0;
    }
    printf("%lld",ans);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 14336
x1,y1,x2,y2=map(int,input().split())
x=abs(x2-x1)
y=abs(y2-y1)
if x2>x1:
  if y2>y1:
    print(x2-y,y2+x,x1-y,y1+x)
  else:
    print(x2+y,y2+x,x1+y,y1+x)
else:
  if y2>y1:
    print(x2-y,y2-x,x1-y,y1-x)
  else:
    print(x2+y,y2-x,x1+y,y1-x)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long ll;

int N, K;
int a[100] = {0};

int main()
{
    cin >> K;
    int top = 0;
    for (int i = 0; i < K; i++)
    {
        int p = 0;
        while (p < top && (a[p] == a[p + 1] + 1 || a[p] == 9))
        {
            p++;
        }

        if (p == top)
        {
            if (a[p] == 9)
                top++, p++;
        }

        a[p]++;
        for (int j = p - 1; j >= 0; j--)
        {
            a[j] = max(a[j + 1] - 1, 0);
        }
    }

    for (int i = top; i >= 0; i--)
    {
        cout << a[i];
    }
    cout << endl;
    // system("pause");
}

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

#define ll long long
#define pb push_back
#define f first
#define s second
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
const int N = 2e5 + 10;
ll a[N], b[N];

vector<ll> prefa, prefb;

int main() {
    fast;
    int n, m, k; cin >> n >> m >> k;
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 0; i < m; i++)cin >> b[i];
    prefa.pb(0);
    prefb.pb(0);
    for(int i = 1; i <= n; i++)
        prefa.pb(prefa[i - 1] + a[i - 1]);

    for(int i = 1; i <= m; i++)
        prefb.pb(prefb[i - 1] + b[i - 1]);
    ll ans = 0, now, pos;
    for(ll i = 0; i <= n; i++)
    {
        if(prefa[i] > k)break;
        now = k - prefa[i];
        if(now == 0)
        {
            ans = max(ans, i);
            break;
        }
        pos = (int)(upper_bound(prefb.begin(), prefb.end(), now) - prefb.begin());
        pos--;
        //cout << i << ' ' << now << ' ' << pos << endl;
        ans = max(ans, i + pos);
    }
    for(ll i = 0; i <= m; i++)
    {
        if(prefb[i] > k)break;
        now = k - prefb[i];
        if(now == 0)
        {
            ans = max(ans, i);
            break;
        }
        pos = (int)(upper_bound(prefa.begin(), prefa.end(), now) - prefa.begin());
        pos--;
        ans = max(ans, i + pos);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11052
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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 REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

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

vector<lint> make_power(int n){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= 2;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint r, g, b, n;
    lint ans = 0;
    cin >> r >> g >> b >> n;
    REP(i, 4000){
        REP(j, 4000){
            lint ball_r = r * i;
            lint ball_g = g * j;
            lint ball_b = (n - ball_r - ball_g);
            if(0 <= ball_r && ball_r <= n && 0 <= ball_g && ball_g <= n && 0 <= ball_b && ball_b <= n && ball_r + ball_g + ball_b == n){
                if(ball_b % b == 0){ans++;}
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
from collections import defaultdict
N, W = map(int, input().split())
dp = defaultdict(int)
dp[0] = 0
for _ in range(N):
    w, v = map(int, input().split())
    for pw, pv in dp.copy().items():
        if pw + w <= W:
            dp[pw + w] = max(dp[pw + w], pv + v)

print(max(dp.values()))

Measured memory_bytes: 4008
#include <stdlib.h>
#include <stdio.h>

int main()
{int n,i;
char s[100001][11];
long long ans=0,counter[5]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%s",s[i]);
    }
    for(i=0;i<n;i++){
        if(s[i][0]=='M'){
            counter[0]++;
        }else if(s[i][0]=='A'){
            counter[1]++;
        }else if(s[i][0]=='R'){
            counter[2]++;
        }else if(s[i][0]=='C'){
            counter[3]++;
        }else if(s[i][0]=='H'){
            counter[4]++;
        }
    }
    ans+=counter[0]*counter[1]*counter[2];
    ans+=counter[0]*counter[1]*counter[3];
    ans+=counter[0]*counter[1]*counter[4];
    ans+=counter[0]*counter[2]*counter[3];
    ans+=counter[0]*counter[2]*counter[4];
    ans+=counter[0]*counter[3]*counter[4];
    ans+=counter[1]*counter[2]*counter[3];
    ans+=counter[1]*counter[2]*counter[4];
    ans+=counter[1]*counter[3]*counter[4];
    ans+=counter[2]*counter[3]*counter[4];
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABBQEasy solver = new ABBQEasy();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABBQEasy {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] l = new int[2 * n];
            for (int i = 0; i < 2 * n; i++) {
                l[i] = in.nextInt();
            }
            Arrays.sort(l);
            int ans = 0;
            for (int i = 0; i < 2 * n; i += 2) {
                ans += l[i];
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23124
# 左向きがw、 右がE
n = int(input())
sarr = input()
L = 'W'
R = 'E'

RtoL = 0
lead = sarr[0]
for s in sarr[1:]:
	if s == R:
		RtoL += 1

LtoR = 0

lowest = RtoL
for s in sarr[1:]:
	if lead == L:
		LtoR += 1
	if s == R:
		RtoL -= 1
	
	tmpres = LtoR + RtoL
	
	if tmpres < lowest:
		lowest = tmpres
	
	lead = s

print(lowest)
	

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

using namespace std;

string s;
int a[int(5e5) + 5];

int main() {
    cin >> s;

    a[0] = 0;

    int cnt_lst = 0;

    for(int i = 0;i < (int)s.size();i++){
        if(s[i] == '<'){
            cnt_lst++;
        }
        else{
            cnt_lst = 0;
        }
        a[i + 1] = cnt_lst;
    }

    cnt_lst = 0;

    for(int i = (int)s.size() - 1;i >= 0;i--){
        if(s[i] == '>'){
            cnt_lst++;
        }
        else{
            cnt_lst = 0;
        }
        a[i] = max(a[i],cnt_lst);
    }

    long long sum = 0;

    for(int i = 0;i <= (int)s.size();i++){
        sum += a[i];
    }

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 2820
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int count = 0;


void insertSort(int *A,int n,int g){
  int i,j;
  int key;
  for( i = g ; i < n ; i++){
    j = i;
    key = A[i];
    while( 0 <= j - g){
      if( A[j-g] <= key) break;
      A[j] = A[j-g];
      j -= g;
      count++;
    }
   A[j] = key;
 }
}


int main(){
  int n;
  int i,j;
  int *A;
  int G[20];

  scanf("%d", &n);
  A = malloc(n * sizeof(int));
  for( i = 0 ; i < n ; i++ ) scanf("%d", &A[i]);

  int m = 0;
  G[0] = 0;
  while(1){
    if( n < 3*G[m]+1) break;
    G[m+1] = 3*G[m] + 1;
    m++;
 }

 for( i = m ; i > 0 ; i--) insertSort(A,n,G[i]);

  printf("%d\n", m);
  for( i = m ; i >= 1 ; i-- ) printf("%d ", G[i]);
  printf("\n");
  printf("%d\n", count);

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

  return 0;
}



Measured memory_bytes: 5660
def main():
    N, M, K = map(int, input().split())
    for i in range(N+1):
        for j in range(M+1):
            b = M * i + N * j - (i * j) * 2
            if K == b:
                print("Yes")
                return
    print("No")


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

const ll INF=-100000;

//a,b x
int main(){
	ll H,W,D; cin>>H>>W>>D;
	vector<ll> d(H*W+1,0);
	vector<P> p(H*W+1);
	rep(i,H){
		rep(j,W){
			ll tmp; cin>>tmp;
			p[tmp]=mp(i,j);
		}
	}
	for(int i=D+1;i<=H*W;i++) d[i]=d[i-D]+abs(p[i].a-p[i-D].a)+abs(p[i].b-p[i-D].b);
	ll Q; cin>>Q;
	vector<ll> ans(Q);
	rep(i,Q){
		ll l,r; cin>>l>>r;
		ans[i]=d[r]-d[l];
	}
	rep(i,Q) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int x, y;
    cin>>x>>y;
    cout<<x + y/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A, B, C;
		A = new int[N];
		B = new int[N];
		C = new int[N-1];
		int x = 0;
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
		B[i] = sc.nextInt();
		x = x + B[i];
		}
		for(int i=0;i<N-1;i++) {
			C[i] = sc.nextInt();
		}
		for(int i=0;i<N-1;i++) {
			if(A[i+1]==A[i]+1) {
				x = x + C[A[i]-1];
			}
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 21716
#include <stdio.h>
int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a < b){
if(b < c){
printf("Yes\n");
}
else{
printf("No\n");
}
}
else{
printf("No\n");
}

return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll ll_mod=1e9+7;

int main(){
    ll n; cin >> n;
    ll ans=0;
    for(ll i=0; i<n; i++){
        ll im=i+1;
        ll k=n/im;
        ans += k*(k+1)*im/2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
    S[++top]=x;
}

int pop() {
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    top=0;
    char s[100];
    
    while(scanf("%s", s) != EOF) {
        if (s[0]=='+') {
            a=pop();
            b=pop();
            push(b+a);
        }
        else if (s[0]=='-') {
            a=pop();
            b=pop();
            push(b-a);
        }
        else if (s[0]=='*') {
            a=pop();
            b=pop();
            push(b*a);
        }
        else {
            push(atoi(s));
        }
    }
    
    printf("%d\n", pop());
    
    return 0;
}


Measured memory_bytes: 2760
# frozen_string_literal: true

h, w = gets.split.map(&:to_i)
s = Array.new(h) { gets.chomp.chars }

s.unshift Array.new(w) { nil }
s << Array.new(w) { nil }
s.each { |e| e.unshift nil }

s.each_cons(3) do |lines|
  lines[1][1..-1].each_with_index do |c, idx|
    if c == '#'
      print '#'
    else
      print lines.map { |l| l[idx..(idx + 2)].count('#') }.inject(:+)
    end
  end

  puts ''
end

Measured memory_bytes: 2172
n, k = map(int, input().split())
x = list(map(int, input().split()))
result = 10**9
for i in range(n - (k-1)):
    temp = x[i+k-1] - x[i]
    result = min(result, temp + abs(x[i+k-1]), temp + abs(x[i]))
print(result)

Measured memory_bytes: 14224
using System;

class Program{
	public static void Main(){
		string[] str = Console.ReadLine().Split('/');
		int a = int.Parse(str[2]);
		if (a>=10)
			Console.WriteLine("2018/01/{0}",a);
		else
			Console.WriteLine("2018/01/0{0}",a);
	}
}

Measured memory_bytes: 13140
import heapq

n, m = [int(i) for i in input().split()]
U = [[int(i) for i in input().split()] for j in range(m)]
s, t = [int(i) for i in input().split()]

E = [[] for i in range(n + 1)]

for u, v in U:
    E[u].append(v)

visited = [[False] * 3 for i in range(n + 1)]

V = []
heapq.heappush(V, (0, s))

while V:
    c, v = heapq.heappop(V)
    if v == t and c % 3 == 0:
        print(c // 3)
        exit()
    if visited[v][c % 3]:
        continue
    visited[v][c % 3] = True

    for to in E[v]:
        heapq.heappush(V, (c + 1, to))

print(-1)

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<int> tmpe, tmpo;
  for (int i = 0; i < n; i += 2) tmpe.push_back(a[i]);
  for (int i = 1; i < n; i += 2) tmpo.push_back(a[i]);

  sort(tmpe.begin(), tmpe.end());
  sort(tmpo.begin(), tmpo.end());

  vector<P> e, o;
  int cnt = 1;
  for (int i = 0; i < tmpe.size() - 1; i++) {
    if (tmpe[i] != tmpe[i+1]) {
      e.push_back(P(cnt, tmpe[i]));
      cnt = 0;
    }
    cnt++;
  }
  e.push_back(P(cnt, tmpe[tmpe.size()-1]));
  cnt = 1;
  for (int i = 0; i < tmpo.size() - 1; i++) {
    if (tmpo[i] != tmpo[i+1]) {
      o.push_back(P(cnt, tmpo[i]));
      cnt = 0;
    }
    cnt++;
  }
  o.push_back(P(cnt, tmpo[tmpo.size()-1]));
  e.push_back(P(0, -1));
  o.push_back(P(0, -1));
  sort(e.begin(), e.end());
  sort(o.begin(), o.end());

  int ediff = n / 2 - e[e.size()-1].first;
  int odiff = n / 2 - o[o.size()-1].first;
  if (e[e.size()-1].second == o[o.size()-1].second) {
    if (e[e.size()-2].first < o[o.size()-2].first) {
      odiff = n / 2 - o[o.size()-2].first;
    } else {
      ediff = n / 2 - e[e.size()-2].first;
    }
  }

  // 解答
  cout << ediff + odiff << endl;
  return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,i,a;
	t = 1;
	while(t--) {
     a = 0;
	 cin >> n;
	 int arr[n];
     for(i = 0; i < n; i++)
      cin >> arr[i];
     if(n % 2) {
      cout << a << endl;
      continue;
	 }
     sort(arr, arr + n);
     a = arr[n / 2] - arr[n / 2 - 1];
     cout << a << endl;
	}
	return 0;
}



Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
using ll = long long;
int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a + b) cout << min(a,k) << endl;
  else cout << a - (k - a - b) << endl;
  return 0;
}


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

int main()
{
	int a,b,sum,i,ara[100001],cnt;
	while(scanf("%d %d",&a,&b)==2)
	{
		sum = 0;
		for(i=0;i<a;i++)
		{
			scanf("%d",&ara[i]);
		}
		sort(ara,ara+a);
		cnt = 0;
		for(i=a-1;i>=0;i--)
		{
			cnt++;

			sum = sum + ara[i];
			if(cnt==b)
				break;
		}
		printf("%d\n",sum);
	}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s[0]!='A') cout<<"WA\n";
    else if(s.find('C')==string::npos) cout<<"WA\n";
    else if(s.find('C')<2||s.find('C')>=s.length()-1) cout<<"WA\n";
    else
    {
        int lc_num=0;
        for(int i=0; i<s.length(); i++)
        {
            if(s[i]>='a'&&s[i]<='z') lc_num++;
        }
        if(lc_num==s.length()-2) cout<<"AC\n";
        else cout<<"WA\n";
    }
	return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void calc() {

	Int N; std::cin >> N;
	std::cout << pow(2, (Int)log2(N));

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N,M;
int res;
int main() {
  cin >> N >> M;
  for (int bit = 0; bit < (1 << M); bit++){
    res += 1900 * M + (N - M) * 100;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256