akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int a, b;
int main()
{
	scanf("%d %d", &a, &b);
	if(a + b > 9) printf("error\n");
	else printf("%d", a + b);
	return 0;
}

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

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

const int MAXN = 2500;

int N, M, P;
vector<pii> adj[MAXN+10];
ll dist[MAXN+10], ans;

int main()
{
    int i, j;

    scanf("%d%d%d", &N, &M, &P);
    for(i=1; i<=M; i++)
    {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c); c-=P;
        adj[a].push_back({b, c});
    }

    for(i=1; i<=N; i++) dist[i]=-987654321;
    dist[1]=0;
    for(i=1; i<=N*2; i++)
    {
        for(int now=1; now<=N; now++)
        {
            for(pii nxt : adj[now])
            {
                if(dist[now]+nxt.second>dist[nxt.first])
                {
                    dist[nxt.first]=dist[now]+nxt.second;
                }
            }
        }
        if(i==N-1) ans=dist[N];
    }
    if(ans!=dist[N]) printf("-1");
    else printf("%lld", max(0ll, dist[N]));
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static int[] preorder;
        static int[] inorder;

        static List<int> postorder = new List<int>();
        static int pos = 0;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            preorder = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            inorder = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Reconstruct(0, n);

            Console.WriteLine(string.Join(" ", Array.ConvertAll(postorder.ToArray(), p => p.ToString())));
        }

        static void Reconstruct(int left, int right)
        {
            if (left >= right) return;

            int root = preorder[pos++];
            int m = Array.IndexOf(inorder, root);

            Reconstruct(left, m);
            Reconstruct(m + 1, right);

            postorder.Add(root);
        }
    }
}

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

ll binpow(ll a,ll b,ll mod){
    ll ret=1;
    while(b>0){
        if(b&1){
            ret=ret*a%mod;
        }
        a=a*a%mod;
        b=b>>1;
    }
    return ret;
}

int main(){

    int n;
    cin >> n;
    vector<vector<int>> cnt(10,vector<int>(10,0));

    for(int i=1;i<=n;i++){
        int h=i;
        while(h/10!=0){
            h/=10;
        }
        int t=i%10;
        cnt[h][t]++;
    }
    ll ans=0L;
    rep(i,10){
        rep(j,10){
            ans+=(ll)cnt[i][j]*cnt[j][i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
h,w,d=map(int,input().split())
ind={}
for i in range(h):
    l=list(map(int,input().split()))

    for j in range(w):
        ind[l[j]]=(i,j)
dp=[0]*(h*w)
for i in range(d+1,h*w+1):
    x,y=ind[i]
    z,q=ind[i-d]
    dp[i-1]=abs(z-x)+abs(y-q)+dp[i-d-1]


q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(dp[r-1]-dp[l-1])

Measured memory_bytes: 23812
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    set<ll> st;
    rep(i,k){
        ll d;
        cin>>d;
        st.insert(d);
    }
    ll ans;
    for(ll i=n;;i++){
        string s=to_string(i);
        int m=s.size();
        bool ok=1;
        rep(j,m){
            if(st.count(s[j]-'0'))ok=0;
        }
        if(ok){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3660
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = l[0], W = l[1];

            var array = new char[H][];
            for (var i = 0; i < H; i++)
                array[i] = Console.ReadLine().ToCharArray();

            for (var i = 0; i < H; i++)
            {
                for (var j = 1; j < W; j++)
                {
                    if (array[i][j] != '.' && array[i][j - 1] != '.')
                    {
                        array[i][j] = 'x';
                        array[i][j - 1] = 'x';
                    }

                }
            }
            for (var i = 0; i < W; i++)
            {
                for (var j = 1; j < H; j++)
                {
                    if (array[j][i] != '.' && array[j - 1][i] != '.')
                    {
                        array[j][i] = 'x';
                        array[j - 1][i] = 'x';
                    }

                }
            }

            var count = 0;
            for (var i = 0; i < H; i++)
                count += array[i].Count(z => z == '#');

            Console.WriteLine(count == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#define N 200000
using namespace std;

int n,s;
int a[N+5];
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s^=a[i];
	}
	for(i=1;i<=n;i++)
		printf("%d ",s^a[i]);
	return 0;
}

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

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

  int ans;
  if(a+b >= a-b) ans = a+b;
  else ans = a-b;

  if(ans < a*b) ans = a*b;

  cout << ans << endl;
  // cout << max(a+b, a-b, a*b) << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
using namespace std;
const vector<int> unit={1,5,10,50,100,500};
int main(){
	int r=0,x;
	for(int i=0;i<unit.size();i++)scanf("%d",&x),r+=unit[i]*x;
	r/=1000;
	printf("%d\n",!!r);
}

Measured memory_bytes: 1016
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll a, b;
		cin >> a >> b;
	cout << a * b << endl;
	
}


Measured memory_bytes: 3664
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    T=I()
    import heapq
    
    def calc(X):
        #厳しいところから見ていき，大きいものから入れていく
        hq=[]
        heapq.heapify(hq)
        X.sort(reverse=True)#厳しい順に
        N2=len(X)
        cur=0
        temp=0
        for i in range(N2-1,-1,-1):
            while cur<=N2-1:
                k=X[cur][0]
                if k>i:
                    heapq.heappush(hq,-1*X[cur][1])
                    cur+=1
                else:
                    break
            if len(hq)!=0:
                a=heapq.heappop(hq)
                temp+=-1*a
                
        #print(X,temp)
        return temp 
    
    
    for _ in range(T):
        # 左右それぞれどちらにいきたいかで分けていくことで問題を独立に
        N=I()
        ans=0
        L=[]
        R=[]
        for i in range(N):
            K,l,r=MI()
            if l>=r:
                ans+=r
                L.append((K,l-r))#左からK以内なら+l-r点
            else:
                ans+=l
                R.append((N-K,r-l))#右からN-K以内なら+r-l点
                
        ans+=calc(L)
        ans+=calc(R)
        print(ans)
        
        
        

main()






Measured memory_bytes: 92688
#include <stdio.h>
int main(void){
   char a;
   scanf("%c",&a);
   if((a>='a')&&(a<='z')){
       printf("a\n");
   }
   else if((a>='A')&&(a<='Z')){
       printf("A\n");
   }
   return 0;
}


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

using namespace std;

struct coord {
	int x;
	int y;
};

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector < coord > v(n);
	for (int i = 0; i < n; i++)
		cin>>v[i].x>>v[i].y;
	vector < int > perm(n);
	for (int i = 0; i < n; i++)
		perm[i] = i;
	double res = 0.0;
	int cnt = 0;
	do {
		cnt++;
		for (int i = 0; i + 1 < n; i++) {
			int a = perm[i];
			int b = perm[i + 1];
			res += hypot(v[a].x - v[b].x, v[a].y - v[b].y);
		}
	} while (next_permutation(perm.begin(), perm.end()));
	printf("%0.10lf\n", res / cnt);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 int H, W;
 bool seen[10000][10000];
 char S[10000][10000];
 int dx[4] = {1, -1, 0, 0};
 int dy[4] = {0, 0, 1, -1};
vector<pair<ll, ll>> prime_factorize(ll n) { //素因数分解と各素数の個数
    vector<pair<ll, ll>> res;

    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i != 0)
        {
            continue;
        }
        int num = 0;
        
        while (n % i == 0)
        {
            ++num;
            n /= i;
        }
        res.push_back(make_pair(i, num));
       
    }
     if (n != 1) 
        {
            res.push_back(make_pair(n, 1));
        }
        return res;
        
} 
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void dfs(int st, int fi) {
  //  cout << st << " " << fi <<  endl;
    if (st < 0 || fi < 0 || st >= H || fi >= W)
    {
        return ;
    }
    if (S[st][fi] == '#')
    {
        return ;
    }

    if (seen[st][fi] == 1)
    {
        return ;
    }
    
    
    if (S[st][fi] == '.')
    {
        seen[st][fi] = 1;
    }
    

    dfs(st + 1, fi);
    dfs(st, fi + 1);
    dfs(st, fi - 1);
    dfs(st - 1, fi);
    
}
int main() {
   int N;
   cin >> N;
   vector<string> S(N);

    for(int i = 0; i < N; i++) cin >> S[i];
    
    int str[N][26];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 26; j++) {
            str[i][j] = 0;
        }
    }


    for(int i = 0; i < N; i++) {
        for(auto j : S[i]) {
           
            str[i][j - 'a'] += 1;
            
        }
    }
    int str1[26];

    for(int i = 0; i < 26; i++) str1[i] = 10000000;

    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < N; j++) {
            str1[i] = min(str[j][i], str1[i]);
        }
    }
    string S1 = "";
    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < str1[i]; j++) {
            S1 += (char)('a' + i);
        }
    }
    cout << S1 << endl;

 return 0;
}


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

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

    string s;
    cin >> s;

    int east_num = 0;
    int west_num = 0;
    int ans = 300000;

    // Eの数を数える
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'E') ++east_num;
    }

    // 先頭行からシミュレーション
    for (int i = 0; i < n; ++i) {

        // リーダの左側のW数、右側のEの数が向きを変更する人の数
        if (s[i] == 'E') --east_num;
        ans = min(ans, east_num + west_num);

        // 次のシミュレーションのための情報
        if (s[i] == 'W') ++west_num;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 832
a, op, b = gets.split
while op != "?"
  case op
  when "+"
    n = a.to_i + b.to_i
  when "-"
    n = a.to_i - b.to_i
  when "*"
    n = a.to_i * b.to_i
  when "/"
    n = a.to_i / b.to_i
  end
  puts n
  a, op, b = gets.split
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	for(ll i=1;i*i<=n;i++)
 	{
 		if(n%i==0)
 		{
 			ll a=i;
 			ll b=n/i;
 			if(a<=9&&b<=9)
 			{
 				cout<<"Yes"<<endl;
 				return 0;
 			}
 		}
 	}
 	cout<<"No"<<endl;	
    return 0;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

ll dp[100001];

int main(){
    int N, M; cin >> N >> M;
    map<int, int> mp;
    REP( i, M ){
        int a; cin >> a;
        mp[a] = 1;
    };

    dp[0] = 1;
    dp[1] = ( mp[1] == 1 ? 0 : 1 );

    for( int i = 2; i <= N; i++ ){
        if( mp[i] == 1 ) continue;
        dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= MOD;
    }

    cout << dp[N] << endl;
}

/*

*/

Measured memory_bytes: 5760
#include <stdio.h>


int main()
{
    int h,w,a,b;scanf("%d%d%d%d",&h,&w,&a,&b);
    for (int i=1;i<=h;i++)
    {
        for (int j=1;j<=w;j++)
        {
            if (i<=b && j<=a)
                printf("0");
            else if(i>b && j>a)
                printf("0");
            else
                printf("1");
        }
        printf("\n");
    }


}


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

const long long MOD = 2;

void solve(long long N, long long P, std::vector<long long> A) {
    long long oddCnt = 0, evenCnt = 0;
    for (long long i = 0; i < N; i++) {
        if (A[i] % 2 == 1) {
            oddCnt++;
        } else {
            evenCnt++;
        }
    }
    if (evenCnt == N) {
        if (P == 1) {
            cout << 0 << endl;
            return;
        } else {
            printf("%lld", (long long)pow(2, N));
            return;
        }
    }
    if (oddCnt == N) {
        if (P == 1) {
            printf("%lld\n", (long long)pow(2, N - 1));
            return;
        } else {
            printf("%lld\n", (long long)pow(2, N - 1));
            return;
        }
    }
    if (P == 1) {
        printf("%lld\n", (long long)pow(2, oddCnt - 1) * (long long)pow(2, evenCnt));
        return;
    } else {
        printf("%lld\n", (long long)pow(2, oddCnt - 1) * (long long)pow(2, evenCnt));
        return;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long P;
    scanf("%lld", &P);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, P, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,k,d,a;
    ll ans=0;
    cin>>n>>m;
    queue<int> vec[100001];
    priority_queue<int> q;
    fr(i,n){
        ll a,b;
        cin>>b>>a;
        vec[b].push(a);
    }
    Fr(i,m){
        while(!vec[i].empty()){
            q.push(vec[i].front());
            vec[i].pop();
        }
        if(q.size()>0){ans+=q.top();
        q.pop();}
    }
    cout<<ans;
}

Measured memory_bytes: 71460
import heapq 
n,m = map(int,input().split())
l = list(map(int,input().split()))
l1 = [-i for i in l]
heapq.heapify(l1)

for i in range(m):
  a = heapq.heappop(l1)
  b = -(-a//2)
  heapq.heappush(l1,b)
print(sum(l1)*-1)
  

Measured memory_bytes: 14180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 2e5 + 10;
int f[MAXN];
int dp[MAXN][2];





int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n; cin >> n;
  string s; cin >> s;
  int m = 0;
  for (char c : s) {
    if (c == '1') m++;
  }
  for (int i = 1; i <= m; i++) {
    int tmp = i % __builtin_popcount(i);
    f[i] = f[tmp] + 1;
  }
  if (m-1 > 0) {
    int cur = 1;
    for (int i = n-1; i >= 0; i--) {
      dp[i][0] = cur % (m-1);
      cur = dp[i][0] * 2;
    }
  }
  int cur = 1;
  for (int i = n-1; i >= 0; i--) {
    dp[i][1] = cur % (m+1);
    cur = dp[i][1] * 2;
  }
  int a[2] = {0};
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      if (m-1 > 0) a[0] = (a[0] + dp[i][0]) % (m-1);
      a[1] = (a[1] + dp[i][1]) % (m+1);
    }
  }
  for (int i = 0; i < n; i++) {
    int ret;
    if (s[i] == '0') {
      ret =  f[(a[1] + dp[i][1]) % (m+1)] + 1;
    } else {
      if (m-1 == 0) ret = 0;
      else {
        ret = f[(a[0] - dp[i][0] + (m-1)) % (m-1)] + 1;
      }
    }
    cout << ret << '\n';
  }









/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 5240
#include <stdio.h>
#include<string.h>

int c(int n, int a[][2], int d[][36]);
 
void  select(int n, int a[][2]);

void  bubble(int n, int a[][2]);

int main(void) {
    int a[36][2], b[36][2], d[37][36], dc[37] = {};
    int n,i;
    scanf("%d%*c", &n);
    for(i = 0; n > i; i++){
        scanf("%c%d%*c", &a[i][1], &a[i][0]);
        d[a[i][0]][dc[a[i][0]]] = a[i][1];
        dc[a[i][0]]++;
    }
     
    memcpy(b, a, sizeof(a));
    bubble(n, a);
    for(i = 0; n > i; i++){
        printf("%c%d", a[i][1], a[i][0]);
        if(i < n-1) printf(" ");
    }
    printf("\n");
    if(c(n, a, d) == -1) printf("Not stable\n");
    else printf("Stable\n");
 
    memcpy(a, b, sizeof(a));
    select(n,a);
    for(i = 0; n > i; i++){
        printf("%c%d", a[i][1], a[i][0]);
        if(i < n-1) printf(" ");
    }
    printf("\n");
    if(c(n, a, d) == -1) printf("Not stable\n");
    else printf("Stable\n");
    return 0;
}



int c(int n, int a[][2], int d[][36]){
    int dc[36] = {}, i;
    for(i = 0; n > i; i++){
        if(d[a[i][0]][dc[a[i][0]]] != a[i][1]) return -1;
        dc[a[i][0]]++;
    }
    return 0;

}
    void  select(int n, int a[][2]){
    int f = 1, i, j = 0;
      
    for(j = 0; n-1 > j; j++){
        int minp, min = 101;
        for(i = j; n > i; i++){
            if(a[i][0] < min){
                min = a[i][0];
                minp = i;
            }
        }
        if(j != minp){
        int buf = a[j][0];
        a[j][0] = a[minp][0];
        a[minp][0] = buf;
        buf = a[j][1];
        a[j][1] = a[minp][1];
        a[minp][1] = buf;
        }
    }
}


void  bubble(int n, int a[][2]){
    int f = 1, i;
      
    while(f){
        f = 0;
        for(i = 0; n-1 > i; i++){
            if(a[i][0] > a[i+1][0]){
                int buf = a[i+1][0];
                a[i+1][0] = a[i][0];
                a[i][0] = buf;
                buf = a[i+1][1];
                a[i+1][1] = a[i][1];
                a[i][1] = buf;
                f = 1;
            }
        }
    }
}



Measured memory_bytes: 2092
#include <iostream>
using namespace std;
int main() {
	int K, N, i, m=0, sum = 0, x=0,z;
	int p[1000];
	cin >> N >> K;
	for (i = 0; i < N; i++)
		cin >> p[i];


	for ( z = 0; z < N && m < K; z++) {
		int min = p[0];
x=0;
		for (i = 0; i < N; i++) {
			if (min > p[i]) {
				min = p[i];
				x = i; }}
		sum += min;
		m++;
		p[x] = 10000000;
	}
	cout << sum;
return 0;
}

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

#define mp make_pair
#define fi first
#define se second
#define forn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) forn(i, 0, (n))
#define all(x) x.begin(), x.end()
#define len(x) (int)x.size()
#define endl '\n'

#define ld long double
#define vc vector
#define pq priority_queue
#define uset unordered_set
#define umap unordered_map
#define vi vc<int>
#define pii pair<int, int>
#define vii vc<pii>

inline void FASTIO(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void solve(){
    return;
}

signed main(){
    FASTIO();
    int a, b, c,d ; cin >> a >> b >> c >> d;
    int x = (a - 1) / d + 1, y = (c - 1) / b + 1;
    if(y <= x) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int X, Y;
    cin >> X >> Y;
 
    string ans = "No";
    for(int i = 0; i < X + 1; i++) {
        int j = X - i;
        if(2 * i + 4 * j == Y) {
            ans = "Yes";
            break;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

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

int main() {
  string s;
  string ans;  
  cin >> s;
    

  if (s =="A") ans = "T";
  if (s =="C") ans = "G";
  if (s =="G") ans = "C";
  if (s =="T") ans = "A";
  cout << ans << endl;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors[1:]

n = int(input())
ans = set()

divisors = make_divisors(n)
for value in divisors:
  key = n
  while key % value == 0:
    key //= value
  if key%value == 1:
    ans.add(value)

divisors2 = set(make_divisors(n-1))
ans = ans.union(divisors2)
print(len(ans))

Measured memory_bytes: 3316
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
//#include<ext/rope>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
template<typename T> void debug(T x)
{
    cout<<"value="<<x<<endl;
    return;
}
signed main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	ll a;
	long double b;
	cin>>a>>b;
    cout<<(ll)(a*b);
	return 0;
}


Measured memory_bytes: 3732
def main():
    from itertools import product

    n, *xyh = map(int, open(0).read().split())
    a = range(101)

    if n - xyh[2::3].count(0) == 1:
        i = xyh[2::3].index(1)
        print(xyh[3*i], xyh[3*i+1], xyh[3*i+2])
        return
    a = range(101)
    for x, y in product(a, a):
        l = None
        for i, j, h in zip(*[iter(xyh)] * 3):
            if h == 0:
                continue
            ll = h + abs(x - i) + abs(y - j)
            if l:
                if ll != l:
                    break
            else:
                l = ll
        else:
            print(x, y, l)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
char a[1111][1111];int dp[1111][1111];
signed main(){
    int h,w;cin>>h>>w;
    rep(i,0,h)rep(j,0,w)cin>>a[i][j];
    rep(i,0,h){
        if(a[i][0]=='.')dp[i][0]=1;else break;
        }
    rep(i,0,w){
        if(a[0][i]=='.')dp[0][i]=1;else break;}

    rep(i,1,h)rep(j,1,w){
        if(a[i][j]=='#')dp[i][j]=0;
        else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    }
    cout<<dp[h-1][w-1]<<endl;return 0;
}

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

void GatheringChildren(int& N, std::string S)
{
    // Easy access to even/odd index counts...
    int parityCounts[2];
    parityCounts[0] = 0;
    parityCounts[1] = 0;

    // Our result/answer array
    int ans[N];

    for (int i = 0; i < N; i++) ans[i] = 0;

    char currentChar = 'R';

    int lastPair = -1;

    for (int i = 0; i < N; i++)
    {
        if (S[i] == currentChar) parityCounts[i % 2]++;

        else
        {
            if (S[i] == 'L')
            {
                lastPair = i - 1;
                ans[lastPair] += parityCounts[lastPair % 2];
                ans[lastPair+1] += parityCounts[(lastPair+1) % 2];
            }

            // This basically means we have currentChar as an 'L' and S[i] == 'R', so we need to have kept track of last pivot pair
            // as the L's all go to the left to converge at the prior'RL' pivot point
            else
            {
                ans[lastPair] += parityCounts[lastPair % 2];
                ans[lastPair+1] += parityCounts[(lastPair+1) % 2];
            }
            
            // Reset counts now that we have just hit and accounted for pivot/lastPair...
            parityCounts[0] = 0;
            parityCounts[1] = 0;

            // Account for current character's parity...
            parityCounts[i % 2]++;
            // Update current character...
            currentChar = S[i];
        }
    }

    ans[lastPair] += parityCounts[lastPair % 2];
    ans[lastPair+1] += parityCounts[(lastPair+1) % 2];

    for (int i = 0; i < N-1; i++) printf("%d ", ans[i]);
    printf("%d\n", ans[N-1]);
}

int main()
{
    std::ios::sync_with_stdio(false);

    std::string S;

    std::cin >> S;

    int N = S.length();

    GatheringChildren(N, S);

    return 0;
}

Measured memory_bytes: 1104
let () =
  let open Queue in
  let (n:int),(quantum:int) = Scanf.scanf "%d %d\n" (fun a b -> a,b) in
  let (q:(string * int) t) = create () in
  for i=1 to n do
    add (Scanf.scanf "%s %d\n" (fun a b -> a,b)) q
  done;
  let (sum:int ref) = ref 0 in
  while not (is_empty q) do
    let (p:string),(t:int) = take q in
    if t <= quantum then (sum := !sum+t; Printf.printf "%s %d\n" p !sum)
    else (add (p,t-quantum) q; sum := !sum+quantum)
  done

Measured memory_bytes: 12832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int all = sc.nextInt(), hs = sc.nextInt();
		for(; hs > 0; hs--) {
			all -= sc.nextInt();
		}
		if(all < 0) {
			System.out.println(-1);
		}else {
			System.out.println(all);
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

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


void swap(int& a, int& b){
	int tmp = a;
	a = b;
	b = tmp;
}

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

	for(int i=0;i<N;i++){
    int minid = i;
		for(int j=i;j<N;j++){
			if(a[minid]>a[j]){
        minid = j;
			}
		}
    if(minid != i){
      swap(a[i],a[minid]);
      ans++;
    }
	}
	for(int i=0;i<N;i++){
		if(i == N-1) {
			cout << a[i] << endl;
		}else {
			cout << a[i] << " ";
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3100
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
class UnionFind {
private:
  vector<int> a;

public:
  int siz;
  UnionFind(int x) : a(x, -1), siz(x) {}

  int root(int x) {
    return a[x] < 0 ? x : a[x] = root(a[x]);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    siz--;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] =x;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -a[root(x)];
  }
};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(--x, --y);
  }
  cout << uf.siz << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;


int main(){
    LL x;
    cin >> x;
    LL ans = 1;
    for(LL i=2; i*i<=x; i++){
        LL now = i*i;
        for(LL j=2; now <= x; j++){
            ans = max(ans, now);
            now *= i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
# print(sc)
for i in range(10**n):
  i2=str(i)
#   print(i2)
  if len(i2)==n and all([i2[s-1]==str(c) for s,c in sc]):
      print(i2)
      exit()
print(-1)

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

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

    int m = min(A, B);
    int count = 0;
    for(int i = m; i >= 0; i--) {
        if(A % i == 0 && B % i == 0) {
            count++;
        }
        if(count == K) { cout << i; return 0; }
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, x[100009]; vector<int> G[100009], que[1100009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int va, vb;
		cin >> va >> vb; va--, vb--;
		G[va].push_back(vb);
		G[vb].push_back(va);
	}
	fill(x, x + N, -1);
	cin >> K;
	for (int i = 0; i < K; i++) {
		int pos, val;
		cin >> pos >> val; pos--;
		x[pos] = val;
		que[val].push_back(pos);
	}
	bool ok = true;
	for (int i = 0; i <= 1000000 + N; i++) {
		for (int j : que[i]) {
			for (int k : G[j]) {
				if (x[k] == -1) {
					x[k] = i + 1;
					que[i + 1].push_back(k);
				}
				else if (x[k] != i + 1 && x[k] != i - 1) ok = false;
			}
		}
	}
	cout << (ok ? "Yes\n" : "No\n");
	if (ok) {
		for (int i = 0; i < N; i++) {
			cout << x[i] << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 35328
module Main where

import Data.Maybe (fromJust)
import Data.List
import qualified Data.ByteString.Char8 as BS

bytestr2Int = fst . fromJust . BS.readInt
getInt = bytestr2Int <$> BS.getLine
getIntL_H = map bytestr2Int. BS.words <$> BS.getLine
getIntL_V n = replicate n $ getInt
getInt2D n = replicate n $ getIntL_H


main :: IO ()
main = do
    n <- getInt
    ns <- getIntL_H
    putStrLn . makeList . map (show . snd) $ sortStudents n $ zip ns [1..]

makeList :: [String] -> String
makeList [x]  = x
makeList (x:xs) = x ++ ' ':(makeList xs)

sortStudents :: Int -> [(Int,Int)] -> [(Int,Int)]
sortStudents 0 _ = []
sortStudents 1 x = x
sortStudents n nps = mysort (sortStudents (hn) l) (sortStudents (n-hn) r)
    where
        hn = div n 2
        (l,r) = splitAt hn nps


mysort :: [(Int,Int)] -> [(Int,Int)] -> [(Int,Int)]
mysort [] r = r
mysort l [] = l
mysort lnps@((ln,lp):lr) rnps@((rn,rp):rr) =
    if ln < rn then
        (ln,lp):(mysort lr rnps)
    else
        (rn,rp):(mysort lnps rr)


Measured memory_bytes: 32124
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;
typedef long long int ll;

ll r=0;
vector<int> vc,vk;
string s;
bool a[200010];

int main(){
    cin>>s;
    for(int i=0;i<s.length();i++){
        a[i]=(s[i]=='B');
        if(a[i])vc.push_back(i);
    }
    
    for(int i=0;i<vc.size();i++){
        vk.push_back(s.length()-1-i);
    }
    sort(vk.begin(),vk.end());
    
    for(int i=0;i<vc.size();i++){
        /*
        printf("%d ",vc[i]);
        printf("%d ",vk[i]);
        cout<<endl;
        */
        r+=vk[i]-vc[i];
    }
    printf("%lld\n",r);
}

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

const int MAX_SUM = 1500001;

vector< int > getHistgram(int N, const vector< int >& x) {
	vector< int > ret(MAX_SUM, 0);
	for (int i=0; i<N; ++i) {
		int sum = 0;
		for (int j=i; j<N; ++j) {
			sum += x[j];
			ret[sum]++;
		}
	}
	return ret;
}

void run(int N, int M) {
	vector< int > h(N), w(M);
	for (int i=0; i<N; ++i) cin >> h[i];
	for (int i=0; i<M; ++i) cin >> w[i];
	
	vector< int > cnt_h = getHistgram(N, h);
	vector< int > cnt_w = getHistgram(M, w);
	
	long long ans = 0;
	for (int i=0; i<MAX_SUM; ++i) ans += (long long)cnt_h[i] * cnt_w[i];
	cout << ans << endl;
}

int main() {
	int N, M;
	while (cin >> N >> M, N) run(N, M);
}


Measured memory_bytes: 14572
#include<cstdio>
#include<iostream>

using namespace std;

int main()
{
	int n,r;
	int yama[51];
	int stook[51];

	while(1){
		cin>>n>>r;
		if(n==0&&r==0)
			break;
		int p,c;
		
			for(int i=1;i<=n;i++)
				yama[i]=i;
			
		for(int t=0;t<r;t++){
			cin>>p>>c;
			for(int i=1;i<=p-1;i++)
				stook[i]=yama[n-i+1];
	
			for(int i=1;i<=c;i++)
				yama[n-i+1]=yama[n-p+2-i];

			for(int i=1;i<=p-1;i++)
				yama[n-c-i+1]=stook[i];
		}

			cout<<yama[n]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
    	Scanner s = new Scanner(System.in);
        try {
            int A_size;
            
            while(true){
                boolean nosol = true;
                long res = 0;
                /* input from here */
                A_size = s.nextInt();
                if(A_size==0){
                    break;
                } else if(A_size==1){
                    System.out.println(s.nextInt());
                    continue;
                } else {
                	HashMap<Long,Integer> A = new HashMap<Long,Integer>();
                    for(int i=0;i<A_size;i++){
                        long t = s.nextLong();
                        if(A.containsKey(t)){
                        	int v = A.get(t);
                        	if(v+1>A_size/2){
                        		res = t;
                        		nosol = false;
                        	}
                        	A.put(t, v+1);                        	
                        } else {
                        	A.put(t,1);
                        }
                        if(i % 30000 == 0) System.gc();
                    }
                }
                /* input till here */
                if(nosol){
                    System.out.println("NO COLOR");
                } else {
                	System.out.println(res);
                }
                 
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        	s.close();
        }
    }
}

Measured memory_bytes: 68132
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int A, B, M;
  cin >> A >> B >> M;

  vector<int> va(A), vb(B);
  for (auto &a : va) {
    cin >> a;
  }
  for (auto &b: vb) {
    cin >> b;
  }

  int ans = *min_element(va.begin(), va.end()) + *min_element(vb.begin(), vb.end());

  while (M--) {
    int x, y, c;
    cin >> x >> y >> c;
    ans = min(va[x-1] + vb[y-1]-c, ans);
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 1792
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

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




int main()
{
  // input & declare
  int n,tmp;
  cin >> n;
  std::vector<int> v;
  for(int i = 0; i < n; i++)
  {
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());

  // process
  bool all = true;
  for(int i : v){
    if (i % 10 != 0) {
      all = false;
    }
  }
  if (all) {
    std::cout << "0" << '\n';
    exit(0);
  }


  int i = 0;
  while (true) {
    int sum = accumulate(v.begin(),v.end(),0);
    if (sum % 10 == 0) {
    sum = accumulate(v.begin(),v.end(),-v[i]);
    }
    if(sum % 10 != 0){
      std::cout << sum << '\n';
      exit(0);
    }
    i++;
  }

 
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

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

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

int yesno(bool flag, string yes, string no) {
	if (flag)cout << yes << endl;
	else cout << no << endl;
	return 0;
}

int printint(int n) {
	cout << n << endl;
	return 0;
}

int prints(string s) {
	cout << s << endl;
	return 0;
}

int ans;

int main() {

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 764
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long llong;
using namespace std;



int main() {
	int m, f, r;

	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)break;
		else if (m == -1 || f == -1)cout << 'F' << endl;
		else if (m + f >= 80)cout << 'A' << endl;
		else if (m + f >= 65)cout << 'B' << endl;
		else if (m + f >= 50)cout << 'C' << endl;
		else if (m + f >= 30) {
			if (r >= 50)cout << 'C' << endl;
			else cout << 'D' << endl;
		}
		else cout << 'F' << endl;
	}
	return 0;
}



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

typedef long long ll;

int main(){
	int N;
	scanf("%d",&N);
	
	for(int k = 1 ; ; k ++){
		if(k*(k-1) > N*2){
			puts("No");
			return 0;
		}
		if(k*(k-1) < N*2)continue;
		puts("Yes");
		printf("%d\n",k);
		vector<int> vec[1000];
		int cnt = 1;
		for(int i = 1 ; i <= k ; i ++){
			for(int j = i+1 ; j <= k ; j ++){
				vec[i].push_back(cnt);
				vec[j].push_back(cnt);
				cnt ++;
			}
		}
		for(int i = 1 ; i <= k ; i ++){
			printf("%d",k-1);
			for(int j = 0 ; j < k-1 ; j ++){
				printf(" %d",vec[i][j]);
			}
			puts("");
		}
		return 0;
	}
}
	

Measured memory_bytes: 2304
// ※※※ 上級者の解答を勉強する. ※※※
// ats5515氏.
// https://atcoder.jp/contests/abc134/submissions/6459574
#include <bits/stdc++.h>
#define int long long
using namespace std;
int INF = (int)1 << 62;

// 広義単調増加列の長さを返却.
// @param a: 整数配列.
// @return: 広義単調増加列の長さ.
int LIS(vector<int> &a){
    int N = a.size();
    vector<int> dp(N, INF);
    for(int i = 0; i < N; ++i) *upper_bound(dp.begin(), dp.begin() + N, a[i]) = a[i];
    return lower_bound(dp.begin(), dp.begin() + N, INF) - dp.begin();
}

signed main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    vector<int> A(N);
    for(int i = 0; i < N; i++) scanf("%d", &A[i]);
    reverse(A.begin(), A.end());

    // 2. 出力 ～ 後処理.
    printf("%d\n", LIS(A));
    return 0;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int W, H;
    cin >> W >> H;
    if (W == 0 && H == 0){
      break;
    }
    vector<vector<char>> C(H, vector<char>(W));
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        cin >> C[i][j];
      }
    }
    vector<vector<string>> dp(H, vector<string>(W, ""));
    if (isdigit(C[0][0])){
      if (C[0][0] != '0'){
        dp[0][0] += C[0][0];
      }
    }
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        if (isdigit(C[i][j])){
          if (i > 0){
            string S = dp[i - 1][j] + C[i][j];
            if (S != "0"){
              if (dp[i][j].size() < S.size() || dp[i][j].size() == S.size() && dp[i][j] < S){
                dp[i][j] = S;
              }
            }
          }
          if (j > 0){
            string S = dp[i][j - 1] + C[i][j];
            if (S != "0"){
              if (dp[i][j].size() < S.size() || dp[i][j].size() == S.size() && dp[i][j] < S){
                dp[i][j] = S;
              }
            }
          }
        }
      }
    }
    string ans = "";
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        if (ans.size() < dp[i][j].size() || ans.size() == dp[i][j].size() && ans < dp[i][j]){
          ans = dp[i][j];
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3180
K,N=map(int,input().split())
A=list(map(int,input().split()))

mx=0
for i in range(N-1):
    a=A[i+1]-A[i]
    mx=max(mx,a)
lst=(K-A[-1])+A[0]
mx=max(lst,mx)
ans=K-mx
print(ans)

Measured memory_bytes: 78540
#include <iostream>

int main() {
  // 入力
  int total_squares;
  int white_num;
  std::cin >> total_squares >> white_num;

  // 黒色に塗ることになるマスの数
  int black_num = total_squares * total_squares - white_num;

  // 出力
  std::cout << black_num << std::endl;

  return 0;
}


Measured memory_bytes: 888
import java.lang.reflect.Array;
import java.util.*;



public class Main {
    private void print(ArrayList<Integer> arrayMid) {
        StringBuilder Mid = new StringBuilder();
        for (int i = 0; i < arrayMid.size(); i++) {
            Mid.append(arrayMid.get(i) + " ");
        }
        System.out.println(Mid);
    }

    private void Even(int K, int N) {
        ArrayList<Integer> arrayMid = new ArrayList<Integer>(N);
        arrayMid.add(0, K / 2);
        for (int i = 1; i < N; i ++) {
            arrayMid.add(i, K);
        }
        print(arrayMid);
    }

    private void Odd(int K, int N) {
        ArrayList<Integer> arrayMid = new ArrayList<Integer>(N);
        for (int i = 0; i < N; i++) {
            arrayMid.add(i, (K + 1) / 2);

        }
        for (int i = 0; i < N / 2; i++) {
            if (arrayMid.get(arrayMid.size() - 1) == 1) arrayMid.remove(arrayMid.size() - 1);
            else {
                arrayMid.set((arrayMid.size() - 1), arrayMid.get(arrayMid.size() - 1) - 1);
                for (int j = arrayMid.size(); j < N; j++) arrayMid.add(j, K);
            }
        }
        print(arrayMid);
    }

    private void Judge(int K, int N) {
        if (K % 2 == 0) Even(K, N);
        else Odd(K, N);
    }

    public static void main (String[] args) {
        Scanner input  = new Scanner(System.in);
        int[] in = new int[2];
        for (int i = 0; i < 2; i++) {
            in[i] = input.nextInt();
        }
        Main myEncyclopedia = new Main();
        myEncyclopedia.Judge(in[0], in[1]);
        input.close();
    }

}


Measured memory_bytes: 72196