akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <set>
#define maxw 1005
#define maxp 105

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< vector<bool> > Mb; // 1-indexed.
//const ull Br = 7ull;
//const ull Bc = 11ull;
const ull Br = 233ull;
const ull Bc = 998244353ull;

int w, h, p;
char s[maxw];
Mb ima, pat, tmp;
ull has[maxw][maxw], powBr, powBc;
int decrypt(char c){
  if(c >= 'A' && c <= 'Z') return c - 'A';
  if(c >= 'a' && c <= 'z') return c - 'a' + 26;
  if(c >= '0' && c <= '9') return c - '0' + 52;
  if(c == '+') return 62;
  return 63;
}
void calcHash(Mb a, int n, int m){ // n * m.
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= m;j++) has[i][j] = has[i][j - 1] * Br + a[i][j];
    for(int j = m;j >= p;j--) has[i][j] -= has[i][j - p] * powBr;
  }
  
//  cout << has[n][m] << endl;
//  system("pause");
  
  for(int i = p;i <= m;i++){
    for(int j = 1;j <= n;j++) has[j][i] = has[j - 1][i] * Bc + has[j][i];
    for(int j = n;j >= p;j--) has[j][i] -= has[j - p][i] * powBc;
  }
}
void fli(Mb &a, int n, int m){
  for(int i = 1;i <= n;i++) reverse(a[i].begin() + 1, a[i].begin() + m + 1);
}
void rot(Mb &a, int n, int m){
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= m;j++){
      tmp[j][p - i + 1] = a[i][j];
    }
  }
  a = tmp;
}
int main(){
  while(~scanf("%d%d%d", &w, &h, &p) && h){
    powBr = powBc = 1;
    for(int i = 1;i <= p;i++) powBr *= Br, powBc *= Bc;
    ima.resize(h + 1);
    for(int i = 1;i <= h;i++){
      ima[i].resize(w + 1);
      scanf("%s", s);
      for(int j = 1;j <= w;j += 6){
        int x = decrypt(s[j / 6]);
        for(int k = j + 5;k >= j;k--){
          ima[i][k] = x & 1;
          x >>= 1;
        }
      }
    }
    pat.resize(p + 1), tmp.resize(p + 1);
    for(int i = 1;i <= p;i++){
      pat[i].resize(p + 1), tmp[i].resize(p + 1);
      scanf("%s", s);
      for(int j = 1;j <= p;j += 6){
        int x = decrypt(s[j / 6]);
        for(int k = j + 5;k >= j;k--){
          pat[i][k] = x & 1;
          x >>= 1;
        }
      }
    }
    
//    for(int i = 1;i <= h;i++){
//      for(int j = 1;j <= w;j++){
//        cout << ima[i][j] << " ";
//      }
//      cout << endl;
//    }
//    for(int i = 1;i <= p;i++){
//      for(int j = 1;j <= p;j++){
//        cout << pat[i][j] << " ";
//      }
//      cout << endl;
//    }
//    system("pause");
    
//    calcHash(pat, p, p);
//    cout << has[p][p] << endl;
//    system("pause");
    
    set <ull> pats;
    for(int i = 1;i <= 2;i++){
      for(int j = 1;j <= 4;j++){
        calcHash(pat, p, p);
        pats.insert(has[p][p]);
        rot(pat, p, p);
      }
      fli(pat, p, p);
    }
    
//    cout << pats.size() << endl;

//    cout << *pats.begin() << endl;
//    system("pause");
    
    int ans = 0;
    calcHash(ima, h, w);
    for(int i = p;i <= h;i++){
      for(int j = p;j <= w;j++){
        ans += pats.count(has[i][j]);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    long long count = 0;
    int v[N];
    for(int i = 0;i<N;i++){
        cin>>v[i];
    }
    int start = 0,temp = 0,p = -1;
    while(p<N-1){
        while(p<N-1 && !(temp&v[p+1])){
            p++;
            count+=p-start+1;
            temp^=v[p];
        }
        while(start<=p && (temp&v[p+1])){
            temp^=v[start++];
        }
    }
    cout<<count<<endl;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <map>
using namespace std;
typedef pair<int,int> pii;
#define fi first
#define se second
const int maxn = 100000;
int N,a[maxn]; pii b[3]; map<int,int> m;
int main() {
    scanf("%d",&N); for (int i = 0;i < N;i++) scanf("%d",&a[i]),m[a[i]]++;
    if (m.size() == 1 && m[0] == N) return printf("Yes\n"),0;
    if (m.size() == 2 && m[0] > 0 && m[0] * 3 == N) return printf("Yes\n"),0;
    if (m.size() == 3) {
        int cnt = 0; for (pii p : m) b[cnt++] = p;
        if ((b[0].fi^b[1].fi^b[2].fi) == 0 && b[0].se == b[1].se && b[0].se == b[2].se) return printf("Yes\n"),0;
    }
    printf("No\n");
}


Measured memory_bytes: 4224
import java.util.Scanner;

//The Balance of the World
public class Main{

	static char[] s;
	static int k;

	static boolean f(char ch){
		while(k<s.length){
			char c = s[k++];
			if((c=='('||c=='[')&&!f(c))return false;
			else if(ch=='('&&c==']')return false;
			else if(ch=='['&&c==')')return false;
			else if(ch=='('&&c==')')return true;
			else if(ch=='['&&c==']')return true;
		}
		return false;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			s = sc.nextLine().toCharArray();
			if(s.length==1)break;
			k = 0;
			boolean f = true;
			while(k<s.length){
				char c = s[k++];
				if(c=='('||c=='[')f&=f(c);
				else if(c==')'||c==']')f=false;
			}
			System.out.println(f?"yes":"no");
		}
	}
}

Measured memory_bytes: 12000
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    s = input()
    t = input()
    if s == t[:-1]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

int
main(int argc, char *argv[])
{
        char buf[20000];
        char *s, *e;
        int i, h;

        while (scanf("%s", buf), buf[0] != '-') {
                s = buf;
                e = s + strlen(buf) - 1;
                for (scanf("%d", &i); i > 0; i--) {
                        for (scanf("%d", &h); h > 0; h--) {
                                *++e = *s++;
                        }
                }
                *++e = '\0';
                printf("%s\n", s);
        }
        return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct UnionFind
{
    void init(int n)
    {
        mN = n;
        mNodeTbl.resize(mN);
        REP(i, mN)
        {
            mNodeTbl[i] = i;
        }
    }
    int find(int x)
    {
        if (x == mNodeTbl[x])
            return x;
        return mNodeTbl[x] = find(mNodeTbl[x]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unit(int x, int y)
    {
        x = find(x);
        y = find(y);
        mNodeTbl[x] = y;
    }

    int mN;
    vector<int> mNodeTbl;
};

struct Edge
{
    int a;
    int b;
    ll w;
};

Edge e[100005];

int main()
{
    int V, E;
    cin >> V >> E;
    REP(i, E)
    {
        cin >> e[i].a >> e[i].b >> e[i].w;
    }
    sort(e, e + E, [](Edge a, Edge b) { return a.w < b.w; });
    UnionFind uf;
    uf.init(V);
    ll cost = 0;
    REP(i, E)
    {
        Edge t = e[i];
        if (uf.same(t.a, t.b))
            continue;
        cost += t.w;
        uf.unit(t.a, t.b);
    }
    cout << cost << endl;
    return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a <= c && c <= b ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<long long, long long>p;
long long mod = 998244353;
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
vector< int64_t > divisor(int64_t n) {
	vector< int64_t > ret;
	for (int64_t i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[303];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	long long sum = 0;
	long long dp[100004];
	long long dp2[100004];
	long long dp3[100004];
	long long dp4[100004];
	for (int i = 0; i < 100004; i++) {
		dp[i] = dp2[i] = dp3[i] = dp4[i] = 0;
	}
	long long ans = 1;
	long long nibeki[303];
	nibeki[0] = 1;
	for (int i = 1; i <= n; i++) {
		nibeki[i] = nibeki[i - 1] * 2;
		nibeki[i] %= mod;
		ans *= 3;
		ans %= mod;
	}
	ans = ans + mod * 3 - 3 * nibeki[n] + 3;
	ans %= mod;
	dp[0] = nibeki[n];
	dp3[0] = 1;
	for (int z = 1; z <= n; z++) {
		sum += a[z];
		for (int i = 0; i <= sum; i++) {
			if (i - a[z] >= 0) {
				dp2[i] = dp[i] + dp[i - a[z]] * modinv(2, mod);
				dp2[i] %= mod;
				dp4[i] = dp3[i] + dp3[i - a[z]];
				dp4[i] %= mod;
			}
			else {
				dp2[i] = dp[i];
				dp4[i] = dp3[i];
			}
		}
		for (int i = 0; i <= sum; i++) {
			dp[i] = dp2[i];
			dp3[i] = dp4[i];
		}
	}
	dp[sum] -= 1;
	dp3[sum] -= 1;
	for (int i = 1; i <= n; i++) {
		dp[sum - a[i]] -= 2;
		dp[sum - a[i]] += mod;
		dp[sum - a[i]] %= mod;
		dp3[sum - a[i]] -= 1;
		dp3[sum - a[i]] += mod;
		dp3[sum - a[i]] %= mod;
	}
	long long minus = 0;
	for (int i = sum / 2+((sum%2)?1:0); i < sum; i++) {
			minus += (dp[i]*3);
			ans += dp3[i] * 3*2;
			ans %= mod;
			minus %= mod;
	}
	cout << (ans + mod - minus) % mod;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
long INF =  __LONG_MAX__ /2;

int main() {
    int N;
    cin>>N;
    vector<vector<int>> A(N, vector<int> (N, 0));
    REP(i, 0, N) REP(j, 0, N){
        cin >> A[i][j];
    } 
    

    vector<vector<long>> M(N, vector<long> (N, INF));
    vector<vector<long>> MAP(N, vector<long> (N, 0));
    REP(i, 0, N){
        REP(j, 0, N){
            REP(k, 0, N){
                long new_path = A[i][k] + A[k][j];
                if(new_path < M[i][j]){
                    M[i][j] = new_path;
                } 
            }
        }
    }
    REP(i, 0, N){
        REP(j, 0, N){
            MAP[i][j] = M[i][j];
            REP(k, 0, N){
                if(A[i][j] == M[i][k] + M[k][j] && i != k && j != k){
                    MAP[i][j] = 0;
                }
            }
        }
    }
    
    long ans = 0;
    REP(i, 0, N){
        REP(j, 0, N){
            if(M[i][j] != A[i][j]){
                ans = -1;
                break;
            }
            ans += MAP[i][j];
        }
        if(ans < 0) break;
    }

    if(ans>=0) ans /= 2;
    cout << ans << endl;
}


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

int main(){
	
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int index[n+1];
	for(int i=1;i<=n;i++){
		index[arr[i]] = i;
	}
	for(int i=1;i<=n;i++){
		cout<<index[i]<<" ";
		
	}
	cout<<endl;
	return 0;
}

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

signed main(){
  int x,y;cin>>x>>y;
  int ans=0;
  if(x==1)ans+=300000;
  if(x==2)ans+=200000;
  if(x==3)ans+=100000;
  swap(x,y);
  if(x==1)ans+=300000;
  if(x==2)ans+=200000;
  if(x==3)ans+=100000;
  if(x==1&&y==1)ans+=400000;
  cout<<ans<<endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void){
    double x1,x2,y1,y2,answer;
    cin >> x1 >> y1 >> x2 >> y2;
    
    answer = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
    printf("%lf\n", answer);
    //cout << answer << endl;
    
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vector<string> W(N);
    REP(i,0,N) cin >> W[i];

    bool f = true;
    REP(i,1,N) {
        REP(j,0,i) {
            if(W[i] == W[j]) {
                f = false;
                break;
            }
        }
        if(W[i-1][SZ(W[i-1])-1] != W[i][0]) f = false;
        if(!f) break;
    }

    if(f) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 3612
from collections import defaultdict
from collections import deque

N, M = map(int, input().split())

graph = defaultdict(list)
edges = []

# 無向グラフの表現
for _ in range(M):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
    edges.append((a, b))

ans = 0

def dfs(graph, node_start, visited):
    global ans
    if len(set(visited)) == len(set(graph)):
        ans += 1
        return
    for node_end in graph[node_start]:
        # 一回も訪れていない
        if node_end not in visited:
            dfs(graph, node_end, visited + [node_end])
    return

dfs(graph, 1, [1])
print(ans)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll

bool check(string s) {
    int n = s.size();
    for(int i=0;i<n;i++) {
        if(s[i]!=s[n-1-i]) return false;
    }
    return true;
}

signed main() {
    fast;

    string s;
    cin>>s;

    if(s.size()==1) {
        cout<<"Yes";
        return  0;
    }

    int  n = s.size();

    if(check(s) && check(s.substr(0,(n-1)/2))) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
/*
解説AC 
dfsを使うのは出てこないよ……
k文字目に使われる文字はk文字目よりも前の文字の辞書順最大の文字の次に大きい以下である。
この性質を用いてdfs
*/

#include <bits/stdc++.h>

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

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

int main(){
    cin>>n;
    dfs("",'a');
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3588
from math import gcd
n,x=map(int,input().split())
c=list(map(int,input().split()))
o=[]
if len(c)==1:
  print(abs(c[0]-x))
else:
  for i in c:
    o.append(abs(i-x))
  ans=gcd(o[1],o[0])
  for j in range(n-2):
      ans=gcd(ans,o[j+2])
  print(ans)

Measured memory_bytes: 20236
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
   

signed main(){
    int N,H,W;
    cin >> N >> H >>  W;
    cout << (N-H+1)*(N-W+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <cstring>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    scanf("%lld%lld",&n, &k);
    n = n % k;
    ll c = n - k;
    if(c < 0) c = -c;
    if(n < c) printf("%lld\n",n);
    else printf("%lld\n",c);
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const ll INF = 1000000000000000001;

int a, n;
int main(void){
    cin >> n >> a;
    for (int i = 0; i <= a; i++){
        if (n >= i && (n - i) % 500 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
const ll INF = 1e18L + 5;

vector<ll> pre; // preprocessing
// pre[mask] - score of group 'mask'
vector<ll> dp;

void rec(int i, const vector<int>& not_taken, ll score_so_far, int mask, int group) {
    if(i == (int) not_taken.size()) {
        dp[mask] = max(dp[mask], score_so_far + pre[group]);
        return;
    }
    rec(i + 1, not_taken, score_so_far, mask, group);
    rec(i + 1, not_taken, score_so_far, mask ^ (1 << not_taken[i]),
        group ^ (1 << not_taken[i]));
}

// O(2^n * n^2 + 3^n)

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<ll>> in(n, vector<ll>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            scanf("%lld", &in[i][j]);
        }
    }
    pre.resize(1 << n);
    // O(2^n * n^2)
    for(int mask = 0; mask < (1 << n); ++mask) {
        for(int i = 0; i < n; ++i) {
            if(mask & (1 << i)) {
                for(int j = i + 1; j < n; ++j) {
                    if(mask & (1 << j)) {
                        pre[mask] += in[i][j];
                    }
                }
            }
        }
    }
    // dp[mask] - best total score if we grouped rabbits from 'mask' already
    dp.resize(1 << n, -INF);
    dp[0] = 0;
    // O(2^n * n + 3^n)
    for(int mask = 0; mask < (1 << n); ++mask) {
        vector<int> not_taken;
        for(int i = 0; i < n; ++i) {
            if(!(mask & (1 << i))) {
                not_taken.push_back(i);
            }
        }
        rec(0, not_taken, dp[mask], mask, 0);
    }
    printf("%lld\n", dp[(1<<n)-1]);
}


Measured memory_bytes: 4320
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int n,k,a[100001];
main(){
	while(cin>>n>>k,n){
		vector<P>v;
		int ans=0,p=0;
		r(i,k){
			cin>>a[i];
			if(!a[i]){
				i--;
				k--;
				p++;
			}
		}
		sort(a,a+k);
		r(i,k){
			int res=1;
			while(i!=k-1&&a[i]==a[i+1]-1){
				res++;i++;
			}
			ans=max(ans,res);
			v.push_back(P(1,res));
			v.push_back(P(0,a[i+1]-a[i]));
		}
		if(p)r(i,v.size()){
			if(v[i].first==0&&v[i].second<=2){
				ans=max(ans,v[i-1].second+v[i+1].second+1);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<tuple<ll, ll, ll>> rec(n);
	rep(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		rec[i] = tie(c, a, b);
	}
	sort(rec.rbegin(), rec.rend());
	for (ll c1 = 0; c1 <= 100; ++c1) {
		for (ll c2 = 0; c2 <= 100; ++c2) {
			ll H = 0;
			bool ok = true;
			rep(i, n) {
				if (i == 0) {
					H = get<0>(rec[i]) + abs(get<1>(rec[i]) - c1) + abs(get<2>(rec[i]) - c2);
				}
				else {
					ll tmp = max(0LL, H - abs(get<1>(rec[i]) - c1) - abs(get<2>(rec[i]) - c2));
					if (tmp != get<0>(rec[i])) ok = false;
				}
			}
			if (ok) {
				printf("%lld %lld %lld\n", c1, c2, H);
				return 0;
			}
		}
	}
	return 0;
}

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

long long gcd(long long A, long long B)
{
    if (A < B)
    {
        return gcd(B, A);
    }
    if (B == 0)
    {
        return A;
    }
    return gcd(B, A % B);
}

int main()
{
    unsigned long long int A, B;
    cin >> A >> B;

    unsigned long long int g = gcd(A, B);
    long long s = sqrt(g);

    ulong counter = 1;
    for (ulong i = 2; i <= s; i++)
    {
        if (g % i == 0)
            counter++;

        while (g % i == 0)
            g /= i;
    }
    if (g > 1)
        counter++;

    cout << counter;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int i, n, num, min, MAX;
    long SUM;

    SUM = 0;
    min = 1000000;
    MAX = -1000000;

    scanf("%d\n", &n);

    for ( i = 0 ; i < n ; i++ ){
    	scanf("%d", &num);
    	if (num < min){
    		min = num;
    	}
    	if (MAX < num){
    		MAX = num;
    	}
    	SUM = SUM + num;
    }

    printf ("%d %d %ld\n", min, MAX, SUM);

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

using P = pair<int, int>;

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

    vector<P> red;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        red.emplace_back(a, b);
    }

    vector<P> blue;
    for (int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        blue.emplace_back(c, d);
    }

    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    int ri = 0,
        bi = 0,
        ans = 0;
    vector<int> num(300, 0);
    while (bi < N) {
        while (ri < N and red[ri].first < blue[bi].first) {
            num[red[ri].second]++;
            ri++;
        }
        for (int x = 299; x >= 0; x--) {
            if (num[x] > 0 and x < blue[bi].second) {
                num[x]--;
                ans++;
                break;
            }
        }
        bi++;
    }

    cout << ans << endl;


    return 0;
}

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

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

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll a,b;
    cin>>a>>b;
    ll n;
    cin>>n;
    ll ans = 1e18;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(b%j) continue;
            ans = min(ans, abs(a-b/j*i));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3212
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n)
        cin >> h[i];
    int maxx = 0;
    int before = -1;
    int cnt = 0;
    for(int i=0;i<=n;i++){
        if(i == n || h[i] > before){
            maxx = max(maxx, cnt);
            cnt = 0;
        }
        else{
            cnt++;
        }
        before = h[i];
    }
    cout << maxx << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int ans = 0;
    if(a>c){
        if(a>=d){
            ans = 0;
        }
        else{
            if(b<=d){
                ans = b-a;
            }
            else{
                ans = d-a;
            }
        }
    }
    else
    {
        if(b<=c){
            ans = 0;
        }
        else{
            if(d<=b){
                ans = d-c;
            }
            else{
                ans = b-c;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <unordered_set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> dp(N + 1);
	dp[0] = 1;
	unordered_set<int> a;
	int n;
	for (int i = 0; i < M; i++) {
		cin >> n;
		a.insert(n);
	}
	for (int i = 0; i < N; i++) {
		if (a.count(i)) continue;
		for (int j = 1; j <= 2; j++) {
			if (i + j > N) break;
			if (a.count(i + j)) continue;
			dp[i + j] = (dp[i + j] + dp[i]) % 1000000007;
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 7668
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M];int C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
	}
	
	const int N=1e6+10;
	ll a[N];
	void main()
	{//PRE();
		int ln=qread(),q=qread();fo(i,1,ln) a[i]=qread();
		while(q--)
		{
			ll n=qread()-1,st=qread(),M=qread();st%=M;
			ll ans=n;
			ll s1=0,s2=st;ll tt=n/ln;
			ll t1=0;fo(i,1,ln) t1+=(a[i]%M)==0;s1+=tt*t1;
			ll t2=0;fo(i,1,ln) t2+=(a[i]%M);s2+=tt*t2;
			n%=ln;fo(i,1,n) s1+=(a[i]%M)==0,s2+=(a[i]%M);
			deb(s1);deb(s2);
			write2(ans-s1-s2/M);
		}
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"\n---------------------Zory-------------------\nTime: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 384
import math
import sys


N = int(input())
Ax = list(map(int,input().split()))
for A in Ax:
    if A % 2 != 0:
        continue
    else:
        if A % 3 != 0 and A % 5 != 0:
            print("DENIED")
            exit(0)

print("APPROVED")



Measured memory_bytes: 38256
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
  stack<int> s1;
  stack<pair<int,int> > s2 ;
  int sum = 0;
  char c;
  for(int i = 0 ;cin >> c;i++) {
    if(c == '\\') {
      s1.push(i);
    }
    else if(c == '/' && s1.size() >0) {
      int j=s1.top();
      s1.pop();
      int d = i-j;
      sum +=d;
      while(s2.size() >0 && s2.top().first >j){
        d+=s2.top().second;
        s2.pop();
      }
      s2.push(make_pair(j,d));
    }
  }
  vector<int> ans;
  while(s2.size()) {
    ans.push_back(s2.top().second);
    s2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout << sum <<endl;
  cout << ans.size();
  for(int i =0; i<ans.size(); i++) {
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

bool dp[80][80][80 * 2 * 80 + 1] = {};

int main() {
  int h, w;
  cin >> h >> w;
  int a[h][w], b[h][w], m[h][w];
  REP(i, h) {
    REP(j, w) { cin >> a[i][j]; }
  }
  REP(i, h) {
    REP(j, w) { cin >> b[i][j]; }
  }
  REP(i, h) {
    REP(j, w) { m[i][j] = abs(a[i][j] - b[i][j]); }
  }

  REP(i, h) {
    REP(j, w) { REP(k, (80 * 2 * 80) + 1) dp[i][j][k] = false; }
  }
  dp[0][0][m[0][0]] = true;
  REP(i, h) {
    REP(j, w) {
      REP(k, (80 * 2 * 80) + 1) {
        if (i != 0) {
          dp[i][j][k] = dp[i][j][k] || dp[i - 1][j][abs(k - m[i][j])];
          if (k + m[i][j] <= 2 * 80 * 80) {
            dp[i][j][k] = dp[i][j][k] || dp[i - 1][j][abs(k + m[i][j])];
          }
        }
        if (j != 0) {
          dp[i][j][k] = dp[i][j][k] || dp[i][j - 1][abs(k - m[i][j])];
          if (k + m[i][j] <= 2 * 80 * 80) {
            dp[i][j][k] = dp[i][j][k] || dp[i][j - 1][abs(k + m[i][j])];
          }
        }
      }
    }
  }
  REP(k, 80 * 2 * 80 + 1) {
    if (dp[h - 1][w - 1][k]) {
      cout << k << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 80384
import  fractions
import  math
A, B = map(int, input().split())

c=fractions.gcd(A,B)

Cnt=[]

def prime_decomposition(n):
  i = 2
  table = set([])
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.add(int(i))
    i += 1
  if n > 1:
    table.add(int(n))
  return table

Cnt=prime_decomposition(c)
Cnt=list(Cnt)
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

ans=1


for i in range(0,len(Cnt)):
    if is_prime(int(Cnt[i])):
        ans+=1

print(ans)

Measured memory_bytes: 64496
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll h[1000000];
ll v[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll DP[50][500][500];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll comb[51][51];
int main() {
	rep(i,0,51){
		comb[i][0]=1;
	}
	rep(i,0,51){
		comb[0][i]=1;
	}
	rep(i,1,51){
		rep(j,1,51){
			if(i==j){
				comb[i][j]=1;
			}else if(j>i){
				comb[i][j]=0;
			}else{
				comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
			}
		}
	}

	cin>>N>>A>>B;
	rep(i,0,N){
		cin>>v[i];
	}
	sort(v,v+N);
	reverse(v,v+N);
	ll sum=0;
	rep(i,0,A){
		sum+=v[i];
	}
	if(v[0]==v[A-1]){
		ll count=0;
		rep(i,0,N){
			if(v[i]==v[0])count++;
		}

		rep(i,A,B+1){
			ans+=comb[count][i];
		}
	}else{
		ll count=0;
		ll pos=N;
		rep(i,0,N){
			if(v[i]==v[A-1])count++;
			if(pos==N && v[i]==v[A-1])pos=i;
		}
		ans = comb[count][A-pos];
	}
	
	cout<<fixed<<setprecision(7)<<(double)sum/A<<endl;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	char a,b;
	cin>>a>>b;
	cout<<(a=='H'?(b=='H'?"H":"D"):(b=='H'?"D":"H"))<<endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
ll X[202020],Y;
__int128 S[202020];
ll dp[202020];
int ok[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Y;
	FOR(i,N) cin>>X[i+1], S[i+1]=S[i]+X[i+1];
	__int128 ret=1LL<<60;
	
	for(int i=1;i<=N;i++) {
		__int128 tot=i*Y;
		int left=N;
		int step=1;
		while(left>0) {
			if(step==1) {
				tot+=5*(S[left]-S[max(left-i,0)]);
			}
			else {
				tot+=(2*step+1)*(S[left]-S[max(left-i,0)]);
			}
			left-=i;
			step++;
		}
		ret=min(ret,tot);
	}
	
	cout<<((ll)ret+N*Y)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

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


long long int n,m,k;
long long int x,y;
long long int mod = 1000000007;

long long int factorial(long long int n){
    long long int res;
    if (n == 0) return 1;
    res = (n%mod)*factorial(n-1)%mod;
    return res;
}

long long int f(long long int n, long long int m){
    long long int res;
    if(m == 1){
        return n;
    }
    if(m%2){
        res = n*f(n*n%mod, m/2)%mod;
    }
    else{
        res = f(n*n%mod, m/2)%mod;
    }
    return res;
}

int main(){
    cin >> x >> y;
    if((x+y) % 3 != 0 || 2*x-y < 0 || 2*y - x < 0) {
        cout << 0 << endl;
        return 0;
    }
    n = (2*x - y)/3;
    m = (2*y - x)/3;

    long long int nf, mf, nmf, nr, mr;
    nf = factorial(n);
    // cout << n << " " << nf << endl;
    mf = factorial(m);
    nmf = factorial(n+m);
    nr = f(nf,mod-2);
    mr = f(mf,mod-2);
    long long int ans;
    ans = (nr%mod)*(mr%mod);
    ans = (ans%mod)*(nmf%mod)%mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 24388
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
 int A,B,C;
 cin>>A>>B>>C;
 if(B/A<C){
     cout<<B/A<<endl;
 }
 else{
     cout<<C<<endl;
 }
}

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

int main() {// 単調非減少＝広義の単調増加。
  int N;
  cin >> N;
  vector<int> vec(N);
  rep (i, N) cin >> vec[i];
  
  int pre = 0;
  for (int i = 0; i < N; i++) {
    if (pre <= vec[i]-1) pre = vec[i]-1; //1個前と比べて自分自身をー１するか決め、その値に変えることで、－１したかどうかが次の計算にも引き継がれる
    else if (pre == vec[i]) pre = vec[i];//後続のために、できることならー１して次に渡したい。
    else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>

using namespace std;

#define NMAX 10000

typedef struct s{
	long long D;
	long long P;
} S;

bool operator<(S a,S b){
	return a.P>b.P;
}


int main(){

	long long N,M;
	S sp[NMAX];

	while(1){
		cin>>N>>M;
		int Dsum=0;
		if(N==0&&M==0) break;
		for(int i=0;i<N;i++){
			cin>>sp[i].D>>sp[i].P;
			Dsum+=sp[i].D;
		}
		if(Dsum<=M){
			cout<<"0"<<endl;
			continue;
		}
		sort(sp,sp+N);
		for(int i=0;i<N;i++){
			if(sp[i].D<=M){
				M-=sp[i].D;
				sp[i].D=0;
			}
			else{
				sp[i].D-=M;
				M=0;
				break;
			}
		}
		long long ans=0;
		for(int i=0;i<N;i++){
			ans+=sp[i].D*sp[i].P;
		}
		cout<<ans<<endl;
	}
}

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

int bubble_sort(int a[], int n) {
  int swaps = 0;
  bool swap_flag = 1;

  for (int i = 0; swap_flag; ++i) {
    swap_flag = 0;
    for (int j = n - 1; j >= i + 1; --j) {
      if (a[j] < a[j - 1]) {
        swap(a[j], a[j - 1]);
        swap_flag = 1;
        swaps++;
      }
    }
  }
  return swaps;
}

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

  swaps = bubble_sort(a, n);

  for (int i = 0; i < n; ++i) {
    if (i) {
      cout << ' ';
    }
    cout << a[i];
  }
  cout << endl;
  cout << swaps << endl;

  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long
int main() {
   ll n;
   cin>>n;
    ll a[n];
    ll i,j,k,p;
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    ll cnt=0,l=0,h=0;
    for(i=0;i<n;i++)
        for(j=0;j<i;j++)
            for(k=0;k<j;k++)
                if(a[i]!=a[j] && a[j]!=a[k] && a[i] < a[j] + a[k]) cnt++;
    cout<<cnt<<endl;
    
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    cout << (N+999)/1000*1000-N << endl;
    return 0;
}

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

int main(void){

    int A, B, C;
    cin >> A >> B >> C;

    if (A >= B && A >= C){
      cout << 10 * A + B + C;
    } else if (B >= A && B >= C){
      cout << 10 * B + A + C;
    } else if (C >= A && C >= B){
      cout << 10 * C + B + A;
    }
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int s[M],c[M];
  rep(i,M) cin >> s[i] >> c[i];
  int ans = 0;
  if(N!=1) ans = pow(10,N-1);
  int ans_max = pow(10,N);
  bool correct = true;
  int i;
  for(i=ans;i<ans_max;i++){
    correct = true;
    string ans_2 = to_string(i);
    rep(j,M){
      string c_2 = to_string(c[j]);
      if(ans_2[s[j]-1]!=c_2[0]){
        correct = false;
      }
    }
    if(correct) break;
  }
  if(correct) printf("%d",i);
  else printf("%d", -1);
}

Measured memory_bytes: 4068
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    char a;
    cin >> a;
    if (a >= 'a' && a <= 'z')
        cout << 'a' << endl;
    else
        cout << 'A' << endl;
}

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

int main() {

    int n; cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n ; i++) {
        cin >> a[i];
    }
    int ans = 0;
    int x = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] != x) {
            ans++;
        }
        else {
            x++;
        }

    }
    if (x == 1) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4064
from sys import stdin

n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

while True:
    if a+1 != b:
        a += 1
    else:
        print("Borys")
        exit()
    if b-1 != a:
        b -= 1
    else:
        print("Alice")
        exit()

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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int Ma1, Ma2;
  Ma1 = H1 * 60 + M1;
  Ma2 = H2 * 60 + M2;

  cout << Ma2 - Ma1 - K << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long x = scan.nextLong();
		long a = x;
		long b = n - x;
		long remainder = b % a;
		long sum = 0;

		while (true) {
			sum += (b - remainder) * 3;

			if (remainder == 0) {
				break;
			}else {
				long num = a;
				a = remainder;
				b = num;
				remainder = b % a;
			}
		}

		System.out.println(sum);
		scan.close();
	}

}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	map<int64_t, int64_t> mp;
	for (auto &&a : as)
	{
		mp[a]++;
	}

	int64_t ans = 1, mod = 1000000007;

	if (n % 2 == 0)
	{
		for (int64_t i = 1; i < n; i += 2)
		{
			if (mp[i] != 2)
			{
				cout << 0 << endl;
				return 0;
			}

			(ans *= 2) %= mod;
		}
	}
	else
	{
		if (mp[0] != 1)
		{
			cout << 0 << endl;
			return 0;
		}

		for (int64_t i = 2; i < n; i += 2)
		{
			if (mp[i] != 2)
			{
				cout << 0 << endl;
				return 0;
			}

			(ans *= 2) %= mod;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b; scanf("%d%d", &a, &b);
	if(a>=13) printf("%d\n", b);
	else if(a>=6) printf("%d\n", b/2);
	else printf("0\n");
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		S[i] = (S[i] - 'A' + N) % 26 + 'A';
	}

	cout << S << "\n";

	return 0;
}

Measured memory_bytes: 256