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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

int N, A, B, C;
vector<string> S;
int dp[MAX_N][5][5][5];

// S[i] を見ていて、 (a, b, c) のとき行けるなら 1, 無理なら 0
int dfs(int i, int a, int b, int c) {
    if(i >= N) {
        return (a >= 0 && b >= 0 && c >= 0) ? 1 : 0;
    }
    if(a < 0 || b < 0 || c < 0) { return 0; }
    if(a >= 5) { a = 4; }
    if(b >= 5) { b = 4; }
    if(c >= 5) { c = 4; }

    int& ret = dp[i][a][b][c];
    if(~ret) { return ret; }

    if(S[i] == "AB") {
        ret = dfs(i+1, a+1, b-1, c);
        chmax(ret, dfs(i+1, a-1, b+1, c));
    }
    else if(S[i] == "AC") {
        ret = dfs(i+1, a+1, b, c-1);
        chmax(ret, dfs(i+1, a-1, b, c+1));
    }
    else if(S[i] == "BC") {
        ret = dfs(i+1, a, b+1, c-1);
        chmax(ret, dfs(i+1, a, b-1, c+1));
    }
    return ret;
}


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

    cin >> N >> A >> B >> C;
    S.resize(N);
    REP(i, N) {
        cin >> S[i];
    }
    MINUS(dp);
    int res = dfs(0, A, B, C);
    if(res == 0) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    // 経路復元
    int a = A;
    int b = B;
    int c = C;
    vector<char> ans;
    REP(i, N) {
        if (S[i] == "AB") {
            if(dfs(i+1, a+1, b-1, c) == 1) {
                ans.push_back('A');
                a++;
                b--;
            }
            else {
                ans.push_back('B');
                a--;
                b++;
            }
        } else if (S[i] == "AC") {
            if(dfs(i+1, a+1, b, c-1) == 1) {
                ans.push_back('A');
                a++;
                c--;
            }
            else {
                ans.push_back('C');
                a--;
                c++;
            }
        } else if (S[i] == "BC") {
            if(dfs(i+1, a, b+1, c-1) == 1) {
                ans.push_back('B');
                b++;
                c--;
            }
            else {
                ans.push_back('C');
                b--;
                c++;
            }
        }
    }
    for(auto& c : ans) {
        printf("%c\n", c);
    }

    return 0;
}


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

using namespace std;

int main() {
long long l,r;
cin>>l>>r;
 long long  mina=100000000;

int a=l%673;
if((r-l+a>=673)&&(r-l+1>=3))
cout<<0;
else
{
    for(int i=l;i<=r-1;i++)
    {
        for(int j=i+1;j<=r;j++)
        {
          if(((i%2019)*(j%2019))%2019<mina)
          mina=((i%2019)*(j%2019))%2019;
       
        }
    }
cout<<mina;
}
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
ac,wa,tle,re=0,0,0,0
for i in range(int(input())):
    s=input()
    if s=='AC': ac+=1
    elif s=='WA': wa+=1
    elif s=='TLE': tle+=1
    elif s=='RE': re+=1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)


Measured memory_bytes: 69844
num, ave = map(int, input().split())
numx = list(map(int, input().split()))

L = len(numx)
numy = [0] * L
for i in range(L):
    numy[i]= numx[i] - ave

if abs(min(numy)) < abs(max(numy)):
    maxX = max(numy)
else:
    maxX = abs(min(numy))
dp = [[0] * (2 * maxX * L + 1) for i in range(L+1)]
dp[0][maxX*L] = 1
for i in range(L):
    for j in range(2*maxX*L+1):
        if (j-numy[i]) < 0 or (j-numy[i]) > 2*maxX*L:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j] + dp[i][j-numy[i]]
print(dp[L][maxX*L]-1)

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


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

    if(a%2==1&&b%2==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

int main() {
	int n, q;
	while (cin >> n >> q, n) {
		map<int, string>mp;
		map<string, int>m;
		rep(i, n) {
			string s;
			int j, k;
			cin >> s >> j >> k;
			mp[k - j + 1] = s;
			m[s] = j;
		}
		rep(i, q) {
			int d; cin >> d;
			bool flag = false;
			for (auto p : mp) {
				if (0 <= d - p.first&&d - p.first < m[p.second]) {
					flag = true;
					cout << p.second << ' ' << d - p.first + 1 << endl;
					break;
				}
			}
			if (!flag)puts("Unknown");
		}
	}
}

Measured memory_bytes: 3272
n = int(raw_input())
A = map(int, raw_input().split())

def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in xrange(p,r):
        if A[j] <= x:
            i += 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
    tmp = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp
    return i+1

def main():
    i = partition(A, 0, n-1)
    print ' '.join(map(str, A[:i])), '[{}]'.format(A[i]), ' '.join(map(str,A[i+1:]))
    return 0

main()

Measured memory_bytes: 14848
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    bool f = false;
    if (a > b) {
        swap(a, b);
        f = true;
    }
    vector<int> s(n);
    iota(begin(s), end(s), 1);
    int k = n, c = n;
    bool rev = false;
    for (int i = 0, l = 0; i <= n; ++i) {
        if (i % b == 0 || k == a) {
            reverse(begin(s) + l, begin(s) + i);
            if (i - l == b) rev = true;
            l = i;
            c = k;
        } else {
            --k;
        }
    }
    if (c > a || !rev) {
        cout << -1 << endl;
        return 0;
    }

    if (f) {
        reverse(begin(s), end(s));
        // for (int i = 0; i < n; ++i) s[i] = n + 1 - s[i];
    }
    for (int i = 0; i < n; ++i) {
        cout << s[i] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3328
import sys
input=sys.stdin.readline
n=int(input())
H=[]
for _ in range(n):
    a,b,c=map(int,input().split())
    H.append((a,b,c))
DP=[[0]*3 for _ in range(n)]
DP[0]=[H[0][0],H[0][1],H[0][2]]
for i in range(1,n):
    DP[i][0]=max(DP[i-1][1]+H[i][0],DP[i-1][2]+H[i][0])
    DP[i][1]=max(DP[i-1][2]+H[i][1],DP[i-1][0]+H[i][1])
    DP[i][2]=max(DP[i-1][0]+H[i][2],DP[i-1][1]+H[i][2])
print(max(DP[-1]))

Measured memory_bytes: 69980
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	ll x;
	cin >> x;
	ll res = 0;
	res += x / 500 * 1000;
	x %= 500;
	res += x / 5 * 5;
	put(res);
	return 0;
}

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N;
int P[200010];
int idx[200010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) {
    cin >> P[i];
    P[i]--;
    idx[P[i]] = i;
  }
  int l = 0, r = 0;
  int ans = 0;
  while (l < N) {
    while (r+1 < N && idx[r] < idx[r+1]) r++;
    CHMAX(ans, r-l+1);
    l = ++r;
  }
  cout << N-ans << endl;

  return 0;
}

Measured memory_bytes: 3328
S = []
H = []
C = []
D = []

value = [1,2,3,4,5,6,7,8,9,10,11,12,13]


n = int(input())

for i in range(n):
  M,N = map(str,input().split())
  if M == "S":
    S.append(int(N))
  if M == "H":
    H.append(int(N))
  if M == "C":
    C.append(int(N))
  if M == "D":
    D.append(int(N))

for i in range(len(value)):
  if (value[i] in S) == False:
    print("S",value[i])
for i in range(len(value)):
  if (value[i] in H) == False:
    print("H",value[i])
for i in range(len(value)):
  if (value[i] in C) == False:
    print("C",value[i])
for i in range(len(value)):
  if (value[i] in D) == False:
    print("D",value[i])


Measured memory_bytes: 5616
n = int(input())
list = [0]*4

for i in range(n):
    a = str(input());
    if a == 'AC':
        list[0]+=1;
    elif a == 'WA':
        list[1]+=1;
    elif a == 'TLE':
        list[2]+=1;
    else:
        list[3]+=1;

print('AC','x',list[0]);
print('WA','x',list[1]);
print('TLE','x',list[2]);
print('RE','x',list[3]);

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
using namespace std;
typedef long long i64;
 
const int maxn = 1e5;

int main() {
    int k;
    cin >> k;
    if (k <= 9) {
        cout << k << endl;
        return 0;
    }
    int a[99];
    int d = 2;
    a[0] = 0;
    a[1] = 1;
    for (int _ = 0; _ < k - 10; _++) {
        int found = -1;
        for (int i = 0; i < d - 1; i++) {
            // printf("%d %d\n", a[i], a[i+1]);
            if (a[i] <= a[i + 1] && a[i + 1] - (a[i] + 1) <= 1 && a[i] < 9) {
                a[i] += 1;
                found = i;
                break;
            }
        }
        if (found == -1 && abs(a[d - 1] + 1 - a[d - 2]) <= 1 && a[d - 1] < 9) {
            a[d - 1] += 1;
            found = d - 1;
        } else if (found == -1) {
            d++;
            a[d - 1] = 1;
            found = d - 1;
        }
        for (int j = found - 1; j >= 0; j--) {
            a[j] = max(a[j + 1] - 1, 0);
        }
    }
    for (int i = d - 1; i >= 0; i--) {
        cout << a[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
//python interactive_runner.py python3 local_testing_tool.py 0 -- ./Code
 
#define x first
#define y second
#define rep(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn(i,b) for(int i = 0; i < int(b); ++i)
const long long INF =1000000000000000000;

void solve(){
	long long N;
	cin>>N;
	long long M = N;
	int suma = 0;
	for(long long j = 2;j*j<=N;j++){
		int num = 0;
		while(M%j==0){
			M/=j;
			num++;
		}
		if(num>=1){
			int start = 0;
			int fin = 100;
			while(fin-start>1){
				int mid = (fin+start)/2;
				if((1LL*(mid)*(mid+1))>2*num){
					fin = mid;
				}
				else{
					start = mid;
				}
			}
			suma +=start;	
		}
		
	}
	if(M!=1){
		suma+=1;
	}
	cout<<suma<<'\n';
}
int main(){

	 solve();
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
la = list(map(int, input().split()))

lb = [0]*(n+1)
lb_flip = [-100000000000000]*(n+1)

for i in range(n):
	lb[i+1] = max(lb[i]+la[i], lb_flip[i]-la[i])
	lb_flip[i+1] = max(lb[i]-la[i], lb_flip[i]+la[i])

#print(lb)
#print(lb_flip)

print(lb[n])

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

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

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
using Int = int64_t;


void calc() {

	std::string S; std::cin >> S;
	bool flag = true;
	rep(i, S.size() - 1) {
		if (S[i] != S[i + 1])flag = false;
	}

	if (flag)std::cout << "No";
	else std::cout << "Yes";
	
}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
int cnt[2020];
int dist[2020][2020];
vector<int> ga[2020];
queue<int> q;
void BFS(int src){
	q.push(src);
	memset(dist[src],63,sizeof(dist[src]));
	dist[src][src]=0;
	int pp;
	while(q.size()){
		pp=q.front();
		q.pop();
		for(int snk:ga[pp]){
			if(dist[src][snk]>dist[src][pp]+1){
				dist[src][snk]=dist[src][pp]+1;
				q.push(snk);
			} 
		}
	}
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	cin>>n>>x>>y;
	for(int i=1;i<n;i++){
		ga[i].push_back(i+1);
		ga[i+1].push_back(i);
	}
	ga[x].push_back(y);
	ga[y].push_back(x);
	for(int i=1;i<=n;i++){
		BFS(i);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			cnt[dist[i][j]]++;
		}
	}
	for(int i=1;i<n;i++)
		cout<<cnt[i]<<endl;
	return 0;
}


Measured memory_bytes: 16128
def IfSquare(n):
    i = 0
    while i*i < n:
        i += 1
    if i*i == n:
        return True
    else:
        return False

n,d = map(int,input().split(' '))
X = []
i = 0
while i < n:
    x = tuple(map(int,input().split(' ')))
    X.append(x)
    i += 1
count = 0
i = 0
while i < len(X):
    j = i+1
    while j < len(X):
        distance = 0
        p = 0
        while p < d:
            distance += (X[i][p] - X[j][p])*(X[i][p] - X[j][p])
            p += 1
        if IfSquare(distance):
            count += 1
        j += 1
    i += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K; cin>>N>>K;
  vector<pair<ll,ll>>Z(N);
  vector<ll>X(N),Y(N);
  for(int i=0; i<N; i++){
    ll x,y; cin>>x>>y;
    X[i]=x, Y[i]=y, Z[i]={x,y};
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ll ans=4e18+1;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      for(int a=0; a<N-1; a++){
        for(int b=a+1; b<N; b++){
          ll wl=X[i], wh=X[j], hl=Y[a], hh=Y[b], temp=0;
          for(int k=0; k<N; k++){
            if(wl<=Z[k].first && Z[k].first<=wh && hl<=Z[k].second && Z[k].second<=hh) temp++;
          }
          if(temp>=K) ans=min(ans,(wh-wl)*(hh-hl));
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
if x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 12:
  x_group = "A"
elif x == 4 or x == 6 or x == 9 or x == 11:
  x_group = "B"
else:
  x_group = "C"
if y == 1 or y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12:
  y_group = "A"
elif y == 4 or y == 6 or y == 9 or y == 11:
  y_group = "B"
else:
  y_group = "C"
if x_group == y_group:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
h,w = map(int,input().split())
s_list = [list(input()) for nesya in range(h)]
for s in s_list:
  s.insert(0,'.')
  s.append('.')
a = ['.']*(w+2)
s_list.insert(0,a)
s_list.append(a)
c = 0
for i in range(1,w+1):
  for j in range(1,h+1):
    if c == 1:
      break
    if s_list[j][i] == '#':
      if s_list[j-1][i] == s_list[j+1][i] == s_list[j][i-1] == s_list[j][i+1] == '.':
        c += 1
        print('No')
        break
if c == 0:
  print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int D;
    cin >> D;
    string ans;
    if ( D == 25 ) ans = "Christmas";
    if ( D == 24 ) ans = "Christmas Eve";
    if ( D == 23 ) ans = "Christmas Eve Eve";
    if ( D == 22 ) ans = "Christmas Eve Eve Eve";
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{   
    int n;
    scanf("%d", &n);
    int d[n];
    for (int i=0; i < n; i++) scanf("%d", &d[i]);

    int num[101];
    for (int i=0; i < 101; i++) num[i] = 0;

    for (int i=0; i < n; i++) num[d[i]]++;

    int res = 0;
    for (int i=0; i < 101; i++){
        if (num[i] != 0) res++;
    }

    printf("%d\n", res);

    return 0;
}


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

using namespace std;


void solve(){

  cout << fixed << setprecision(5);
  long long a, b;
  cin >> a >> b;
  double answer = (a + b) / 2.0;
  // 1.5 --> 15
  //cout << "Test " << (long long)(10.0 * answer) << endl;
  if((long long)(10.0 * answer) % 10 == 0){
    cout << (long long)answer << endl;
  }
  else{

  //  cout << answer << endl;
    cout << "IMPOSSIBLE" << endl;
  }

}

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


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

#define INT_BITS 64
typedef long long ll;

ll maxSubarrayXOR(ll a[], int n) {
    int index = 0;
    for(int i = INT_BITS-1; i >= 0; i--) {
        int pos = index;
        int f = 0;
        for(int j = index; j < n; j++) {
            if((a[j] & (1LL << i))) f = 1, pos = j;
        }
        if(!f) continue;
        swap(a[index], a[pos]);
        for(int j = 0; j < n; j++) {
            if(j != index && (a[j] & (1LL << i))) a[j] ^= a[index];
        }
        index++;
    }
    ll res = 0;
    for(int i = 0; i < n; i++) res ^= a[i];
    return res;
}

int n;
ll a[100010], d[60], ans = 0;
int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        scanf("%lld", a+i);
        for(int j = 0; j < INT_BITS; j++) {
            if((a[i] & (1LL << j))) d[j]++;
        }
    }
    for(int i = 0; i < 60; i++) {
        if((d[i] & 1)) {
            ans += (1LL << i);
            for(int j = 0; j < n; j++) {
                if((a[j] & (1LL << i))) a[j] ^= (1LL << i);
            }
        }
    }
    cout << ans + 2*maxSubarrayXOR(a, n);
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){

    ll a,b;
    cin >> a >> b;
    ll g= gcd(a,b);

    vector<ll> v;

    for(ll i = 2;i*i<=g;i++){
        if(g%i)continue;
        else{
            v.push_back(i);
            while(g%i==0){
                g/=i;
            }
        }
    }
    if(g!=1)v.push_back(g);


    cout << v.size()+1 << endl;
    return 0;
}  

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

using namespace std;

int main(){

    int n;
    cin >> n;

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

    //累積和と累積xor
    vector<int> accum_sum(n + 1, 0);
    vector<int> accum_xor(n + 1, 0);

    for(int i = 0; i < n; ++i){
        accum_sum[i + 1] = accum_sum[i] + a[i];
        accum_xor[i + 1] = accum_xor[i] ^ a[i];
    }

    //二分探索用の判定関数
    //stから見てnum個先までの和とxorが同じかどうかを判定する
    auto func = [&](int st, int num){

        if(st + num >= n)
            return false;

        int sum_add = accum_sum[st + num + 1] - accum_sum[st];
        int sum_xor = accum_xor[st + num + 1] ^ accum_xor[st];

        return (sum_add == sum_xor);
    };

    long long answer = 0;

    for(int i = 0; i < n; ++i){

        int ok = 0;
        int ng = 1e9;

        while(ng - ok > 1){

            int num = (ok + ng) / 2;
            (func(i, num) ? ok : ng) = num;
        }
        answer += ok + 1;
    }

    cout << answer << endl;


}

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

using namespace std;

typedef long long ll;

const int N = 200005;


int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	string s;
	cin>>s;
	
	int x = (s[0]-'0')*10 + (s[1]-'0');
	int y = (s[2]-'0')*10 + (s[3]-'0');
	
	if(x < 13 && x != 0){
		if(y < 13 && y != 0){
			cout<<"AMBIGUOUS";
		}
		else{
			cout<<"MMYY";
		}
	}else{
		if(y < 13 && y!=0){
			cout<<"YYMM";
		}
		else{
			cout<<"NA";
		}
	}
	
	return 0;
}


Measured memory_bytes: 3624
// new day,new strength,new thougts

#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;
const ll mod=1e9+7;

#pragma GCC Optimize("Ofast")

ll f(ll num){
	ll ans=0;
	while(num>0){
		ans+=(num%10);
		num/=10;
	}
	return ans;
}

int main(){
	ll n;cin>>n;
	ll ans=inf;
	FOR(i,1,n-1){
		ans=min(ans,f(i)+f(n-i));
	}
	cout<<ans;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    string S1 = S.substr(0, N/2);
    string S2 = S.substr(N/2);
    if (S1 == S2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())

a = [num for num in map(int, input().split())]

#print(n, a)

def t(i):
  ret = 0
  
  while True:
    if i % 2 == 0:
      ret += 1
      i = i / 2
    else:
      break
  
  return ret

ans = 1000000
for i in range(n):
  ret = t(a[i])
  #print(ret)
  if ret == 0:
    print(0)
    sys.exit(0)
  else:
    #print(ret, ans, min(ret, ans))
    ans = min(ret, ans)
print(ans)

Measured memory_bytes: 38640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		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;
	}

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

///////////////////////////



int main() {
	ll N, M;
	cin >> N >> M;

	vector<ll> c(100001,0);
	repn(i, N) {
		ll x;
		cin >> x;
		c[x]++;
	}

	vector<vector<ll>> rm(M);
	rep(i, 100001) {
		if (c[i] > 0) {
			rm[i%M].push_back(c[i]);
		}
	}


	vector<ll> cnt(M,0), od(M,0);
	rep(i, M) {
		for (ll j : rm[i]) {
			cnt[i] += j;
			if (j % 2 == 1) { od[i]++; }
		}

		//cout << i << cnt[i] << od[i] << endl;
	}

	ll ans = 0;
	ans += cnt[0] / 2;


	repn(i, M - 1) {
		ll j = M - i;
		if (j < i) { continue; }
		if (j == i) { ans += cnt[i] /2; continue; }

		if ((od[i] <= cnt[j]) && (od[j] <= cnt[i])) { ans += (cnt[i] + cnt[j]) / 2; }
		else { ll amari = max(od[i] - cnt[j], od[j] - cnt[i]); ans += (cnt[i] + cnt[j] - amari) / 2; }
		
	}

	cout << ans << endl;

	system("PAUSE");
}


Measured memory_bytes: 8312
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> auto gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> auto ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> auto lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> auto le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    int n, m;
    while(cin >> n >> m and n and m) {
        vector<ll> p(n + 1);
        vector<ll> pairs = {0};
        for(int i = 1; i <= n; i++) {
            cin >> p[i];
        }
        sort(p.begin(), p.end());
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if(p[i] + p[j] <= m) {
                    pairs.push_back(p[i] + p[j]);
                }
            }
        }
        sort(pairs.begin(), pairs.end());
        ll ans = max(p[le(p.begin(), p.end(), m)], pairs[le(pairs.begin(), pairs.end(), m)]);
        for(int i = 0; i < pairs.size() and pairs[i] <= m; i++) {
            ans = max(ans, pairs[i] + p[le(p.begin(), p.end(), m - pairs[i])]);
            ans = max(ans, pairs[i] + pairs[le(pairs.begin(), pairs.end(), m - pairs[i])]);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 18844
def li():
    return [int(x) for x in input().split()]

N, K = li()
P = [0] + li()
C = [0] + li()

def get_cycle(start_i):
    cycle = []
    i = start_i
    while True:
        i = P[i]
        if i == start_i:
            break
        cycle.append(i)
    cycle.append(start_i)
    return cycle

def get_cycle_scores(cycle):
    score = 0
    scores = [score]
    for i in cycle:
        score += C[i]
        scores.append(score)
    return scores

max_scores = []
for start_i in range(1,N+1):
    cycle = get_cycle(start_i)
    scores = get_cycle_scores(cycle)
    cycle_len = len(cycle)
    score_per_cycle = scores[cycle_len]
    # 1cycle以下の場合は全て調べればよし
    if K <= len(cycle):
        max_score = max(scores[move] for move in range(1, K+1))
        max_scores.append(max_score)
        continue
    # 1サイクルごとのスコアがマイナスならサイクルを回らないのがハイスコア
    if score_per_cycle <= 0:
        max_score = max(scores[move] for move in range(1, cycle_len+1))
        max_scores.append(max_score)
        continue
    # 1サイクルごとのスコアがプラスなら限界までサイクルを回るのがハイスコア
    # ラスト1cycleのスコアを調べる
    scores_last_cycle = []
    for move in range(K-cycle_len+1, K+1):
        # 何周したか
        loop_cnt = move // cycle_len
        # あまり
        rest_move = move % cycle_len
        # スコア = 1周ごとのスコア * 何周したか + あまり
        score = loop_cnt * score_per_cycle + scores[rest_move]
        scores_last_cycle.append(score)

    max_scores.append(max(scores_last_cycle))

print(max(max_scores))



Measured memory_bytes: 127692
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){

    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}


int n;

void dfs(string s, char mx){
    if(s.length()==n){
        cout<<s<<endl;
    }else{
        for(char c='a';c<=mx;c++){
            dfs(s+c,((c==mx) ? (char)(mx+1) : mx));
        }
    }
}

signed main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    rep(i,0,n) cin>>a[i];

    map<int,int> mp;
    vector<int> jun;

    mp[1]=1;
    jun.push_back(1);
    int pred=1;
    int cnt=1;
    int st=0;
    int len=n-1;

    for(int i=0;i<n;i++){
        cnt++;
        if(mp[a[pred-1]]!=0LL){
            jun.push_back(a[pred-1]);
            st=mp[a[pred-1]];
            len=cnt-st;
            break;
        }
        else{
            jun.push_back(a[pred-1]);
            mp[a[pred-1]]=cnt;
            
            pred=a[pred-1];
        }
    }
    
    /*rep(i,0,n+1){
        cout<<jun[i]<<" ";
    }*/
    
    //cout<<endl;
    
    if(k<st-1LL){
        cout<<jun[k]<<endl;
    }else{
        cout<<jun[st-1LL+((k-st+1LL)%len)]<<endl;
    }
    //cout<<len<<" "<<st<<endl;
    //cout<<(727202214173249351-2)%3<<endl;


}  

Measured memory_bytes: 18440
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { a:[usize;5],};
    let mut sum = 0;
    for i in 0..5 {
        sum += if a[i] >= 40 { a[i] } else { 40 };
    }
    println!("{}", sum / 5);
}



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

int main() {
    ll n;cin>>n;
    ll a[n],b[n],c[n];
    for(ll i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];

    for(ll i=1;i<n; i++){
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(a[i-1],c[i-1]);
        c[i]+=max(a[i-1],b[i-1]);
    }
    cout << max(a[n-1], max(b[n-1], c[n-1]));
}


Measured memory_bytes: 5980
#include <stdio.h>
int X[100001], LH[100001];
int L[100001], R[100001];
int flag[100001], N;
void qsort(int l, int r)
{
	int i = l, j = r, mid;
	mid = R[(l+r)/2];
	do
	{
		while(R[i]<mid) i++;
		while(R[j]>mid) j--;
		if(i<=j)
		{
			int t = R[i]; R[i] = R[j]; R[j] = t;
			t = L[i]; L[i] = L[j]; L[j] = t;
			i++; j--;
		}
	}while(i<=j);
	if(i<r) qsort(i, r);
	if(l<j) qsort(l, j); 
}
int main()
{
	scanf("%d", &N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d%d", &X[i], &LH[i]);
		L[i] = X[i]-LH[i];
		R[i] = X[i]+LH[i];
	}
	qsort(1, N);
	int temp = N, end = R[1];
	for(int i=2;i<=temp;i++)
	{
		if(L[i]<end)
		{
			N--;
		}
		else
		{
			end = R[i];
		}
	}
	printf("%d\n", N);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
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;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  int a,b,c; cin >>a >>b >>c;
  if (a+b+c>=22){
    cout <<"bust" <<endl;
  }else{
    cout <<"win" <<endl;
  }
  
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;

void main()
{
	auto ip = readln.split, A = ip[0], B = ip[1], C = ip[2];
	if(A == B){
		writeln(C);
	}
	if(B == C){
		writeln(A);
	}
	if(C == A){
		writeln(B);
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

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

  int maximam = max(a,b);
  maximam = max(maximam,c);
  
  printf("%d\n",a+b+c-maximam+(int)pow(2,K)*maximam);

  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

int main() {
  int A[5];
  for (auto &a: A) {
    cin >> a;
  }

  sort(ALL(A),[](int a, int b){ return (a-1)%10 < (b-1)%10; });

  int ans = accumulate(begin(A)+1,end(A),A[0],[](int acc, int x){ return acc+((x+9)/10)*10;});
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  static int N;
  static int[] h;
  static int[] memo;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    h = new int[N];
    memo = new int[N];

    for(int i = 0; i < N; i++){
      h[i] = sc.nextInt();
      memo[i] = -1;
    }
    memo[0] = 0;
    System.out.println(dp(N - 1));
  }

  static int dp(int i){
    if(memo[i] == -1){
      int one = (int)1e+5;
      int two = (int)1e+5;

      one = dp(i - 1) + Math.abs(h[i] - h[i - 1]);
      if(i >= 2)
      	two = dp(i - 2) + Math.abs(h[i] - h[i - 2]);

      memo[i] = Math.min(one, two);
    }
    return memo[i];
  }
}

Measured memory_bytes: 60812
#include <stdio.h>
#define N_MAX 50000

#include <stdlib.h>
#include <math.h>

char* eratosthenes(int N){
     char *a=malloc(N+1); int i, j;
     a[0]=0, a[1]=0; for(i=2; i<=N; i++) a[i]=1;
     for(i=2; i<=(int)sqrt(N); i++)
	  if(a[i]!=0) for(j=2*i; j<=N; j+=i) a[j]=0;
     return a;
}

int main(int argc, char *argv[]){
     int c, n, i;
     char *isPrime;

     isPrime=eratosthenes(N_MAX);
     
     while(scanf("%d",&n), n!=0){
	  c=0;

	  for(i=2; i<=n/2; i++)
	       if(isPrime[i] && isPrime[n-i])
		    c++;
	  
	  printf("%d\n",c);
     }

     return 0;
}

Measured memory_bytes: 0
import Data.Char (isUpper)
import Data.List (elemIndex)

f s = cond1 && cond2 && cond3
  where n = length s
        cond1 = s !! 0 == 'A'
        cond2 = (length . filter isUpper) s == 2
        cond3 = case elemIndex 'C' s of
                  Just i -> 2 <= i && i < n - 1
                  Nothing -> False

main = do
  s <- getLine
  putStrLn $ if f s then "AC" else "WA"

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

S = input()
ans = 0
for i in range(4):
	if S[i] == "+":
		ans += 1
	else:
		ans -= 1

print(ans)

Measured memory_bytes: 5148
#include <stdio.h>

int main(void){
	int a, b, c;
	int m, k;

	scanf("%d %d %d\n", &a, &b, &c);
	for(m = a, k = 0; m <= b; m++){
		if (c % m == 0){
			k++;
		}
	}
	
	printf("%d\n", k);

	return 0;
}

Measured memory_bytes: 1836
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


const ll mod = 998244353;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll count2[101000];
int main(){
    ll N;
    cin >> N;
    fill(count2, count2+101000, 0);
    for(int i = 0; i < N; i++){
        ll d;   cin >>d;
        if((i == 0 && d != 0) || (i != 0 && d == 0)){
            cout << 0 << endl;
            return 0;
        }
        count2[d]++;
    }

    ll res = 1;
    ll cum = 1;
    for(int i = 1; i < N; i++){
        if(cum == N){
            break;
        }
        res = mul(res, powMod(count2[i-1], count2[i]));
        cum += count2[i];
    }

    cout << res << endl;



    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

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

int main(){
	int a[3];
	cinf(a,3);
	for(int i=0;i<=1;i++){
		for(int j=2;j>=0;j--){
			if(a[j-1]>a[j])
				swap(&a[j-1],&a[j]);
		}
	}
	rep(i,2){
		cout << a[i] << " ";
	}
	cout << a[2] << endl;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int count = 0;
    do {
      n /= k;
      count++;
    } while (n!=0);
    System.out.println(count);

  }

}


Measured memory_bytes: 21716
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

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

    // input
    ll N, C;
    cin >> N >> C;

    vector<ll> X(N+1);
    vector<ll> V(N+1);

    X[0] = 0;
    V[0] = 0;

    FOR(i, 1, N+1){
        cin >> X.at(i);
        cin >> V.at(i);
    }

    // 価値の累積和
    vector<ll> Ac(N+1);

    // i個目まで食べたときの満腹度
    vector<ll> f(N+1);

    // iまで行けるときのMax満腹度
    vector<ll> g(N+1);

    ll max_value = 0;

    // mode 0 : Bで折り返す
    // mode 1 : Aで折り返す
    FOR(mode, 0, 2){

        if(mode==1){
            reverse(X.begin()+1, X.end());
            FOR(i, 1, N+1){
                X[i] = C - X[i];
            }
            reverse(V.begin()+1, V.end());
        }

        Ac[0] = V[0];
        FOR(i, 1, N+1){
            Ac[i] = Ac[i-1] + V[i];
        }

        FOR(i, 0, N+1){
            f[i] = Ac[i] - X[i];
        }

        g[0] = f[0];
        FOR(i, 1, N+1){
            g[i] = max(g[i-1], f[i]);
        }

        // xbを固定する
        FOR(i, 0, N+1){
            ll xb = X[i];
            
            ll b_eat;
            ll b_walk;
            if(i==0){
                b_eat = 0;
                b_walk = 0;
            }else{
                b_eat = Ac[N] - Ac[i-1];
                b_walk = C - xb;
            }
            ll b_value = b_eat -  2 * b_walk;
            
            ll a_value;
            if(i==0){
                a_value = g[N];
            }else{
                a_value = g[i-1];
            }

            ll value = a_value + b_value;
            max_value = max(max_value, value);
        }
    }

    p(max_value);
    
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
typedef unsigned long long llu;

int main() {
  
  int n;
  llu x;
  scanf("%d", &n);
  scanf("%llu", &x);
  
  llu a[51][2] = {{1, 1}};
  for (int i=0; i<n; i++) {
    a[i+1][0] = a[i][0]*2 + 3;
    a[i+1][1] = a[i][1]*2 + 1;
  }
  
  llu c = 0;
  while (n+1) {
    if (x == a[n][0]) {
      c += a[n][1];
      break;
    }
    x -= 1;
    n -= 1;
    if (x > a[n][0]) {
      c += 1 + a[n][1];
      x -= 1 + a[n][0];
    }
    if (x == 0)
      break;
  }
  
  printf("%llu\n", c);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define INF 9999999
#define LINF 9999999999999999
#define SINF "%"
#define uint unsigned int
#define msn(a,v) memset(a,v,sizeof(a))
#define ms(a) msn(a,0)
#define NONE -1
#define ll unsigned long long
#define uchar unsigned char
#define sint short int
#define usint unsigned sint
#define xsize(a) sizeof(a)/1024/1024
#define fr(aaaaa,bbbbb) for(aaaaa = 1;aaaaa <= bbbbb;aaaaa++)
#define frr(aaaaa,bbbbb,ccccc) for(aaaaa = ccccc;aaaaa <= bbbbb;aaaaa++)
using namespace std;

int x;

int main(){
	cin >> x;
	int nowsum = 0,ans;
	for(ans = 1;nowsum < x;ans++){
		nowsum += ans;
	}
	cout << ans-1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

void solve() {
    int x, y;
    std::cin >> x >> y;

    for (int a = 0; a <= 100; ++a) {
        for (int b = 0; b <= 100; ++b) {
            if (a + b == x && a * 2 + b * 4 == y) {
                std::cout << "Yes\n";
                return;
            }
        }
    }

    std::cout << "No\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3668
import java.util.*;

/**
 * C Main
 *
 * @date 2020.08.22
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

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

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = this.sc.nextInt();
    int[] a = new int[n];
    int sum = 0;

    for (int i = 0; i < n; i++) {
      a[i] = this.sc.nextInt();
      sum += a[i];
    }

    double avg = sum * 1.0 / n;
    int high = (int) (Math.ceil(avg));
    int low = (int) (Math.floor(avg));

    int totalCostAtHigh = 0;
    for (int i = 0; i < n; i++) {
      totalCostAtHigh += this.cost(a[i], high);
    }
    if (high == low) {
      System.out.println(totalCostAtHigh);
      return;
    }

    int totalCostAtLow = 0;
    for (int i = 0; i < n; i++) {
      totalCostAtLow += this.cost(a[i], low);
    }

    System.out.println(totalCostAtHigh < totalCostAtLow ? totalCostAtHigh : totalCostAtLow);
  }

  public int cost(int from, int to) {
    if (from == to) {
      return 0;
    }

    return (from - to) * (from - to);
  }
}


Measured memory_bytes: 27148