akhauriyash/Code-Regression huggingface dataset:
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 


int main() {
    io;
    ll n ;
    cin>>n;
   vector<ll > t(n);
   vector<string> s(n); 
    rep(i,0,n){
        cin>>s[i]>>t[i];
    }

    string x;
    cin>>x;
    auto it = find(s.begin(),s.end(), x);
    int index = it -s.begin();
    ll sum = accumulate(t.begin()+index+1, t.end(),0);
    cout<<sum;

  
  

 
 
 
    
 
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define out(x) cout << (x) << endl

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int h, w; string s[55];
    cin >> h >> w;
    rep(i, h) cin >> s[i];

    queue<P> que; que.push(P(0, 0));
    bool seen[55][55]; rep(i, h)rep(j, w) seen[i][j] = false;
    int d[55][55]; rep(i, h)rep(j, w) d[i][j] = 100000;
    d[0][0] = 0;
    int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
    bool isok = false;
    while(!que.empty()){
        P p = que.front(); que.pop();
        if(p.fi == h-1 && p.se == w-1){
            isok = true;
            break;
        }
        rep(i, 4){
            P np = P(p.fi + dx[i], p.se + dy[i]);
            if(np.fi < 0 || np.fi >= h || np.se < 0 || np.se >= w) continue;
            if(seen[np.fi][np.se] || s[np.fi][np.se] == '#') continue;
            que.push(np); seen[np.fi][np.se] = true;
            d[np.fi][np.se] = d[p.fi][p.se] + 1;
        }
    }

    if(!isok){
        out(-1); return 0;
    }
    int res = 0;
    rep(i, h)rep(j, w) if(s[i][j] == '#') res++;
    res = h * w - (d[h-1][w-1] + 1) - res;
    out(res);
}

Measured memory_bytes: 256
n,m  = map(int,input().split())

a = [list(map(int,input().split())) for _ in range(n)]
c = [list(map(int,input().split())) for _ in range(m)]

for i in range(n):
  x,y = a[i]
  
  count = 0
  l = abs(x-c[0][0]) + abs(y-c[0][1])
  for j in range(m):
    
    p,q = c[j]
    
    if l > abs(x-p) + abs(y-q):
      l = abs(x-p)+abs(y-q)
      count = j
      
  print(count+1)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int gcd(int x,int y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(void){
    int a,b;
    cin>>a>>b;
    int k=gcd(a,b);
    string s,t;
    cin>>s>>t;
    for(int i=0;i<k;i++){
        if(s[(a/k)*i]!=t[(b/k)*i]){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    cout<<(long long)a*b/k<<endl;
}


Measured memory_bytes: 512
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
M = []
maximum = 0
for n in range(N):
    L.append(gcd(A[n], L[-1]))
    R.append(gcd(A[-n-1], R[-1]))
R.reverse()
for n in range(N):
    M.append(gcd(L[n], R[n+1]))
for n in range(N):
    maximum = max(maximum, M[n])
print(maximum)

Measured memory_bytes: 16144
object Main extends App {
    val stn = ('a' to 'z').toList ::: ('A' to 'Z').toList
    val in = io.Source.stdin.getLines
    for (n <- in if n != "0") {
        val k = in.next
        val kk = Stream.continually(k.split(" ").map(_.toInt)).flatten
        println(in.next.zip(kk).map{case (c, i) =>
            val x = stn.indexWhere(_ == c) - i
            if(x >= 0) stn(x)
            else stn(x+52)
        }.mkString)
    }
}

Measured memory_bytes: 48556
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n;
int a[110];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    printf("%d",a[n-1]-a[0]);
    return 0;
}


Measured memory_bytes: 256
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 1e6+1;
const ll inf = 1e8;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pwr(x, MOD-2);
}

void solve()
{
    int n,d; cin>>n>>d;
    int x[n][d];
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
            cin>>x[i][j];
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int dist = 0;
            for(int k=0;k<d;k++)
                dist += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            int dst = sqrt(dist);
            if(dst*dst == dist)
                ans++;
        }
    }
    cout<<ans;

}

signed main()
{
// #ifndef ONLINE_JUDGE
//     freopen("ladders_and_snakes_sample_input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    
    int t=1;
    // cin >>t;
    for(int tt=1;tt<=t;tt++){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
 


int main(){
     
    int n,m,flag=0;
    char a[50][50][2],b[50][50][2];
    
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j][0];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>b[i][j][0];
        }
    }
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            for(int k=0;k<m;k++){
                flag=0;
                for(int l=0;l<m;l++){
                    //cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<b[k][l][0]<<" "<<a[i+k][j+l][0]<<endl;
                    if(b[k][l][0]!=a[i+k][j+l][0]){
                        //cout<<"Wrong!"<<endl;
                        flag=1;
                        break;
                    }
                    if(k==m-1&&l==m-1){
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                if(flag==1)break;
            }
        }
    }
    cout<<"No"<<endl;
    
     
    return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a[3];
    REP(i,3) cin>>a[i];
    sort(a,a+3);

    int ans;
    if((a[2]-a[0]+a[2]-a[1])%2==0){
        ans=(a[2]-a[0]+a[2]-a[1])/2;
    }
    else{
        ans=(a[2]-a[0]+a[2]-a[1]+3)/2;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

ll factmod(ll a,ll b,ll m) {
  if(a<b)return 0;
  ll s=1;
  while(a>=b){
    s = s*a % m;
    a -= 1;
  }
  return s;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll combmod(ll a,ll b,ll m){
  if(b==0)return 1;
  ll c=factmod(a,a-b+1,m);
  ll d=modinv(factmod(b,1,m),m);
  ll e=(c*d)%m;
  return e;
}

void modsum(ll &a,ll b,ll m){
  a+=b;
  a%=m;
}

void modsub(ll &a,ll b,ll m){
  a-=b;
  a+=m;
  a%=m;
}

void modmul(ll &a,ll b,ll m){
  a*=b;
  a%=m;
}

void modquo(ll &a,ll b,ll m){
  a*=modinv(b,m);
  a%=m;
}

int main(){

  ll n;
  cin >> n;

  ll a=powmod(10,n,mod);
  ll b=powmod(9,n,mod);
  ll c=powmod(8,n,mod);
  modsub(a,b,mod);
  modsub(a,b,mod);
  modsum(a,c,mod);

  cout << a << endl;

  return 0;
}

Measured memory_bytes: 3636
N = int(input())
lst = list(map(int, input().split()))
cnt = 0

for i in range(N):
    if i == 0:
        cnt += 1
    else:
        canview = True
        for j in range(0, i):
            if lst[j] > lst[i]:
                canview = False
        if canview:
            cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n; cin >> n;
	string s;
	VI ans(4,0);
	string t[4]={"AC","WA","TLE","RE"};
	REP(i,n){
		cin >> s;
		REP(j,4){
			if(s==t[j])
				ans[j]++;
		}
	}
	REP(i,4)
		cout << t[i] << " x " << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3628
def isCLKWISE(ph):
    if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33908
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define int long long
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int INF = 1e18;
const int M = 1e9 + 7;

const int maxn = 2e5;
pii a[maxn];



signed main()
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n;
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i].se >> a[i].fi;
	}
	sort(a, a + n);
	int cur = 0;
	for(int i = 0; i < n; ++i){
		cur += a[i].se;
		if(cur > a[i].fi){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;



    
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
 
using namespace std;
 
int main()
{
   
   int n;
   cin>>n;
   int x = 7%n;
   rep(i,n){
       if(x==0){
           cout<<i+1<<endl;
           return 0;
       }
       x=(x*10+7)%n;
   }
       cout<<"-1"<<endl;
   
   return 0;
}

Measured memory_bytes: 3620
import sys
n=int(input())

l=0
print(l)
sys.stdout.flush()
sl=input()
if sl=="Vacant":
    exit()
r=n-1
print(r)
sys.stdout.flush()
sr=input()
if sr=="Vacant":
    exit()



for _ in range(18):
    m=(l+r)//2
    print(m)
    sys.stdout.flush()
    s=input()
    if s=="Vacant":
        exit()
    if (m-1-l)%2 and s!=sl:
        sr=s
        r=m
    if (m-1-l)%2==0 and s==sl:
        sr=s
        r=m
    if (r-m-1)%2 and s!=sr:
        sl=s
        l=m
    if (r-m-1)%2==0 and s==sr:
        sl=s
        l=m


Measured memory_bytes: 40344
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
int main()
{
    int n, q;
    cin >> n >> q;
    typedef std::stack<int> stk;
    vector<stk> S(n);

    while (q)
    {
        int query;
        cin >> query;
        int t;
        cin >> t;
        stk &s = S.at(t);
        if (query == 0)
        {
            //push(t,x)
            int x;
            cin >> x;
            s.push(x);
        }
        if (query == 1)
        {
            //top(t)
            if (!s.empty())
            {
                cout << s.top() << endl;
            }
        }
        if (query == 2)
        {
            //pop(t)
            if (!s.empty())
            {
                s.pop();
            }
        }
        q--;
    }
}


Measured memory_bytes: 4384
using System;
namespace aizu
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] c = Console.ReadLine().Split();
            int a = int.Parse(c[0]);
            int b = int.Parse(c[1]);
            Console.WriteLine(a*b + " " + (a+b)*2);
        }
    }
}


Measured memory_bytes: 13920
#include <iostream>
#include <string>

int main() {
std::string str;
std::cin >> str;
  if (str == "MON") {
    std::cout << 6;
  }
  if (str == "TUE") {
    std::cout << 5;
  }
  if (str == "WED") {
    std::cout << 4;
  }
  if (str == "THU") {
    std::cout << 3;
  }
  if (str == "FRI") {
    std::cout << 2;
  }
  if (str == "SAT") {
    std::cout << 1;
  }
  if (str == "SUN") {
    std::cout << 7;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n;
    while(cin>>n){
        string s[n],x;
        int sum=0,time[n];
        for(int i=0;i<n;i++){
            cin>>s[i]>>time[i];
        }
        cin>>x;
        int flag=0;
        for(int i=0;i<n;i++){
            if(flag!=1){
                if(s[i]==x)flag=1;
            }
            else if(flag==1){
                sum+=time[i];
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e5 + 7;
const llong mod = 998244353;
const llong inf = 1e18 + 9;

using namespace std;

string s;
llong P[1001][1001];

llong n, l, dp[mxn], h[mxn], k;

int main (){
    cin >> n >> k;
    for (int i = 1; i <= n; i ++){
        cin >> h[i];
    }for (int i = 1; i <= n; i ++){
        dp[i] = inf;
    }
    dp[1] = dp[0] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 1; i <= n; i ++){
        for (int j = i + 1; j <= min(k + i, n); j ++){
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }cout << dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int asumisu, kitaeri;
	while (scanf("%d%d", &asumisu, &kitaeri) == 2 && (asumisu != 0 || kitaeri != 0)) {
		if (asumisu > kitaeri) {
			int kugyu = asumisu;
			asumisu = kitaeri;
			kitaeri = kugyu;
		}
		printf("%d %d\n", asumisu, kitaeri);
	}
	return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    ll X,Y;
    cin >>X>>Y;
    int ans=0;
    while(X<=Y){
        X *=2;
        ans++;
    }
    cout <<ans<<endl;
}

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

using namespace std;

int n;
string a[1000];

int depth[1000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = "#" + a[i];
  }

  int mx = -1;
  for (int start = 1; start <= n; start++) {
    queue<int> q;
    for (int i = 1; i <= n; ++i) {
      depth[i] = 0;
    }
    q.push(start);
    depth[start] = 1;
    bool ok = true;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int j = 1; j <= n; j++) {
        if (a[v][j] == '1') {
          if (depth[j] == 0) {
            q.push(j);
            depth[j] = depth[v] + 1;
          } else if (depth[j] != depth[v] + 1 && depth[j] != depth[v] - 1) {
            ok = false;
          }
        }
      }
    }
    if (ok) {
      for (int j = 1; j<= n; j++) {
        mx = max(mx, depth[j]);
      }
    }
  }
  cout << mx << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
void QueSort(char (*A)[11],int *,int,int);
int main(){
  int  n,q;
  char A[100000][11];
  int  B[100000];
  int  i;
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s%d",&A[i],&B[i]);
  }
  QueSort(A,B,n,q);
  return 0;
}
void QueSort(char (*A)[11],int *B,int n,int q){
  int  s=0,t=0, i;
  
  while(t!=n){
    for(i=0;i<n;i++){
      if(B[i]!=0){
	if(B[i]<= q){
	  s+=B[i];
	  t++;
	  printf("%s %d\n",A[i],s);
	  B[i]=0;
	}
	else{
	  s+=q;
	  B[i]-=q;
	}
      }
    }
  }
}



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

int main(){
    string N;
    char c[3];
    cin >> c;
    for (int i =0 ; i<3 ; i++){
        if(c[i] == '1'){
            cout << '9';
        }else{
            cout << '1';
        }
    }


    return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	int ans = 1;
	while(ans*2 <= N) ans *= 2;

	cout << ans << endl;



	return 0;

}


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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  if((B-A)%2==0) cout << (B-A)/2 << endl;
  else{
    long long C=min((N-B+1+N-A)/2, (A+B-1)/2), D=min(B-1, N-A);
    cout << min(C, D) << endl;
  }
}

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

using namespace std;

typedef long long ll;

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

ll N;
vector<ll> x,y;
ll x1[2000],y1[2000],x2[2000],y2[2000];

ll c[4020][4020];//x1,x2があるのでNの倍必要

int main() {
    cin >> N;
    rep(i,N) {
        cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];//[x1,x2) [y1,y2)

        x.push_back(x1[i]);x.push_back(x2[i]);
        y.push_back(y1[i]);y.push_back(y2[i]);
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    x.erase(unique(x.begin(),x.end()),x.end());
    y.erase(unique(y.begin(),y.end()),y.end());

    rep(i,N) {
        ll ix1 = lower_bound(x.begin(),x.end(),x1[i]) - x.begin();
        ll ix2 = lower_bound(x.begin(),x.end(),x2[i]) - x.begin();
        ll iy1 = lower_bound(y.begin(),y.end(),y1[i]) - y.begin();
        ll iy2 = lower_bound(y.begin(),y.end(),y2[i]) - y.begin();

        c[iy1][ix1]++;
        c[iy1][ix2]--;
        c[iy2][ix1]--;
        c[iy2][ix2]++;
    }

    rep(i,y.size()) {
        rep(j,x.size() - 1) {
            c[i][j + 1] += c[i][j]; 
        }
    }

    rep(j,x.size()) {
        rep(i,y.size() - 1) {
            c[i + 1][j] += c[i][j];
        }
    }

    ll ans = 0;
    rep(i,y.size() - 1) {
        rep(j,x.size() - 1) {
            if(c[i][j] > 0) {
                ans += (x[j + 1] - x[j]) * (y[i + 1] - y[i]);
            }
        }
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 128892
S = input()
T = input()

N = len(S)
M = len(T)

res = 10**18

for i in range(N - M + 1):
    tmp = 0
    for j in range(M):
        if S[i + j] != T[j]:
            tmp += 1
    res = min(res, tmp)

print(res)

Measured memory_bytes: 67592
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner time = new Scanner(System.in);
    int S = time.nextInt();
    
    int h = S/3600;
    int m = (S%3600)/60;
    int s =(S%3600)%60;
    System.out.println(h +":"+ m +":"+ s);
    }
}


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

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> l;
    ll ans = 0;
    rep(i, n) {
        l[a[i] + i]++;
    }
    rep(i, n) {
        ans += l[i - a[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 27332
#include<cstdio>
#include<iostream> 
#define RI register int
#define CI const int&
using namespace std;
const int N=5005,mod=1e9+7;
int n,a,b,f[N][2],g[N],dp[N][2],ans;
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline int sum(CI x,CI y)
{
	int t=x+y; return t>=mod?t-mod:t;
}
inline int sub(CI x,CI y)
{
	int t=x-y; return t<0?t+mod:t;
}
inline int quick_pow(int x,int p,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
int main()
{
	RI i,j; scanf("%d%d%d",&n,&a,&b); if (a>b) swap(a,b);
	if (b==1) return printf("%d",quick_pow(2,n)),0;
	for (f[0][0]=f[0][1]=i=1;i<=n;++i) for (j=1;j<=i;++j)
	{
		if (j>=a) inc(f[i][0],f[i-j][1]); inc(f[i][1],f[i-j][0]);
	}
	for (g[0]=i=1;i<=n;++i) g[i]=sum(f[i][0],f[i][1]);
	for (i=1;i<n;++i) 
	{
		if (i<a) dp[i][0]=1; for (j=1;j<min(i,a);++j) inc(dp[i][0],dp[i-j][1]);
		if (i<b) dp[i][1]=g[i-1]; for (j=1;j<min(i,b);++j)
		inc(dp[i][1],1LL*dp[i-j][0]*(j<=2?1:g[j-2])%mod);
		if (n-i<a) inc(ans,dp[i][1]); if (n-i<b) inc(ans,1LL*dp[i][0]*g[n-i-1]%mod);
	}
	return printf("%d",sub(quick_pow(2,n),ans)),0;
}

Measured memory_bytes: 3860
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut vec = vec![0;n];
        for i in 0..n {
            vec[i] = i;
        }
        UnionFind {
            par : vec,
            rank : vec![0;n],
        }
    }

    fn find(&mut self, x: usize) -> usize {
        if x == self.par[x] {
            x
        }else{
            let par = self.par[x];
            let res = self.find(par);
            self.par[x] = res;
            res
        }
    }

    fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }

    fn unite(&mut self, a: usize, b: usize){
        let apar = self.find(a);
        let bpar = self.find(b);
        if self.rank[apar] > self.rank[bpar] {
            self.par[bpar] = apar;
        }else{
            self.par[apar] = bpar;
            if self.rank[apar] == self.rank[bpar] {
                self.rank[bpar] += 1;
            }
        }
    }
}

fn main() {
    input!{
      n: usize,
      m: usize,
      ps: [usize; n],
      xys: [(usize, usize); m]
    }

    let mut tree = UnionFind::new(n+1);
    for (x, y) in xys {
        tree.unite(x, y);
    }

    let mut ans = 0;
    for i in 0..n {
        let a = ps[i];
        let b = i+1;
        if tree.same(a, b) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
/*
 * Created By : pash123
 * 2020-09-19-17.21
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

const int M=1e9+7;


int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    sum=n-1;
    for(int a=2;a<n;++a)
    {
        if(n%a==0)
           sum+=(n/a)-1;
        else
           sum+=(n/a);
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3604
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        xx: [i64; n]
    }

    let p = (xx.iter().fold(0, |sum, x| sum + x) as f64) / n as f64;
    let p = (p + 0.5) as i64;
    let result = xx.iter().map(|x| (x - p) * (x - p)).fold(0, |sum, d| sum + d);

    println!("{}", result);
}


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

using namespace std;

typedef long long ll;

const int N = 1005;
const int dx[2] = {0, 1};
const int dy[2] = {1, 0};
const int MOD = 1000000007;

string grid[N];
int row, col, v[N][N]; ll a[N][N];

bool boundary(int i, int j) {
  return (i >= 1 && i <= row) && (j >= 1 && j <= col);
}

ll dfs(int i, int j) {
  v[i][j] = 1;
  if (i == row && j == col) return a[i][j] = 1;
  for (int k = 0; k < 2; k++) {
    int x = i + dx[k];
    int y = j + dy[k];
    if (boundary(x, y) && grid[x][y] != '#') {
      if (v[x][y] == 0) {
        a[i][j] += dfs(x, y);
        a[i][j] %= MOD;
      } else {
        a[i][j] += a[x][y];
        a[i][j] %= MOD;
      }
    }
  }
  return a[i][j];
}

int main() {
  scanf("%d %d", &row, &col);
  for (int i = 1; i <= row; i++) {
    string temp;
    cin >> temp;
    grid[i] = "/";
    grid[i] += temp;
  }
  printf("%lld\n", dfs(1, 1));
  return 0;
}


Measured memory_bytes: 13312
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    string[] strings = new string[n];
    int[] times = new int[n];
    long answer = 0;
		for(int i = 0; i < n; i++)
    {
      string[] input = Console.ReadLine().Split(' ');
      strings[i] = input[0];
      times[i] = int.Parse(input[1]);
    }

    bool check = false;
    string aim = Console.ReadLine();
    for(int i = 0; i < n; i++)
    {
      if(check) answer += times[i];
      if(strings[i] == aim) check = true;
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11092
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			if(N==0)
				return;
			jump a[][]=new jump[N][N];
			ArrayList<jump>AL=new ArrayList<jump>();
			int field[][]=new int[N][N];
			boolean judge[][]=new boolean[N][N];
			int cnt=0;
			for(int i=0;i<N;i++)
				for(int j=0;j<N;j++)
				{
					jump b=new jump();
					b.x=in.nextInt();
					b.y=in.nextInt();
					a[j][i]=b;
				}

			for(int i=0;i<N;i++)
				for(int j=0;j<N;j++)
				{
					int xx=j;
					int yy=i;
					if(field[j][i]==0)
						for(;;)					
						{
							if(field[xx][yy]==2)
							{
								if(judge[xx][yy]==false)
								{
									cnt++;
									judge[xx][yy]=true;
									break;
								}
								else
									break;
							}
							field[xx][yy]=2;
							jump b=new jump();
							b.x=xx;
							b.y=yy;
							AL.add(b);
							int tx=a[xx][yy].x;
							int ty=a[xx][yy].y;
							xx=tx;
							yy=ty;
						}
					for(int k=0;k<AL.size();k++)
					{
						int rex=AL.get(k).x;
						int rey=AL.get(k).y;
						judge[rex][rey]=true;
					}
				}
			System.out.println(cnt);
		}
	}
}
class jump
{
	int x;
	int y;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int x,k,d;
    cin>>x>>k>>d;

    if(x < 0) x *= -1;

    if(k > x/d)
    {
        int right = x/d;
        if((k-right)%2==0)
        {
            cout<< x - right*d;
        }
        else
        {
            cout<<abs(x-(right+1)*d);
        }
    }
    else
    {
        cout<< x - k*d;
    }

}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
vector<int> G[100050];
int in_degree[100050];
queue<int> q1;
int d[100050];

int main()
{
    int n,m;
    cin>>n>>m;
    while(m--){
        int from , to;
        scanf("%d%d",&from,&to);
        G[from].push_back(to);
        in_degree[to]++;
    }
    for(int i=1;i<=n;i++){
        if(!in_degree[i]){
            q1.push(i);
        }
    }

    while(!q1.empty()){
        int v = q1.front();
        q1.pop();
        for(auto T:G[v]){
            d[T]=max(d[T],d[v]+1);
            in_degree[T]--;
            if(!in_degree[T])   q1.push(T);
        }

    }

    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,d[i]);
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <climits>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include<ctime>
#include<set>
using namespace std;
bool d[1000000001]={0};
void dfs(string s,int n3,int n5,int n7)
{
    if(n3==0&&n5==0&&n7==0)
        d[atoi(s.c_str())]=true;
    if(n3>0)
        dfs(s+"3",n3-1,n5,n7);
    if(n5>0)
        dfs(s+"5",n3,n5-1,n7);
    if(n7>0)
        dfs(s+"7",n3,n5,n7-1);
}
int main()
{
ios::sync_with_stdio(false);
for(int i=0;i<=6;++i)
    for(int j=0;j<=6&&i+j<=6;++j)
        for(int k=0;k<=6&&i+j+k<=6;++k)
            dfs("",1+i,1+j,1+k);

int t;
cin>>t;
int res=0;
for(int i=0;i<=t;i++)
    if(d[i])
        res++;
cout<<res<<endl;
}


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

int main(){
  vector<int> n,other;
  other.push_back(2);
  for(int i=3;i<55555;i+=2){
    bool flag=false;
    for(int j=0;j<n.size();j++){
      if(i%n[j]==0){
        flag=true;
        break;
      }
    }for(int j=0;j<other.size();j++){
      if(i%other[j]==0){
        flag=true;
        break;
      }
    }if(flag) continue;
    if(i%5==1) n.push_back(i);
    else other.push_back(i);
  }
  int num; cin>>num;
  for(int i=0;i<num-1;i++){
    cout<<n[i]<<' ';
  }
  cout<<n[num-1]<<endl;
}

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


int main()
{
	int n, i, count = 0;
	int a[30];

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n - 2; i++) {
		if ((a[i] < a[i + 1]&&a[i+1] < a[i + 2]) || (a[i + 2] < a[i + 1]&&a[i+1] < a[i])) {
			count += 1;
		}
	}
	cout << count << endl;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, M, ans=0, tmp=0, state=0;
deque<ll> Q;
vector<vector<ll>> G;

signed main(){
    cin >> N >> M;
    G.resize(N);
    vector<ll> used(N);
    for(int i=0;i<M;i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        if(i==0) {
            Q.push_front(a);
            Q.push_back(b);
            used[a] = true;
            used[b] = true;
        }
    }
    while (true) {
        bool update = false;
        int u = Q.front();
        for (int i = 0; i < G[u].size(); i++) {
            int to = G[u][i];
            if (used[to]) continue;
            used[to] = true;
            update = true;
            Q.push_front(to);
            break;
        }
        int v = Q.back();
        for (int i = 0; i < G[v].size(); i++) {
            int to = G[v][i];
            if (used[to]) continue;
            used[to] = true;
            update = true;
            Q.push_back(to);
            break;
        }
        if (!update) break;
    }
 
    cout << Q.size() << endl;
    for(int i = 0;i<Q.size();i++) cout << Q[i]  + 1 << " ";
 
    return 0;
}

Measured memory_bytes: 10236
SIZE=4*10**5+1; MOD=10**9+7 #998244353 #ここを変更する
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
 
def chofuku(ball,box): # nHk mod MOD の計算
    return choose(box+ball-1,box)



N,K=map(int,input().split())
ans=0
for i in range(min(N,K+1)):
    ans+=choose(N,i)*chofuku(N-i,i)%MOD

print(ans%MOD)



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

int main() {
	unordered_map<string,int> A;
	A["MON"] = 6;
	A["TUE"] = 5;
	A["WED"] = 4;
	A["THU"] = 3;
	A["FRI"] = 2;
	A["SAT"] = 1;
	A["SUN"] = 7;
	string S;
	cin >> S;
	cout << A[S];
}

Measured memory_bytes: 256
#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;

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int N;
ll A[100010];
ll X[100010];
ll Y[100010];

int main(){
  cin >> N;
  rep(i, N) cin >> A[i];
  X[0] = A[0];
  Y[0] = A[N-1];
  rep(i, N){
    X[i+1] = gcd(X[i], A[i+1]);
    Y[i+1] = gcd(Y[i], A[(N-1)-(i+1)]);
  }
  ll ans = 0;
  ans = max(X[N-2], Y[N-2]);
  // rep(i, N) cout << X[i] << " " << Y[i] << endl;

  rep(i, N-2){
    // cout << gcd(X[i], Y[(N-1)-(i+2)]) << endl;
    ans = max(ans, gcd(X[i], Y[(N-1)-(i+2)]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
using LL=long long;

LL GCD(LL a, LL b, LL& x, LL& y) {
	if (b == 0) {
		x = 1; y = 0;
		return a;
	}
	LL d = GCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

int main() {
	LL a1, a2;
	int x, y; cin >> x >> y;
	GCD(x, y, a1, a2);
	cout << a1 << " " << a2 << endl;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

LL n, k, num[100005];

int main(){
	scanf("%lld%lld", &n, &k);
	LL ans = 0;
	for(int i = 1; i <= n; i++){
		LL a, b;
		scanf("%lld%lld", &a, &b);
		num[a] += b;
		ans = max(ans, a);
	}
	LL tot = 0;
	LL pos;
	for(int i = 1; i <= ans; i++){
		tot += num[i];
		if(tot >= k){
			pos = i;
			break;
		}
	}
	printf("%lld\n", pos);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main()
{
  long long a,b,c;
  cin>>a>>b>>c;
  if (a<b)
    swap(a,b);
  if (c%a==0)
    cout<<c/a<<endl;
  else
    cout<<c/a+1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)

using namespace std;
const int maxn = 4e5+7;

int n,m;

struct node
{
    int color,ck;
    node(int color,int ck):color(color),ck(ck){}
    node(){}
    bool operator < (const node &rhs) const
    {
        return ck<rhs.ck;
    }
};

vector<node>vv[5];

int tot=0;

void add(int u,int v)
{
    if (v==0) vv[0].pb(node(tot,u));
    else if (u==0) vv[1].pb(node(tot,v));
    else if (v==m) vv[2].pb(node(tot,u));
    else if (u==n) vv[3].pb(node(tot,v));
}

int table[maxn];
stack<int>STA;
int main()
{
    int k;scanf("%d%d%d",&n,&m,&k);
    for (int i=1;i<=k;i++)
    {
        int u,v,uu,vv;scanf("%d%d%d%d",&u,&v,&uu,&vv);
        if (((u==0 || u==n) || (v==0 || v==m)) && ((uu==0 || uu==n) || (vv==0 || vv==m)))
        {
            tot++;
            add(u,v);add(uu,vv);
        }
    }
    for (int i=0;i<4;i++) sort(vv[i].begin(),vv[i].end());

    int num=0,sz;
    sz=vv[0].size();for (int i=sz-1;i>=0;i--) table[++num]=vv[0][i].color;
    sz=vv[1].size();for (int i=0;i<sz;i++) table[++num]=vv[1][i].color;
    sz=vv[2].size();for (int i=0;i<sz;i++) table[++num]=vv[2][i].color;
    sz=vv[3].size();for (int i=sz-1;i>=0;i--) table[++num]=vv[3][i].color;


    for (int i=1;i<=num;i++)
    {
        if (!STA.empty() && table[i]==STA.top()) STA.pop();
        else STA.push(table[i]);
    }

    if (STA.empty()) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 2972
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m;
vi x,y,z;
class UnionFind {
    private:
        vi par;    // x の親ノード
        vi rank;   // 木の高さ
        vi mem;    // メンバの数
        int siz;             // 集合の個数
    public:
        UnionFind(int n) :
            par(n, -1), rank(n, 0), mem(n, 1), siz(n) {
            REP(i,n) par[i] = i;
        }
    
    int size() { return siz; }

    // 集合の追加
    void makeset() {
        par.pb(par.size());
        rank.pb(0);
        mem.pb(1);
        siz++;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    int member(int x){
        x = find(x);
        return mem[x];
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]){
            par[x] = y;
            mem[y] += mem[x];
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
            mem[x] += mem[y];
        }
        siz--;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};
map<int,int> ret;

signed main(){
    I(n); I(m);
    x.resize(m);
    y.resize(m);
    z.resize(m);
    UnionFind uf = UnionFind(n);
    REP(i,m){
        I(x[i]); x[i]--;
        I(y[i]); y[i]--;
        I(z[i]); z[i] %= 2;
        uf.unite(x[i],y[i]);
    }
    REP(i,n){
        ret[ uf.find(i) ]++;
    }
    int ans = 0;
    for(auto p:ret) ans++;
    cout << ans << endl;
}

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

int main() {
    string A, B;
    cin >> A >> B;
    if (A.length() > B.length()) cout << "GREATER" << endl;
    else if (A.length() < B.length()) cout << "LESS" << endl;
    else {
        for (int i = 0; i < A.length(); i++) {
            if (A[i] > B[i]) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if (A[i] < B[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int a=abs(A-B)-1;
    if(N%2==0){
        if(a%2==0){
            cout<<"Borys"<<endl;
        }else{
            cout<<"Alice"<<endl;
        }
    }else{
        if(a%2==0){
            cout<<"Borys"<<endl;
        }else{
            cout<<"Alice"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

V g[201];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  REP(i,n){
    string s;
    cin >> s;
    REP(j,s.size()){
      if (s.at(j) == '1'){
        g[i+1].push_back(j+1);
      }
    }
  }
  I t=-1;
  REP(i,n+1){
    if (i==0) continue;
    V v(n+1);
    I rr[201][201];
    REP(j,201){
      REP(k, 201){
        rr[j][k] = 0;
      }
    }
    queue<P> q;
    q.push(P(i,1));
    I an=-1;
    while(q.size() > 0){
      P p = q.front();q.pop();
      REP(j,g[p.first].size()){
        I k = g[p.first].at(j);
        //cout << p.first << " " << p.second << " " << k << endl;
        if (rr[p.first][k] != 1){
          if (v[k] != 0){
            if (v[k] != p.second + 1){
              queue<P> tmp;
              swap(q,tmp);
              an = -1;
              break;
            }
          }else{
            v[k] = p.second + 1;
            an = max(an,v[k]);
            q.push(P(k, v[k]));
          }
          rr[p.first][k] = 1;
          rr[k][p.first] = 1;
        }
      }
    }
    t = max(t,an);
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 1024
s = input()
cnt = 0
arr = []
for i in range(len(s)):
    arr.append(s[i])
    while len(arr) >= 3 and arr[-3] != arr[-1]:
        a = arr.pop()
        b = arr.pop()
        arr.append(a)
        cnt += 1
print('First' if cnt % 2 else 'Second')


Measured memory_bytes: 45296