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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

vector<ll> enum_div(ll n)
{
    vector<ll > ret;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            ret.push_back(n/i);
        }
    }

    sort(ret.begin(), ret.end());
    return ret;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i%2 != 0) {
            vector<ll> cnt = enum_div(i);
            if (cnt.size() == 8) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 510
using namespace std;
int n,m,a[maxn];
int sum,b[maxn];
int ans;
bool check(int k) {
	int s1=0,s2=0;
	for(int i=1;i<=n;i++) s1+=a[i]%k,b[i]=a[i]%k;
	sort(b+1,b+n+1);
	for(int i=1;i<=n-s1/k;i++) s2+=b[i];
	return s2<=m;
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
	for(int i=1;i*i<=sum;i++) {
		if(sum%i) continue;
		if(check(i)) ans=max(ans,i);
		if(check(sum/i)) ans=max(ans,sum/i);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n,x;
    cin>>n>>x;
    vector<int> l(n),v(n+1);
    for(int i=0; i<n; i++) cin>>l[i];
    for(int i=1; i<=n; i++) v[i]=v[i-1]+l[i-1];
    cout<<upper_bound(v.begin(),v.end(),x)-v.begin();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#define m 256
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int ii[n+1],r[n+1],o[n+1];
		for(int i=1;i<=n;i++){
			cin>>ii[i];
		}
		int ss=16,aa=16,cc=16;
		long long h,mh=10000000000000;
		for(int s=15;s>=0;s--){
			for(int a=15;a>=0;a--){
				for(int c=15;c>=0;c--){
					int oc[m];
					for(int i=0;i<m;i++){
						oc[i]=0;
					}
					h=0;
					r[0]=s;
					for(int i=1;i<=n;i++){
						r[i]=(a*r[i-1]+c)%m;
						o[i]=(r[i]+ii[i])%m;
						oc[o[i]]++;
					}
					for(int i=0;i<m;i++){
						if(oc[i]>0){
							float h1=oc[i],h2=n;
							h=h-(h1/h2)*log(h1/h2)*100000;
						}
					}
					if(h<mh){
						ss=s;
						aa=a;
						cc=c;
						mh=h;
					}
					else if(h==mh){
						if(s<ss||a<aa||c<cc){
							ss=s;
							aa=a;
							cc=c;
						}
					}
				}
			}
		}
		cout<<ss<<" "<<aa<<" "<<cc<<endl;
	}
    return 0;
}

Measured memory_bytes: 1184
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	string c[3];
	for (ll i = 0; i < 3; ++i) cin >> c[i];
 
	// 解法
	cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
}


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

X = sum([(2 * (k + 1) - n - 1) * x[k] for k in range(n)])
Y = sum([(2 * (k + 1) - m - 1) * y[k] for k in range(m)])
print(X * Y % (10 ** 9 + 7))


Measured memory_bytes: 18556
A, B, C, K = map(int, input().split())
l = [[A, 1], [B, 0], [C, -1]]
res = 0

for e in l:
    if K >= e[0]:
        K -= e[0]
        res += e[1] * e[0]
    else:
        res += e[1] * K
        break

print(res)

Measured memory_bytes: 9156
from itertools import combinations, permutations


def f(x, lst, rem):
    d = int(1e9+7)
    tpl = ()
    for v in range(len(lst) - rem + 1):
        for t in combinations(lst, v + 1):
            if abs(x - sum(t)) + 10 * v < d:
                d = abs(x - sum(t)) + 10 * v
                tpl = t
    for v in tpl:
        lst.remove(v)
    return d, lst


def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for i in range(N)]

    ans = int(1e9+7)
    for ABC in permutations((A, B, C), 3):
        lst = L[:]
        accum = 0
        for i, v in enumerate(ABC):
            d, lst = f(v, lst, 3 - i)
            accum += d
        ans = min(ans, accum)
    print(ans)


main()


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

main() {
    int N,M; cin >> N >> M;
    int A[N+1][M+1];
    rep(i,N) rep(j,M) cin >> A[i][j];
    rep(i,N) A[i][M]=0;
    rep(i,M) A[N][i]=0;
    rep(i,N){
        rep(j,M){
           A[i][M]+=A[i][j];
        }
    }
    rep(i,M){
        rep(j,N){
            A[N][i]+=A[j][i];
        }
    }
    A[N][M]=0;
    rep(i,N) A[N][M]+=A[i][M];
    rep(i,N+1) {rep(j,M+1) {cout << A[i][j] <<(j==M ? "":" ");} cout << endl;} 

    return 0;
}


Measured memory_bytes: 3168
import sys
inp = sys.stdin.read().strip()
ctr, maks = -1, 0
for idx in range(len(inp)):
	if inp[idx] == 'A' and ctr == -1:
		ctr = 1
	else:
		if ctr != -1: ctr += 1
		if inp[idx] == 'Z':
			maks = max(ctr, maks)
print maks

Measured memory_bytes: 9152
N = int(input())
dct = {}
for _ in range(N):
    x = int(input())
    n = dct.get(x, 0) + 1
    dct[x] = n

ret = 0
for k, v in dct.items():
    if v % 2 == 1:
        ret += 1
print(ret)

Measured memory_bytes: 15068
import java.util.Scanner;

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

        char[] s = sc.next().toCharArray();

        int max = 0;
        int cnt = 0;
        for (int i = 0; i < s.length; i++) {
            if (check(s[i])) {
                cnt++;
                max = Math.max(cnt, max);
            } else {
                max = Math.max(cnt, max);
                cnt = 0;
            }
        }
        
        System.out.println(max);
    }

    static boolean check(char c) {
        switch (c) {
            case 'A':
            case 'C':
            case 'G':
            case 'T': return true;
            default: return false;
        }
    }
}


Measured memory_bytes: 23380
#include<cstdio>
#include<algorithm>
using namespace std;
pair<int, pair<int, int>> a[200100];
pair<int, pair<int, int>> b[200100];
int dap[200100];
int ch[510];
int main()
{
	int n,m,k;
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d", &a[i].second.first, &a[i].first);
		a[i].second.second = i;
	}
	for (int i = 0; i < k; i++)
	{
		scanf("%d %d", &b[i].second.first, &b[i].first);
		b[i].second.second=i;
	}
	sort(a, a + m);
	sort(b, b + k);
	int idx = 0;
	for (int i = 0; i < k; i++)
	{
		while (b[i].first >= a[idx].first)
		{
			if (idx >= m)break;
			ch[a[idx].second.first]++;
			idx++;
		}
		int gap = 0;
		for (int y = b[i].second.first; y <= b[i].first; y++)
			gap += ch[y];
		dap[b[i].second.second] = gap;
	}
	for (int i = 0; i < k; i++)
		printf("%d\n", dap[i]);
}

Measured memory_bytes: 5888
N = int(input())
X = [int(i) for i in input().split()]

count = 0
ll = []

for P in range(1, 101):
    for k in range(N):
        count += (X[k] - P) ** 2
        if k == N-1:
            ll.append(count)
            count = 0
        else:
            pass
print(min(ll))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  int n = in(), a = in(), b = in();
  int cnt = 0;

  REP(i, n){
    int t = in();
    if (a <= t && t < b) continue;
    cnt++;
  }

  cout << cnt << endl;

}



Measured memory_bytes: 256
N = int(input())
a, b = [], []
for _ in range(N):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

ans = 0
add_v = 0
i = N - 1
while i >= 0:
    r = (a[i] + add_v) % b[i]
    if r != 0:
        to_add = b[i] - r
        add_v += to_add
        ans += to_add
    i -= 1
print(ans)


Measured memory_bytes: 11020
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
struct edge{
    int to;
    ll cost;
};
const ll INF = 1e18;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,m,s,t; cin >> n >> m >> s >> t;
    s--; t--;
    vector<edge> G[n];
    vector<edge> rG[n];
    rep(i,m){
        int u,v; ll a,b;
        cin >> u >> v >> a >> b;
        u--; v--;
        G[u].pb({v,a}); G[v].pb({u,a});
        rG[u].pb({v,b}); rG[v].pb({u,b});
    }
    ll d[n],rd[n];
    
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d, d+n,INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    fill(rd,rd+n, INF);
    rd[t] = 0;
    que.push(P(0, t));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (rd[v] < p.first) continue;

        for (int i=0; i<rG[v].size(); ++i) {
            edge e = rG[v][i];
            if (rd[e.to] > rd[v] + e.cost) {
                rd[e.to] = rd[v] + e.cost;
                que.push(P(rd[e.to], e.to));
            }
        }
    }
    ll score[n];
    rep(i,n){
        score[i]=1e15-d[i]-rd[i];
    }
    vector<ll> ans;
    ll res=0;
    rep(i,n){
        chmax(res,score[n-1-i]);
        ans.pb(res);
    }
    reverse(ALL(ans));
    for(ll u:ans) cout << u << endl;
}


Measured memory_bytes: 21856
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
using namespace std;
const double eps=1e-8;


int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int cost=1900*(m)+100*(n-m);
        double ans=0,pre,p=1;
        double ac=pow(0.5,m);
        for(int i=1;;i++)
        {
            ans+=cost*i*p*ac;
            p=p*(1-ac);
            if(ans-pre<eps) break;
            pre=ans;
        }
        int out=ans+0.5;
        cout<<out<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }


int main()
{
    int P, Q, R;
    cin >> P >> Q >> R;

    int ans = P + Q + R - max(P,max(Q,R));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n, k;
    cin >> n >> k;
    
    vvl G(n);
    vl a(n-1), b(n-1);
    rep(i, n-1) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
        G[a[i]].pb(b[i]);
        G[b[i]].pb(a[i]);
    }

    ll ans = INF;
    if(k%2 == 0) {
        rep(root, n) {

            vl dist(n, -1);  // dist[v] : 頂点vの根からの距離
            queue<ll> Q;
            dist[root] = 0;
            Q.push(root);
            while(!Q.empty()) {
                ll v = Q.front();  Q.pop();
                for(ll u : G[v]) {
                    if(dist[u] == -1) {
                        dist[u] = dist[v] + 1;
                        Q.push(u);
                    }
                }
            }

            ll cnt = 0;
            rep(v, n) {
                if(dist[v] > k/2) {
                    cnt++;
                }
            }

            chmin(ans, cnt);
        }
    }
    else if(k%2 == 1) {
        rep(i, n-1) {
            
            vl dist(n, -1);  // dist[v] : 頂点vの辺iからの距離
            queue<ll> Q;
            dist[a[i]] = 0;  dist[b[i]] = 0;
            Q.push(a[i]);  Q.push(b[i]);
            while(!Q.empty()) {
                ll v = Q.front();  Q.pop();
                for(ll u : G[v]) {
                    if(dist[u] == -1) {
                        dist[u] = dist[v] + 1;
                        Q.push(u);
                    }
                }
            }

            ll cnt = 0;
            rep(v, n) {
                if(dist[v] > k/2) {
                    cnt++;
                }
            }

            chmin(ans, cnt);
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3768
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var uft, rank, ch, ans []int

func find(x int) int {
	if uft[x] == x {
		return x
	}

	uft[x] = find(uft[x])
	return uft[x]
}

func union(a, b, i int) {
	ans[i-1] = ans[i]
	ar, br := find(a), find(b)
	if ar == br {
		return
	}

	ans[i-1] -= ch[ar] * ch[br]

	if rank[ar] < rank[br] {
		uft[ar] = br
		ch[br] += ch[ar]
		return
	} else if rank[ar] == rank[br] {
		rank[ar]++
	}
	uft[br] = ar
	ch[ar] += ch[br]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, m)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}

	uft = make([]int, n+1)
	rank = make([]int, n+1)
	ch = make([]int, n+1)
	for i := range uft {
		uft[i] = i
		ch[i] = 1
	}

	ans = make([]int, m)
	ans[m-1] = n * (n - 1) / 2
	for i := m - 1; i >= 1; i-- {
		union(as[i], bs[i], i)
	}

	wr := bufio.NewWriter(os.Stdout)
	for _, v := range ans {
		wr.WriteString(strconv.Itoa(v) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 8320
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    cout << N * (N + 1) / 2 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
char s[100005];
char ss[100005];
char sss[10005];
int a=0;
int b=0;
int main()
{
    scanf("%d",&n);
    cin>>s;
    for(int i=0;i<n;i++)
    {
        //printf("%c",s[i]);
        if(s[i]=='(')
            a++;
        else if(s[i]==')')
            b++;
    }
    int st=0;
    int ed=0;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]==')'&&st==0)
        {
            ss[cnt]='(';
            cnt++;
        }
        if(s[i]==')'&&st>0)
        {
            st--;
            continue;
        }
        if(s[i]=='(')
            st++;
    }
    int ccnt=0;
    if(st>0)
    {
        while(st)
        {
            sss[ccnt]=')';
            ccnt++;
            st--;
        }
    }
    for(int i=0;i<cnt;i++)
        printf("%c",ss[i]);
    for(int i=0;i<n;i++)
        printf("%c",s[i]);
    if(ccnt==0)
        printf("\n");
    else
        for(int i=0;i<ccnt;i++)
    {
        if(i!=ccnt-1)
            printf("%c",sss[i]);
        else
            printf("%c\n",sss[i]);
    }
}

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

int main() {
int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  int counter=0;
  
  for(int i=0;i<N-2;i++){
    if((vec[i]<vec[i+1]&&vec[i+1]<vec[i+2])||(vec[i+2]<vec[i+1]&&vec[i+1]<vec[i])){
      counter++;
    }
  }
  
  cout<<counter<<endl;

    

}


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

int main(void){
    int n;
    cin >> n;
    int cnt = 0, a;
    rep(i, n){
        cin >> a;
        if(a % 2 == 1 && i % 2 == 0) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3548
using System;

namespace LevelC
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');

            var A = int.Parse(str[0]);
            var B = int.Parse(str[1]);
            var H = int.Parse(str[2]);
            var M = int.Parse(str[3]);

            var As = ((2*Math.PI) / 12) * (H+(M/60.0d));
            var Ax = A*Math.Sin(As);
            var Ay = A*Math.Cos(As);

            var Bs = ((2 * Math.PI) / 60) * M;
            var Bx = B*Math.Sin(Bs);
            var By = B*Math.Cos(Bs);

            var Dist = Math.Sqrt(((Ax - Bx)* (Ax - Bx)) +((Ay-By)* (Ay - By)));

            Console.WriteLine(Dist);
        }
    }
}


Measured memory_bytes: 18712
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S {
    mint x, w;
    S(mint x=0, mint w=1):x(x),w(w) {}
};

S op(S a, S b) {
    return S(a.x*b.w + b.x, a.w*b.w);
}

S e() { return S();}

S mapping(int f, S a) {
    if (f == 0) return a;
    return S((a.w-1)*inv9*f, a.w);
}

int composition(int f, int g) {
    if (f == 0) return g;
    return f;
}

int id() { return 0;}

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

    lazy_segtree<S,op,e,int,mapping,composition,id> t(n);
    rep(i,n) t.set(i, S(1,10));
    rep(qi,q) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        t.apply(l,r,d);
        S ans = t.prod(0,n);
        cout << ans.x.val() << endl;
    }
    return 0;
}

Measured memory_bytes: 9872
//#include<bits/stdc++.h>
//
//using namespace std;
//
//const int maxn=310;
//
//int n,m,k;
//int s[maxn][maxn];
//
//const int inf=0x3f3f3f3f;
//
//void floyd(){
//	for(int k=1;k<=n;k++){
//		for(int i=1;i<=n;i++){
//			for(int j=1;j<=n;j++){
//				if(s[i][j]>s[i][k]+s[k][j]){
//					s[i][j]=s[i][k]+s[k][j];
//				}
//			}
//		}
////		printf("%d\n",k);
//	}
//}
//
//int main(){
//	scanf("%d%d%d",&n,&m,&k);
//	memset(s,inf,sizeof(s));
//	for(int i=0;i<m;i++){
//		int x,y,w;
//		scanf("%d%d%d",&x,&y,&w);
//		s[x][y]=w;
//		s[y][x]=w;
//	}
//	
//	floyd();
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=n;j++){
//			if(s[i][j]<=k) s[i][j]=1;
//		}
//	}
//	
//	floyd();
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=n;j++){
//			printf("%d ",s[i][j]);
//		}
//		printf("\n");
//	}
//	int q;
//	while(q--){
//		int x,y;
//		scanf("%d%d",&x,&y);
//		printf("%d\n",s[x][y]-1);
//	}
//	return 0;
//}
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e6+6;

int a[maxn];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]+a[j]>a[k]){
					ans++;
				}
				else break;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
var
	n,i:Longint;
	ans,a,m:int64;
	sum:array[1..100000]of int64;
function power(a,b:int64):int64;
var s:int64;
begin
	if b=0 then power:=1
	else begin
		s:=power(a*a mod m,b div 2);
		if b mod 2=1 then s:=s*a mod m;
		power:=s;
	end;
end;
begin
	m:=1000000007;
	read(n);
	sum[1]:=1;
	for i:=2 to n do sum[i]:=(sum[i-1]+power(i,m-2))mod m;
	for i:=1 to n do begin
		read(a);
		ans:=(ans+(sum[i]+sum[n-i+1]+m-1)mod m*a mod m)mod m;
	end;
	for i:=1 to n do ans:=ans*i mod m;
	writeln(ans);
end.


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vi h(n);
    vcin(h);
    sort(h);
    int Min=INT_MAX;
    rep(i,k-1,n-1){
        Min=min(Min,h[i]-h[i-k+1]);
    }
    cout << Min << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++){
            p[i] = stdIn.nextInt();
        }
        int count = 0;
        int[] c = p.clone();
        Arrays.sort(c);
        for(int i = 0; i < n; i++){
            if(p[i] != c[i]){
                count++;
                if(count > 2){
                    System.out.println("NO");
                    return;
                } 
            }
        }
        System.out.println("YES");
    }
}

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

using namespace std;

int main(void) {
	string s, t, u;
	cin >> s >> t >> u;
	if (s[s.size() - 1] == t[0]) {
		if (t[t.size() - 1] == u[0]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
	string s;
	string l="qwertasdfgzxcvb";
	string r="yuiophjklnm";

	int w;   //0:l 1:r
	int cnt;

	while(1){
		cin>>s;
		if (s=="#") break;

		cnt=0;
		if(l.find(s[0])!=-1) w=0;
		else w=1;

		for(int i1=1;i1<s.size();i1++){
			if(l.find(s[i1])!=-1 && w==1){
				cnt++;
				w=0;
			}
			if(r.find(s[i1])!=-1 && w==0){
				cnt++;
				w=1;
			}
		}

		cout<<cnt<<endl;

	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, m, g[10][10]{}, ans=0;
    cin >> n >> m;
    REP(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a][b] = 1;
        g[b][a] = 1;
    }
    vector<int> ls;
    REP(i,n-1) ls.push_back(i+1);
    while(1){
        bool ok = true;
        REP(i,n-1){
            ok &= g[ls[i]][ls[i+1]];
        }
        if(ok) ans++;
        if(!next_permutation(ALL(ls)))break;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    ll S; cin >> S;
    ll n = 1;
    while(n * n < S) n++;
    ll m = n * n - S;
    cout << 0 << " ";
    cout << 0 << " ";
    cout << n << " ";
    cout << m << " ";
    if(m) cout << 1 << " ";
    else cout << 0 << " ";
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

s = input()

d = deque(list(s))

rev = False

for i in range(int(input())):
    tp = input().split()

    if tp[0] == '1':
        rev = not rev
    else:
        f, c = tp[1:]

        if rev:
            f = '12'[f == '1']

        if f == '1':
            d.appendleft(c)
        else:
            d.append(c)

if rev:
    print(*list(d)[::-1], sep='')
else:
    print(*list(d), sep='')

Measured memory_bytes: 91160
local band = bit.band
local FenwickTree = {}
FenwickTree.create = function(self, n)
  self.n = n
  self.v = {}
  for i = 1, n do self.v[i] = 0LL end
end
FenwickTree.add = function(self, pos, val)
  while pos <= self.n do
    self.v[pos] = self.v[pos] + val
    pos = pos + band(pos, -pos)
  end
end
FenwickTree.sum = function(self, r)
  local ret = 0
  while 0 < r do
    ret = ret + self.v[r]
    r = r - band(r, -r)
  end
  return ret
end
FenwickTree.new = function(n)
  local obj = {}
  setmetatable(obj, {__index = FenwickTree})
  obj:create(n)
  return obj
end

local n, q = io.read("*n", "*n")
local fw = FenwickTree.new(n)
for i = 1, n do
  local a = io.read("*n")
  fw:add(i, a)
end
for iq = 1, q do
  local a, b, c = io.read("*n", "*n", "*n")
  if a == 0 then
    fw:add(b + 1, c)
  else
    local ans = fw:sum(c)
    if 0 < b then ans = ans - fw:sum(b) end
    ans = tostring(ans):gsub("LL", "")
    print(ans)
  end
end


Measured memory_bytes: 49892
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	X := nextInt()
	Y := nextInt()
	g := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		g[i] = make([]int, N+1)
	}
	for i := 0; i < N+1; i++ {
		for j := 0; j < N+1; j++ {
			g[i][j] = abs(i - j)
		}
	}
	for i := 0; i < N+1-1; i++ {
		g[i][i+1] = 1
		g[i+1][i] = 1
	}
	g[X][Y] = 1
	g[Y][X] = 1
	lens := make([]int, 2001)
	for i := 1; i < N+1-1; i++ {
		for j := i + 1; j < N+1; j++ {
			length := g[i][j]
			length = min(length, g[i][X]+g[Y][j]+1)
			length = min(length, g[i][Y]+g[Y][j]+1)
			lens[length]++
		}
	}
	for i := 1; i < N; i++ {
		fmt.Println(lens[i])
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 33920
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
 
      if((B-A)%2==0){
    System.out.println(((B-A)/2)+A);
      }else{
	System.out.println("IMPOSSIBLE");
      }
      }
}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
#define re register
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const int mod=1e9+7,maxn=5005;
struct E{int v,nxt;}e[maxn<<1];
int head[maxn],n,num,sum[maxn],f[maxn],dp[maxn][maxn],bl[maxn];
inline int dqm(int x) {return x<0?x+mod:x;}
inline int qm(int x) {return x>=mod?x-mod:x;}
inline void upd(int &x,int y) {x+=y;if(x>=mod)x-=mod;}
inline void add(int x,int y) {
	e[++num].v=y;e[num].nxt=head[x];head[x]=num;
	e[++num].v=x;e[num].nxt=head[y];head[y]=num;
}
void dfs(int x,int fa) {
	sum[x]=1;dp[x][1]=1;
	for(re int v,i=head[x];i;i=e[i].nxt) {
		if(e[i].v==fa) continue;
		dfs(v=e[i].v,x);
		for(re int j=1;j<=sum[x];++j) 
			for(re int k=1;k<=sum[v];++k) {
				upd(bl[j+k],1ll*dp[x][j]*dp[v][k]%mod);
				upd(bl[j],1ll*dp[x][j]*dqm(-dp[v][k])%mod*f[k]%mod);
			}
		sum[x]+=sum[v];
		for(re int j=1;j<=sum[x];++j)dp[x][j]=bl[j],bl[j]=0;
	}
}
int main() {
	n=read();for(re int i=1;i<n;i++)add(read(),read());
	f[0]=1;for(re int i=2;i<=n;i+=2) f[i]=1ll*f[i-2]*(i-1)%mod;
	int ans=0;dfs(1,0);
	for(re int i=2;i<=n;i+=2) upd(ans,1ll*dp[1][i]*f[i]%mod);
	printf("%d\n",ans);
	return 0;
}


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

#define ___ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;
int ache[102];

int main(){___
  int x, n; cin >> x >> n;
  for (int i = 0; i < n; ++i){
    int p;  cin >> p;
    ache[p] = 1;
  }
  int ans;
  int mn = 1000;
  for (int i = 0; i <= 101; ++i){
    if(!ache[i] and abs(i-x)<mn){
      ans = i;
      mn = abs(i-x);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:f64 = read();
    
    println!("{}", format!("{:.10}", if (n as usize)%2==0 {(n/2.0)/n} else {((n as usize)/2+1)as f64/n}));

}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

long long f(long long x, long long m){
    return (x *x) % m;
}

int main(){
    long long n, x, m;
    cin >> n >> x >> m;

    set<long long> T;
    long long now = x;
    long long start;

    //cycleのstartを検知
    for(long long i = 0; i < m; i++){
        //printf("i %lld %lld\n", i+1, now);
        if(T.find(now) == T.end()) T.insert(now);
        else{
            start = now;
            break;
        }

        now = f(now, m);
    }

    bool find = false;
    vector<long long> loop;
    long long dist = 0;
    //printf("start %lld\n", start);
    now = x;
    for(long long i = 0; i < m; i++){
        //printf("i %lld %lld\n", i+1, now);
        if(now == start and find == false){
            //printf("find\n");
            find = true;
            dist = i;
        }
        else if(now == start and find == true) break;

        if(find == true){
            loop.push_back(now);
        }
        
        now = f(now, m);
    }
    //printf("dist %lld\n", dist);

    long long fre = 0;
    for(long long i = 0; i < loop.size(); i++) fre += loop[i];

    long long ans = 0;
    if(n <= dist) {
        now = x;
        for(long long i = 0; i < n; i++){
            ans += now;
            now = f(now, m);
        }
    }
    else{
        now = x;
        for(long long i = 0; i < dist; i++){
            ans += now;
            now = f(now, m);
        }
        long long r = (n-dist)/((long long)loop.size());
        long long amari = (n-dist) % ((long long)loop.size());

        ans += fre * r;
        for(long long i = 0; i < amari; i++) ans += loop[i];
    }

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

Measured memory_bytes: 6244
#include <bits/stdc++.h>
using namespace std;
 
int N,M,Q,m=0;
vector<int> A(10,1),a(50),b(50),c(50),d(50);
 
 
void dfs(int n,int k){
  A.at(n)=k;
  if(n==N-1){
    int x=0;
    for(int i=0;i<Q;i++){
      if(A.at(b.at(i)-1)-A.at(a.at(i)-1)==c.at(i)){
        x+=d.at(i);
      }
    }
    m=max(x,m);
    return;
  }
  for(int i=k;i<=M;i++){
    dfs(n+1,i);
  }
  return;
}
    
 
 
int main(){
  
  cin >> N >> M >> Q;
  for(int i=0;i<Q;i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }
  dfs(0,1);
  cout << m << endl;
  
}

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

int main() {
    string str, copy1, copy2;
    int m, h;
    while(1) {
        cin >> str;
        if (str == "-") break;
        cin >> m;
        for (int i=0;i<m;i++) {
            cin >> h;
            copy1 = str.substr(0,h);
            copy2 = str.substr(h,str.size()-h);
            str = copy2 + copy1;
        }
        cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
a_ = Is()
c = 0
for e in a_:
    t = e
    while t > 1 and t/2 == t//2:
        c += 1
        t = t//2
print(c)

Measured memory_bytes: 4588
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = a/10;
    int c = a-(a/1000)*1000;
    if (b%111==0 || c%111==0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int D;
    cin >> D;
    int N = 26;
    vi c(N);
    vvi s(D,vi(N));
    in(N,c);
    rep(i,D) rep(j,N) cin >> s[i][j];
    
    vi ans(D,1);
    
    vi las(N,-1);
    
    
    rep(d,D){
        int los = 0;
        rep(i,N) los += c[i]*(d-las[i]);
        int an = 0;
        rep(i,N){
            if(chmax(an,s[d][i]-los+c[i]*(d-las[i]))) ans[d] = i+1;
        }
        las[ans[d]-1] = d;
    }









    rep(i,D) cout << ans[i] << endl;
    
    

    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int a[2*N];
  for (int i = 0; i < 2 * N; i++) cin >> a[i];

  sort(a, a + 2 * N);
  int ans = 0;
  for (int i = 2 * N - 1; i > 0; i -= 2) {
    ans += min(a[i], a[i-1]);
  }

  // 解答
  cout << ans << endl;
}


Measured memory_bytes: 256
#define scanf_s scanf
#include <stdio.h>
#include <iostream>
using namespace std;
#define MAX 200
int main(void)
{
	int a, b, sum, cou = 0;
	while (scanf_s("%d %d", &a, &b) != EOF) {
		sum = a + b;
		while (1) {
			if (sum <= 0) break;
			sum /= 10;
			++cou;
		}
		printf("%d\n", cou);
		cou = 0;
	}
}

Measured memory_bytes: 1188
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static int jumpCost(int start, int jumpLength, int end, int[] height, int[][] costs) {
        if (costs[start][jumpLength - 1] != Integer.MAX_VALUE) {
            return costs[start][jumpLength - 1];
        }
        if (start + jumpLength == end) {
            costs[start][jumpLength - 1] = Math.abs(height[start + jumpLength] - height[start]);
            return costs[start][jumpLength - 1];
        }
        if (start + jumpLength > end) {
            return Integer.MAX_VALUE;
        } else {
            costs[start][jumpLength - 1] = Math.abs(height[start + jumpLength] - height[start]);
            costs[start + jumpLength][0] = jumpCost(start + jumpLength, 1, end, height, costs);
            costs[start + jumpLength][1] = jumpCost(start + jumpLength, 2, end, height, costs);
            return costs[start][jumpLength - 1]
                    + Math.min(
                    costs[start + jumpLength][0],
                    costs[start + jumpLength][1]);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[][] costs = new int[n][2];

        int[] height = new int[n];
        for (int i = 0; i < n; i++) {
            height[i] = sc.nextInt();
            costs[i][0] = Integer.MAX_VALUE;
            costs[i][1] = Integer.MAX_VALUE;
        }

        int totalCost = 0;
        totalCost = Math.min(
                jumpCost(0, 1, n - 1, height, costs),
                jumpCost(0, 2, n - 1, height, costs));
        System.out.println(totalCost);

//        for (int i = 0; i < n; i++) {
//            System.out.printf("%d ", height[i]);
//        }


    }
}


Measured memory_bytes: 80244
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

s = input()
n = len(s)
for i in range(n):
    if i >= 1:
        if s[i] == s[i-1]:
            print(i,i+1)
            quit()
    if i >= 2:
        if s[i] == s[i-2]:
            print(i-1,i+1)
            quit()
print(-1,-1)

Measured memory_bytes: 4204
<?php 
  $num = intval(trim(fgets(STDIN)));
  $count =0;
  for($i = 0 ; $i < $num; $i ++){
      $f = intval(trim(fgets(STDIN)));
      if(is_prime($f)){
           $count ++;
      }
  }
  print $count."\n";
  function is_prime($n){
     
      if($n == 2){
          return true;
      }
      if($n % 2 ==0){
          return false;
      }
      for($i = 3 ; $i <= sqrt($n); $i +=2){
          if($n % $i ==0){
              return false;
          }
      }
      return true;
  }
  
  
  
?>


Measured memory_bytes: 9256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int n,x,d,ans;
int gcd(int a,int b){
	if(b)RE gcd(b,a%b);else RE a;
}
signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	cin>>n>>x>>d;
	if(!d){
		if(x)cout<<n+1;else cout<<1;
		RE 0; 
	}
	int t=gcd(x,d);x/=t;d/=t;
	if(d<0){
		d=-d;x=-x;
	}
	for(int i=0;i<d;i++){
		set<P<int,int> > s;
		for(int k=i;k<=n;k+=d){
			int t=k*x,mini=(k-1)*k/2,maxi=(n-k+n-1)*k/2;
			s.insert(MP(t/d+mini,t/d+maxi));
		}
		if(!s.size())continue;
		int en=-1e18;
		auto k=s.begin();
		while(k!=s.end()){
			P<int,int> u=(*k);
			if(en<u.first){
				ans+=u.second-u.first+1;en=u.second;
			}else if(u.second>en){
				ans+=u.second-en;
				en=u.second;
			}
			k++;
		}
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 12800
// atcoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"

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

const double PI = 3.14159265358979323846;

vector<string> strrr;
int64_t max_depth;

string search(int64_t a, int64_t b, int64_t c, string str, int64_t depth)
{
	string temp = "", temp1 = "";
	if (a < 0 || b < 0 || c < 0)
	{
		return "0";
	}
	
	if (max_depth == depth)
	{
		return str;
	}


	
	if (strrr[depth] == "AB")
	{
		temp = search(a + 1, b - 1, c, str + "A", depth + 1);
		if(temp != "0")
		{
			return temp;
		}
		temp1 = search(a - 1, b + 1, c, str + "B", depth + 1);
	}
	else if (strrr[depth] == "AC")
	{
		temp = search(a + 1, b, c - 1, str + "A", depth + 1);
		if (temp != "0")
		{
			return temp;
		}
		temp1 = search(a - 1, b, c + 1, str + "C", depth + 1);
	}
	else
	{
		temp = search(a, b + 1, c - 1, str + "B", depth + 1);
		if (temp != "0")
		{
			return temp;
		}
		temp1 = search(a, b - 1, c + 1, str + "C", depth + 1);
	}


	if (temp1 != "0")
	{
		return temp1;
	}
	else
	{
		return "0";
	}
	
	
}



int main()
{
	string s, t;
	cin >> s >> t;
	if (s.size()  + 1== t.size())
	{
		
		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] != t[i])
			{
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
	else
	{
		puts("No");
	}

	return 0;
	
}

Measured memory_bytes: 3604