akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
int main(){
    ll n; cin >> n;

    ll max_ = 0, sum_ = 0;
    rep(i,n){
        ll p; cin >> p;
        chmax(max_, p);
        sum_ += p;
    }
    sum_ -= max_;
    sum_ += (max_ / 2);

    cout << sum_ << endl;
}

Measured memory_bytes: 256
t1,n1=map(int,input().split())
t2,n2=map(int,input().split())
t3,n3=map(int,input().split())
t4,n4=map(int,input().split())

if t1==1:
    t1=6000
elif t1==2:
    t1=4000
elif t1==3:
    t1=3000
else:
    t1=2000
    
if t2==1:
    t2=6000
elif t2==2:
    t2=4000
elif t2==3:
    t2=3000
else:
    t2=2000
    
if t3==1:
    t3=6000
elif t3==2:
    t3=4000
elif t3==3:
    t3=3000
else:
    t3=2000
    
if t4==1:
    t4=6000
elif t4==2:
    t4=4000
elif t4==3:
    t4=3000
else:
    t4=2000
    
print(t1*n1)
print(t2*n2)
print(t3*n3)
print(t4*n4)


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

using namespace std;

#define ll long long int

int main() 
{
    ll x,y,a,b,c,i,j,k,z,ans=0,p=0,q=0,temp;
    cin>>x>>y>>a>>b>>c;
    ll r[a+5],g[b+5],co[c+5];
    for(i=0;i<a;i++)
        cin>>r[i];
    for(i=0;i<b;i++)
        cin>>g[i];
    for(i=0;i<c;i++)
        cin>>co[i];
    co[i]=0;
    sort(r,r+a,greater<ll>());
    sort(g,g+b,greater<ll>());
    sort(co,co+c,greater<ll>());
    i=0;
    j=0;
    k=0;
    r[x]=-1;
    g[y]=-1;
    for(z=0;z<x+y;z++)
    {
        temp=max(max(r[i],g[j]),co[k]);
        ans+=temp;
        if(temp==r[i])
            i++;
        else if(temp==g[j])
            j++;
        else
            k++;
    }
    cout<<ans<<"\n";
    return 0;    
}

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

int main(){
	int a,b,t;



	while(1){
		cin >> a >> b;

		if(a==0 && b==0)
			break;

		if(a>b){
			t=a;
			a=b;
			b=t;
		}
		cout<<a<<" "<<b<<endl;
	}

	return 0;
}

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

int main(){
	int n,j=0;
	int sum1=0,sum2=0,sum,cnt=0;
	string str1,str2,ans;

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> str1 >> str2; 
		//cout << "str1=" << str1 << " " << "str2=" << str2 << endl;
	

		for(int i=0;i<str1.size();i++){
			if(str1[i]=='m'){
				if(i==0){
					sum1 = 1000; 
				} else {
					//cout << "str1[i-1]-'0'=" << str1[i-1]-'0' << endl; 
					sum1 = sum1 + 1000 * (str1[i-1]-'0');
				}
			}
	
			if(str1[i]=='c'){
				if(i==0||str1[i-1]=='m'){
					sum1 = sum1 + 100; 
				} else {
					//cout << "str1[i-1]-'0'=" << str1[i-1]-'0' << endl;
					sum1 = sum1 + 100 * (str1[i-1]-'0');
				}
			}

			if(str1[i]=='x'){
				if(i==0||str1[i-1]=='m'||str1[i-1]=='c'){
					sum1 = sum1 + 10; 
				} else {
					//cout << "str1[i-1]-'0'=" << str1[i-1]-'0' << endl;
					sum1 = sum1 + 10 * (str1[i-1]-'0');
				}
			}

			if(str1[i]=='i'){
				if(i==0||str1[i-1]=='m'||str1[i-1]=='c'||str1[i-1]=='x'){
					sum1 = sum1 + 1; 
				} else {
					sum1 = sum1 + 1 * (str1[i-1]-'0');
				}
			}
			//cout << "i=" << i << " " << "str1[i]=" << str1[i] << endl;
			//if(i!=0) cout << "str1[i-1]-'0'=" << str1[i-1]-'0' << endl;
			//cout << "sum1=" << sum1 << endl;
		}

		for(int i=0;i<str2.size();i++){
			if(str2[i]=='m'){
				if(i==0){
					sum2 = 1000; 
				} else {
					//cout << "str2[i-1]-'0'=" << str2[i-1]-'0' << endl; 
					sum2 = sum2 + 1000 * (str2[i-1]-'0');
				}
			}

			if(str2[i]=='c'){
				if(i==0||str2[i-1]=='m'){
					sum2 = sum2 + 100; 
				} else {
					//cout << "str2[i-1]-'0'=" << str2[i-1]-'0' << endl;
					sum2 = sum2 + 100 * (str2[i-1]-'0');
				}
			}

			if(str2[i]=='x'){
				if(i==0||str2[i-1]=='m'||str2[i-1]=='c'){
					sum2 = sum2 + 10; 
				} else {
					//cout << "str2[i-1]-'0'=" << str2[i-1]-'0' << endl;
					sum2 = sum2 + 10 * (str2[i-1]-'0');
				}
			}

			if(str2[i]=='i'){
				if(i==0||str2[i-1]=='m'||str2[i-1]=='c'||str2[i-1]=='x'){
					sum2 = sum2 + 1; 
				} else {
					sum2 = sum2 + 1 * (str2[i-1]-'0');
				}
			}
			//cout << "i=" << i << " " << "str2[i]=" << str2[i] << endl;
			//if(i!=0) cout << "str2[i-1]-'0'=" << str2[i-1]-'0' << endl;
			//cout << "sum2=" << sum2 << endl;
		}

		sum = sum1 + sum2;

		while(1000<=sum){
			sum = sum - 1000;
			cnt++;
		}
		if(1<cnt){
			ans += (cnt + '0');
			ans += 'm';
		} else if(cnt==1){
			ans += 'm';

		}
		cnt=0;

		while(100<=sum){
			sum = sum - 100;
			cnt++;
		}
		if(1<cnt){
			ans += (cnt + '0');
			ans += 'c';
		} else if(cnt==1){
			ans += 'c';
		}
		cnt=0;

		while(10<=sum){
			sum = sum - 10;
			cnt++;
		}
		if(1<cnt){
			ans += (cnt + '0');
			ans += 'x';
		} else if(cnt==1){
			ans += 'x';
		}
		cnt=0;

		while(1<=sum){
			sum = sum - 1;
			cnt++;
		}
		if(1<cnt){
			ans += (cnt + '0');
			ans += 'i';
		} else if(cnt==1){
			ans += 'i';
		}
		cnt=0;

		cout << ans << endl;
		ans.clear();
		sum1=0,sum2=0,sum=0;
		str1.clear();
		str2.clear();
		ans.clear();

	}

	return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };
int a[100006];

int modpow(int x, int n, int md) {
	if (!n)return 1;
	int res = modpow(x*x%md, n / 2, md);
	if (n & 1)res = res*x%md;
	return res;
}

int fsum[100005];

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	for (int i = 1; i <= n; i++) {
		fsum[i] = modpow(i, mod - 2, mod);
	}
	for (int i = 1; i < n; i++) {
		fsum[i + 1] += fsum[i];
		fsum[i + 1] %= mod;
	}
	int ans = 0;

	rep(i, n) {
		int l = i+1, r = n - i;
		ans += (fsum[r]+fsum[l]-1) * a[i];
		ans %= mod;
	}
	rep(i, n)ans = ans*(i + 1) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int sum=0;
int main()
{
  int i,j,n,minj,buf;
  int A[100];

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  
  for(i=0;i<n;i++){
	minj=i;
	for(j=i;j<n;j++)if(A[j] < A[minj])minj=j;
	
	if(i!=minj){buf=A[i];A[i]=A[minj];A[minj]=buf;sum++;}
  }//i
  for(i=0;i<n;i++){printf("%d",A[i]);
	if(i==n-1)printf("\n");
	else printf(" ");}
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2148
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

R = [0] * (N + 1)

for a, b in AB:
    R[a] += 1
    R[b] += 1

for i in range(1, N + 1):
    print(R[i])


Measured memory_bytes: 3060
import itertools

def sieve(n):
    is_prime = [True for _ in range(n)]
    is_prime[0] = False
    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return table
  
prime = sieve(10**5)
acu = [0] * ((10**5)//2+5)
for i in range(1,(10**5)//2+5):
    k = (i-1) * 2 +1
    if k in prime and (k+1)//2 in prime:
        acu[i] = acu[i-1] + 1
    else:
        acu[i] = acu[i-1]

q = int(input())

for i in range(q):
    l,r = map(int,input().split())
    li = (l-1) // 2
    ri = (r-1) // 2
    print(acu[ri+1]-acu[li])

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

int main()
{
    int r, g, b, N;
    cin >> r >> g >> b;

    N = r*100 + g*10 + b;

    if (N%4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl; 
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#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(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}
int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N,M,X,Y;
	cin>>N>>M>>X>>Y;

	int x,y,maxX=-INF,minY=INF;
	REP(i,N){
		cin>>x;
		chmax(maxX,x);
	}

	REP(i,M){
		cin>>y;
		chmin(minY,y);
	}

	if((X<maxX)&&(Y>minY)&&(maxX<minY)) 
		print("No War");
	else 
		print("War");
	return 0;
}


Measured memory_bytes: 256
import sys
def main():
	n=int(input()) 
	idx=[] 
	c=0 
	for i in range(n):
		x,y=map(int,input().split()) 
		if x==y:
			idx.append(c) 
		c+=1  
	if len(idx)<3:
		print('No') 
	else:
		flag=False 
		#print(idx)
		for i in range(len(idx)-2): 
			if idx[i]-idx[i+1]==-1 and idx[i+1]-idx[i+2]==-1:
				flag=True  
				break 
		dd={False:'No',True:'Yes'}
		print(dd[flag])
 
try:
	sys.stdin = open('INP01.txt', 'r')  

	# Printing the Output to output.txt file 
	sys.stdout = open('out.txt', 'w')   
	main() 
except:
	main() 


Measured memory_bytes: 62684
#include <iostream>
 
#define ll long long
 
using namespace std;
 
ll a[50];
 
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  for(int i = 0; i < 50; i++)
    a[i] = i;
  
  ll k;
  cin >> k;
  
  int n = 50;
  ll complete_operations = k/n;
  
  //50回毎に1減るから
  for(int i = 0; i < 50; i++)
    a[i] += complete_operations;
  
  int rem = k % n;
 
  for(int i = 0; i < 50 && rem > 0; i++)
  {
    a[i] += n +1;
    
    for(int j = 0; j < 50; j++)
      a[j]--;
        
    rem--;
  }   
  
  cout << n << '\n';
  for(int i = 0; i < n; i++)
    cout << a[i] << ' ';
  cout << '\n';
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <set>

using namespace std;

using intll_t = long long;

intll_t mergeCounting(vector<int>& inOutList) {
    if (inOutList.size() == 0) {
        throw exception();
    }
    if (inOutList.size() == 1) {
        return 0;
    }
    int formerLen = floor(inOutList.size() / 2);
    vector<int> former, latter;
    former.reserve(formerLen);
    latter.reserve(inOutList.size() - formerLen);
    copy(inOutList.begin(), inOutList.begin() + formerLen, back_inserter(former));
    copy(inOutList.begin() + formerLen, inOutList.end(), back_inserter(latter));
    intll_t transCnt = 0;
    transCnt += mergeCounting(former);
    transCnt += mergeCounting(latter);
    auto formerIt = former.begin();
    auto latterIt = latter.begin();
    auto outIt = inOutList.begin();
    while (outIt != inOutList.end()) {
        int formerVal = (formerIt == former.end()) ? numeric_limits<int>::max() : *formerIt;
        int latterVal = (latterIt == latter.end()) ? numeric_limits<int>::max() : *latterIt;
        if (formerVal < latterVal) {
            *outIt = formerVal;
            ++formerIt;
        } else {
            *outIt = latterVal;
            ++latterIt;
            transCnt += distance(formerIt, former.end());
        }
        ++outIt;
    }
    return transCnt;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> ais;
    ais.reserve(n);
    for (int i = 0; i < n; i++) {
        int number;
        scanf("%d", &number);
        ais.push_back(number);
    }
    intll_t cnt = mergeCounting(ais);
    printf("%lld", cnt);
    printf("\n");
    return 0;
}


Measured memory_bytes: 5336
#include <bits/stdc++.h>
#define ll long long
#define make_pair mp
const int MAX=1e5+10;
using namespace std;

int main(){
  ll Q;
  cin>>Q;
  ll l[Q],r[Q];
  for(ll i=0;i<Q;i++) cin>>l[i]>>r[i];
  vector<int> N(MAX,1);
  N[0]=0;
  N[1]=0;
  for(ll i=2;i<MAX;i++){
    if(!N[i]) continue;
    else{
      for(ll j=i*2;j<MAX;j+=i) N[j]=0;
    }
  }
  vector<int> A(MAX,0);
  for(ll i=0;i<MAX;i++){
    if(N[i]==1&&N[(i+1)/2]==1) A[i]=1;
  } 
  for(ll i=1;i<MAX;i++) A[i]+=A[i-1];
  for(ll i=0;i<Q;i++){
    cout<<A[r[i]]-A[l[i]-1]<<endl;
  }
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, pt=0, t, px=0, x, py=0, y, d;
  cin >> n;
  
  forll(i, 0, n){
	cin >> t >> x >> y;
	d = abs(x-px) + abs(y-py);
	if ((d > (t - pt)) || ((t - pt - d) % 2 == 1)){
	  cout << "No" << endl;
	  return 0;
	}
	px = x;
	py = y;
	pt = t;
  }
  cout << "Yes" << endl;
}


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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  LL n; cin >> n;
  LL ans = 2 * (n / 11);
  n %= 11;
  ans += (n > 0) + (n > 6);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	string a,b;

	cin>>a>>b;
	map<char,int>wa1,wa2;
	
	for(auto x : a )wa1[x]++;
	for(auto x : b)wa2[x]++;
	std::vector<int> occ1(sz(a)+1),occ2(sz(a)+1);
	for(auto p : wa1){
		occ1[p.second]++;
	}
	for(auto p : wa2)occ2[p.second]++;

	for(int i=1;i<=sz(a);i++){
		if(occ2[i]!=occ1[i]){
			return cout<<"No\n",0;
		}
	}
	cout<<"Yes\n";
}		



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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N;
	cin >> N;
	int s = 0;
	while(N) {
		s += N % 10 == 2;
		N /= 10;
	}
	cout << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 
    int entry_sell,entry_buy;
    int entry_tanka[1000];
    int i,j,min,sum,index;
    
    //入力
    scanf("%d",&entry_sell);
    scanf("%d",&entry_buy);
    
    for(i=0; i<entry_sell; i++){
        scanf("%d",&entry_tanka[i]);
    }
    
    sum=0;
    for(i=0;i<entry_buy; i++){
        
        //最小単価を探す
        min=entry_tanka[0];
        index=0;
        for(j=1; j<entry_sell;j++){
            if(entry_tanka[j]<min){
                min = entry_tanka[j];
                index=j;
            }
        }
        //tanka[index]が最小なので買う
        sum = sum+min;
        for(j=index; j<entry_sell; j++){
            entry_tanka[j]=entry_tanka[j+1];
        }
        entry_tanka[entry_sell]='\0';
        entry_sell--;
    }
    
    printf("%d\n",sum);
    
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;int mx=0,tmp=0,last;
	cin>>last;
	for (int x=1;x<n;x++){
		int a;cin>>a;
		if(a>last)tmp=0;
		else if(a<=last)tmp++;
		if(tmp>mx){
			mx=tmp;
		}
		last=a;
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(string, S);
  
  if(S.size() % 2) fin("No");
  else {
    for (int i = 0; i < S.size() / 2; i++)
    {
      if(S[i*2] != 'h' || S[i*2+1] != 'i') {
        fin("No");
        return 0;
      }
    }
    fin("Yes");
    
  }
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    uli n,sum=0;
    cin >> n;
    rep(i, 1, n + 1) {
        if(i % 15 == 0) {
            continue;
        }
        else if(i % 3 == 0)
            continue;
        else if(i % 5 == 0)
            continue;
        else
            sum += i;
    }
    cout << sum << endl;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    if(a > 9 || b > 9)
        cout << "-1";
    else
        cout << a * b;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int[][] map = new int[n][n];
			ArrayList<Integer> list = new ArrayList<Integer>();
			
			int min;
			for(int i=0;i<n;i++){
				min = Integer.MAX_VALUE;
				for(int j=0;j<n;j++){
					map[i][j] = sc.nextInt();
					min = Math.min(min, map[i][j]);
				}
				list.add(min);
			}
			
			int max;
			int ans = 0;
			for(int i=0;i<n;i++){
				max = 0;
				for(int j=0;j<n;j++){
					max = Math.max(max, map[j][i]);
				}
				if(list.contains(max)==true){
					ans = max;
					break;
				}
			}
			System.out.println(ans);
		}
	}	
}

Measured memory_bytes: 19464
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool ok = true;
    if(s[0] != 'A'){
        ok = false;
    }
    auto pos = s.substr(2, s.size() - 3).find("C");
    if(pos == string::npos){
        ok = false;
    }
    for(auto& c : s){
        if(isupper(c) && &c != &s[0] && &c != &s[pos + 2]){
            printde(c);
            ok = false;
        }
    }
    cout << (ok ? "AC" : "WA") << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		final int N = Integer.parseInt(in.next());
		final int K = Integer.parseInt(in.next());
		final int C = Integer.parseInt(in.next());
		final String S = in.next();
		int[] right_count = new int[N];
		int cnt = N - 1;
		int right_range = 0;
		while(cnt >= 0) {
			if(S.charAt(cnt) == 'o') {
				right_range += 1;
				right_count[cnt] = right_range;
				for(int i = 0; i < C; i++) {
					cnt -= 1;
					cnt = Math.max(0, cnt);
					right_count[cnt] = right_range;
				}
			}else{
				right_count[cnt] = right_range;
			}
			cnt -= 1;
		}
		int range_seen = 0;
		List<Integer> ans = new ArrayList<Integer>();
		if(right_range == K) {
			cnt = 0;
			while(cnt < N) {
				if(S.charAt(cnt) == 'o') {
					range_seen += 1;
					ans.add(cnt + 1);
					boolean flag = false;
					for(int i = 0; i < C; i++) {
						cnt += 1;
						if(cnt < N) {
							if((S.charAt(cnt) == 'o') && (cnt + C + 1 < N)) {
								if(right_count[cnt + C + 1] == K - range_seen) flag = true;
							}else if((S.charAt(cnt) == 'o') && (range_seen == K)) flag = true;
						}
					}
					if(flag == true) {
						ans.remove(ans.size() - 1);
					}
				}
				cnt += 1;
			}
		}
		for(int i = 0; i < ans.size(); i++) 
			System.out.println(ans.get(i));
	}
}

Measured memory_bytes: 46468
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  int x[5];
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
    if (x[i] == 0) ans = i + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/env python

def main():
    N = int(input())
    D = list(map(int, input().split()))
    ans = 0
    for i in range(N-1):
        d1 = D[i]
        for d2 in D[i+1:]:
            ans += d1 * d2

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

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

	private void execute() {
		Scanner sc = new Scanner(System.in);
		final int X = sc.nextInt();
		final int Y = sc.nextInt();
		System.out.println((X+Y/2));
		sc.close();
	}
}


Measured memory_bytes: 23252
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int K = sc.nextInt();
    int mx = A;
    if(mx < B) {
      mx = B;
    }
    if(mx < C) {
      mx = C;
    }
    System.out.println(A + B + C + mx * ((1 << K) - 1));
  }
}

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

int bubblesort(int A[], int N) {
 int sw =0;
 bool flag = 1;
 for ( int i = 0; flag; i++ ) {
   flag = 0;
   for ( int j = N - 1; j >= i + 1; j-- ) {
     if ( A[j] < A[j - 1] ) {
       swap( A[j], A[j - 1] ) ;
       flag = 1;
       sw++;
     }
   }
 }
 return sw;
}

int main() {
 int A[100], N, sw;
 cin >> N;
 for ( int i = 0; i < N; i++ ) cin >> A[i];

 sw = bubblesort(A, N);

 for ( int i = 0; i < N; i++ ) {
   if (i) cout << " ";
   cout << A[i];
  }
  cout << endl;
  cout << sw << endl;


  return 0;
} 


Measured memory_bytes: 3116
import java.util.*;

class Main{
    public static void main(String[] args) {
      
        Scanner scan = new Scanner(System.in);
        int[] x = new int[30];
        int t=0,j,count=0;
        
        
        while(scan.hasNextInt()){
        	count = 0;
			int lim = scan.nextInt();
        	int ptr = 0; //?????????????´???°?????°
        	int[] prime = new int[500000]; //?´???°???????´?????????????
        	
        	if(lim >= 2){
        		prime[ptr++] = 2; 
        		count++;
        	}
        	if(lim >= 3){
				prime[ptr++] = 3; 
				count++;
			}
			
        	for (int n = 5; n <= lim; n += 2) { 
        	    boolean wflag = false; 
        	    for (int i = 1; prime[i] * prime[i] <= n; i++) {
              
            	    if (0 == n % prime[i]) {
                    	wflag = true;
                    	break;
                	}
            	}
            	if (!wflag) { 
                	prime[ptr++] = n; 
                	count++; 
            	}
        	}
        	x[t] = count;
        
        	t++;
        	
		}
        	for (j=0; j<t;j++)  {
            System.out.println(x[j]);
            }
    }
}

Measured memory_bytes: 56132
import sys
input = sys.stdin.readline
from bisect import bisect_left as bl
N, M = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

S = sorted(A)
D = {a: i for i, a in enumerate(S)}

BB = [0] * (N+1)
for i in range(N):
    BB[D[A[i]] + 1] = B[i]

for i in range(1, N+1):
    BB[i-1] ^= BB[i]

A = [D[a] for a in A]
X = [[] for _ in range(N+1)]
DD = {}
for i in range(M):
    l, r = map(int, input().split())
    l = bl(S, l)
    r = bl(S, r+1)
    X[l].append(r)
    X[r].append(l)
    DD[(l<<18) + r] = i
    DD[(r<<18) + l] = i

Q = [i for i in range(N+1)]
P = [-1] * (N+1)
R = []
while Q:
    i = Q.pop()
    if P[i] < 0:
        R.append(i)
    for j in X[i]:
        if P[j] >= 0: continue
        if j != P[i]:
            R.append(j)
            P[j] = i
            Q.append(j)

ANS = []
for i in R[1:][::-1]:
    if BB[i]:
        BB[i] ^= 1
        BB[P[i]] ^= 1
        if P[i] < 0:
            print(-1)
            break
        ANS.append(DD[(i<<18) + P[i]] + 1)
else:
    print(len(ANS))
    print(*sorted(ANS))


Measured memory_bytes: 120576
import java.util.*;
import java.io.*;

class Main {

	void solve () {

		HashMap<String, String> map = new HashMap<>();
		map.put("Sunny", "Cloudy");
		map.put("Cloudy", "Rainy");
		map.put("Rainy", "Sunny");
		System.out.println(map.get(in.next()));
		
	}

	public static PrintWriter out = new PrintWriter(System.out);
	public static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

}

Measured memory_bytes: 19796
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int N = 0,S = 0,E = 0,W = 0;
		String s = scanner.nextLine();
		for(int i = 0; i < s.length(); i++){
			if (s.charAt(i) =='N') {
				N++;
			}else if (s.charAt(i) =='E'){
				E++;
			}else if (s.charAt(i) =='W'){
				W++;
			}else if (s.charAt(i) =='S'){
				S++;
			}
		}
		if(((N >= 1 && S >= 1) || (N == 0 && S == 0)) && ((W >= 1 && E >= 1) || (W == 0 && E == 0))){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 9428
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

point [a,b,c,d] [i,y] = a * i + b * y + c * (i `div` 10) + d * (y `div` 20)

res GT = "hiroshi"
res LT = "kenjiro"
res EQ = "even"

main = do
    h <- getInts
    k <- getInts
    s <- getInts
    putStrLn $ res $ comparing (point s) h k
    



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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    while(b<=a){
    	b*=2,k--;
    }
    while(c<=b){
    	c*=2,k--;
    }
    if(k>=0)cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3644
import java.io.*;
import java.util.*;


public class Main {

    private static BufferedReader br;
    private static StreamTokenizer st;
    private static PrintWriter pw;

    static final int INF = 1000000007;
    static final int MOD = 1000000007;

    private static void solve() throws IOException {
        long a = nextInt();
        long b = nextInt();
        long c = Math.abs(a - b);
        if (c % 2 == 1) {
            pw.println("IMPOSSIBLE");
        } else {
            pw.println(Math.min(a, b) + c / 2);
        }
    }

    static long gcd(long a, long b) {
        if (a < b) {
            a ^= b;
            b ^= a;
            a ^= b;
        }
        while (b != 0) {
            long t = a % b;
            a = b;
            b = t;
        }
        return a;
    }

    static long inv(long t, long p) {
        return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p;
    }

    public static void main(String args[]) throws IOException {
//        System.out.println(System.getProperty("java.library.path"));

//        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
//        if (!oj) {
//            System.setIn(new FileInputStream("src/in.txt"));
//            System.setOut(new PrintStream("out.txt"));
//        }
        br = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(br);
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        st.ordinaryChar('\'');
        st.ordinaryChar('\"');
        st.ordinaryChar('/');

//        long t = System.currentTimeMillis();
        solve();
//        if (!oj) {
//            pw.println("[" + (System.currentTimeMillis() - t) + "ms]");
//        }
        pw.flush();
    }

    private static long[] anLong(int n) throws IOException {
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    private static String next(int len) throws IOException {
        int b = br.read();
        while (b == '\n' || b == ' ' || b == '\r' || b == '\t') {
            b = br.read();
        }
        char ch[] = new char[len];
        ch[0] = (char) b;
        int idx = 1;
        while (idx < len && (b = br.read()) != ' ' && b != '\n' && b != '\r' && b != '\t') {
            ch[idx++] = (char) b;
        }
        return String.valueOf(ch).trim();
    }

    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(nextLine());
    }

    private static double nextDouble() throws IOException {
        st.nextToken();
        return st.nval;
    }

    private static String[] nextSS(String reg) throws IOException {
        return br.readLine().split(reg);
    }

    private static String nextLine() throws IOException {
        return br.readLine();
    }
}

Measured memory_bytes: 23124
import java.util.Scanner

object Main {
  def solve(): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextLong()
    val K = sc.nextLong()
    val sum = K match {
      case 0 => N * N
      case _ => ((K + 1 to N) map { b =>
        (N / b) * (b - K) + math.max(N % b - K + 1, 0)
      }).sum
    }
    println(sum)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }
}


Measured memory_bytes: 39320
#include <cstdio>

using namespace std;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a==b && b==c) {
        printf("1\n");
    } else if (a==b || b==c || c==a) {
        printf("2\n");
    } else {
        printf("3\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>

const int W_MAX = 30;
const int N_MAX = 30;

int w;
int n;
int a[N_MAX + 1];
int b[N_MAX + 1];
int out[W_MAX + 1];

void chenge(int *farst, int *second){
	int tmp;
	tmp = *farst;
	*farst = *second;
	*second = tmp;
}

int main(void){
	scanf("%d", &w);
	scanf("%d", &n);

	for(int i = 0; i <= w; i++){
		out[i] = i;
	}

	for(int i = 1; i <= n; i++){
		scanf("%d,%d", &a[i], &b[i]);
		chenge(&out[a[i]], &out[b[i]]);
	}
	
	for(int i = 1; i <= w; i++){
		printf("%d\n", out[i]);
	}

	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ABC140A
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            Console.WriteLine(N * N * N);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int s=0;
int upper;
int N;
int T[51];
int dp[51][900][900];

int dfs(int idx,int a,int b) {
    if(idx==N) {
        int t=max({a,b,s-a-b});
        return t;
    }
    if(dp[idx][a][b]!=-1) return dp[idx][a][b];
    int ret=dfs(idx+1,a,b);
    if(upper>a+T[idx]) ret=min(ret,dfs(idx+1,a+T[idx],b));
    if(upper>b+T[idx]) ret=min(ret,dfs(idx+1,a,b+T[idx]));
    return dp[idx][a][b]=ret;
}

int main() {
    memset(dp,-1,sizeof(dp));
    cin>>N;
    rep(i,N) cin>>T[i];
    rep(i,N) s+=T[i];
    upper=s/3+51;
    cout<<dfs(0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 164484
#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;

template<typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}
int n;
const int maxn = 110;
int sum = 0;
int s[maxn];
void solve() {
  cin >> n;
  rep(i,0,n)
  {
    cin >> s[i];
    sum += s[i];
  }
  if (sum % 10 != 0) {
    cout << sum << endl;
    return;
  } else {
    sort(s, s + n);
    rep(i,0,n)
    {
      if (s[i] % 10 == 0) {
        continue;
      } else {
        cout << sum - s[i] << endl;
        return;
      }
    }
    cout << 0 << endl;
    return;
  }
}

int main() {
  solve();
  return 0;
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    vector<vector<char>>a(h+2,vector<char>(w+2,'#'));

    rep2(i,1,h){
        rep2(j,1,w)cin>>a[i][j];
    }


    rep(i,h+2){
        rep(j,w+2)cout<<a[i][j];
        cout<<endl;
    }

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], l = tmp[1];

	int sum = 0;
	int min = 100000;

	for (int i = 1; i <= n; i++)
	{
	    int taste = l + i - 1;

	    if (Math.Abs(min) > Math.Abs(taste))
	    {
		min = taste;
	    }
	    min = Math.Min(min, Math.Abs(taste));
	    sum += taste;
	}

	int ans = sum - min;
	WriteLine(ans);
    }
}


Measured memory_bytes: 13396
n=int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

addc = []
for i in range(n-1):
    if a[i+1] == a[i]+1:
        addc.append(c[a[i]-1])
ans = sum(b)+sum(addc)
print(str(ans))

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

using namespace std;

#define FOR(i,l,r) for( int i = l ; i < r; i++ )

int mod = 1e9+7;

void addMod( int & a, int b ) {
    a += b;
    if( a >= mod ) a -= mod;
}

void subMod( int & a, int b ) {
    a -= b;
    if( a < 0 ) a += mod;
} 

int main() {
    int n; cin>>n;
    int k; cin>>k;
    int dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    FOR(i,0,n) {
        int ma; cin>>ma;
        int fake[k+1];
        memset(fake,0,sizeof(fake));
        for( int j = k-1; j >= 0; j-- ) {
            int left = k-j;
            int L = j+1;
            int R = j+min(left,ma);
            addMod(fake[L],dp[j]);
            if( R+1 < k+1 ) subMod(fake[R+1],dp[j]);
        }
        for( int j = 1; j < k+1; j++ ) addMod(fake[j],fake[j-1]);
        for( int j = 0; j < k+1; j++ ) addMod(dp[j],fake[j]); 
    }
    cout<<dp[k]<<"\n";
    return 0;   
}		

Measured memory_bytes: 1024
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//////////////////////////////////
int n;
#define MAX_N 200010
int a[MAX_N];
int b[MAX_N];
int p[MAX_N];
set<int> s;
//////////////////////////////////

int main(void){
   cin >> n;
   rep(i,n){ scanf("%d",&a[i]);}
   rep(i,n){
      b[--a[i]] = i;
   }
   rep(i,n) s.insert(i);
   
   s.insert(-1);
   s.insert(n);
   
   ll ans = 0;
   for(int i = n-1;i >= 0;i--){
      /*for(auto i : s) cout << i << " ";
      cout << endl;*/
      
      ll left = *(s.find(b[i])) - *(--s.find(b[i]));
      ll right = *(++s.find(b[i])) - *(s.find(b[i]));
      //cout << left << " " << right << endl;
      ans += (i + 1)*left*right;
      
      s.erase(b[i]);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int n;
vector<pair<int, int>> vp;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    vp.resize(n);
    rep(i, n)
    {
        int s, t;
        cin >> s >> t;
        vp.emplace_back(t, s);
    }
    sort(vp.begin(), vp.end());
    int last = 0, cnt = 0;
    for (auto p : vp) {
        if (last < p.second) {
            last = p.first;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++) cin>>a[i];
  
  ll m=0;
  ll f;
  for(i=0;i<n;i++){
    m=max(abs(a[i]),m);
    if(m==a[i]) f=i;
    if(m==-a[i]) f=-i;
  }

  vector<P> v;

  ll ff=f;
  if(f==0){
    if(a[0]>0) ff=0;
    else ff=-1;
  }


  if(ff>=0){
    for(i=1;i<n;i++){
        v.pb(P(f,i));
        v.pb(P(f,i));
        f=i;
    }
  }
  else {
    f=-f;
    for(i=n-2;i>=0;i--){
      v.pb(P(f,i));
      v.pb(P(f,i));
      f=i;
    }
  }
  
  cout<<v.size()<<endl;
  for(i=0;i<v.size();i++) cout<<1+v[i].fi<<" "<<1+v[i].se<<endl;
  return 0;
}

Measured memory_bytes: 256