akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
l, r, d = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 0

for i in range(l, r+1):
    if i%d == 0:
        ans += 1
        
print(ans)

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

long a, b, x;
long cnt;
int main() {
    cin >> a;
    cin >> b;
    cin >> x;
    if (a % x == 0) {
        cout << b / x - a / x + 1 << endl;
    } else {
        cout << b / x - a / x << endl;
    }
}


Measured memory_bytes: 256
l = input()
dp1 = [0] * (len(l)+1)
dp2 = [0] * (len(l)+1)
 
dp1[1] = 1
dp2[1] = 2
if l == '1':
  print(3)
  exit()
for i in range(1, len(l)):
  if l[i] == '0':
    dp1[i+1] = 3 * dp1[i]
    dp1[i+1] %= 1000000007
    dp2[i+1] = dp2[i]
  else:
    dp1[i+1] = 3 * dp1[i] + dp2[i]
    dp1[i+1] %= 1000000007
    dp2[i+1] = 2 * dp2[i]
    dp2[i+1] %= 1000000007
print((dp1[len(l)] + dp2[len(l)]) % 1000000007)

Measured memory_bytes: 41328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=1,a;
    cin>>n;
    if(n==1)
        cout<<"1"<<endl;
    else
    {
        for(i=1; i<=n; i++)
        {
            c=c*2;
            if(c>n)
                break;
            a=c;
        }
        cout<<a<<endl;
    }
}


Measured memory_bytes: 256
S = input()
s0 = 0 < int(S[:2]) <= 12
s1 = 0 < int(S[2:]) <= 12
if s0 and s1:
    print('AMBIGUOUS')
elif s0 and not s1:
    print('MMYY')
elif not s0 and s1:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);

char s[5];

int main() {
  cin >> s;
  if (s[0]==s[1] && s[1]==s[2]) cout << "Yes";
  else if (s[1]==s[2] && s[2]==s[3]) cout << "Yes";
  else cout << "No";
  cout << endl;

}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

def main():
    S=input()

    mode="L"
    start=0
    base=0
    end=0
    group=[]
    for i in range(len(S)):
        s=S[i]
        if mode=="L" and s==mode:
            mode="R"
            base=i-1
        elif mode=="R" and s==mode:
            mode="L"
            end=i-1
            group.append((start,base,end))
            start=i
        elif s=="\n":
            end=i-1
            group.append((start,base,end))
    # print(group)

    A=[0 for _ in range(len(S)-1)]
    for g in group:
        s=g[0]
        b=g[1]
        e=g[2]
        l=e-s+1
        if l//2==0:
            A[b]=A[b+1]=l/2
        else:
            A[b]=(b-s)//2+(e-b)//2+1
            A[b+1]=l-A[b]
    
    print(*A)

main()

Measured memory_bytes: 83544
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000009
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls rt<<1
#define rs rt<<1|1
const int maxn=3e5+10;
const int N=2e5+10;
using namespace std;
int id(int l,int r){return l+r|l!=r;}
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,a[maxn];
ll l[maxn],r[maxn];
multiset<int>dp;
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,3*n)scanf("%d",&a[i]);
    ll now=0;
    rep(i,1,3*n)
    {
        dp.insert(a[i]);
        now+=a[i];
        if(dp.size()>n){now-=*dp.begin();dp.erase(dp.begin());}
        if(dp.size()==n)l[i]=now;
    }
    now=0;
    dp.clear();
    for(i=3*n;i>=1;i--)
    {
        dp.insert(a[i]);
        now+=a[i];
        if(dp.size()>n){now-=*--dp.end();
        dp.erase(--dp.end());}
        if(dp.size()==n)r[i]=now;
    }
    ll ret=-1e18;
    rep(i,1,3*n)
    {
        if(i>=n&&3*n-i>=n)
        {
            //printf("%lld %lld\n",l[i],r[i+1]);
            ret=max(ret,l[i]-r[i+1]);
        }
    }
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 10368
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n,k=map(int,input().split())
	H=list(map(int,input().split()))
	H.sort()
	
	if n<=k:
		print(0)
		exit(0)
	else:
		print(sum(H[:n-k]))
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 21988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN =

int n;
vector<pair<int,int> > rng;

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    REP (i, n) {
        int x, l;
        cin >> x >> l;
        rng.emplace_back(x-l, x+l);
    }

    sort(ALL(rng), [&](pii p1, pii p2) {
        return p1.Y < p2.Y;
    });

    int lst = -iNF;
    int ans = 0;
    for (auto p : rng) {
        if (p.X >= lst) {
            ans++;
            lst = p.Y;
        }
    }

    cout << ans << endl;
    return 0; 
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};

typedef vector<set<Edge>> Graph;

struct Segtree {

};

signed main(void) {

	int n, m;
	cin >> n >> m;

	vector<ll> a(n), b(m), upc(n * m + 1);
	multiset<ll> aa, ba;
	REP(i, n) {
		cin >> a[i];
		aa.insert(a[i]);
	}

	REP(i, m) {
		cin >> b[i];
		ba.insert(b[i]);
	}

	REP(i, n) {
		REP(j, m) {
			upc[min(a[i], b[j])]++;
		}
	}

	for (int i = n * m; 1 <= i; i--)
		upc[i - 1] += upc[i];

	ll used = 0;
	ll ans = 1;
	for (int i = n * m; 1 <= i; i--) {
		if (aa.count(i) > 1 || ba.count(i) > 1) {
			cout << 0 << endl;
			return 0;
		}
		if (aa.count(i)) {
			if (!ba.count(i)) {
				int cc = 0;
				REP(j, m) {
					cc += b[j] > i;
				}

				ans *= cc;
			}
		}

		else if (ba.count(i)) {
			if (!aa.count(i)) {
				int cc = 0;
				REP(j, n) {
					cc += a[j] > i;
				}

				ans *= cc;
			}
		}
		else {

			ans *= upc[i] - used;

		}
		ans %= MODU;
		used++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8192
n=int(input())
a=list(map(int,input().split()))
c,d=dict(),dict()
for i in range(n):
    if i+1-a[i] in c:
        c[i+1-a[i]]+=1
    else:
        c[i+1-a[i]]=1
    if i+1+a[i] in d:
        d[i+1+a[i]]+=1
    else:
        d[i+1+a[i]]=1
ans=0
for i in c:
    if i in d:
        ans+=(c[i]*d[i])
print(ans)


Measured memory_bytes: 57676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    } 
    
    return 0;
}




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

using namespace std;
typedef pair<int, int> pii;

int main(void) {
  int h, w, n;
  cin >> h >> w >> n;

  vector<string> s(h);
  map<char, pii> mp;
  for (int i = 0; i < h; i++) {
    cin >> s[i];
    for (int j = 0; j < w; j++) {
      if (s[i][j] == 'S') {
        s[i][j] = '0';
      }
      if (isdigit(s[i][j])) {
        mp[s[i][j]] = pii(i, j);
      }
    }
  }

  int ans = 0;
  int di[] = {-1, 0, 0, 1}, dj[] = {0, -1, 1, 0};
  for (char c = '0'; c < n + '0'; c++) {
    bool used[1010][1010] = {};
    queue< pair<pii, int> > que;
    used[mp[c].first][mp[c].second] = true;
    que.push(make_pair(mp[c], 0));

    while (!que.empty()) {
      auto v = que.front(); que.pop();
      if (v.first == mp[c + 1]) {
        ans += v.second; break;
      }
      for (int i = 0; i < 4; i++) {
        int ni = v.first.first + di[i], nj = v.first.second + dj[i];
        if (ni >= 0 && ni < h && nj >= 0 && nj < w && !used[ni][nj] && s[ni][nj] != 'X') {
          used[ni][nj] = true;
          que.push(make_pair(pii(ni, nj), v.second + 1));
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4928
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<(a-b==b-c?"YES":"NO");
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

struct unionfind {
    vector<int> par; // 各要素の根
    // vi size; // 自分以下の子の数(根の場合は集合の要素数)
    vector<bool> closed;
    unionfind(int n) {
        par.resize(n, -1);
        // size.resize(n, 1);
        closed.resize(n, false);
        // rep(i, n) {
        //     par[i] = i;
        // }
    }
    int root(int x) { // 要素xの根を返す
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) { // 要素xとyを同一の集合(根)に結合
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        closed[x] = closed[x] | closed[y];
    }
    bool same(int x, int y) { // 要素xとyが同一の集合に属するか判定
        return root(x) == root(y);
    }
    int size(int x) {
        return -par[root(x)];
    }
};

int n, m;

int main() {
    cin >> n >> m;
    unionfind f(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        f.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, f.size(i));
    }
    cout << ans << "\n";
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf (1 << 21)
#define mod 1000000007

int main() {
    ll N, M; cin >> N >> M;
    vector<pair<ll,ll>> ab(N);
    for (int i = 0; i < N; i++) {
        cin >> ab.at(i).first >> ab.at(i).second;
    }
    sort(ab.begin(),ab.end());
    ll cnt = M;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (cnt > ab.at(i).second) {
            cnt -= ab.at(i).second;
            ans += ab.at(i).first * ab.at(i).second;
        }
        else {
            ans += cnt * ab.at(i).first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
int wt[1000006];
int cost[1000006];
int dp[101][100005] = {0};
int knapsack(int i, int w) {
	if (i == -1 or w == 0)
		return 0;
	if (dp[i][w] != -1)
		return dp[i][w];
	if (w < wt[i])
		return dp[i][w] = knapsack(i - 1, w);
	return dp[i][w] = max(knapsack(i - 1, w - wt[i]) + cost[i], knapsack(i - 1, w));

}

int botKnapsack(int n, int w) {
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= w; j++) {
			if (j < wt[i - 1])
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = max(dp[i - 1][j - wt[i - 1]] + cost[i - 1], dp[i - 1][j]);
		}
	}
	return dp[n][w];
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int cap;
	cin >> cap;
	for (int i = 0; i < n; i++)
		cin >> wt[i] >> cost[i];
	cout << botKnapsack(n, cap);
	return 0;
}

Measured memory_bytes: 81728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[4];
		for(int i=0;i<4;i++) {
			num[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		for(int i=0;i<4;i++) {
			if(!(num[i] == 1||num[i]==4||num[i]==7||num[i]==9)) {
				System.out.println("NO");
				return;
			}
		}

		int n = 21;
		for(int i=0;i<4;i++) {
			n-=num[i];
		}
		if(n == 0){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll S(ll n){
	if(n<10) return n;
	else return n%10+S(n/10);
}

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

	if(n%S(n) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
s = str(input())
a = 0
if len(s)%2 != 0:
    print("No")
    exit()
for i in range(len(s)):
    if a%2 == 0:
        if s[i] != "h":
            print("No")
            exit()
    else:
        if s[i] != "i":
            print("No")
            exit()
    a += 1
print("Yes")

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

int n, L, Q, lg;
std::vector <int> a;
std::vector <std::pair<int,int>> query;
std::vector <std::vector<int>> reach;

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

	std::cin >> n;
	a.resize (n+1);
	for (int i = 1; i <= n; ++i)
		std::cin >> a[i];
	std::cin >> L >> Q;
	query.resize (Q);
	for (int i = 0; i < Q; ++i)
		std::cin >> query[i].first >> query[i].second;
	lg = std::__lg (n);
	if ((1<<lg) < n) lg++;
	std::cerr << "lg = " << lg << "\n";
	reach.assign (n+1, std::vector<int> (lg+1, 0));

	for (int i = 1; i <= n; ++i) {
		if (a[i] + L >= a[n])
			reach[i][0] = n;
		else
			reach[i][0] = std::upper_bound (a.begin()+1, a.end(), a[i]+L)-a.begin()-1;
	}
	for (int j = 1; j <= lg; ++j)
		for (int i = 1; i <= n; ++i)
			reach[i][j] = reach[reach[i][j-1]][j-1];
	for (int i = 0; i < Q; ++i) {
		int st = query[i].first, ed = query[i].second;
		if (st > ed) std::swap (st, ed);
		int ans = 0;
		for (int j = lg; j >= 0; --j)
			if (reach[st][j] < ed)
				st = reach[st][j], ans += (1<<j);
		std::cout << ans+1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 12160
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		ArrayList<Integer> list = new ArrayList<Integer>();

		for (int i = 1; i <= 100; i++)  {
			if (a % i == 0 && b % i == 0 ) {
				list.add(i);
			}
		}
		System.out.println(list.get(list.size() - k));


	}

}


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

int main()
{
    ll t,n,i,x;
    scanf("%lld", &t);
    if(t==1){
        printf("0\n");
    }
    else{
        printf("1\n");
    }
    return 0;
}

Measured memory_bytes: 3708
#include <iostream>

using namespace std;

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


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

int main() {
	long long n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	if ((b - a) % 2 == 0) {
		printf("%lld\n", (b - a) / 2);
	} else {
		printf("%lld\n", min(a + (b - a) / 2, n - b + 1 + (b - a) / 2));
	}
	return 0;
}

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

int main(void) {
  int x1, y1, x2, y2, x3, y3, x4, y4, a, b;

  if(scanf("%d %d %d %d", &x1, &y1, &x2, &y2) == 1);

  a = x2 - x1;//a4
  b = y2 - y1;//b3

  x3 = x2 - b;
  y3 = y2 + a;
  x4 = x1 - b;
  y4 = y1 + a;


  printf("%d %d %d %d", x3, y3, x4, y4);

  return 0;
}


Measured memory_bytes: 128
#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)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

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

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    vector<ll> a(N);
    rep(i,N)cin>>a[i];
    ll r = 0;
    ll sum = 0;
    ll ans = 0;
    for(ll l = 0; l < N; ++l){
        while(r < N && (sum + a[r]) == (sum ^ a[r])){
            sum += a[r];
            r++;
        }
        ans += r - l;
        if(l == r)r++;
        else sum -= a[l];
    }
    cout<<ans<<endl;
}

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

const int INF = 1000000;

int main()
{
    int n;
    cin >> n;
    int a[100003], b[100003];
    vector<int> v[100003];
    for(int i = 0; i < n - 1; i++){
        cin >> a[i] >> b[i];
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    queue<int> que;
    int df[100003];
    fill(df, df + n + 1, INF);
    df[1] = 0;
    que.push(1);
    while(que.size()){
        int now = que.front();
        que.pop();
        int l = v[now].size();
        for(int i = 0; i < l; i++){
            int next = v[now][i];
            if(df[next] == INF){
                df[next] = df[now] + 1;
                que.push(next);
            }
        }
    }
    int ds[100003];
    fill(ds, ds + n + 1, INF);
    ds[n] = 0;
    que.push(n);
    while(que.size()){
        int now = que.front();
        que.pop();
        int l = v[now].size();
        for(int i = 0; i < l; i++){
            int next = v[now][i];
            if(ds[next] == INF){
                ds[next] = ds[now] + 1;
                que.push(next);
            }
        }
    }
    int s = 0, f = 0;
    for(int i = 1; i <= n; i++){
        if(ds[i] < df[i]) s++;
        else f++;
    }
    if(f > s) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

Measured memory_bytes: 7424
def main():
    n = [int(x) for x in input()]
    op_cnt = len(n) - 1
    for i in range(2 ** op_cnt):
        op = ["-"] * op_cnt
        for j in range(op_cnt):
            if ((i >> j) & 1):
                op[op_cnt - 1 -j] = "+"
        #print(op)
        formula = ""
        #print(list(zip(n,op + [""])))
        for p_n,p_o in zip(n,op + [""]):
            formula += (str(p_n) + p_o)
        #print(formula)
        if eval(formula) == 7:
            print(formula + "=7")
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    vector<pair<int,int>> st;
    for(int i=1;i<n+1;i++){
        int x;cin>>x;
        st.push_back(make_pair(x,i));
    }
    sort(st.begin(),st.end());
    rep(i,n) cout<<st[i].second<<" ";
    return 0;
}


Measured memory_bytes: 1780
#include<stdio.h>

int main (){

int l, r, d, i;
int count = 0;

scanf ("%d %d %d", &l, &r, &d);
for (i = l; i <= r; i++){
if (i % d == 0){
count++;
}
}
printf("%d\n", count);
return 0;
}


Measured memory_bytes: 1632
#include<iostream>
#include<map>
#include<set>
#include<string>
using namespace std;

int main() {
	map<string, set<int> > id;
	string w; int p;
	while(cin >> w >> p) id[w].insert(p);
	for(map<string, set<int> >::iterator itw=id.begin(); itw!=id.end(); ++itw) {
		cout << (*itw).first << endl;
		for(set<int>::iterator itp=(*itw).second.begin();
				itp!=(*itw).second.end(); ++itp) {
			cout << (itp==(*itw).second.begin()?"":" ") << *itp;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

/*
ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}*/

string s;
pair<int, int> cnta[100000], cntc[100001];
int xcnt;
ll cnt, mem;

int main(){
	
	cin >> s;
	cnt = 0;
	xcnt = 0;
	cntc[s.size()] = make_pair(0, 0);
	lp(s.size()) {
		if (s[i] == 'A')cnta[i] = make_pair(1, 0);
		else if (s[i] == '?') {
			cnta[i] = make_pair(0, 1);
			xcnt++;
		}
		else cnta[i] = make_pair(0, 0);
		if (i) {
			cnta[i].first+= cnta[i - 1].first;
			cnta[i].second += cnta[i - 1].second;
		}
	}
	for (int i = s.size() - 1; i >= 0;i--) {
		if (s[i] == 'C')cntc[i] = make_pair(1, 0);
		else if (s[i] == '?')cntc[i] = make_pair(0, 1);
		else cntc[i] = make_pair(0, 0);
		cntc[i].first += cntc[i + 1].first;
		cntc[i].second += cntc[i + 1].second;
	}
	if (xcnt <= 3) {
		lp(s.size()) {
			if (s[i] == 'B') {
				mem = ll(cnta[i].first)*ll(cntc[i].first) % mod;
				LP(xcnt, j)mem = mem * 3 % mod;
				cnt += mem;
				mem = ll(cnta[i].second)*ll(cntc[i].first) + ll(cnta[i].first)*ll(cntc[i].second) % mod;
				LP(xcnt - 1, j)mem = mem * 3 % mod;
				cnt += mem;
				mem = ll(cnta[i].second)*ll(cntc[i].second) % mod;
				LP(xcnt - 2, j)mem = mem * 3 % mod;
				cnt += mem;
				cnt %= mod;
			}
			else if (s[i] == '?') {
				mem = ll(cnta[i].first)*ll(cntc[i].first) % mod;
				LP(xcnt - 1, j)mem = mem * 3 % mod;
				cnt += mem;
				mem = ll(cnta[i].second - 1)*ll(cntc[i].first) + ll(cnta[i].first)*ll(cntc[i].second - 1) % mod;
				LP(xcnt - 2, j)mem = mem * 3 % mod;
				cnt += mem;
				mem = ll(cnta[i].second - 1)*ll(cntc[i].second - 1) % mod;
				LP(xcnt - 3, j)mem = mem * 3 % mod;
				cnt += mem;
				cnt %= mod;
			}
		}
	}
	else {
		lp(s.size()) {
			if (s[i] == 'B') {
				cnt += ll(cnta[i].first * 3 + cnta[i].second)*ll(cntc[i].first * 3 + cntc[i].second) * 3 % mod;
				cnt %= mod;
			}
			else if (s[i] == '?') {
				cnt += ll(cnta[i].first * 3 + cnta[i].second - 1)*ll(cntc[i].first * 3 + cntc[i].second - 1) % mod;
				cnt %= mod;
			}
		}
		LP(xcnt - 3, j)cnt = cnt * 3 % mod;
	}
//	lp(s.size()) {
//		cout << i << sp << cnta[i].first << sp << cnta[i].second << sp << cntc[i].first << sp << cntc[i].second << endl;
//	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2048
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> B(N);
    B[0] = A[0];
    for(ll i = 1; i < N; i++) B[i] = B[i-1] + A[i]; 
    map<ll, ll> mp;
    mp[0]++;
    ll ans = 0;
    rep(i, B.size()) {
        ans += mp[B[i]]++;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x,t;
  cin >> n >> x >> t;
  if(n%x!=0){
    cout << t*((n/x)+1) << endl;
  }
  else{
    cout << t*(n/x) << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int i,j;
        Scanner sc= new Scanner(System.in);

        while(true){
            int H= sc.nextInt();
            int W= sc.nextInt();

            if(H==0&&W==0){
                break;
            }

            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if((i+j)%2==0){
                        System.out.printf("#");
                    }else{
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }    
}


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

int main(){
int N;
cin>>N;
vector<int> h(N);
rep(i,N)cin>>h[i];
reverse(h.begin(),h.end());
int a=0;
int x=0;
for(int i=1;i<N;i++){
   if(h[i-1]<=h[i]){
      x++;
   }
   else{
      x=0;
   }
   a=max(a,x);
}
cout<<a<<endl;
return 0;
}

Measured memory_bytes: 3732
n = int(input())
s1 = str(input())
s2 = str(input())

cnt = 1

for i in range(n):
    if i == 0:
        if s1[i] == s2[i]:
            cnt = cnt * 3
            previous = 'tate'
        else:
            cnt = cnt * 6
            previous = 'yoko1'
    else:
        if s1[i] == s2[i]:   #tate
            if previous == 'tate':
                cnt = cnt * 2
            elif previous == 'yoko2':
                cnt = cnt * 1
                previous = 'tate'
        else:   #yoko
            if previous == 'tate':
                cnt = cnt * 2
                previous = 'yoko1'
            elif previous == 'yoko2':
                cnt = cnt * 3
                previous = 'yoko1'
            elif previous == 'yoko1':
                previous = 'yoko2'
        
print(cnt%1000000007)

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

using namespace std;

typedef long long ll;

int main() {
  int n, m, p;
  int x[100];
  while(cin >> n >> m >> p, n + m + p) {
    int sx = 0;
    for (int i = 0; i < n; i++) {
      cin >> x[i];
      sx += x[i];
    }
    if(x[m-1] == 0) cout << 0 << endl;
    else cout << (100 - p) * sx / x[m-1] << endl;
  }
}

Measured memory_bytes: 2992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

int main() {
    int N,y,min=9999999;
    cin >> N;
    vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  if(a[0]==a[N-1]){
    cout << 0 <<endl;
    return 0;
  }
  for(int i=a[0];i<=a[N-1];i++){
    y=0;
    for(int j=0;j<N;j++){
      y += (a[j]-i)*(a[j]-i);
    }
    if(y<min) min =y;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N=sc.nextInt(),K=sc.nextInt(),p[]=new int[N],sum[]=new int[N+1];
		for(int i=0;i<N;i++) {
			p[i]=sc.nextInt()+1;
			if(i==0)sum[i]=0;
			sum[i+1]=sum[i]+p[i];
		}
		double ans=0;
		for(int i=0;i<=N-K;i++) {
			ans=Math.max(ans,sum[i+K]-sum[i]);
		}
		System.out.println((double)ans/2);
	}
}

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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010


//main function here
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int n,x,y;
    cin>>n>>x>>y;
    vector<int> m(n,0);
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int f=j-i;
            f=min(abs(x-i) + 1 + abs(y-j),f);
            // cout<<f<<"\n";
            m[f]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<m[i]<<"\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans = 1;
        for (int i = 0 ; i < N ; i ++) {
            if (ans + K  < ans * 2) {
                ans += K;
            } else {
                ans *= 2;
            }
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 22740
/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e9+7;
const ll MAXN=1000200;
ll i,j,mask,test;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll n;
cin>>n;
map<ll,ll> a,b;
F(i,0,n)
{
    ll x;
    cin>>x;
    if(i%2==0)
    {
        a[x]++;
    }
    else
    {
        b[x]++;
    }
}
ll mx1=0,mx2=0,p1,p2;
for(auto t:a)
{
    if(mx1<t.second)
    {
        mx1=t.second;
        p1=t.first;
    }
}
for(auto t:b)
{
    if(mx2<t.second)
    {
        mx2=t.second;
        p2=t.first;
    }
}
n/=2;
if(p1!=p2)
{
    cout<<2*n-mx1-mx2;
}
else
{
    ll minn=mod;
    for(ll i=1;i<=1e5;i++)
    {
        if(p1!=i)
        minn=min(minn,2*n-mx1-b[i]);
    }
    for(ll i=1;i<=1e5;i++)
    {
        if(p2!=i)
        minn=min(minn,2*n-mx2-a[i]);
    }
    cout<<minn;
}
return 0;
}


Measured memory_bytes: 16104
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <tuple>

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

void solve(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pairs(m);
  rep(i, m){
     cin >> pairs[i].first >> pairs[i].second; 
  }
  int maxleft = pairs[0].first;
  int minright = pairs[0].second;
  rep(i,m){
     maxleft = max(maxleft, pairs[i].first);
     minright = min(minright, pairs[i].second);
  }
  cout << max(minright - maxleft + 1, 0) << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int x, y;
    cin >> x >> y;
    int b = y - 2 * x;
    if (b < 0 || b % 2 != 0) {
        cout << "No" << endl;
    }
    else {
        b /= 2;
        int a = x - b;
        if (a < 0 || 100 < a)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;            
    }
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	ll N;
	std::cin >> N;
	ll h;
	vll t(3), pre_t(3, 0);
	rep(i, 0, N) {
		rep(j, 0, 3) {
			std::cin >> h;
			t[j] = max(pre_t[(j + 1) % 3], pre_t[(j + 2) % 3]) + h;
		}
		pre_t = t;
	}

	std::cout << max(t[0], max(t[1], t[2])) << endl;

	return 0;
}


Measured memory_bytes: 256
import itertools
K=int(input())
X,Y=map(int,input().split())
Mdist=abs(X)+abs(Y)
if Mdist%2==1 and K%2==0:
    print(-1)
    exit()
    #K:偶数ならマンハッタン距離が偶数の点にしか行けない
    #逆にKが偶数ならマンハッタン距離が偶数の任意の点に行ける
    #K:奇数なら理論上どこでも行ける
    #よってこれ以外のパターンは全部可能
    #(0,0)->(2n+1,0)->(n+1,n+1)->(1,0)
#K:奇数のとき、移動回数と距離がmod2 で合同
def searcheven(x,y):
    if abs(x)+abs(y)>2*K:
        return None
    if (abs(x)+abs(y))%2==1:
        return None
    for ps in itertools.product([-1,1],repeat=4):
        p1,p2,p3,p4=ps
        if p1*p4==p2*p3:
            if p3*(K-p1*x-p2*y)==-p1*K:
                a,b=0,p4*K
                if abs(x-a)+abs(y-b)==K and abs(a)+abs(b)==K:
                    return (a,b)
                a,b=p3*K,0
                if abs(x-a)+abs(y-b)==K and abs(a)+abs(b)==K:
                    return (a,b)
            else:
                pass
        else:
            tmp1=K-p1*x-p2*y
            tmp2=K
            tmp3=p4*tmp1+p2*tmp2
            tmp4=-p3*tmp1-p1*tmp2
            det=-p1*p4+p2*p3
            a,b=(tmp3//det,tmp4//det)
            if abs(x-a)+abs(y-b)==K and abs(a)+abs(b)==K:
                return (a,b)
            else:
                pass
    return None

ans=[(0,0)]
while(True):
    nx,ny=ans[-1]
    if abs(nx-X)+abs(ny-Y)<=2*K:
        if (abs(nx-X)+abs(ny-Y))%2==0:
            p,q=searcheven(X-nx,Y-ny)
            ans.append((p+nx,q+ny))
            ans.append((X,Y))
            break
        else:
            if abs(nx-X)+abs(ny-Y)==K:
                ans.append((X,Y))
                break
            tmpx=K//2
            tmpy=K-tmpx
            nextkouho=[(tmpx,tmpy),(tmpx,-tmpy),(-tmpx,tmpy),(-tmpx,-tmpy),(K,0),(-K,0),(0,K),(0,-K)]
            for point in nextkouho:
                ptmp,qtmp=point
                p=ptmp+nx;q=qtmp+ny
                if abs(X-p)+abs(Y-q)<=2*K:
                    ans.append((p,q))
                    break
    elif abs(nx)+K<=abs(X):
        if X<0:
            ans.append((nx-K,ny))
            continue
        else:
            ans.append((nx+K,ny))
            continue
    elif abs(ny)+K<=abs(Y):
        if Y<0:
            ans.append((nx,ny-K))
            continue
        else:
            ans.append((nx,ny+K))
            continue


#print(ans)
s=len(ans)-1
flag=1
for i in range(s):
    ax,ay=ans[i]
    bx,by=ans[i+1]
    if abs(ax-bx)+abs(ay-by)==K:
        pass
    else:
        flag=0
        break
if flag==0:
    print("NG")
print(s)
for i in range(1,s+1):
    print(ans[i][0],ans[i][1])


Measured memory_bytes: 59744
#include <iostream>
#include <stack>

using namespace std;
int main()
{
	stack<int> st;
	int i, n;
	
	while(cin >> n)
	{
		if(n != 0)
		{
			st.push(n);
		}
		else
		{
			i = st.top();
			cout << i << endl;
			st.pop();
		}
	}
	
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
    int seats;
    char state[10];
    cin>>seats;
    int start=0,end=seats,tmp;
    int start_sex;
    cout<<start<<endl;
    fflush(stdout);
    cin>>state;
    if(state[0]=='V')return 0;
    else start_sex=state[0];
    for(int i=0;i<20;i++){
        tmp=(start+end)/2;
        cout<<tmp<<endl;
        fflush(stdout);
        cin>>state;
        if(state[0]=='V')return 0;
        if((tmp-start)&1){
            if(state[0]==start_sex)end=tmp;
            else {start=tmp;start_sex=state[0];}}
        else{
            if(state[0]!=start_sex)end=tmp;
            else {start=tmp;start_sex=state[0];}}
    }
    return 0;


}

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

int g[15][15];

int main() {
  int n;
  cin >> n;
  rep(i,n)rep(j,n) g[i][j] = -1;
  rep(i,n) {
    int a;
    cin >> a;
    rep(j,a) {
      int x, y;
      cin >> x >> y;
      x--;
      g[i][x] = y;
    }
  }
  int ans = 0;
  rep(i,1<<n) {
    bool ok = true;
    vector<int> d(n);
    rep(j,n) if((i>>j)&1) {
      d[j] = 1;
    }
    rep(j,n) {
      if(d[j]) {
        rep(k,n) {
          if(g[j][k] == -1) continue;
          if(d[k] != g[j][k]) ok = false;
        }
      }
    }
    if(ok) {
      string s;
      int m = i;
      int l = i;
      int count = -1;
      while(m>0) {
        m /= 2;
        count++;
      }
      for(int j = count; j >= 0; j--) {
        if(l>=pow(2,j)) {
          l -= pow(2,j);
          s.push_back('1');
        }
        else s.push_back('0');
      }
      int cnt = 0;
      rep(j,s.size()) if(s.at(j) == '1') cnt++;
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    mod = 998244353

    n = int(input())
    d = list(map(int, input().split()))

    if d[0] > 0:
        print('0')
        exit()

    if len(d) == 1:
        print('1')
        exit()

    d.sort()
    d.pop(0)
    if d[0] == 0:
        print('0')
        exit()

    tmp = 1
    ans = 1
    max_num = max(d)
    dic = dict()
    for i in range(n-1):
        if d[i] in dic:
            dic[d[i]] += 1
        else:
            dic[d[i]] = 1

    for i in range(1, max_num+1):
        if i in dic:
            count = dic[i]
        else:
            print('0')
            exit()
        if count == 0:
            print('0')
            exit()
        ans *= tmp ** count
        ans %= mod
        tmp = count

    print(ans)


Measured memory_bytes: 18424
// AOJ 0146: Lupin The 4th
// 2017.9.28 bal4u@uu
// 2017.11.21

#include <stdio.h>
#include <string.h>

#define INF 0x7fffffff
#define MAX 32768

int s[16], d[16], v[16];	// ????????±?????????????????¢???????????±?????°
int dd[16][16];
int dp[16][MAX];			// DP????????¨?????????
int w[16][MAX];				// ????????±????????°
short prev[16][MAX][2];		// ???????????????????????????
int ord[16];				// ???????????????????????????????????????????????´???

int main()
{
	int n, i, j, k, lim, ans;
	int ii, t, x;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d%d%d", s+i, d+i, v+i);
	for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
		t = d[i] - d[j]; if (t < 0) t = -t;
		dd[i][j] = dd[j][i] = t;
	}

	memset(prev, -1, sizeof(prev));
	for (ii = 1, i = 0; i < n; i++, ii <<= 1) w[i][ii] = v[i];

	lim = (1 << n) - 1;
	for (k = 0; k <= lim; k++) {
		for (ii = 1, i = 0; i < n; i++, ii <<= 1) {		// ??´????????????
			if (k & ii) continue;
			t = k | ii;
			for (j = 0; j < n; j++) {	// ??´?????????
				if (i == j || w[j][k] == 0) continue;
				x = dp[j][k] + dd[i][j]*(7+(w[j][k]<<1));
				if (!dp[i][t] || x < dp[i][t]) {
					dp[i][t] = x, w[i][t] = w[j][k] + v[i];
					prev[i][t][0] = j;
					prev[i][t][1] = k;
				}
			}
		}
	}

	// ???????§???????????????????
	for (ans = INF, ii = 0, i = 0; i < n; i++) {
		if ((t = dp[i][lim]) > 0 && t < ans) ans = t, ii = i;
	}

	// ?????£???????????????
	for (ord[0] = ii, i = ii, j = lim, k = 1; k < n; k++) {
		ord[k] = prev[i][j][0];
		     j = prev[i][j][1];
		     i = ord[k];
	}

	// ??????
	printf("%d", s[ord[n-1]]);
	for (i = 1; i < n; i++) printf(" %d", s[ord[n-i-1]]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 7276
#include<stdio.h>

int main(void)
{
   int W,H,x,y,r;

   scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

   if(0<=x-r && W>=x+r && 0<=y-r && H>=y+r){
      printf("Yes\n");
   }else{
      printf("No\n");
   }

   return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int k; cin >> k;
  int amari = 0, ans = 0;

  while (true) {
    ++ans;
    amari = (7 + amari * 10) % k;
    
    if (amari == 0) {
      cout << ans << endl;
      return (0);
    }

    if (ans >= 1000000) break;
  }

  cout << -1 << endl;

  return (0);
}


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-

def arraycount(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

n = int(input())

a = arraycount(digit_list(n))

for i in range(len(a)):
    a[i][0],a[i][1] = a[i][1],a[i][0]

a.sort()
a.reverse()

if a[0][0] >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064