akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    data class Line(var to: Int, val c: Int, val t: Int)

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toInt()
        val B = sc.next().toInt()
        pw.println(arrayOf(A + B, A - B, A * B).max()!!)
    }
}


Measured memory_bytes: 35916
all_ele = []
sum_ele = []
h,w = [int(x) for x in input().split()]
for ele in range(h):
    all_ele.append([int(x) for x in input().split()])
    all_ele[ele].append(sum(all_ele[ele]))
    
all_ele.append([int(x) for x in range(w+1)])

for a in range(len(all_ele[0])):
    for b in range(h):
        sum_ele.append(all_ele[b][a])
    all_ele[h][a] = sum(sum_ele)
    sum_ele = []
    
for out1 in all_ele:
    print(' '.join(map(str,out1)))


Measured memory_bytes: 5684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> d(n);
    vector<int> hg(n);
    for (int i = 0; i < n; i++) {
        cin >> hg.at(i);
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        d.at(a - 1).push_back(b - 1);
        d.at(b - 1).push_back(a - 1);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int f = 1;
        int y = d.at(i).size();
        for (int j = 0; j < y; j++) {
            if (hg.at(i) <= hg.at(d.at(i).at(j)))f = 0;
        }
        ans += f;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8804
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int dx[] = {  0, -1, 0, 1};
int dy[] = { -1,  0, 1, 0};


class node_t 
{
public:
  node_t(int xx, int yy, int zz) : x(xx), y(yy), z(zz) {};
  
public:
  int x;
  int y;
  int z;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W;

  std::cin >> H >> W;

  std::vector<std::string> a(H);

  for (auto& s : a)
    std::cin >> s;

  int ids[444][444], id = 1;

  memset(ids, 0, sizeof(ids));

  std::map<int, std::pair<int, int>> map;

  for (int i = 0; i < H; i ++)
    for (int j = 0; j < W; j ++)
      if (a[i][j] == '#')
        if (ids[i][j] == 0) {
          ids[i][j] = id ++;
          
          std::queue<node_t> queue;

          queue.emplace(j, i, 0);

          map[id].first ++;

          while (! queue.empty()) {
            node_t node = queue.front(); queue.pop();

            for (int i = 0; i < 4; i ++) {
              int x = node.x + dx[i], y = node.y + dy[i], z = 1 - node.z;

              if (x < 0 || x >= W || y < 0 || y >= H)
                continue;

              if (ids[y][x])
                continue;

              if ((z == 0 && a[y][x] == '.') ||
                  (z == 1 && a[y][x] == '#'))

                continue;

              ids[y][x] = id;

              (z == 0 ? map[id].first : map[id].second) ++;

              queue.emplace(x, y, z);
            }
          }
        }

  long long c = 0;

  for (const auto& kv : map) {
    long long x = kv.second.first, y = kv.second.second;

    c += x * y;
  }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <utility> //pairを使う
using namespace std;

typedef unsigned long long ll;

const ll inf = 1000000000000;
const ll mod = 10007;

int main(){
	int k, s, t = 0;
	cin >> k >> s;
	for(int i = 0; i <= k; i++){
		int a, b;
		if(s - i < 0){
			break;
		}
		if(s - i > k * 2){
			continue;
		}
		if(s - i > k){
			a = k; b = s - i - k;
			t += a - b + 1;
		}else{
			a = s - i; b = 0;
			t += a - b + 1;
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b && b<c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define N 200050
using namespace std;
typedef long long LL;
int a[N],n,x;
LL sum[N];
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
	n = rd(), x = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	for (int i=1;i<=n;i++) sum[i] = a[i] + sum[i-1];
	LL ans = 1LL << 62;
	for (int t=1;t<=n;t++) {
		LL cnt = 1, cur = 1LL * (n+t) * x;
		cur += sum[n] - sum[n-t];
		for (int p=n;p>=1;p-=t) {
			++cnt;
			if (cnt > 31622) {
				cur = 1LL<<62;
				break;
			}
			LL xs = cnt==2 ? 4LL : 2LL*cnt-1;
			cur += xs * sum[p];
			if (p-t >= 0) cur -= (xs * sum[p-t]);
		}
		ans = min(ans, cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int A,B,C;
	
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	
	if(A==5&&B==7&&C==5) {
		printf("YES\n");
	}
	else 	if(A==5&&B==5&&C==7) {
		printf("YES\n");
	}
	else if(A==7&&B==5&&C==5) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
		}
	return 0;
}
	

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	vector<int> s;
	vector<int> t;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		s.push_back(tmp);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int tmp;
		cin >> tmp;
		t.push_back(tmp);
	}

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	int s_place = 0; // sの現在位置
	int ans = 0;     // 答え
	int t_place = 0; // tの現在位置
	int late = -1;
	while (s_place < n && t_place < q) {
		  // sのほうが大きいならtを増やす
		if (s[s_place] > t[t_place]) {
			t_place++;
		} else if (s[s_place] < t[t_place]) {
		  // tのほうが大きいならsを増やす
			s_place++;
		} else {
			// 同じかつ違う整数がヒットしたならカウントしてsを増やす
			if (late != t[t_place]) {
				ans++;
				late = t[t_place];
			}
			s_place++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1324
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

template<class T> void swap(T &a, T &b ){
    T temp;
    temp = a;
    a = b;
    b = temp;   
}

int main(){
    int M1,D1;
    int M2,D2;

    cin >> M1 >> D1 >> M2 >> D2;
    if( M1 != M2 ){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 764
N = int(input())
a = list(map(float, input().split()))

while N > 1:
  b = []
  for i in range(0,N-1,2):
    c = (a[i] * a[i+1])/(a[i] + a[i+1])
    b.append(c)
    
  if N % 2 != 0:
    b.append(a[N-1])
    
  a = b
  N = len(a)

print(a[0])

Measured memory_bytes: 3064
def pf(a,n,p):
    bi = str(format(n,"b"))
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

N=int(input())
mod=10**9+7

ans=pf(10,N,mod)-pf(9,N,mod)*2+pf(8,N,mod)

print(ans%mod)

Measured memory_bytes: 9188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long r = sc.nextLong();
        long d = sc.nextLong();
        long x = sc.nextLong();
        
        for (int i = 0; i < 10; i++) {
            x = x * r - d;
            System.out.println(x);
        }
    }
}


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

typedef long long LL;
typedef long double LB;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const LB eps = 1e-8;
const LL MOD = 1e9 + 7;
const int DIGS = 70;

template <typename T>
inline bool scan_d (T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; //EOF
    while (c != '-' && (c < '0' || c > '9') ) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}
template<typename T>
void print(T x) {
    static char s[33], *s1; s1 = s;
    if (!x) *s1++ = '0';
    if (x < 0) putchar('-'), x = -x;
    while(x) *s1++ = (x % 10 + '0'), x /= 10;
    while(s1-- != s) putchar(*s1);
}
template<typename T> void println(T x) { print(x); putchar('\n');}

LL n;
//LL dig[DIGS];
//
//void init() {
//    dig[0] = 0;
//    while(n > 0) {
//        dig[++ dig[0]] = n & 1;
//        n >>= 1;
//    }
//}
map<LL, LL> ans;
LL calc(LL x) {
    if(x == 0) return 1;
    if(x == 1) return 2;
    if(x == 2) return 4;
    LL ret = ans[x];
    if(!ret) {
        ret += calc(x >> 1);
        if(ret >= MOD) ret -= MOD;
        ret += calc((x - 1) >> 1);
        if(ret >= MOD) ret -= MOD;
        ret += calc((x - 2) >> 1);
        if(ret >= MOD) ret -= MOD;
        ans[x] = ret;
    }
    return ret;
}

int main() {
#ifdef ___LOCAL_WONZY___
//    freopen("input.txt", "r", stdin);
#endif // ___LOCAL_WONZY___
    scan_d(n);
//        init();
    println(calc(n));
    return 0;
}


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

struct StCity
{
  StCity() : m_nPref(0), m_nYear(0) { }

  int m_nPref;
  int m_nYear;
};

void fnInput(int& rnPrefSiz, vector<StCity>& rvoCity)
{
  int nCitySiz;
  cin >> rnPrefSiz >> nCitySiz;
  rvoCity.resize(nCitySiz);

  for (StCity& roCity : rvoCity)
  {
    cin >> roCity.m_nPref >> roCity.m_nYear;
    --roCity.m_nPref;
  }
}

void fnIdNum(int nPrefSiz, const vector<StCity>& cnrvoCity)
{
  vector<vector<int>> vvnCity(nPrefSiz);
                                           // vvnCity[ nPref ] に nYear を保存 
  for (int i = 0; i < cnrvoCity.size(); ++i)
    vvnCity[ cnrvoCity[i].m_nPref ].push_back( cnrvoCity[i].m_nYear );

  for (int i = 0; i < vvnCity.size(); ++i)
  {                                        // vvnCity[ nPref ] 毎に nYear を昇順に sort
    sort( begin(vvnCity[i]), end(vvnCity[i]) );
                                           // vvnCity[ nPref ] 毎に nYear の重複を除く
    vvnCity[i].erase( unique( begin(vvnCity[i]), end(vvnCity[i]) ), end(vvnCity[i]) );
  }

  for (int i = 0; i < cnrvoCity.size(); ++i)
  {
    int nPref = cnrvoCity[i].m_nPref;
    cout << setfill('0') << setw(6) << nPref + 1;
                   // nYear で sort済の vvnCity[ nPref ] に対して、求める nYear を二分索引して
                   // イテレータを算出し、vvnCity[ nPref ]の begin イテレータを削除し、
                   // nYear が小さい方から何番目かを取得する
    int nIdNum = lower_bound( begin( vvnCity[ nPref ] ), end( vvnCity[ nPref ] ), 
                              cnrvoCity[i].m_nYear ) - begin( vvnCity[ nPref ] );   
    cout << setfill('0') << setw(6) << nIdNum + 1 << endl;
  }
}
  
int main()
{
  int nPrefSiz;
  vector<StCity> voCity;
  
  fnInput(nPrefSiz, voCity);
  fnIdNum(nPrefSiz, voCity);

  return 0;
}

Measured memory_bytes: 9400
#include <cstdio>

int main()
{
    int N = 2, K = 1, Q = 1;

    scanf("%d %d %d", &N, &K, &Q);
    int score[N] = {};
    int t = 0;
    for (int i = 0; i < Q; ++i)
    {
        scanf("%d", &t);
        ++score[t-1]; // i start with 1.
    }

    // Output
    for (int i = 0; i < N; ++i)
    {
        printf("%s\n", K - ( Q - score[i]) > 0 ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 896
N = int(input())
A = [int(i) for i in input().split()]
Sunuke = A[0]
Rac = sum(A[1:])
minPoint = abs(Sunuke-Rac)
for i in range(1, N-1):
    Sunuke += A[i]
    Rac -= A[i]
    minPoint = min(minPoint, abs(Sunuke-Rac))
print(minPoint)

Measured memory_bytes: 24832
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
min_cost = 10**9
for num in range(-100, 101, 1):
    sbn_array = np.abs(alist - num)
    cost = np.sum(sbn_array**2)
    min_cost = min(min_cost, cost)
print(min_cost)


Measured memory_bytes: 12500
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int dp[509];

int main() {
    int N;
    cin >> N;
    
    mem( dp, 0);
    
    int c, s, f;
    rep1( i, N-1) {
        cin >> c >> s >> f;
        
        dp[i] = s;
        
        rep1( j, i) {
            if ( dp[j]<=s ) {
                dp[j] = s+c;
            } else if( dp[j]%f == 0) {
                dp[j] += c;
            } else {
                dp[j] += (dp[j]/f)*f + f - dp[j] + c;
            }
        }
    }
    rep1(i,N) {
        cout1( dp[i]);
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>){
  val n = readLine()!!.toInt()
  val a = readLine()!!.split(" ")
  val result = IntArray(n)
  for( (i, v) in a.withIndex() )
    result[v.toInt()-1] = i+1

  println(result.joinToString(separator=" "))
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;

ll divceil(ll x, ll y) {
    assert(y!=0);
    return (x+y-1)/y;
}

ll K, X, Y;

ll xx = 1, yy = 1;

vector<pair<ll,ll>> ans;

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

    cin>>K>>X>>Y;

    if ((X+Y)%2) {
	if (K%2==0) out(-1);
    }


    // transpose to make goal in Q1
    if (X<0) {
	X = -X;
	xx = -1;
    }

    if (Y<0) {
	Y = -Y;
	yy = -1;
    }

    // A: positive movement
    // B: negative movement
    // N: min moves

    // NK = A+B
    // A-B = X+Y

    // A = (NK+X+Y)/2
    // B = (NK-X-Y)/2

    // B implies:
    // NK >= X+Y ----------> N = ceil((X+Y)/K)
    // (NK = X+Y)mod2 -----> if (X+Y) is odd, K cannot be even

    // Also if N=1, then K=X+Y. This is implied by the problem statement itself
    

    
    ll N = divceil(X+Y, K);
    while (N*K-X-Y < 0) N++;
    if (N==1 && X+Y!=K) N++;
    while ((N*K+X+Y)%2!=0) N++;

    ll B = (N*K-X-Y)/2;
    //ll A = (N*K+X+Y)/2;



    ll x = 0;
    ll y = 0;

    while (B>0) {
	if (B-K >= 0) {
	    x -= K;
	    // if (abs(x-X) < abs(y-Y)) {
	    // 	x -= K;
	    // } else {
	    // 	y -= K;
	    // }
	    ans.push_back({x,y});
	    B -= K;
	} else {
	    ll rest = B;
	    ll rem = K - rest;
	    if (abs(x-X) < abs(y-Y)) {
		x -= rest;
		y += rem;
	    } else {
		y -= rest;
		x += rem;
	    }
	    ans.push_back({x,y});
	    B -= rest;
	}
    }

    while (x < X) {
	ll go = min(X-x, K);
	ll rest = K - go;
	x += go;
	y += rest;
	ans.push_back({x,y});
    }

    assert(abs(Y-y)%K == 0);
    while (y < Y) {
	y += K;
	ans.push_back({x,y});
    }


    assert((int)ans.size() == N);
    cout<<N<<"\n";
    for (auto p: ans) {
	cout<<(xx*p.first)<<" "<<(yy*p.second)<<"\n";
    }

    
    return 0;
}


Measured memory_bytes: 7312
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s,ss,sss;
	int i,j;
	int x,y;
	int z;
	int flg;
	while(1){
		cin>>s;
		if(s=="0000")	break;
		flg=0;
		for(i=0;i<3;i++){
			if(s[i]!=s[i+1]){
				flg=1;
				break;
			}
		}
		if(flg==1){
			j=1;
			if(s=="6174")	j=0;
			else{
				while(1){
					if(s=="6174")	break;
					ss=s;
					sort(ss.begin(),ss.end(),greater<char>());
					if(ss=="6174")	break;
					sss=s;
					sort(sss.begin(),sss.end());
					if(sss=="6174")	break;
					z=1000;
					x=y=0;
					for(i=0;i<4;i++){
						x+=(ss[i]-'0')*z;
						y+=(sss[i]-'0')*z;
						z/=10;
					}
					//cout<<x<<" "<<y<<endl;
					z=x-y;
					//cout<<z<<endl;
					for(i=3;i>=0;i--){
						s[i]=(z%10)+'0';
						z/=10;
					}
					//cout<<s<<endl;
					if(s=="6174")	break;
					j++;
				}
			}
		}
		if(flg==1)	cout<<j<<endl;
		else 		cout<<"NA"<<endl;
	}
	return 0;
}
		
	


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

int main()
{
    ciosup;
    int n, k;
    cin >> n >> k;
    vint a(n),b(n);
    vecin(a);
    ll tot = 0;
    REP(i, n)
    {
        tot += a[i];
    }
    vector<int> lis;
    for (int i = 1; i * i <= tot; ++i)
    {
        if (tot % i == 0)
        {
            lis.eb(tot / i);
            lis.eb(i);
        }
    }
    int ans = -1;
    for (auto elem : lis)
    {
        REP(i, n)
        {
            b[i] = a[i] % elem;
        }
        sort(b.begin(), b.end());
        ll costneg = 0,costpos = 0;
        REP(i,n){
            costneg += b[i];
        }
        if (costneg <= k)
        {
            ans = max(ans,elem);
            continue;
        }
        IREP(i,n){
            costneg -= b[i];
            costpos += elem - b[i];
            if (max(costpos,costneg) <= k)
            {
                ans = max(ans,elem);
                continue;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int h ,a;
  cin>>h>>a;
  if(h%a==0)
    cout<<h/a;
  else
  {
    cout<<h/a+1;
  }
  
  return 0;
}

Measured memory_bytes: 256
N=int(raw_input())
S=["" for i in range(N)]
for i in range(N):
    S[i] = raw_input()


S.sort()

maxc = -1
sol = []
prev = S[0]
count = 0
S.append("")

for i in range(N+1):
    if prev == S[i]:
        count += 1
    else:
        if maxc < count:
            sol = [prev]
            maxc = count
        elif maxc == count:
            sol.append(prev)

        count = 1
        prev = S[i]
#print sol
for i in range(len(sol)):
    print sol[i]


Measured memory_bytes: 23224
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math



n = stdin.readline().rstrip()
if n == 'SUN':
    print(7)
if n == 'MON':
    print(6)
if n == 'TUE':
    print(5)
if n == 'WED':
    print(4)
if n == 'THU':
    print(3)
if n == 'FRI':
    print(2)
if n == 'SAT':
    print(1)


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

using namespace std;

int main()
{
	int n;
	int a;
	int cnt = 0;

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(a%2) cnt++;
	}

	if(cnt%2) cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 256
N,M=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
X.sort()
rui=[]
for i in range(len(X)-1):
  rui.append(X[i+1]-X[i])
rui.sort()
if N==1:
  print(sum(rui))
elif M>=N:
  print(sum(rui[0:-(N-1)]))
else:
  print(0)

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

int main(void){
    int h, w, diag;
    int bh, bw;
    while(cin >> h >> w && h) {
        int mind = numeric_limits<int>::max();
//        int bh = numeric_limits<int>::max();
        diag = h*h + w*w;
        for(int i=1; i<151; ++i) {
            for(int j=i+1; j<151; ++j) {
                int t = i*i+j*j;
                if(t > diag || (t==diag && i>h)) {
                    if(t < mind || (t==mind && i<bh)) {
                        mind = t;
                        bh = i;
                        bw = j;
                    }
                    break;
                }
            }
        }
        cout << bh << " " << bw << endl;
    }
}

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

int main(){
	string s;
  	cin>>s;
  
  	long long int L=s.size();
  	long long int n=0;
  	long long int p=1;
  	int d[2019]={0};
  	long long int cnt=0;
  	d[0]++;
    for(int i=L-1;i>=0;i--){
        n=(n+(s[i]-'0')*p)%2019;
      	p=(p*10)%2019;
        d[n]++;
    }
  	for(int i=0;i<2019;i++){
    	cnt+=d[i]*(d[i]-1)/2;
    }
	
  	cout<<cnt<<endl;
}


Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll sum[202020];
ll mod = 2019;

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

	string S;
	cin >> S;
	int N = S.size();
	reverse(all(S));
	ll cur = 1;
	map<ll, ll>mp;
	mp[0]++;
	for (int i = 0; i < N; i++) {
		sum[i + 1] = sum[i] + (S[i] - '0')*cur;
		sum[i + 1] %= mod;
		mp[sum[i + 1]]++;
		cur *= 10;
		cur %= mod;
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		mp[sum[i]]--;
		ans += mp[sum[i]];
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 5348
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
long long z = 0;
long long f[200005];
long long bio[10000];
long long bp(long long x, long long p)
{
	long long t = x, pr = 1;
	for(int i = 1; i <= p; i *= 2)
	{
		if((i & p) != 0)
		{
			pr *= t;
			pr %= MOD;
		}
		t *= t;
		t %= MOD;
	}
	return pr;
}
long long modmi(long long x, long long y)
{
	return ((x % MOD) - (y % MOD) + MOD) % MOD;
}
long long modd(long long x, long long y)
{
	return ((x % MOD) * (bp(y, MOD-2) % MOD)) % MOD;
}
long long u(long long x, long long y)
{
	return modd(f[x+y], (f[x] * f[y]) % MOD);
}
int main()
{
	f[0] = 1;
	for(int i = 1; i <= 200000; i++)
	{
		f[i] = f[i-1] * i;
		f[i] %= MOD;
	}
	int r, s, b;
	cin >> r >> s >> b;

	z = u(r-1, s-1);

	pair <int, int> p[b];
	for(int i = 0; i < b; i++)
	{
		cin >> p[i].first >> p[i].second;
		p[i].first--;
		p[i].second--;
	}
	sort(p, p + b);
	long long bz;
	for(int i = 0; i < b; i++)
	{
		bio[i] = u(p[i].first, p[i].second);
		for(int j = 0; j < i; j++)
		{
			if(p[j].first <= p[i].first && p[j].second <= p[i].second)
			{
				bio[i] = modmi(bio[i], (bio[j] * u(p[i].first-p[j].first, p[i].second-p[j].second)));
			}
		}
		bz = u(r-p[i].first-1, s-p[i].second-1);
		z = modmi(z, ((bio[i] * bz) % MOD));
	}
	cout << z << endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int x[100005],y[100005],z[100005];
vector<int> G[100005];
bool used[100005];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
		x[i]--;
		y[i]--;
		G[x[i]].push_back(y[i]);
		G[y[i]].push_back(x[i]);
	}
	memset(used,false,sizeof(used));
	int cnt=0;
	for(int i=0;i<n;i++){
		if(!used[i]){
			dfs(i);
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

int main(){
    ll X,Y; cin>>X>>Y;
    if(abs(X-Y)<=1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define ll long long
#define vi vector<long long>
#define pi pair<long long, long long>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)123456789;
const ll N = (1<<12);


ll n;
pair<ll, ll> a[100001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("C.txt", "r", stdin);
    #endif
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i].F;
        a[i].S = i+1;
    }
    sort(a, a+n);
    for(int i=0; i<n; i++) cout << a[i].S _;

}




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

int X[10];

int main(){
  rep(i, 5) cin >> X[i];
  int sums = 0;
  rep(i, 5) sums += X[i];
  cout << 15 - sums << endl;
}


Measured memory_bytes: 3464
s = int(input())
a = [s, ]
for i in range(2, 1000001):
    if s % 2 == 0:
        b = s // 2
    else:
        b = 3 * s + 1
    if b in a:
        print(i)
        break
    a.append(b)
    s = b

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

int main() {
	int n, a[3]; cin >> n >> a[0] >> a[1] >> a[2];
	if(a[0] + a[1] + a[2] == 0) {
		cout << "No" << '\n';
		return 0;
	}
	if(a[0] + a[1] + a[2] == 1) {
		char ans[n];
		for(int i = 0; i < n; ++i) {
			string _s; cin >> _s;
			int s[] = {_s[0] - 'A', _s[1] - 'A'};
			if(a[s[0]] == 0 and a[s[1]] == 0) {
				cout << "No" << '\n';
				return 0;
			}
			if(a[s[0]] == 0) ans[i] = s[0] + 'A';
			if(a[s[1]] == 0) ans[i] = s[1] + 'A';
			swap(a[s[0]], a[s[1]]);
		}
		cout << "Yes" << '\n';
		for(int i = 0; i < n; ++i) {
			cout << ans[i] << '\n';
		}
		return 0;
	}
	int s[n][2];
	char ans[n];
	for(int i = 0; i < n; ++i) {
		string _s; cin >> _s;
		s[i][0] = _s[0] - 'A';
		s[i][1] = _s[1] - 'A';
	}
	for(int i = 0; i < n; ++i) {
		if(a[s[i][0]] == 0 and a[s[i][1]] == 0) {
			cout << "No" << '\n';
			return 0;
		}
		int pl, mi;
		if(a[s[i][0]] == 0) {
			pl = s[i][0];
			mi = s[i][1];
		} else if(a[s[i][1]] == 0) {
			pl = s[i][1];
			mi = s[i][0];
		} else if(i + 1 < n) {
			for(int j = 0; j < 2; ++j) {
				if(s[i][0] == s[i + 1][j]) {
					pl = s[i][0];
					mi = s[i][1];
				}
				if(s[i][1] == s[i + 1][j]) {
					pl = s[i][1];
					mi = s[i][0];
				}
			}
		} else {
			pl = s[i][0];
			mi = s[i][1];
		}
		ans[i] = pl + 'A';
		a[pl]++;
		a[mi]--;
	}
	cout << "Yes" << '\n';
	for(int i = 0; i < n; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 4504
#include<iostream>
#include<bits/stdc++.h>
 
using namespace std;
 
string s , t;
 
int LCS(int l , int m)
{
    int i , j ;
    vector<vector<int>>dp(l+1,vector<int>(m+1,0));
    for( i = 0 ; i <=l ; i++)
    {
        for( j = 0 ; j <=m ; j++)
        {
            if(i==0 || j==0) dp[i][j]=0;
 
            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    i = l;
    j = m;
    string ans;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}
int main()
{
    cin>>s>>t;
    LCS(s.length(),t.length());
}

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

int main() {
	bool ball[3] = { true, false, false };
	string s;
	while (cin >> s) {
		int x = s[0]-'A', y = s[2]-'A';
		int temp = ball[x];
		ball[x] = ball[y];
		ball[y] = temp;
	}
	cout << (ball[0] ? 'A' : ball[1] ? 'B' : 'C') << endl;
	return 0;
}

Measured memory_bytes: 0
# 2019-11-27 15:57:35(JST)
import sys
from string import ascii_lowercase as alphabet
from bisect import bisect_left as bi_l

def main():
    s = sys.stdin.readline().rstrip()
    n = len(s)
    used = set(s)
    not_used = sorted(set(alphabet) - used)

    if not_used:
        ans = s +  not_used[0]
    else:
        cand = []
        for i in range(n-1, 0, -1):
            cand.append(s[i])
            if s[i-1] > s[i]:
                continue
            else:
                ans = s[:i-1] + cand[bi_l(cand, s[i-1])]
                break
        else:
            ans = -1
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4084
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    X=int(input())
    while True:
        # 素数リスト
        n = X
        primes = set(range(2, n + 1))
        for i in range(2, int(n ** 0.5 + 1)):
            primes.difference_update(range(i * 2, n + 1, i))
        if X in primes:
            print(X)
            break
        else:
            X+=1


resolve()

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

int halfComb[2001]; // 0 to 2000  init with 0

void init() {
  for(int i = 0; i < 1001; i++)
    for(int j = 0; j < 1001; j++)
      halfComb[i+j]++;
}

int main(){
  int cnt;
  int n, mx;

  init();
  
  while(cin >> n) {
    cnt = 0;
    mx =  (n<2000?n:2000); // (a, b) の組合せそれぞれに対して(c, d) は高々2000通り
    for(int i = 0; i <= mx; i++) {  // 0 <= a+b <= 2000
      if(n-i <= 2000)       // 0 <= c+d <= 2000
	cnt += halfComb[i] * halfComb[n-i];
    }
    cout << cnt << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){

    long long a,b;

    cin >> a >> b;

    if(a<b)
        swap(a,b);

    long long x,y,z;
    x = a;
    y = b;
    z = a % b;
    while(z!=0){
        x = y;
        y = z;
        z = x%y;
    }

    cout << (a*b)/y << endl;

    return 0;
}

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

#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define ld long double
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
#define sze(v) (int)(v.size())

typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<vector<int>>Vv;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue <int, vector<int>, greater<int>>PQL;
typedef unordered_map<int,int>ump;

const int mod=1e9+7;
const int modx=998244353;
const int Nx=1e5+2;
const int inf= (int)(1e19+10LL);

void solve(){
 int n;
 sl(n);
 Vl a(n);
 for(auto &it:a)sl(it);
 Vl arr(2*n);
 for(int i=0;i<n;i++)arr[i]=a[i];
 for(int i=n;i<2*n;i++)arr[i]=a[i-n];
 //for(auto it:arr)cout<<it<<" ";
 Vl ans;
 int xr;
 for(int i=0;i<n-1;i++){
   	 if(i==0)xr=arr[i];
   	 else{
		 xr=xr^arr[i];
	 }
 }
 ans.pb(xr);
 int cnt=1;
 for(int i=n-1;i<2*n;i++){
	 int past=i-(n-1);
	 //cout<<past<<endl;
	 xr=xr^arr[past];
	 xr=xr^arr[i];
	 ans.pb(xr);
	 cnt++;
	 if(cnt==n)break;
 }
 for(int i=1;i<sze(ans);i++)cout<<ans[i]<<" ";
 cout<<ans[0]<<endl;
 /*
 Vl dek;
 for(int i=1;i<sze(ans);i++)dek.pb(ans[i]);
 dek.pb(ans[0]);
 
 for(int i=0;i<sze(dek);i++){
	 int val=dek[i];
	 for(int j=0;j<sze(dek);j++){
		 if(i==j)continue;
		 val=val^dek[j];
	 }
	 cout<<val<<endl;
 }
  */
}
 
signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


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

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

    int n,ans = 0;
    
    cin >> n;

    int d[n];

    rep(i, n){
        cin >> d[i];
    }

    sort(d, d + n);

    rep(i, n){
        if(d[i] != d[i + 1]) ans++; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

ll ans=0;
bool graph[9][9];
void serch(ll v,ll n,bool visited[]){
    bool all=true;
    for (ll i=0;i<n;i++){
        if (!visited[i]){
            all=false;
        }
    }
    if (all){
        ans++;
    }
    for (ll i=0;i<n;i++){
        if (graph[v][i] and !visited[i]){
            visited[i]=true;
            serch(i,n,visited);
            visited[i]=false;
        }
    }
}

int main(){
    for (ll i=0;i<8;i++){
        fill(graph[i],graph[i]+9,false);
    }
    ll n,m;
    cin >> n >> m;
    for (ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        graph[a-1][b-1]=true;
        graph[b-1][a-1]=true;
    }
    bool  visited[n];
    fill(visited,visited+n,false);
    visited[0]=true;
    serch(0,n,visited);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int d[16];//正直？
vector<pair<int,int>> A[16];

int main(){
    int n;
    cin >> n;
    int k=(1<<n);
    //cerr<<k<<endl;
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            int x,y;
            cin >> x>>y;
            x--;
            A[i].push_back(mp(x,y));
        }
    }
    int ans=0;
    rep(i,k){
        rep(j,n){
            d[j]=-1;
        }
        int temp=0;
        bool ok=1;
        rep(j,n){
            if((i>>j)&1){
                //cerr<<i<<endl;
                /*
                if(i==7){
                    cerr<<j<<endl;
                }
                */
                temp++;
                //cerr<<i<<' '<<j<<endl;
                //cerr<<"safe"<<endl;
                int a=A[j].size();
                //cerr<<i<<' '<<a<<endl;
                rep(l,a){
                    int x,y;
                    tie(x,y)=A[j][l];
                    /*
                    if(i==7){
                        cerr<<d[x]<<' '<<x<<' '<<y<<endl;
                    }
                    */
                    if(d[x]==-1){
                        d[x]=y;
                    }else if(d[x]==y){
                        continue;
                    }else{
                        ok=0;
                    }
                }
            }
            /*
            else{
                int a=A[j].size();
                rep(l,a){
                    int x,y;
                    tie(x,y)=A[j][l];
                    if(d[x]==-1){
                        if(y==0){
                            d[x]=1;
                        }else{
                            d[x]=0;
                        }
                    }else if(d[x]==y){
                        ok=0;
                    }
                }
            }
            */
            //cerr<<i<<endl;
        }
        rep(j,n){
            if((i>>j)&1){
                if(d[j]==0){
                    ok=0;
                }
            }else{
                if(d[j]==1){
                    ok=0;
                }
            }
        }
        //cerr<<i<<endl;
        if(ok){

            if(ans<temp){
                cerr<<i<<' '<<temp<<endl;
            }
            ans=max(ans,temp);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  if (s[0] != '1' or s[n - 2] != '1' or s[n - 1] != '0') return cout << -1 << '\n', 0;
  for (int i = 1; i < n / 2; i++) if (s[i] != s[n - 2 - i]) return cout << -1 << '\n', 0;
  V< pair<int, int> > res;
  res.emplace_back(0, 1);
  int p = 1, t = 1;
  for (int i = 1; i < n / 2; i++) if (s[i] == '0') {
    res.emplace_back(p, ++t);
  } else {
    res.emplace_back(p, ++t);
    p = t;
  }
  while (res.size() < n - 1) res.emplace_back(p, ++t);
  for (int i = 0; i < n - 1; i++) cout << res[i].first + 1 << ' ' << res[i].second + 1 << '\n';
}

Measured memory_bytes: 2372
def main():
    H, W = (int(i) for i in input().split())
    c = [[i for i in input().split()] for j in range(H)]
    al = {i: chr(ord('A') + i) for i in range(26)}
    for h in range(H):
        for w in range(W):
            if c[h][w] == "snuke":
                return print(al[w]+str(h+1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   long double a,b,n;
   while(cin >> a >> b >> n){
      ull ans=0;
      rep(i,n){
         ans+=(ull)(a*pow(10,i+1)/b)%10;
         //cout << tmp << endl;
         //tmp-=(int)tmp;
      }
      cout << ans << endl;
   }
}

Measured memory_bytes: 1284
#include <cstdio>

const int mod = 1e9 + 7;
const int MAXN = 45, MAXS = ( 1 << 17 ) + 5;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

int f[MAXN][MAXS];
int N, X, Y, Z, st, all;

int bit( const int i ) { return 1 << i - 1; }
bool chk( const int S ) { return ( S & st ) == st; }
void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }
int insert( const int S, const int v ) { return ( S << v | bit( v ) ) & all; }

int main()
{
	read( N ), read( X ), read( Y ), read( Z );
	int up = 1 << X + Y + Z;
	all = ( bit( X + Y + Z ) << 1 ) - 1;
	st = bit( Z ) | bit( Y + Z ) | bit( X + Y + Z );
	
	f[0][0] = 1;
	for( int i = 0 ; i < N ; i ++ )
		for( int S = 0 ; S < up ; S ++ )
			if( f[i][S] && ! chk( S ) )
				for( int k = 1, T ; k <= 10 ; k ++ )
					if( ! chk( T = insert( S, k ) ) )
						add( f[i + 1][T], f[i][S] );
	int ans = 1;
	for( int i = 1 ; i <= N ; i ++ )
		ans = 10ll * ans % mod;
	for( int S = 0 ; S < up ; S ++ )
		if( ! chk( S ) )
			add( ans, mod - f[N][S] );
	write( ans ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 20224
import math
from decimal import Decimal
X = int(input())
now = 100
year = 0

while True:
    if now >= X:
        break
    #now = int(now * Decimal("1.01"))
    #now = int(now * round(Decimal(1.01), 2))
    now += now // 100

    year += 1

print(year)


Measured memory_bytes: 9952
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cassert>
#include <random>
#include <time.h>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define re return
#define mp make_pair

using namespace std;

typedef long long ll;

const double pi = 3.14159265;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const ll N = 2e5 + 5;
const ll P0 = 281;
const ll P1 = 257;


int main()
{
    //freopen("ladder.in ", "r", stdin);
    //freopen("OMOMOMMG.txt", "w", stdout);
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b;
    cin >> a >> b;
    if(a > b)
        swap(a, b);
    for (int i = 0; i < b; i++)
        cout << a;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
from fractions import Fraction

# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def main():
    a, b = map(int, input().split())
    print(lcm(a, b))



if __name__ == '__main__':
    main()



Measured memory_bytes: 63212