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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vi data(n);
    int sum = 0;
    rep(i, n) {
        cin >> data[i];
        sum += data[i];
    }
    int ans = INF;

    int add = 0;
    rep(i, n-1) {
        add += data[i];
        ans = min(ans, abs(add - (sum - add)));
    }
    cout << ans << endl;



    return 0;
}



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

int main(void){
  int n, i, x;
  cin >> n;
  vector<int> cards;
  for(i = 0; i < n; i++){
    cin >> x;
    cards.push_back(x);
  }
  sort(cards.begin(), cards.end());

  int alice = 0, bob = 0;
  for(i = 0; i < n; i++){
    if(i%2 == 0) alice += cards[i];
    else bob += cards[i];
  }

  cout << abs(alice-bob) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
cnt = 0
for i in range(a, b+1):
    t = str(i)
    if t[0] == t[-1] and t[1] == t[-2]:
        cnt += 1
print(cnt)




Measured memory_bytes: 27120
#include<iostream>

#define rep(i,n) for(int i=0;i<(n);i++)
#define max(a,b) a>b?a:b;
using namespace std;

int d[401][401];
const int INF = 100000000;

int main() {
    rep(i,400) rep(j,400) d[i][j]=-INF;
    rep(i,400) d[i][i]=0;
    int n,m;
    cin>>n>>m;
    rep(i,m) {
        int a,b,c;
        cin>>a>>b>>c;
        d[a][b]=c;
    }
    rep(k,n) rep(i,n) rep(j,n) d[i][j] = max(d[i][j],d[i][k]+d[k][j]);

    cout<<d[0][n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
void input() { cin >> S; }
void solve() {
    x = S[0] - 'A';
    if(x > -1 && x < 26)
        cout << "A" << endl;
    else
        cout << "a" << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}


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

using namespace std;

int n,i,k,sum,mn=0x3f3f3f3f;

int main() 
{
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>k;
        sum+=k;
        if (k<mn && k%10!=0) mn=k;
    }
    if (sum%10!=0) cout<<sum; else if (mn!=0x3f3f3f3f) cout<<sum-mn; else cout<<0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  vector<P> Hate(M);
  if (N == 2 && M == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> Hate[i].first >> Hate[i].second;
    Hate[i].first--;
    Hate[i].second--;
  }
  sort(Hate.begin(),Hate.end());

  int ans = 0;
  int cnt = 0;
  int m = 999999;
  for (int i = 0; i < N; i++) {
    while (Hate[cnt].first == i) {
      m = min(m,Hate[cnt].second);
      cnt++;
    }
    if (i == m - 1) {
      ans++;
      m = 999999;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    cout << fixed << setprecision(10);
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    if (2*x == w && 2*y == h ) {
        cout << double(w)*double(h)/2 << " " << 1 << endl;
    }
    else {
        cout << double(w)*double(h)/2 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = sorted(list(mapint()))
Bs = sorted(list(mapint()))
Cs = sorted(list(mapint()))

from bisect import bisect_left, bisect_right

ans = 0
for b in Bs:
    a_idx = bisect_left(As, b)
    c_idx = N-bisect_right(Cs, b)
    ans += a_idx*c_idx
print(ans)

Measured memory_bytes: 105908
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef complex<double> cmplx;
const double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = (int)1e+9 + 7;
const double eps = 1e-8;
const int N = 500'000;

int n, m, k;

void solve()
{
    int a, b;
    cin >> a >> b;
    if ((a * b) & 1) 
        cout << "Yes";
    else
        cout << "No";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int test = 1;
    //cin >> test;
    for (; test; --test)
        solve();
    return 0;
}


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

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

struct Card{
    char type;
    int value;
};

void bubleSort(Card C[], int N);
void selectSort(Card C[], int N);
void printArray(Card C[],int N);
bool isStable(Card C1[], Card C2[], int N);

int main(void) {
    int N;
    Card C1[100], C2[100];
   
    scanf("%d", &N);
    rep(i,N)
    //これだと上手くいかない    scanf("%c%d", &C1[i].type, &C1[i].value);
    cin >> C1[i].type >> C1[i].value;
    
    rep(i,N)
        C2[i] = C1[i];
    bubleSort(C1,N);
    printf("Stable\n");

    selectSort(C2,N);
    if( isStable(C1,C2,N) ) {
        printf("Stable\n");
    }
    else{
        printf("Not stable\n");
    }

    return 0;
}

bool isStable(Card C1[], Card C2[], int N) {
    for(int i = 0;i < N; i++) {
        if(C1[i].type != C2[i].type) {
            return false;
        }
    }
    return true;
} 

void bubleSort(Card C[], int N) {
    bool flag = true;

    while (flag)  {
        flag = false;
        int j = 0;
        for(int i = j; i < N-1;i++) {
            if(C[i].value > C[i+1].value) {
                flag = true;
                Card tmp = C[i]; C[i] = C[i+1]; C[i+1] = tmp;
            }
        }
        j++;
    }
    printArray(C, N);
}

void selectSort(Card C[], int N) {
    for(int i = 0; i < N-1; i++) {
        int minj = i;
        // 線形探索で最小値の位置(minj)を見つける
        for(int j = i+1; j < N; j++) {
            if(C[j].value < C[minj].value) {
                minj = j;
            }
        }
        Card tmp;
        tmp = C[i]; C[i] = C[minj]; C[minj] = tmp;
    }
    printArray(C,N);
}

void printArray(Card C[], int N) {
    rep(i,N-1)
        printf("%c%d ",C[i].type ,C[i].value);
    printf("%c%d\n", C[N-1].type,C[N-1].value);
}


Measured memory_bytes: 3212
#!/usr/bin/env python3
import collections

# 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)
def main():
    # Failed to predict input format
    N = int(input())
    A = list(map(int, input().split()))

    dictionary = collections.defaultdict(int)
    result = 0
    for idx, a in enumerate(A):
        current = idx - a
        result += dictionary[current]
        dictionary[idx + a] += 1
    print(result)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 61748
#define DEBUG
// #define FASTIO

#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

#define F first
#define S second 
#define pb push_back

#define endl "\n";
#ifdef FASTIO

#define pr(x) printf("%d", x)
#define ps    printf(" ")
#define pl(x) printf("%lld", x)
#define pf(x) printf("%lf", x)
#define sc(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define sf(x) scanf("%lf", &x)
#define IOS 

#endif

#ifndef FASTIO
    #define IOS { ios :: sync_with_stdio(false); cin.tie(0); }
#endif

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) {
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef vector < int > vi;

const int maxn = 2e5 + 7;

const ll inf = 1e15;

const ll md = 1e9 + 7;


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}

ll a[maxn];
ll sz[maxn];
pair<ll, int> q[maxn];
map<ll, int> M;
vector < int > G[maxn];

ll tsz[maxn];
ll f[maxn];

void dfs(int x, int pi) {
    sz[x] = 1; f[x] = 0;
    for (int y : G[x]) {
        if (y == pi) continue;
        dfs(y, x);
        sz[x] += sz[y];
        f[x] += f[y] + sz[y];
    }
}

int main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;

    int n; cin >> n;
    
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        q[i] = {a[i], i};
        sz[i] = 1;
        M[a[i]] = i;
    }

    sort(q + 1, q + n + 1);

    int eg = 0;
    vector < pii > veg;

    
    for (int i = n; i >= 1; i--) {
        int j = q[i].S;
        ll curz = n - sz[j] - sz[j];
        if (a[j] - curz < a[j]) {
            int y = M[a[j] - curz];
            if (y) {
                G[y].pb(j); G[j].pb(y);
                veg.pb({y, j});
                sz[y] += sz[j];
                eg++;
            }
        }
    }

    if (eg < n - 1) {
        cout << -1 << endl; return 0;
    }

    dfs(1, -1);

    if (f[1] != a[1]) {
        cout << -1 << endl;
        return 0;
    }

    for (pii e : veg) {
        cout << e.F << " " << e.S << endl;
    }
}


Measured memory_bytes: 29556
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000001

using namespace std;
#define ll long long
#define dbg if(0)



int main(){
    int a=0;
    int b=0;
    cin>>a>>b;
    cout<<a+b/2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//harmony
int main(){
    long n,s,c=0;
    cin>>n>>s;
    if((s+n)%2==0){
        c=(s+n)/2;
        cout<<c<<endl;
    }

    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i,j,temp;
	cin>>n;
	vector<pair<ll,int>> a;
	REP(i,0,n-1) cin>>temp,a.EB(temp,i+1);
	sort(all(a));
	reverse(all(a));
	//dbg(a);
	ll dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	REP(i,1,n){
		REP(j,0,i){
			if(!j) dp[i][j]=dp[i-1][j]+a[i-1].F*abs(a[i-1].S-n+i-1-j);
			else if(j==i) dp[i][j]=dp[i-1][j-1]+a[i-1].F*abs(a[i-1].S-j);
			else dp[i][j]=max(dp[i-1][j-1]+a[i-1].F*abs(a[i-1].S-j),dp[i-1][j]+a[i-1].F*abs(a[i-1].S-n+i-1-j));
			//dbg(i,j,dp[i][j]);
		}
	}
	ll ans=0;
	REP(i,0,n) ans=max(ans,dp[n][i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 34896
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
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; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    string S;
    cin >> S;
    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define lli long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fi(a,n) for(lli i=a; i<=n; i++)
const int M=1000000007;
using namespace std;
const int mxn=2e5;
int n,m,p[mxn];
vector<int> adj[mxn],ans;
int dp[mxn];
int vis[mxn],act[mxn];

// int pro(int a[],int n){
// 	int mxp=1;
// 	int mip=1;
// 	int mxf=1;
// 	int f=0;
// 	int mini=INT_MAX;
// 	int maxa=INT_MIN;
// 	for(int i=0;i<n;i++){
// 		mini=min(mini,arr[i]);
// 		maxa=max(maxa,a[i]);
// 		if(a[i]>0){
// 			mxp=mxh*a[i];
// 			mip=min(mip*a[i],1);
// 			flag=1;
// 		}
// 		else if(a[i]==0){
// 			mxp=1;mip=1;
// 		}
// 		else {
// 			int temp=
// 		}
// 	}
// }
int main() {
	// io
fast
int t;
cin>>t;
if(t==0)cout<<1<<endl;
else cout<<0;
}


Measured memory_bytes: 8336
int main(){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				printf("#");
			}
			printf("\n");
			if(i==H)printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 572
N, K = list(map(int, input().split()))
pro = 0.0
for i in range(1, N + 1):
    mul = i
    count = 0
    while mul < K:
        mul *= 2
        count += 1
    pro += (1 / N) * ((1 / 2) ** count)
print('{:.10f}'.format(pro))

Measured memory_bytes: 2940
#include <iostream>
#include<cstring>

using namespace std;

int main()
{
    int n,f[1000]={0},a[100];
    string b;
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>b;
    a[i]=b[0];
    f[a[i]]++;
    }
    cout<<"AC x "<<f['A']<<endl;
    cout<<"WA x "<<f['W']<<endl;
    cout<<"TLE x "<<f['T']<<endl;
    cout<<"RE x "<<f['R']<<endl;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int a, b;
    cin >> a >> b;

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

    return 0;
}

Measured memory_bytes: 256
nums = [int(x) for x in input().split()]

bool1 = nums[0] == nums[1]
bool2 = nums[0] == nums[2]
bool3 = nums[1] == nums[2]

bool_list = [bool1, bool2, bool3]

if bool_list.count(True) == 0 or bool_list.count(True) == 3:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
import heapq
import math

n = int(input())
if n==1:
    print(0);exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

li = factorization(n)
ans = 0
for f in li:
    f = f[1]
    for i in range(1,f+1):
        if i>f:
            break
        f-=i
        ans+=1
print(ans)
        

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

int main(){
    int n,k;
    cin>>n>>k;
    set<int>se;
    rep(i,k){
        int d; cin>>d;
        rep(j,d){
            int a; cin>>a;
            se.insert(a);
        }
    }
    cout<<n-se.size()<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int N, X;

    cin >> N >> X;

    vector<long long> D(N+2, 0);
    for(int i = 2; i <= N+1 ; i++) {
        int tmp;
        cin >> tmp;
        D[i] = D[i-1] + tmp;
        if (D[i] > X) {
            cout << i - 1 <<endl;
            return 0;
        }
    }
    cout << N+1 << endl;

}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0513
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

vector<int> cut(vector<int> &card, int n, int k) {
	vector<int> temp(2 * n);
	for (int i = k; i < 2 * n;i++) {
		temp[i - k] = card[i];
	}
	for (int i = 0; i < k;i++) {
		temp[2*n - k + i] = card[i];
	}
	return temp;
}

vector<int> riffle(vector<int> &card, int n) {
	vector<int> temp(2 * n);
	for (int i = 0; i < n;i++) {
		temp[2 * i] = card[i];
		temp[2 * i + 1] = card[n + i];
	}
	return temp;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<int> card(2*n);
	iota(card.begin(), card.end(), 1);
	for (int i = 0; i < m;i++) {
		int k; cin >> k;
		if (k == 0) {
			card = riffle(card, n);
		}
		else {
			card = cut(card, n, k);
		}
	}
	for (auto n : card) {
		cout << n << endl;
	}
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int n;
long long value[2][3];
long long dfs(long long capital, long long i, vector<pair<long long,long long>> &product){
  if(product.size() == 0) return capital;
  else if(i == product.size()-1){
  	return capital/product[i].first*product[i].second + capital%product[i].first;
  }
  long long ret=0;
  for(int j=0;j*product[i].first<=capital;j++){
    ret=max(ret,dfs(capital-j*product[i].first,i+1,product) + j*product[i].second);
  }
  return ret;
}
int main(){
  cin >> n;
  for(int i=0;i<2;i++) for(int j=0;j<3;j++) cin >> value[i][j];
  vector<pair<long long,long long>> forth,back;
  for(int j=0;j<3;j++){
    if(value[0][j]<value[1][j]) forth.push_back({value[0][j],value[1][j]});
    if(value[0][j]>value[1][j]) back.push_back({value[1][j],value[0][j]});                                             
  }
  long long acorn1=dfs(n,0,forth);
  long long acorn2=dfs(acorn1,0,back);
  cout << acorn2 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();
    static int mod = 998244353;

    public static void main(String[] args) {
        int N = in.i();
        int K = in.i();
        int[][] LR = new int[K][];
        for (int i = 0; i < K; i++) {
            LR[i] = new int[]{in.i(), in.i()};
        }
        int[] dp = new int[N + 1];
        dp[1] = 1;
        int[] sum = new int[N + 2];
        sum[2] = 1;
        for (int i = 2; i <= N; i++) {
            for (int j = 0; j < K; j++) {
                int r = i - LR[j][0];
                int l = i - LR[j][1];
                if (r < 1) continue;
                if (l < 1) l = 1;
                dp[i] = sum(dp[i], sum[r + 1], -sum[l]);
            }
            sum[i + 1] = sum(sum[i], dp[i]);
        }
        out.println(dp[N]);
    }

    static int sum(int... a) {
        long s = 0;
        for (int i = 0; i < a.length; i++) {
            s = (s + a[i]) % mod;
        }
        s = (s + mod) % mod;
        return (int)s;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 53232
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;

int main()
{

	int n, tmp, types = 0;
	int key[3] = { -1, -1, -1 };
	map<int, int> cnt;

	cin >> n;

	vector<int> a;

	for (int i = 0; i < n; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}

	for (int i = 0; i < n; i++) {
		auto itr = cnt.find(a[i]);
		if (itr != cnt.end())
			itr->second++;
		else {
			if (types >= 3) {
				types = 4;
				break;
			}
			else {
				cnt.insert(make_pair(a[i], 1));
				key[types] = cnt.find(a[i])->first;
				types++;
			}

		}
	}

	// x y z x y z x y z - 3種 / x, y ,zは任意の異なる数(ただしx⊕y=z)
	// x x 0 x x 0 x x 0 - 2種 / xは任意
	// 0 0 0 0 0 0 0 0 0 - 1種 / 全て0
	// 以上の3通りのとき成立

	if (types == 3) {
		int _cnt = cnt.find(key[0])->second;
		if ((key[0] ^ key[1]) == key[2] && cnt.find(key[1])->second == _cnt && cnt.find(key[2])->second == _cnt)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else if (types == 2) {
		if ((key[0] == 0 && cnt.find(key[0])->second * 2 == cnt.find(key[1])->second) ||
			(key[1] == 0 && cnt.find(key[1])->second * 2 == cnt.find(key[0])->second))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else if (types == 1) {
		if (key[0] == 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		cout << "No" << endl;


	return 0;

}

Measured memory_bytes: 892
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S; cin >> S;
  int i = 0;
  for (char c : S) {
    if (c == '+') ++i;
    else          --i;
  }
  cout << i << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std ;
long  long x , y , ans = 0 ;
int main()
{
	cin >> x >> y ;
	if ( x < 0 && y > 0 ) 
	{
		long long kk = x * -1 ;
		if ( kk > y )
		{
			long long qwq = y * -1 ;
			ans = (abs ( x - (qwq) ) + 1);
		}
		
		else if ( kk < y ) 
		ans = (y - ( x * -1 ) + 1) ; 
		
		else
		ans = 1 ;
		   
	}
	if ( x < 0 && y < 0)
	{
		long long kk = x * -1 , yy = y * -1 ;
		
		if ( kk < yy )
		ans = ( yy - kk + 2 ) ;
		
		else if ( kk > yy)
		ans = ( kk - yy ) ;
		
		else
		ans = 0 ;
	}
	if (  x > 0 && y < 0 )
	{
		long long yy = y * -1 ;
		
		if ( x > yy ) 
		ans = ( x - yy + 1) ;
		
		else if ( x < yy )
		ans = ( yy - x + 1) ;
		
		else
		ans = 1 ;
	}
	
	
	if ( x > 0 && y > 0)
	{
		if ( y > x ) ans = y - x ;
		
		else if ( y < x ) ans = ( x - y + 2) ;
	
		else ans = 0 ;
	}
	
	if ( x > 0 && y == 0)
	ans = x - y + 1 ;
	
	if ( x == 0 && y == 0 )
	ans = 0 ;
	
	if ( x < 0 && y == 0)
	ans = abs (x) ;
	
	if ( x == 0 && y > 0)
	ans = y ;
	
	if ( x == 0 && y < 0)
	ans = abs ( y ) + 1 ;
	
	cout << ans ;
	
	return 0 ;
}

Measured memory_bytes: 256
var
	dp1:array[0..5000]of Boolean;
	dp2:array[0..5000,0..5000]of Longint;
	sum:array[0..5001]of Longint;
	n,k,i,j,id,cnt:Longint;
	flag:Boolean;
	a:array[1..5000]of Longint;
begin
	read(n,k);
	for i:=1 to n do read(a[i]);
	dp2[n][0]:=1;
	for i:=n downto 1 do begin
		for j:=0 to k do dp2[i-1][j]:=dp2[i][j];
		for j:=0 to k-a[i] do if dp2[i][j]=1 then dp2[i-1][j+a[i]]:=1;
	end;
	dp1[0]:=true;
	for i:=1 to n do begin
		sum[0]:=0;
		for j:=0 to k do sum[j+1]:=sum[j]+dp2[i][j];
		flag:=false;
		for j:=0 to k do if dp1[j]then begin
			id:=k-a[i]-j;
			if id<0 then id:=0;
			if sum[k-j]-sum[id]>0 then begin
				flag:=true;
				break;
			end;
		end;
		if not flag then inc(cnt);
		for j:=k downto a[i] do dp1[j]:=dp1[j]or dp1[j-a[i]];
	end;
	writeln(cnt);
end.


Measured memory_bytes: 97792
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 4e3+10;
int n, x, a[N], b[N];
ll dp[N];

int main() {
	scanf("%d%d", &n, &x);
	REP(i,1,n) scanf("%d", a+i),a[i+n]=a[i];
	memset(b,0x3f,sizeof b);
	ll ans = 1e18;
	REP(j,0,n) {
		REP(i,1,n) b[i]=min(b[i],a[i-j+n]);
		ans = min(ans, accumulate(b+1,b+1+n,0ll)+(ll)j*x);
	}
	printf("%lld\n", ans);
}








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

using namespace std;

#define N 200005

int n, m, i, x, y, pos[N], v[N], ans;
queue<int> Q;
vector<int> a[N];

int main (void)
{
	scanf("%d%d",&n,&m);
	for (; m; m--) {
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	Q.push(1),v[1]=1,pos[1]=-1;
	while (!Q.empty()) {
		x=Q.front(); Q.pop();
		for (i=0; i<a[x].size(); i++) {
			y=a[x][i];
			if (v[y]) continue;
			v[y]=1;
			pos[y]=x;
			Q.push(y);
		}
	}
	ans=-1;
	for (i=1; i<=n; i++) if (!v[i]) {
		ans=1;
		break;
	}
	if (ans==1) puts("No");
	else {
		puts("Yes");
		for (i=2; i<=n; i++) printf("%d\n",pos[i]);
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

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

    const int MOD = 1e9+7;
    int N; cin >> N;
    int cnt[60][2] = {0};
    ll ans = 0;
    FOR(i,0,N-1){ 
        ll A; cin >> A;
        FOR(j,0,59){
            bool b = (A&(1LL<<j)) > 0;
            ans = (ans + ((1LL<<j) % MOD * cnt[j][!b] % MOD)) % MOD;
            ++cnt[j][b];
        }
    }
    cout << ans;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

class Main{

    static long[] hash;

    static int[] used;
    static int[][] tmp;
    static int[][] mat;
    static int H,W;
    static boolean ans=false;
    static boolean[][] same;



    static void check(){
        if(ans)return;
        for(int i=0;i<H;++i)tmp[(used[i]%2==0 ? used[i]/2 : H-1-used[i]/2)]=mat[i];

        boolean half = false;
        boolean usd[] = new boolean[W];
        for(int i=0;i<W;++i){
            if(usd[i])continue;
            usd[i]=true;
            boolean flag=false;
            for(int j=0;j<W;++j){
                if(usd[j])continue;
                boolean ok=true;
                for(int h=0;h<H;++h)if(tmp[h][i]!=tmp[H-1-h][j])ok=false;
                if(ok){
                    usd[j]=true;
                    flag=true;
                    break;
                }
            }
            if(!flag){
                if(half)return;
                for(int h=0;h<(H-1-h);++h)if(tmp[h][i]!=tmp[H-1-h][i])return;
                half=true;
            }
        }
        ans=true;
        return;
    }

    static void dfs(int depth){
        if(depth==H || (H%2==1 && depth==H-1)){
            if(H%2==1){
                for(int i=0;i<H;++i)if(used[i]<0){
                    used[i]=depth;
                    check();
                    used[i]=-1;
                }
            }else{
                check();
            }
            return;
        }
        for(int i=0;i<H;++i)if(used[i]<0){
            used[i]=depth;
            for(int j=i+1;j<H;++j){
                if(same[i][j] && used[j]<0){
                    used[j]=depth+1;
                    dfs(depth+2);
                    used[j]=-1;
                }
            }
            used[i]=-1;
        }
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        H = scan.nextInt();
        W = scan.nextInt();
        mat = new int[H][W];
        tmp = new int[H][];
        used = new int[H];
        same = new boolean[H][H];
        Arrays.fill(used,-1);
        int cnt[][] = new int[H][26];
        for(int i=0;i<H;++i){
            String s = scan.next();
            for(int j=0;j<W;++j){
                mat[i][j]=s.charAt(j)-'a';
                cnt[i][mat[i][j]]++;
            }
        }
        for(int i=0;i<H;++i)for(int j=0;j<H;++j){
            for(int k=0;k<26;++k){
                if(cnt[i][k]!=cnt[j][k])break;
                if(k==25)same[i][j]=same[j][i]=true;
            }
        }
        dfs(0);
        if(!ans && H%2==1){
            int[] t = mat[0];
            mat[0] = mat[1];
            mat[1] = t;
            dfs(0);
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");
    }
}

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

int main(){
  int N;
  cin >> N;
  int L[N];
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  sort(L, L+N);
  long long ans = 0;
  for(int i = 0; i < N-2; i++){
    int pos = i+2;
    for(int j = i+1; j < N-1; j++){
      if(pos < N){
        while(L[i]+L[j] > L[pos]){
          pos++;
          if(pos == N){
            break;
          }
        }
      }
      ans += pos-j-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,n=100,ma=0,memo[101]={};
  while(scanf("%d",&a)!=EOF && n--){
    memo[a]++;
    ma=max(ma,memo[a]);
  }
  for(int i=0;i<=100;i++){
    if(memo[i]==ma)cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N + 1);
    A.push_back(0); //先頭に0を追加
    for (int i = 1; i <= N; i++){
        cin >> A.at(i); //最後尾に0を追加
    }
    A.push_back(0);
    
    int S = 0;
    for (int i = 0; i <= N; i++){
            S += fabs(A.at(i) - A.at(i + 1));
    }

    int sum;
    for (int i = 1; i <= N; i++){
        sum = S + fabs(A.at(i - 1) - A.at(i + 1)) - ( (fabs(A.at(i - 1) - A.at(i))) + fabs(A.at(i) - A.at(i + 1)) );
        cout << sum << endl;
    }

}

Measured memory_bytes: 1656
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        for(int i=1; i<s.Length; i++) {
            int n = s.Length - i;
            if (n % 2 == 1) continue;

            bool ok = true;
            for(int j=0; j<n/2; j++) {
                ok &= s[j] == s[n/2 + j];
            }
            if (ok) return n;
        }

        return 1;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
def tsune(pal,R,pre):
    c = 0
    ud = [0 for i in range(n)]
    for i in range(n):
        r = R[i]
        if pal*r > pal*pre:
            pal*=-1
            ud[i] = -pal
        pre =r
    return  ud

def pe(pre):
    ud = [0 for i in range(n)]
    for i in range(n-1):
        if pre >= A[i] and A[i] <= A[i+1]:
            ud[i] = -1
        if pre <= A[i] and A[i] >= A[i+1]:
            ud[i] = 1
        pre = A[i]
    if A[-1] < A[-2]:
        ud[-1] = 0
    if A[-1] > A[-2]:
        ud[-1] = 1
    return ud


def tot(ud):
    tmp = 1000
    kab = 0
    for i in range(n):
        if ud[i] ==-1: #谷　buy kab
            if kab==0:
                kab,tmp = divmod(tmp,A[i])
        elif ud[i] ==1: #　山　sell kab
            tmp +=kab*A[i]
            kab = 0
#        print(tmp,kab)
#    print(ud)
    return tmp
n = ni()
A = list(ma())
ans = 0
ud = pe(1000)
tmp = tot(ud)
ans = max(ans,tmp)
ud = pe(0)
tmp = tot(ud)
ans = max(ans,tmp)
print(ans)


Measured memory_bytes: 9368
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

// 解説見た
func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	n := scanInt()
	s := scanString()
	r, g, b := 0, 0, 0
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'R':
			r++
		case 'G':
			g++
		case 'B':
			b++
		}
	}

	all := r * g * b
	sub := 0
	for i := 0; i < n; i++ {
		for j := (i + 1); j < n; j++ {
			if s[i] == s[j] {
				continue
			}

			k := j*2 - i
			if k >= n || s[k] == s[i] || s[k] == s[j] {
				continue
			}
			sub++
		}
	}

	fmt.Println(all - sub)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


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

typedef long long ll;

int main() {
	ll N,x;
	cin>>N>>x;
	vector<ll> a(N), dp(N,LLONG_MAX);
	for (int i=0; i<N; i++)
		cin>>a[i];
	ll ret=LLONG_MAX;
	for(int i=0; i<N; i++) {
		ll cur=0;
		for(int j=0; j<N; j++)
			dp[j]=min(dp[j],a[(j+N-i)%N]), cur+=dp[j];
		ret=min(ret,cur+i*x);
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int mat[n][m];
    int row[m];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            scanf("%d",&mat[i][j]);
        }
    }
    for(int i = 0;i < m;i++){
        scanf("%d",&row[i]);
    }
    int val;
    for(int i = 0;i < n;i++){
        val = 0;
        for(int j = 0;j < m;j++){
            val += mat[i][j]*row[j];
        }
        printf("%d\n",val);
    }
    return 0;
}



Measured memory_bytes: 2720
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#define USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 30;
const double EPS = 1E-9;

int ga[9];
int ja[9];

int main(){
	int T;
	cin >> T;
	for(int t = 0; t < T; t++){
		for(int i = 0; i < 9; i++) cin >> ga[i];
		for(int j = 0; j < 9; j++) cin >> ja[j];
		sort(ga, ga + 9);
		int countg = 0;
		int countj = 0;
		do{
			int sg = 0, sj = 0;
			for(int i = 0; i < 9; i++){
				if(ga[i] < ja[i]){
					sj += ja[i] + ga[i];
				}else{
					sg += ja[i] + ga[i];
				}
			}
			if(sg > sj){
				countg++;
			}else{
				countj++;
			}
		}while(next_permutation(ga, ga + 9));
		double pg = (double)countg / (double)(countg + countj);
		double pj = 1 - pg;
		cout << pg << " " << pj << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

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

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

bool isg(string s)
{
  if(s.size()%2==1) return false;
  REP(i, s.size()/2) {
    if(s[i]!=s[i+s.size()/2]) return false;
  }
  return true;
}


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

  ll ans = 0;
  // bool ok = false;
  for(ll i = s.size(); i > 1; i --) {
    s.erase(s.size()-1);
    if(isg(s)) {
      cout << s.size() << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  // cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int a,b;
  cin>>a>>b;
  int start=1;
  b=b-1;
  int ans;
  ans=b/(a-1);
    if(b%(a-1)!=0)ans++;
  cout<<ans<<endl;
}

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


#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; rep(i_debug, v.size()) { cout << v[i_debug] << ",";}cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; rep(i_debug, m.size()) { rep(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; } cout << endl; } }

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t/2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

int main() {
    int N,K;
    cin >> N >>K;
    mint ans = K;
    ans = ans.pow(N);
    vector<mint> yaku(K+1,0);

    for(int i=K;i>=2;--i){
        mint cnt(K/i);
        yaku[i] = cnt.pow(N);
        for(int j=2;i*j<=K;++j){
            yaku[i]-=yaku[i*j];
        }
        ans += (yaku[i]*(i-1));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 4048
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a[2][4];
  while(cin>>a[0][0]){
    rep(i,3)cin>>a[0][i+1];
    rep(i,4)cin>>a[1][i];
    int co[2]={0};
    rep(i,4)rep(j,4){
      if(a[0][i]==a[1][j]&&i==j)co[0]++;
      else if(a[0][i]==a[1][j])co[1]++;
    }
    cout<<co[0]<<" "<<co[1]<<endl;
  }
}

Measured memory_bytes: 1160