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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    string s;
    cin >> s;
    string key = "keyence";
    bool ok = false;

    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size()-i;j++){
            string t = s;
            t.erase(i,j);
            if(t==key)ok=true;
        }
    }
    if(ok)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
a = [[0 for i in range(3)] for j in range(3)]
s = [[False for i in range(3)] for j in range(3)]

for i in range(3):
    t = list(map(int, input().split()))
    for j in range(3):
        a[i][j] = t[j]

n = int(input())

for i in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b: s[x][y] = True

ans = 'No'
# yoko
if s[0][0] and s[0][1] and s[0][2]: ans = 'Yes'
if s[1][0] and s[1][1] and s[1][2]: ans = 'Yes'
if s[2][0] and s[2][1] and s[2][2]: ans = 'Yes'
# tate
if s[0][0] and s[1][0] and s[2][0]: ans = 'Yes'
if s[0][1] and s[1][1] and s[2][1]: ans = 'Yes'
if s[0][2] and s[1][2] and s[2][2]: ans = 'Yes'
# naname
if s[0][0] and s[1][1] and s[2][2]: ans = 'Yes'
if s[0][2] and s[1][1] and s[2][0]: ans = 'Yes'

print(ans)



Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int num;
	double wei, hei, bmi;
	
	while(scanf("%d,%lf,%lf", &num, &wei, &hei)!=EOF){
		
		bmi=wei/hei/hei;
		
		if(bmi>=25.0)
		printf("%d\n", num);
	}
	return 0;
}

Measured memory_bytes: 628
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll sqrtN = 512;
struct SqrtDecomposition {
  ll N, K;
  vector<ll> data;
  vector<ll> bucketSum;
  vector<ll> lazyUpdate;
  SqrtDecomposition(ll n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucketSum.assign(K, 0);
    lazyUpdate.assign(K, 0);
  }
  void eval(ll k) {
    if (lazyUpdate[k]) {
      for (ll i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
        data[i] += lazyUpdate[k];
      }
      lazyUpdate[k] = 0;
    }
  }
  // [s, t)
  void update(ll s, ll t, ll x) {
    for (ll k = 0; k < K; ++k) {
      ll l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        bucketSum[k] += x * sqrtN;
        lazyUpdate[k] += x;
      } else {
        eval(k);
        for (ll i = max(s, l); i < min(t, r); ++i) {
          data[i] += x;
          bucketSum[k] += x;
        }
      }
    }
  }
  // [s, t)
  ll find(ll s, ll t) {
    ll ans = 0;
    for (ll k = 0; k < K; ++k) {
      ll l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        ans += bucketSum[k];
      } else {
        eval(k);
        for (ll i = max(s, l); i < min(t, r); ++i) {
          ans += data[i];
        }
      }
    }
    return ans;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, q;
  cin >> n >> q;
  SqrtDecomposition sd(n);
  FOR(i,0,q) {
    ll f;
    cin >> f;
    if(f) {
      ll s,t;
      cin >> s >> t;
      cout << sd.find(s, t+1) << endl;
    } else {
      ll s,t,x;
      cin >> s >> t >> x;
      sd.update(s,t+1,x);
    }
  }
}


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

using ll = long long;

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

	ll weight[n],val[n];
	for(int i=0;i<n;i++){
		cin >> weight[i] >> val[i];
	}

	ll dp[n+1][w+1];

	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
			else{
				ll x;
				x = (j>=weight[i-1])? (dp[i-1][j-weight[i-1]]+val[i-1]):0;
				dp[i][j]=max(dp[i-1][j],x);
			}
		}
	}

	cout << dp[n][w] << "\n";
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i=0;i<N;++i) cin >> L[i];
    sort(L.begin(),L.end());
    int sum=0;
    for (int i=0;i<N-1;++i) sum+=L[i];
    if(sum>L[N-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int  n,m;
	cin>>n>>m;
	int num[n];
	int pos,dig;
	bool bad=false;
	memset(num, -1, sizeof num);
	for(int i=0;i<m;i++)
	{
		cin>>pos>>dig;
		pos--;
		if(num[pos]!=-1 and num[pos]!=dig){bad=true;break;}
		else (num[pos]=dig);
		
	}
	if(m==0)
	{
		if(n==1)cout<<0;
		else
		{	cout<<1;
			for(int i=1;i<n;i++)
			cout<<0;
		}
		return 0;}
	if(num[0]==-1)num[0]=1;
	if(num[0]==0 and n>1)bad=true;
	if(bad)
	cout<<-1<<"\n";
	else
	{
		for(auto x: num)
		{
			if(x==-1)cout<<0;
			else cout<<x;
		}
		
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector<ll> getPositions(const string& s, ll k, ll c) {
  ll n = s.size();
  ll i = 0;
  vector<ll> ans;
  while (i < n && ans.size() < k) {
    if (s[i] == 'o') {
      ans.push_back(i);
      i += c+1;
    } else {
      ++i;
    }
  }
  return ans;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  vector<ll> l = getPositions(s, k, c);
  reverse(all(s));
  vector<ll> r = getPositions(s, k, c);
  reverse(all(s)); // revert state
  rep(i, k) { r[i] = n-1-r[i]; } // update index of r. r is decreasing order.

  // Here, l and r are calculated.
  vector<ll> lastL(n, -1); // lastL[i] .. last position before i.
  rep(i, k) {
    if (l[i]+1 < n) { lastL[l[i]+1] = i; }
  }
  rep(i, n-1) {
    if (lastL[i+1] == -1) { lastL[i+1] = lastL[i]; }
  }
  vector<ll> lastR(n, -1); // lastR[i] .. last position after i.
  rep(i, k) {
    if (r[i]-1 >= 0) { lastR[r[i]-1] = i; }
  }
  for (int i = n-1; i > 0; --i) {
    if (lastR[i-1] == -1) { lastR[i-1] = lastR[i]; }
  }

  vector<ll> ans;
  rep(i, n) {
    if (s[i] == 'x') { continue; }
    ll li = lastL[i]; // last position before i.
    ll ri = lastR[i]; // last position after i.
    ll cnt = 0; // maximum count without i.
    if (li != -1) { cnt += li + 1; }
    if (ri != -1) { cnt += ri + 1; }
    if (li != -1 && ri != -1 && (r[ri]-l[li] <= c)) {
      --cnt;
    }
    if (cnt >= k) { continue; } // we can make k without i
    ans.push_back(i);
  }

  for (int idx : ans) {
    cout << idx + 1 << endl;
  }
}


Measured memory_bytes: 9736
'use strict';
function Main(inputs) {
 
 const input = inputs.split("\n");
 
 const k = Number(input[0].split(' ')[0]);
 const x = Number(input[0].split(' ')[1]);

 console.log(k*500 >= x ? "Yes" : "No");
}
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c; cin >> a >> b >> c;
  int ans = a*b/2;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define task "abc171"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// Head:
// Source:
const int maxn = 2e5 + 7;
ll n;
vector <char > cc;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
#endif
    cin>>n;
    while (n > 0){
        int k  = n % 26; if (k == 0) k = 26;
      	n = n - k;
        cc.pb(char(k + 'a' - 1));
        n = n / 26;
    }
    per(i, 0, SZ(cc)) cout<<cc[i];
 
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
  int a,b,c,d,res1,res2;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if (a<b) res1=a;
  else res1=b;
  if (c<d) res2=c;
  else res2=d;
  printf("%d",res1+res2);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	LL x,k,d;scanf("%lld%lld%lld",&x,&k,&d);
	x=abs(x);
	if(x/d>=k)return printf("%lld",x-d*k),0;
	k-=x/d,x%=d;
	if(k&1)printf("%lld",d-x);
	else printf("%lld",x);
	return 0;
}

Measured memory_bytes: 3824
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for(int i = 0; i < 5; i++) {
            a[i] = sc.nextInt();
        }
        int k = sc.nextInt();

        int max = 0;
        for(int i = 0; i < 5; i++) {
            for(int j = 0; j < 5; j++) {
                max = Math.max(Math.abs(a[i] - a[j]), max);
            }
        }

        if(max > k) System.out.println(":(");
        else System.out.println("Yay!");
        
    } 
}

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


int main() {
    int n;
    cin >> n;
    for (int i = 0; i <= n; i+= 4) {
        if ((n - i) % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

};

int main(){
  int n,k,l; cin >> n >> k >> l;
  UnionFind road(n), rail(n);
  rep(i,k) {
    int p,q; cin >> p >> q;
    p--; q--;
    road.merge(p,q);
  }

  rep(i,l) {
    int r,s; cin >> r >> s;
    r--; s--;
    rail.merge(r,s);
  }

  map<pii,int> C;
  rep(v,n) {
    C[mp(road.root(v), rail.root(v))]++;
  }
  rep(v,n) cout << C[mp(road.root(v), rail.root(v))] << endl;

}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int A[100];

int main()
{
	int N, D, X;

	cin >> N >> D >> X;
	rep(i, N) cin >> A[i];

	rep(i, N) {
		X += 1 + (D - 1) / A[i];
	}

	cout << X << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
	int n,k,x,y;
           cin>>n>>k>>x>>y;
           int ans=0;
           rep(i,1,n+1){
             if(i<=k)ans+=x;
             else ans+=y;
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
pair <long long int, long long int> a[1000000];
int main()
{
	long long n,i,j,k,x,y,ans,l,r;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>x;
		cin>>y;
		a[i].first=x-y;
		a[i].second=x+y;
	}
	sort(a,a+n);
	i=1;
	j=1;
	l=a[0].first;
	r=a[0].second;
	ans=n;
	while (i<=n-1)
	{
		if (a[i].first<r)
		{
			if (a[i].second<=r)
			{
				l=a[i].first;
				r=a[i].second;
				ans--;
			}
			else
			{
				ans--;
			}
		}
		else
		{
			l=a[i].first;
			r=a[i].second;
		}
		i++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

using namespace std;
 
int main(void)
{   
    string s;
    cin >> s;
    map<char, int> mp;

    for(int i = 0;i < s.size();i++){
        mp[s[i]]++;
    }
    
    for(char c = 'a';c <= 'z';c++){
        if(mp[c] % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s="";
    while(n>0){
        n-=1;
        s.push_back((char)'a'+(n%26));
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll mod = 1000000007;
const int MAX = 1000100;
/**
 * caution : set MAX to the proper value
 * caution : don't forget to use Sieve
 **/
bool Is_prime[MAX];
int MinFactor[MAX];
// Eratosthenes's Sieve
// O(NloglogN)
void Sieve(int n = MAX){
    for (int i = 0; i < n; ++i) Is_prime[i] = true, MinFactor[i] = -1;
    Is_prime[0] = false; Is_prime[1] = false; 
    MinFactor[0] = 0; MinFactor[1] = 1;
    for (int i = 2; i < n; ++i) {
        if (Is_prime[i]) {
            MinFactor[i] = i;
            for (int j = 2 * i; j < n; j += i) {
                Is_prime[j] = false;
                if (MinFactor[j] == -1) MinFactor[j] = i;
            }
        }
    }
}
// Factorization O(logN)
vector<pair<int, int>> prime_factor(int n){
    vector<pair<int,int> > res;
    while (n != 1) {
        int prime = MinFactor[n];
        int exp = 0;
        while (MinFactor[n] == prime) {
            ++exp;
            n /= prime;
        }
        res.push_back(make_pair(prime, exp));
    }
    return res;
}

int gcd(int a, int b){return (b == 0 ? a : gcd(b, a % b));}

int main(){
    int n; cin >> n;
    Sieve();
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int full = a[0];
    for(int i = 1; i < n; i++){
        full = gcd(a[i], full);
    }
    bool one = true;
    vector<int> d(1000001, 0);
    for(int i = 0; i < n; i++){
        auto pf = prime_factor(a[i]);
        for(auto p : pf){
            d[p.first]++;
        }
    }
    if(*max_element(d.begin(), d.end()) >= 2) one = false;
    if(one) cout << "pairwise coprime" << endl;
    else if(full == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define MOD 1000000007;

int main() {
    int n;
    cin >> n;
    //vector<int> numCount(n, 0);
    int numCount[100100] = {0};
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        numCount[x]++;
    }

    int ans = 1;
    if (n % 2 == 0) { // 要素数が偶数の時
        for (int i = 1; i < n; i+=2) {
            if (numCount[i] != 2) {
                cout << "0" << endl;
                return 0;
            }
            ans = (ans * 2) % MOD;
        }
    } else { // 要素数が奇数
        if (numCount[0] != 1) {
            cout << "0" << endl;
            return 0;
        }
        for (int i = 2; i < n; i+=2) {
            if (numCount[i] != 2) {
                cout << "0" << endl;
                return 0;
            }
            ans = (ans * 2) % MOD;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 3){
		if(s.at(i) == '1')
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
MOD = 10 ** 9+7
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N = ii()
for h in range(1, 3500):
    for n in range(1, 3500):
        if (4 * h * n - N * n - N * h) > 0 and (N * h * n) % (4 * h * n - N * n - N * h) == 0:
            print(h, n, (N * h * n)//(4 * h * n - N * n - N * h))
            exit()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>

 
int main(){
   int a,b;
   scanf("%d %d", &a,&b);
   if(a<b){
     for(int i=0;i<b;i++){
      	printf("%d", a); 
     }
   } else {
     for(int i=0;i<a;i++){
      	printf("%d", b); 
     }
   }
	return 0;
 
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll x;
cin>>x;
ll now = 100;
int cnt = 0;
while (x > now)
{
    now*=1.01;
    cnt++;
}

cout << cnt << endl;
}

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

using namespace std;

const double EPS = 1e-4;

double calc(double ra, double rb, double s){
    double lb = abs(ra - rb);
    double ub = ra + rb;
    REP(_, 80) {
        double d = (lb + ub) / 2;
        double tha = acos((ra * ra + d * d - rb * rb) / (2.0 * d * ra));
        double thb = acos((rb * rb + d * d - ra * ra) / (2.0 * d * rb));
        double sum = ra * ra * tha + rb * rb * thb - ra * d * sin(tha);
        if(sum > s){
            lb = d;
        }else{
            ub = d;
        }
    }
    return ub;
}
double sq(double x){
    return x * x;
}

bool judge(double x, double y, double r, double W, double H){
    return x - r > -EPS && x + r < W + EPS && 
        y - r > -EPS && y + r < H + EPS;
}

bool solve(double W, double H, double sa, double sb, double sc, bool reversed){
    double ra = sqrt(sa / M_PI);
    double rb = sqrt(sb / M_PI);
    if(2.0 * ra > min(W, H) + EPS) return false;
    if(2.0 * rb > min(W, H) + EPS) return false;
    double D = calc(ra, rb, sc);
    // cout << D << endl;
    double xa = ra;
    double ya = ra;
    // x = 0
    for(double xb : {ra, rb, W - rb}){
        double dy = sqrt(sq(D) - sq(xa - xb));
        for(int sign = -1; sign <= 1; sign += 2){
            double yb = ya + sign * dy;
            if(judge(xb, yb, rb, W, H)){
                assert(judge(xa, ya, ra, W, H));
                assert(abs(hypot(xa - xb, ya - yb) - D) < EPS);
                if(not reversed) {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xa, ya, ra, xb, yb, rb);
                } else {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xb, yb, rb, xa, ya, ra);
                }
                return true;
            }
        }
    }
    // y = 0
    for(double yb : {ra, rb, H - rb}){
        double dx = sqrt(sq(D) - sq(ya - yb));
        for(int sign = -1; sign <= 1; sign += 2){
            double xb = xa + sign * dx;
            if(judge(xb, yb, rb, W, H)){
                assert(judge(xa, ya, ra, W, H));
                assert(abs(hypot(xa - xb, ya - yb) - D) < EPS);
                if(not reversed) {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xa, ya, ra, xb, yb, rb);
                } else {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xb, yb, rb, xa, ya, ra);
                }
                return true;
            }
        }
    }
    return false;
}

int main(){
    double W, H, sa, sb, sc;
    while(cin >> W >> H >> sa >> sb >> sc && W > 0){
        if(solve(W, H, sa, sb, sc, false)) continue;
        if(solve(W, H, sb, sa, sc, true)) continue;
        cout << "impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 1380
#include <iostream>
using namespace std;
int main() {
	int a, b, c, ans = 0, mon;
	cin >> a >> b >> c;
	char k[105][105];
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> k[i][j];
		}
	}
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			mon = 0;
			if (k[i][j] == '.') {
				for (int kk = j; kk < b; ++kk) {
					if (k[i][kk] == '#') break;
					++mon;
				}
				if (mon >= c) ++ans;
				mon = 0;
				for (int kk = i; kk < a; ++kk) {
					if (k[kk][j] == '#') break;
					++mon;
				}
				if (mon >= c) ++ans;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3108
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) //cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int main() {
  string str;
  cin >> str;
  vi ground(str.length()+1);
  ground[0] = 0;
  rep(i, str.length()) {
    if (str[i] == '_') {
      ground[i+1] = ground[i];
    } else if (str[i] == '/') {
      ground[i+1] = ground[i] + 1;
    } else {
      ground[i+1] = ground[i] - 1;
    }
  }

  int A = 0;
  //vi L = {0};
  vi L;
  vi vpd(str.length()+1, 0);
  vi vp(str.length()+1, 0);
  vi st; // x coordinate
  rep(i, str.length()) {
    if ( str[i] == '\\' ) {
      st.pb(i);
    } else if ( str[i] == '/' && !st.empty() ) {
      vpd[st.back()] +=1;
      vpd[st.back()+1] += 1;
      vpd[i] += -1;
      vpd[i+1] += -1;
      debug(vpd);

      //L[L.size()-1] += ( i - st.back() );
      st.pop_back();
      //if ( st.empty() ) {
      //  A += L[L.size()-1];
      //  L.pb(0);
      //}
    }
  }

  rep(i, str.length()) {
    vp[i+1] = vp[i] + vpd[i];
    debug(vp);
  }

  int cond = 0; // 1: water
  FOR(i, 1, str.length()+1) {
    if (cond == 0 && vp[i] == 1) {
      L.pb(0);
    }
    if (vp[i] == 1) {
      cond = 1 - cond;
    }
    if (vp[i] != 0) {
      L.back() += vp[i];
    }
  }

  //if ( L[L.size()-1] == 0 ) {
  //  L.pop_back();
  //}

  rep(i, L.size()) {
    L[i] /= 2;
    A += L[i];
  }

  printf("%d\n", A);
  printf("%lu", L.size());
  rep(i, L.size()) {
    printf(" %d", L[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  int A = 1;
  for (int i = 0; i < M; i++) {
    A *= 2;
  }
  int B = 1900 * M + 100 * (N - M);
  cout << A * B << endl;
}

Measured memory_bytes: 3624
//============================================================================
// Name        : e.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
	int n;cin>>n;
	ll k;cin>>k;
	vector<ll> a(n),f(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>f[i];
	}
	sort(a.begin(),a.end());
	sort(f.begin(),f.end());
	reverse(f.begin(),f.end());
	ll r=a[n-1]*f[0];
	ll l=-1;
	while(r!=l+1){
		ll temp=(r+l)/2;
		ll needk=0;
		for(int i=0;i<n;i++){
			if(a[i]*f[i]>temp){
				needk+=(a[i]*f[i]-temp-1)/f[i]+1;
			}
		}
		if(needk<=k){
			r=temp;
		}else{
			l=temp;
		}
//		cout<<l<<' '<<r<<endl;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 3456
using System;

namespace ABC_090_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine();
            var wort = Console.ReadLine();
            var wors = Console.ReadLine();
            char c11 = word[0];char c12 = word[1];char c13 = word[2];
            char c21 = wort[0];char c22 = wort[1];char c23 = wort[2];
            char c31 = wors[0];char c32 = wors[1];char c33 = wors[2];
            string a = c11.ToString();
            string b = c22.ToString();
            string c = c33.ToString();
            Console.WriteLine(a + b + c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0);
    cout.tie(0);
    int n ;
    cin >> n ;
    cin.ignore() ;
    string str ;
    cin >> str ;
    int cnt = 0 ;
    for(int i = 0 ; i < str.length() && i < n ; i++)
    {
        if(i >= str.length()-2) break ;
        else
        {
            if(str[i] == 'A' && str[i+1] =='B' && str[i+2] == 'C') cnt++ ;
        }

    }
    cout << cnt << endl ;

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000000 + 7;

long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

long long lcm (long long a, long long b) {
  return ((a%mod) * (b%mod)) * modinv(gcd(a, b), mod) % mod;
}

vector<pair<long long, long long> > primeFactarize(long long a) {
  vector<pair<long long, long long> > res;
  for (int i = 2; i * i <= a; ++i) {
    if (a == 0) break;
    if (a % i != 0) continue;
    long long ex = 0;

    while(a % i == 0) {
      ex++;
      a /= i;
    }

    res.push_back(make_pair(i, ex));
  }
  if (a != 0) res.push_back(make_pair(a, 1));

  return res;
}

void solver() {
  long long n;
  cin >> n;

  vector<long long> as(n);
  vector<vector<pair<long long, long long> > > ress;
  for (int i = 0; i < n; i++) {
    cin >> as[i];
    ress.push_back(primeFactarize(as[i]));
  }

  vector<long long> cnts(1000000+1);
  for (int i = 0; i < ress.size(); i++) {
    for (int j = 0; j < ress[i].size(); j++) {
      long long p = ress[i][j].first;
      long long e = ress[i][j].second;
      cnts[p] = max(cnts[p], e);
    }
  }

  long long aLcm = 1;
  for (int i = 0; i < cnts.size(); i++) {
    long long ex = cnts[i];
    if (ex == 0) continue;
    for (int j = 0; j < ex; j++) {
      aLcm *= i;
      aLcm %= mod;
    }
  }

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += aLcm * modinv(as[i], mod) % mod;
    ans %= mod;
  }

  cout << ans << "\n";
}

int main() {
  solver();
}


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

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

  int avg = round(accumulate(a.begin(), a.end(), 0) / float(n));

  int ans = 0;
  for(int i = 0;i < n;i++){
    ans += (a[i] - avg) * (a[i] - avg);
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    string S,T;
    cin>>S>>T;
    int A,B;
    cin>>A>>B;
    string u;
    cin>>u;
    if(u==S) A--;
    else B--;
    cout<<A<<" "<<B<<endl;
}

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

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(n, m, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

int calc_sum(int n) {
    int res = 0;
    while (n) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    int cnt = 0;
    rep(n + 1, i) {
        int sum = calc_sum(i);
        if (a <= sum && sum <= b) cnt += i;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	int sw, light;
	cin >> sw >> light;
	vector<VE> vec(light, VE(11, -1));
	REP(i, light) {
		cin >> vec[i][0];
		REP(k, vec[i][0]) {
			cin >> vec[i][k + 1];
		}
	}
	VE jud(light);
	REP(i, light) {
		cin >> jud[i];
	}

	int ans=0;
	for (int bit = 0; bit < (1 << sw); ++bit) {// ここで全てのビットのパターンを作りだす
		int on_num = 0;
		REP(l, light) {
			int sw_num = 0;
			REP(i, vec[l][0]) {
				if (bit & 1 << (vec[l][i + 1] - 1) ) {
					sw_num++;
				}
			}
			if (sw_num % 2 == jud[l]) {
				on_num++;
			}
		}
		if (on_num == light) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<int> dp(50, 1);
    for (int i = 2; i < 50; ++i) {
        dp[i] = dp[i-1] + dp[i-2];
    }

    int n;
    cin >> n;
    cout << dp[n] << endl;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        map<string, int> mp;
        rep(i, N) {
            string s; cin >> s;
            mp[s]++;
        }
        vector<pair<int, string>> v;
        for(auto p : mp) {
            v.emplace_back(-p.second, p.first);
        }
        sort(all(v));
        rep(i, v.size()) {
            if(v[i].first == v[0].first)
                cout << v[i].second << endl;
        }
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 28272
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
int main() {
	// 入力
    long long D, N;
    cin >> D >> N;
 
    long long ans=1;
    for (int i = 0; i < D; ++i){
        ans *= 100;
    }
    N = N + (N/100);
    ans *= N;
    cout << ans << endl;;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <functional>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> a( n ), b( m );

  for ( int i = 0; i < n; i++ ) {
	cin >> a[ i ];
  }
  for ( int i = 0; i < m; i++ ) {
	cin >> b[ i ];
  }
  sort( b.begin(), b.end(), greater<int>() );
  
  int answer = -1;
  int index = 0;
  int max_vote = 0;
  for ( int i = 0; i < n; i++ ) {
	int count = 0;
	while ( b[ index ] >= a[ i ] ) {
	  count++;
	  index++;
	}
	if ( max_vote < count ) {
	  answer = i + 1;
	  max_vote = count;
	}
  } 
  cout << answer << endl;
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;
const LL LINF = 1e16;

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

  LL ans;
  int N;
  cin >> N;
  vector<LL> a(N);
  vector<LL> sum(N);
  LL acc = 0;
  FOR(i, 0, N) {
    cin >> a[i];
    acc += a[i];
    sum[i] = acc;
  }

  ans = LINF;
  LL temp;
  FOR(i, 0, N - 1) {
    temp = abs(sum[i] - (sum[N - 1] - sum[i]));
    ans = min(ans, temp);
  }

  cout << ans << '\n';

  return 0;
}

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

int main()
{
	string s[3];
	cin >> s[0] >>s[1 ] >> s[2];
	cout<<s[0][0]<<s[1][0]<<s[2][0]<<endl;
	return 0;
}

Measured memory_bytes: 384
A = int(input())
B = int(input())
C = int(input())
X = int(input())
num =0

for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if X ==(500*i + 100*j +50*k):
                num=num+1

print(num)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 1e9 + 7;
const ll maxn = 200005;
const ll N = 500005;
struct p{
	int v,num;
}a[100005],b[100005];
bool cmp(struct p q,struct p w){
	if(q.v!=w.v) return q.v<w.v;
	else return q.num<w.num;
}
int x[100005],y[100005],c[100005],al[100005],bl[100005];
map<pair<int,int>,int>mp;
int main(){  
	int an,bn,m;
	scanf("%d%d%d",&an,&bn,&m);
	for(int i=1;i<=an;i++){
		scanf("%d",&a[i].v);
		a[i].num=i;
	} 
	for(int i=1;i<=bn;i++){
		scanf("%d",&b[i]);
		b[i].num=i;
	} 
	sort(a+1,a+an+1,cmp);
	sort(b+1,b+bn+1,cmp);
	for(int i=1;i<=an;i++) al[a[i].num]=i;
	for(int i=1;i<=bn;i++) bl[b[i].num]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&x[i],&y[i],&c[i]);
		if(c[i]>mp[{x[i],y[i]}]) mp[{x[i],y[i]}]=c[i];
	} 
	int ans=a[1].v+b[1].v;
	for(map<pair<int,int>,int>::iterator it=mp.begin();it!=mp.end();it++){
		if(ans>a[al[it->first.first]].v+b[bl[it->first.second]].v-it->second) ans=a[al[it->first.first]].v+b[bl[it->first.second]].v-it->second;
	}
	printf("%d",ans);
	
		
	return 0;
}


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

char rsp[3] = {'r', 'p', 's'};

char hand(char t) {
  char ret;
  for (int i = 0; i < 3; i++) {
    if (t == rsp[i]) {
      ret = rsp[(i + 1) % 3];
    }
  }
  return ret;
}

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

  int N, K, R, S, P;
  string T;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  char ring_buf[K] = {'\0'};
  char h;
  long long total = 0;
  for (int i = 0; i < N; i++) {
    h = hand(T[i]);
    if (ring_buf[i % K] != h) {
      ring_buf[i % K] = h;
      if (h == 'r') total += R;
      if (h == 'p') total += P;
      if (h == 's') total += S;
    } else{
      ring_buf[i % K] = '\0';
    }
  }
  cout << total << '\n';
}


Measured memory_bytes: 592
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
edge = []
if N&1:
    cnt = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if i+j != N:
                edge.append((i,j))
                cnt += 1

else:
    cnt = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if i+j != N+1:
                edge.append((i,j))
                cnt += 1

print(cnt)
for u,v in edge:
    print(u,v)

Measured memory_bytes: 43120
use std::str::FromStr;
use std::io::*;

fn main() {
    let i = stdin();
    let o = stdout();
    run(&mut i.lock(), &mut o.lock());
}

fn run(i: &mut BufRead, o: &mut Write) {
    let hwd = read_vec::<usize>(i);
    let (h, w, d) = (hwd[0], hwd[1], hwd[2]);
    let wh = w * h;
    let mut a_to_xy = vec![(0, 0); wh + 1];
    for y in 0..h {
        let a = read_vec::<usize>(i);
        for x in 0..w {
            a_to_xy[a[x]] = (x, y);
        }
    }
    fn abs_sub(x0: usize, s1: usize) -> usize {
        (x0 as isize - s1 as isize).abs() as usize
    }

    let mut mps = vec![0; wh + 1];
    for i in 1..wh + 1 - d {
        let xy0 = a_to_xy[i];
        let xy1 = a_to_xy[i + d];
        mps[i + d] = mps[i] + abs_sub(xy0.0, xy1.0) + abs_sub(xy0.1, xy1.1);
    }

    let q = read::<usize>(i);
    for _ in 0..q {
        let lr = read_vec::<usize>(i);
        let (l, r) = (lr[0], lr[1]);
        let mp = mps[r] - mps[l];
        writeln!(o, "{}", mp).unwrap();
    }
}

fn read_line(i: &mut BufRead) -> String {
    let mut line = String::new();
    i.read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn read<T: FromStr>(i: &mut BufRead) -> T {
    read_line(i).parse().ok().unwrap()
}
fn read_vec<T: FromStr>(i: &mut BufRead) -> Vec<T> {
    read_line(i)
        .split(' ')
        .map(|x| x.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 7292
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("file.1", "r", stdin);

  ll n;
  vector<ll> a(5);
  cin >> n;
  int i;
  for (i = 0; i < 5; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll c;
  c = (n + a[0] - 1) / a[0];
  cout << c + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
fn calc(len: usize) -> Vec<Vec<u64>> {
    let mut way = vec![vec![0u64; 10]; len];
    for i in 0..10 {
        way[0][i] = 1;
    }
    for i in 1..len {
        for d in 0..10 {
            for &x in [d - 1, d, d + 1].iter() {
                if x < 10 {
                    way[i][d] = way[i][d].saturating_add(way[i - 1][x]);
                }
            }
        }
    }
    way
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut n: u64 = s.trim().parse().unwrap();
    for len in 1.. {
        let dp = calc(len);
        for i in 1..10 {
            if dp[len - 1][i] < n {
                n -= dp[len - 1][i];
            } else {
                let mut ans = vec![];
                ans.push(i);
                let mut pos = (len - 1, i);
                while pos.0 > 0 {
                    for &x in [pos.1 - 1, pos.1, pos.1 + 1].iter() {
                        if !(x < 10) {
                            continue;
                        }
                        if dp[pos.0 - 1][x] < n {
                            n -= dp[pos.0 - 1][x];
                        } else {
                            ans.push(x);
                            pos = (pos.0 - 1, x);
                            break;
                        }
                    }
                }
                let mut s = String::new();
                for a in ans {
                    s.push_str(&format!("{}", a));
                }
                println!("{}", s);
                return;
            }
        }
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352
<?php
  $c=0;
  while(fscanf(STDIN,"%d",$a)){
  	for($i=0;$i<=9;$i++){
  		for($j=0;$j<=9;$j++){
  			for($k=0;$k<=9;$k++){
  				for($l=0;$l<=9;$l++){
  					if($a==$i+$j+$k+$l)
  						$c++;
  				}
  			}
  		}
  	}
  	print $c."\n";
  	$c=0;
  }
  ?>

Measured memory_bytes: 6548
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

ans = INF
for y in range(-100, 101):
	tmp = 0
	for x in a:
		tmp += (x-y)**2
	ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 5148