akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int N, M, L, R, s[50003], t[50003], e[50003], c[10003]; long long d[10003];
int main() {
	cin >> N >> M;
	while(true) {
		cin >> s[R] >> t[R] >> e[R]; s[R]--, t[R]--;
		if (!e[R]) break; R++;
	}
	cin >> L;
	for (int i = 0; i < L; i++) {
		for (int j = 0; j < M; j++) cin >> c[j];
		for (int j = 0; j < N; j++) d[j] = 0;
		for (int j = 0; j < R; j++) d[s[j]] += c[t[j]] * e[j];
		for (int j = 0; j < N; j++) cout << (j ? " " : "") << d[j];
		cout << endl;
	}
}

Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,m,head[200001],tot=0,q,f[200001][11],g[200001][11];
struct data {
    int next,num;
}edge[200001];
void add(int u,int v) {
    edge[++tot].next=head[u];
    edge[tot].num=v;
    head[u]=tot;
}
int main() {
	memset(head,-1,sizeof(head));
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    scanf("%d",&q);
    memset(f,0,sizeof(f));
    memset(g,-1,sizeof(g));
    for (int i=1;i<=q;i++) {
        int v,d,c;
        scanf("%d%d%d",&v,&d,&c);
        f[v][d]=c;
        g[v][d]=i;
    }
    for (int i=10;i>=1;i--)
        for (int j=1;j<=n;j++) {
            if (g[j][i]>g[j][i-1]) {
                f[j][i-1]=f[j][i];
                g[j][i-1]=g[j][i];
            }
            for (int k=head[j];k!=-1;k=edge[k].next) {
                int kx=edge[k].num;
                if (g[j][i]>g[kx][i-1]) {
                    f[kx][i-1]=f[j][i];
                    g[kx][i-1]=g[j][i];
                }
            }
        }
    for (int i=1;i<=n;i++) printf("%d\n",f[i][0]);
    return 0;
}

Measured memory_bytes: 20224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    cout<<"ai1333";
    rep(i,0,n/100)cout<<"3";
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

	int n[3][3];
	rep(i, 3) rep(j, 3) cin >> n[i][j];
	rep(a1, 101) rep(a2, 101) rep(a3, 101) {
		int b1 = n[0][0] - a1, b2 = n[1][1] - a2, b3 = n[2][2] - a3;
		if (a1 + b2 == n[0][1] && a1 + b3 == n[0][2] && a2 + b1 == n[1][0] && a2 + b3 == n[1][2] && a3 + b1 == n[2][0] && a3 + b2 == n[2][1]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main(){
  int a;
  scanf("%d",&a);
  if (a < 3200){
    printf("%s\n", "red");
    return 0;
  }
  string s;
  cin >> s;
  printf("%s\n", s.c_str());
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define gc getchar
#define int long long 
int n,ans;
int read()
{
	int res=0;char ch=gc();
	while(ch<'0'||ch>'9')ch=gc();
	while(ch>='0'&&ch<='9')res=(res<<3)+(res<<1)+(ch^48),ch=gc();
	return res;
}
void qwrite(int x){
	if(x<0) x=-x,putchar('-');
	if(x>9) qwrite(x/10);
	putchar('0'+x%10);
}
LL exgcd(LL a,LL b,LL &x,LL &y){
	LL d=a; if(b==0) x=1,y=0; else{
		d=exgcd(b,a%b,y,x),y-=a/b*x;
	}
	return d;
}
#define re register
LL x,y;
void exgcd(long long a, long long b)
{
	//当前目的：求解 ax + by = gcd(a, b) 这么一个方程
	
	if(b == 0) //a, b不断改变的过程中，b最终必然会成为0
	{
		//在 b = 0 时方程还要成立？ 使 x = 1, y = 0 ，必然成立 
		x = 1;
		y = 7; //建议返回0。不过y = 7能AC，证明了最后一个等式不受最后一个y影响
		return;
	} 
	
	exgcd(b, a % b);
	long long tx = x;
	x = y;
	y = tx - a / b * y; 
}
inline LL gcd(re int a,re int b){
	return b?gcd(b,a%b):a;
}
inline LL solve(re LL a,re LL b){
	if(gcd(a,b)>1)return 1e18;
	if(b==1)return a;
	if(a==1)return b+1;
	exgcd(a,b);
	x=x%b;x+=b;x%=b;
	return a*x;
}
signed main(){
	n=read();ans=1e18;n*=2;
	re int xx=sqrt(n);
	for(re int i=1;i<=xx;++i){
		if(n%i==0){
			ans=min(ans,solve(i,n/i));
			ans=min(ans,solve(n/i,i));
		}
	}
	printf("%lld",ans-1);
}

Measured memory_bytes: 3752
#include <stdio.h>

int main(void)
{
  int n,i,s;
  scanf("%d",&n);
  s = 100000;
  for( i = 0; i < n; i++ ) {
    s += s*0.05;
    s += (1000-s%1000)%1000;
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
int main()
{
	int a, b;
	int s, l;
	
	scanf("%d %d", &a, &b);
	

	
	s = a*b ;
	
	l = 2*a + 2*b ;
	
	printf("%d %d\n", s, l);
	
	return 0 ;
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

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

    vector<int> P(N), Q(N);
    for (int i=0; i<N; ++i) cin >> P[i];
    for (int i=0; i<N; ++i) cin >> Q[i];

    vector<int> v(N);
    for (int i=1; i<=N; ++i) v[i-1] = i;

    int a = -1, b = -1;
    int i = 1;
    do {
        if (v == P) a = i;
        if (v == Q) b = i;
        i ++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
    
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations
N = int(input())
nums = list(map(int,input().split()))
tcount = 0
numset = set(nums)
comb = combinations(numset,3)
for i in list(comb):
	a = i[0]
	b = i[1]
	c = i[2]
	if(a+b>c and b+c>a and a+c>b):
		tcount += nums.count(a)*nums.count(b)*nums.count(c)
print(tcount)


Measured memory_bytes: 20472
#include <iostream>

using namespace std;

typedef long long ll;

int calced_keta = -1;

void calc(ll n) {
	ll keta = 1;
	ll p = 1;
	ll edge = 0;
	ll max_edge = 0;

	//cout << endl;
	if(n!=0) {
		while(true) {
			//cout << n << "," << keta << "," << p << "," << edge << "," << max_edge << endl;
			edge = max_edge+p*((keta%2LL==1LL)?1LL:-1LL);
			if(edge>0LL) {
				max_edge = edge+p;
				if(edge<=n&&n<max_edge) break;
			}else {
				max_edge = edge-p;
				if(max_edge<=n&&n<edge) break;
			}

			keta++;
			p *= 2LL;
			//if(keta>10) return;
		}
	}

	if(calced_keta==-1LL) {
	}else {
		for(int i = calced_keta-1LL; i > keta; i--) {
			cout << '0';
		}
	}
	cout << ((n==0LL)?'0':'1');
	calced_keta=keta;

	//cout << n << "," << p << "," << keta << endl;
	if(keta>1LL) calc(n+p*((keta%2LL==0)?1LL:-1LL));
	else {
		cout << endl;
	}
}

int main() {
	ll n;
	cin >> n;
	calc(n);
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void){
int a,b;
	scanf("%d %d\n",&a,&b);
	if(a>b)
		printf("a > b\n");
	if(a<b)
		printf("a < b\n");
	if(a==b)
		printf("a == b\n");

	return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  bool a = 0,b = 0,c = 0;
  if(A == 1 || B == 1) a = 1;
  if(A == 2 || B == 2) b = 1;
  if(A == 3 || B == 3) c = 1;
  if(a == 1 && b == 1) cout << 3;
  if(c == 1 && b == 1) cout << 1;
  if(a == 1 && c == 1) cout << 2;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードを示す。負は自身が親ということ。親だった場合は−(その集合のサイズ)
        self.parent = [-1] * N

    def root(self, A):
        # Aがどのグループに属しているか調べる
        # ノード番号を受けとって一番上の親ノードの番号を返す
        # print(A)
        if self.parent[A] < 0:
            return A
        self.parent[A] = self.root(self.parent[A])
        return self.parent[A]

    def size(self, A):
        # 自分のいるグループの頂点数を調べる
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        # AとBをくっつける
        # AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = self.root(A)
        B = self.root(B)

        if A == B:
            return False  # すでにくっついてるからくっつけない

        if self.size(A) < self.size(B):
            # 大きい方(A)に小さいほう(B)をくっ付けたい
            # 大小が逆だったらひっくり返しちゃう。
            A, B = B, A

        # Aのサイズを更新する
        self.parent[A] += self.parent[B]
        # Bの親をAに変更する
        self.parent[B] = A

        return True

    def same(self, A, B):
        return self.root(A) == self.root(B)


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


uf = UnionFind(N)
# frd = [0] * N  # 友達の数

frd = defaultdict(int)

blk = [[] for _ in range(N)]  # ブロック関係。隣接リスト
ans = [0] * N

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    frd[a] += 1
    frd[b] += 1
    uf.unite(a, b)
for i in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    blk[a].append(b)
    blk[b].append(a)
for i in range(N):
    ans[i] = uf.size(i) - 1 - frd[i]
    for j in blk[i]:
        if uf.same(i, j):
            ans[i] -= 1  # 同じグループ内でのblock関係を引く
print(*ans)



Measured memory_bytes: 40704
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    A, B = map(int, input().split())

    num = 1
    cnt = 0
    while B > num:
        num -= 1
        num += A
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

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

	ll a, b, c;
	cin >> a >> b >> c;
	ll x = c - a - b;
	if (x < 0) {
		cout << "No\n";
		return 0;
	}
	if (4 * a * b < x * x)
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

int main()
{

        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        int dx = x2 - x1;
        int dy = y2 - y1;

        int x3 = x2 - dy;
        int y3 = y2 + dx;
        int x4 = x1  - dy;
        int y4 = y1 + dx;

        cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	int n;
	cin>>n;
	vi a(n);
	vi id(n);
	vc<ll> ans(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		id[i]=i;
	}
	sort(id.begin(),id.end(),[&](int i,int j){if(a[i]==a[j]) return i<j;return a[i]>a[j];});
	int cur=n;
	for(int i=0;i<n;i++)
	{
		int nxt;
		if(i==n-1) nxt=0;
		else nxt=a[id[i+1]];
		if(id[i]<cur) cur=id[i];
		ans[cur]+=1LL*(a[id[i]]-nxt)*(i+1);
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<'\n';

}


Measured memory_bytes: 2688
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> point(n);
	rep(i,n){
		cin >> point[i];
	}
	int x = 0;
	rep(i,n){
		if(i>=k){
			if(point[i] > point[i-k]){
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
	}
	return 0;
}

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

int main() {
    int h, w, n, x = 0;
    cin >> h >> w >> n;
    int A[10001];
    int C[10001];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int j = 0; j < n; j++) {
        for (int k = x; k < x + A[j]; k++) {
            C[k] = j + 1;
        }
        x += A[j];
    }
    for (int l = w; l <= (h-1) * (w); l += 2 * w) {
        reverse(C + l, C + l + w);
    }
    for (int m = 0; m < h * w; m++) {
        cout << C[m];
        if ((m + 1) % w == 0) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;



int main(){
    
    
    ll N,M;
    cin >> N >> M;
    vector<ll> a(N);
    rep(i,M) cin >> a[i];
    
    ll mod = 1000000007;
    
    vector<ll> dp(N+1, 0);
    dp[0] = 1;
    vector<bool> b(N+1, true);
    rep(i,M) b[a[i]] = false;
    
    for (int i = 0; i <= N; i++) {
        if(i+1 <= N && b[i+1]){
            dp[i+1] += dp[i];
            dp[i+1] = dp[i+1]%mod;
        }
        if(i+2 <= N && b[i+2]){
            dp[i+2] += dp[i];
            dp[i+2] = dp[i+2]%mod;
        }
    }
    
    
    cout << dp[N] << endl;
    
    
    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    int X, Y;

    scanf("%d%d", &X, &Y);

    int sum = 0;

    if(X == 1){
        sum += 300000;
    }else if(X == 2){
        sum += 200000;
    }else if(X == 3){
        sum += 100000;
    }
    if(Y == 1){
        sum += 300000;
    }else if(Y == 2){
        sum += 200000;
    }else if(Y == 3){
        sum += 100000;
    }
    if(X == 1 && Y == 1){
        sum += 400000;
    }
    printf("%d\n", sum);
}

Measured memory_bytes: 128
import std.stdio, std.conv, std.string, std.algorithm, std.range;

void main() {
  auto input = readln.split.to!(int[]);
  auto A = input[0];
  auto B = input[1];

  auto N = 1;
  auto count=0;
  while(N < B) {
    N--;
    N+=A;
    count++;
  }
  count.writeln;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 二つの値の最小値を求める関数
Int Min(const Int a, const Int b) {
    if (a <= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int n, k, q;
    cin >> n >> k >> q;
    vector<Int> v(n, 0);
    for (Int i = 0; i < q; ++i) {
        Int a;
        cin >> a;
        a--;
        v[a]++;
    }
    for (Int i = 0; i < n; ++i) {
        if (q - v[i] < k) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4044
from collections import defaultdict, deque

def main():
    H, W = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    ch -= 1
    cw -= 1
    dh -= 1
    dw -= 1
    maze = [input() for _ in range(H)]

    INF = 10**12
    path = [[INF] * W for _ in range(H)] # 各マスへの移動コスト
    
    # walk:移動A, warp:移動B
    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    q = deque()
    path[ch][cw] = 0
    q.append((ch, cw, 0))

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk: #移動A
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == "." and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s)) # なぜleft?

        for dx, dy in warp: #移動B
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == "." and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s+1)) # なぜright?

    ans = path[dh][dw] if path[dh][dw] != INF else "-1"
    print(ans)

if __name__ == "__main__":
    main()




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

# define REP(i,n) for (int i=0;i<(n);++i)
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){cout << (v[i]) << " ";} cout << endl;
typedef long long int ll;

int main(void) {

  string s;
  cin >> s;

  int md = 2019;

  int now = 0;
  int ten = 1;
  ll ans = 0;
  map<ll, ll> mp;
  for(int i = s.size()-1; i >= 0; i--){
    (now += (s[i] - '0') * ten) %= md;
    if(now == 0){
      ans++;
    }
    mp[now]++;
    (ten *= 10) %= md;
  }

  for(auto m : mp) {
    ans += m.second * (m.second - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3716
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int windowWidth = sc.nextInt();
        int curtainsWidth = sc.nextInt() * 2;

        System.out.println(curtainsWidth >= windowWidth ? 0 : windowWidth - curtainsWidth);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
} 
signed main(){
    fast();
    int x;
    cin >> x;
    x -= 400;
    x /= 200;
    cout << 8-x << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int check(string s){
  int n = s.length();
  if(n % 2 != 0){
    return 0;
  }
  else{
  string s_back = s.substr(n / 2,n / 2);
  string s_front = s.substr(0,n / 2);

  if(s_front == s_back)
    return 1;
  else
    return 0;
  }
}

int main(void){
  string word;
  cin >> word;

  while(1){
    int word_length = word.length();
    word = word.substr(0,word_length - 1);
    if(check(word)){
      cout << word.length() << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
         ld b;
         int a;
         cin>>a>>b;
         ld ans=a*b;
         int ans1=floor(ans);
         cout<<ans1<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3748
#include<stdio.h>
void bubblesort(int num[], int array_size){
  int flag,counter,i,j,temp;
  counter=0;
  flag=1;
  while(flag==1){
    flag=0;
    for(i=array_size-1;i>0;i--){
      if(num[i]<num[i-1]){
        temp=num[i];
        num[i]=num[i-1];
        num[i-1]=temp;
        flag = 1;
        counter++;
      }
    }
  }
  for(j=0;j<array_size;j++){
    if(j>0)printf(" ");
    printf("%d", num[j]);
  }
  printf("\n%d\n",counter);
}

int main(){
  int i,j,n;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  bubblesort(A,n);
  return 0;
}

Measured memory_bytes: 1812
n,m = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
sum = arr.sum
arr.sort!
for i in 1..m
  if arr[arr.size - i] < (sum.to_f / (4 * m))
    puts "No"
    exit
  end
end
puts "Yes"

Measured memory_bytes: 14348
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
std::set<int> st;
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;



int main(){
	
	long long N,M,K;
	string s;
    
	//std::cin >> N;
    std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
	std::vector<long long> v(N);
	std::vector<long long> w(N);
    std::cin >> s;
    
    
    // 配列入力
    /*
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	*/
	/*
	for(long long i=0; i<N; i++){
		std::cin >> w[i];
	}
	*/
	
	
	//ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    //std::sort(w.begin(),w.end());//昇順ソート
    //std::sort(w.begin(),w.end(),std::greater<long long>());//降順ソート
    /*
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
		if(st.find(v[i])==st.end()){
			st.insert(v[i]);
		}
		else{
			st.erase(v[i]);
		}
	}
	*/

    
    long long sum,sum1;
	sum=0;
	sum1=0;
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	int max;
	int max1;
	max=0;
	max1=0;
	int min;
	int min1;
	min=INF;
	min1=INF;

	int work;
	work=0;;
	
    
	//sum=saiki(N);
	
	
	//文字列入力
	
	for(long long i=0; i<s.length(); i++){
		if(i==M-1){
			if(s[i]=='A'){
				s[i]='a';
			}
			else if(s[i]=='B'){
				s[i]='b';
			}
			else if(s[i]=='C'){
				s[i]='c';
			}
		}
	}
	
    if(1){
    	//printf("%d",N);
    	//puts("Yes");
    	//printf("%d",st.size());
    	//文字列の出力
    	std::cout << s << std::endl;
    	//cout << sum/mod << endl;
	}
	else{
		//puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;

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

    ll A[N + 1];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    A[N] = 0;

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += A[i] / 2;
        A[i] %= 2;
        if (A[i] > 0 && A[i + 1] > 0) {
            ++ans;
            --A[i];
            --A[i + 1];
        }
    }

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


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

int n, s1,s2, a,v[100005];
int main()
{
	int i;
	cin >> n;
	while (n--) {
		scanf ("%d", &a);
		v[a]++;
	}
	for (i = 1; i <= 100000; i++) {
		if (!v[i]) continue;
		if (v[i] == 1) s1++;
		else if (v[i] == 2)s2++;
		else if (v[i] % 2 == 0) s2++;
		else s1++;
	}
	if (s2 % 2 == 0) cout << s1 + s2;
	else cout << s1 + s2 - 1;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

		int x[50], y[50];
		for(int i = 0; i < 50; i ++) {
			x[i] = y[i] = 0;
		}
		for(int i = 0; i < n; i ++) {
			cin >> x[i] >> y[i];
		}

		int ans[20][20];
		for(int i = 0; i < 20; i ++) {
			for(int j = 0; j < 20; j ++) {
				ans[i][j] = -1;
			}
		}
		for(int i = 0; i < n; i ++) {
			ans[x[i]][y[i]] = 0;
		}	


		for(int i = 1; i <= a; i ++) {
			for(int j = 1; j <= b; j ++) {
				if(i == 1 && j == 1) {
					ans[i][j] = 1;
				}
				else if(i == 1) {
					if(ans[i][j] != 0) {
						ans[i][j] = ans[i][j-1];
					}
				}
				else if(j == 1) {
					if(ans[i][j] != 0) {
						ans[i][j] = ans[i-1][j];
					}
				}
				else {
					if(ans[i][j] != 0) {
						ans[i][j] = ans[i-1][j] + ans[i][j-1];
					}
				}
			}
		}

		cout << ans[a][b] << endl;
	}

	return 0;
}

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

int  main()
{
	long n;
	cin >> n;
	long sum = 0;
	for (long i = 1; i <= n - 1; i++)
		sum += i;
	cout << sum << endl;
	return (0);
}


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

using namespace std;

vector<bool> prime(1000010, 1);
int n;

void precalc()
{
    prime[0] = 0; prime[1] = 0; prime[2] = 1;
    for( int i = 2; i * i <= 999999; i++ ){
        if( prime[i] ){
            for( int j = 1; ( j + 1 ) * i <= 999999; j++ ){
                prime[i * ( j + 1 )] = 0;
            }
        }
    }

}

signed main(){
    precalc();
    while( scanf( "%d", &n ) != EOF )
    {
        int ret = 0;
        for( int i = 0; i <= n; i++ )
        {
            if( prime[i] )
            {
                ret++;
            }
        }
        printf( "%d\n", ret );
    }
    return 0;
}


Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int number1 = scanner.nextInt();
    int number2 = scanner.nextInt();
    int number3 = scanner.nextInt();
    System.out.println((number1 + number2 + number3) < 22 ? "win" : "bust");
  }
}

Measured memory_bytes: 21844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    ll a, v; cin >> a >> v;
    ll b, w; cin >> b >> w;
    ll t; cin >> t;
    ll dist = abs(a-b);
    ll V = v - w;
    if (V*t >= dist) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3600
X, K, D = map(int, input().split())

X = abs(X)

cuts = X//D

if cuts>=K:
    print(X-(K*D))
else:
    remainingcuts = K-cuts
    r = X-cuts*D

    if remainingcuts%2 == 1:
        print(abs(r-D))
    else:
        print(r)


Measured memory_bytes: 9196
N,K,L=map(int,input().split())
pq=[list(map(int,input().split())) for i in range(K)]
rs=[list(map(int,input().split())) for i in range(L)]
class UnionFind:
    def __init__(self,N):
        self.Parent=[-1]*N
    def unite(self,m,n):
        rm=self.root(m)
        rn=self.root(n)
        if rm==rn:
            return False
        else:
            if self.size(rm)<self.size(rn):
                rm,rn=rn,rm
            self.Parent[rm]+=self.Parent[rn]
            self.Parent[rn]=rm
            return True
    def root(self,n):
        if self.Parent[n]<0:
            return n
        else:
            self.Parent[n]=self.root(self.Parent[n])
            return self.Parent[n]
    def size(self,n):
        return -self.Parent[self.root(n)]
u=UnionFind(N)
v=UnionFind(N)
for e in pq:
    u.unite(e[0]-1,e[1]-1)
for e in rs:
    v.unite(e[0]-1,e[1]-1)
from collections import defaultdict
d=defaultdict(int)
for i in range(N):
    d[(u.root(i),v.root(i))]+=1
a=[]
for i in range(N):
    a.append(d[(u.root(i),v.root(i))])
print(*a)

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(k--){
        if(c <= b) c *= 2;
        else if(b <= a) b *= 2;
    }
    if(c > b && b > a)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

/*
int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int k;
    cin >> k;
    for(int i = 0; i < k ;i++){
        if(!(b > g)){
            b = b * 2;
        }
        else if(!(g > r)){
            g = g * 2;
        }
    }
    if(b > g && g > r)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}
*/


Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int i;
		String[] str = new String[H];
		for(i = 0;i < H;i ++) {
			str[i] = sc.next();
		}
		for(i = 0;i < W + 2;i ++) {
			System.out.print("#");
		}
		System.out.println("");
		for(i = 0;i < H;i ++) {
			System.out.println("#" + str[i] + "#");
		}
		for(i = 0;i < W + 2;i ++) {
			System.out.print("#");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 22100
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
int n,h[maxn],dp[maxn];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	memset(dp,0x3f3f3f3f,sizeof(dp));
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<endl;
	return 0;
}
//Phoenix-ZH

Measured memory_bytes: 4312
#include<iostream>
#include <math.h>
using namespace std;
int x;
bool IsPrime(int);
int main() {
    cin >> x;
    for (;;x++) {
        if (IsPrime(x)) {
            cout << x << endl;
            break;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;

#define max_n 37
vector<string> stable_check_vs;

vector<string> selectionSort(vector<string> a, int n){
  for(int i = 0; i < n; i++){
    int min_j = i;
    for(int j = i; j < n; j++){
      if((int)a[j][1] < (int)a[min_j][1]) min_j = j;
    }
    if(i != min_j){
      a[i].swap(a[min_j]);
    }
  }
  for(int i = 0; i < n-1; i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  return a;
}

vector<string> bubblesort(vector<string> a, int n){
  for(int i = 0; i < n; i++){
    for(int j = n-1; j>i; j--){
      if((int)a[j][1] < (int)a[j-1][1]){
        a[j].swap(a[j-1]);
      }
    }
  }

  for(int i = 0; i < n-1; i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;

  return a;
}

void solve(vector<string> s, int n){
  vector<string> t, k;
  t = s;
  s = bubblesort(s, n);
  cout << "Stable" << endl;
  t = selectionSort(t, n);
  if(s == t) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  return ;
}
int main(){
  int n;
  cin >> n; cin.ignore();
  vector<string> a;
  string tmp;
  while(cin >> tmp){
    a.push_back(tmp);
  }
  solve(a, n);
  return 0;
}

Measured memory_bytes: 3176
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


n,m=map(int,input().split())
A=make_divisors(m)
ans=0
for i in A:
    if m%i==0 and n<=m//i:
        ans=max(ans,i)
print(ans)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,pre;cin>>n;
  vector<tuple<string,int,int>> a(n);
  for(int i=1;i<=n;i++){
  	cin>>get<0>(a.at(i-1))>>pre;
    get<1>(a.at(i-1))=0-pre;
    get<2>(a.at(i-1))=i;
  }
  sort(a.begin(),a.end());
  for(auto b:a){
  	cout<<get<2>(b)<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll long long
#define endl '\n'
#define pi 3.14159265
string s,t;
ll h,w;
char ch[2000][2000];
ll dp[3001][3001];
ll mod=1e9+7;
ll f(ll i,ll j)
{
    if(i>=h||j>=w)
        return 0;
    if(ch[i][j]=='#')
        return 0;
    if(i==h-1&&j==w-1)
        return 1;
    if(dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=(f(i+1,j)+f(i,j+1))%mod;
    return dp[i][j];
}
int main()
{
    IOS;
    cin>>h>>w;
    for(ll i=0;i<h;i++)
        for(ll j=0;j<w;j++)
            cin>>ch[i][j];
    memset(dp,-1,sizeof(dp));
    cout<<f(0,0);
}

Measured memory_bytes: 74112
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}


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

int main() {
    ll k, a, b, cost = 0, ans = 1;
    cin >> k >> a >> b;

    if (a + 2 > b) {
        cout << 1 + k << endl;
        return 0;
    } 

    while (k != 0)
    {
        if (k < 2) {
            ans += k;
            break;
        }
        if (ans < a) {
            ans++;
            k--;
        } else {
            ans -= a;
            ans += b;
            k -= 2;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define vecin(n, a) rep(i, n)scanf("%d", &a[i])

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	string s, ss;
	scans(s); scans(ss);
	bool flag = false;
	rep(i, s.length() - 1) {
		if (s == ss)flag = true;
		string tmp{ s[s.length() - 1] };
		s.insert(0, tmp);
		s.pop_back();
	}
	if (s == ss)flag = true;
	printyn(flag);

	Please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N,L; cin >>N>>L;
  ll all = L*N;
  all += N*(N-1)/2;
  all -= L;
  if (-L < 0) ;
  else all -= min(-L, N-1);
  

  cout << all << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
char c[2010][2010];
int a[2020][2020][4];
int res=0;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) scanf("%s",&c[i]);
	for (int i=0;i<n;i++)
	{
		a[i][0][0]=0;
		if (c[i][0]=='#') a[i][0][0]=1; 
		for (int j=1;j<m;j++)
		{
			if (c[i][j]=='#') a[i][j][0]=j+1;
			else a[i][j][0]=a[i][j-1][0];
		}
	}
	for (int i=0;i<n;i++)
	{
		a[i][m-1][1]=m;
		if (c[i][m-1]=='#') a[i][m-1][1]=m-1; 
		for (int j=m-2;j>=0;j--)
		{
			if (c[i][j]=='#') a[i][j][1]=j;
			else a[i][j][1]=a[i][j+1][1];
		}
	}
	for (int j=0;j<m;j++)
	{
		a[0][j][2]=0;
		if (c[0][j]=='#') a[0][j][2]=1; 
		for (int i=1;i<n;i++)
		{
			if (c[i][j]=='#') a[i][j][2]=i+1;
			else a[i][j][2]=a[i-1][j][2];
		}
	}
	for (int j=0;j<m;j++)
	{
		a[n-1][j][3]=n;
		if (c[n-1][j]=='#') a[n-1][j][3]=n-1;
		for (int i=n-2;i>=0;i--)
		{
			if (c[i][j]=='#') a[i][j][3]=i;
			else a[i][j][3]=a[i+1][j][3];
			//cout <<a[i+1][j][3]<<" (3)\n"; 
		}
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (c[i][j]=='#') continue;
			int x=a[i][j][1]-a[i][j][0];
			int y=a[i][j][3]-a[i][j][2];
			//cout <<i<<" "<<j<<" "<<res<<" "<<x<<" "<<y<<" ##\n";
			res=max(res,x+y-1);
		} 
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 67968
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sigma_size 30
#define max_size (int)(1e5+10)
#define MAX (int)(1e5+7)
int qread()
{
	char c; int s=0,t=1; while ((c=getchar())<'0' || c>'9') (c=='-' && (t=-1));
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*t;
}

int n;
LL a[max_size];
LL ans[max_size];
LL sum;
int main ()
{
    n = qread();
    for ( int i = 1 ; i <= n ; i++ )
    {
        LL x = qread();
        a[i] = x*2;
        sum += x;
    }
    ans[1] = sum;
    for ( int i = 2 ; i <= n ; i+=2 )
        ans[1] -= a[i];
    for ( int i = 2 ; i <= n ; i++ )
        ans[i] = a[i-1]-ans[i-1];
    for ( int i = 1 ; i <= n ; i++ )
    {
        cout << ans[i];
        if ( i < n ) cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 5184
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int cnt;

void insertionSort(vector<int> &a,int g){
	for(int i=g;i<a.size();i++){
		int v = a[i];
		int j = i - g;
		while(j>=0 && a[j]>v){
			a[j+g] = a[j];
			j = j - g;
			cnt++;
			a[j+g] = v;
		}
	}
}

void shellSort(vector<int> &a){
	vector<int>g;
	cnt = 0;
	for(int h=1;h<=a.size();h=3*h+1)g.push_back(h);
	reverse(g.begin(),g.end());
	int m = g.size();
	printf("%d\n",m);
	for(int i=0;i<g.size();i++)printf(i<g.size()-1?"%d ":"%d\n",g[i]);
	for(int i=0;i<m;i++)insertionSort(a,g[i]);
}

int main(){
	vector<int> a;
	int n,x;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&x),a.push_back(x);
	shellSort(a);
	printf("%d\n",cnt);
	for(int i=0;i<n;i++)printf("%d\n",a[i]);
}

Measured memory_bytes: 5516
from collections import defaultdict

MOD = 998244353


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort(reverse=True)
    total = sum(A)
    half = -(-total//2)
    dp1 = [defaultdict(lambda: 0) for _ in range(2)]
    dp1[0][0] = 1
    dp2 = [defaultdict(lambda: 0) for _ in range(2)]
    dp2[0][0] = 1
    for i in range(N):
        dp1[(i+1) & 1] = defaultdict(lambda: 0)
        dp2[(i+1) & 1] = defaultdict(lambda: 0)
        for j in dp1[i & 1]:
            nj = min(j+A[i], half+1)
            dp1[(i+1) & 1][j] = (dp1[(i+1) & 1][j] + dp1[i & 1][j] * 2) % MOD
            dp1[(i+1) & 1][nj] = (dp1[(i+1) & 1][nj] + dp1[i & 1][j]) % MOD
            dp2[(i+1) & 1][j] = (dp2[(i+1) & 1][j] + dp2[i & 1][j]) % MOD
            dp2[(i+1) & 1][nj] = (dp2[(i+1) & 1][nj] + dp2[i & 1][j]) % MOD
    ans = (3**N) % MOD
    for t in dp1[N & 1]:
        if t >= half:
            ans = (ans - dp1[N & 1][t] * 3) % MOD
            if total % 2 == 0 and t == half:
                ans = (ans + dp2[N & 1][t] * 3) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 142208
use proconio::input;
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

fn main() {
    input! {
        n: Bytes
    }

    let ans = {
        let mut ans = 0;
        for &x in &n {
            ans += x-b'0';
            ans %= 9;
        }
        ans
    };

    if ans == 0 {
        println!("Yes")
    } else {
        println!("No")
    }
}

Measured memory_bytes: 2316
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_d"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func chmax(x *int, v int) {
	if *x < v {
		*x = v
	}
}

func solve(N, W int, wvs [][]int) int {
	t := make([][]int, N+1, N+1) // t[item_index][weight]
	for i := range t {
		t[i] = make([]int, W+1, W+1)
	}
	for i, wv := range wvs {
		w, v := wv[0], wv[1]
		for sumWeight := 0; sumWeight <= W; sumWeight++ {
			if wd := sumWeight - w; wd >= 0 {
				chmax(&t[i+1][sumWeight], t[i][wd]+v)
			}
			chmax(&t[i+1][sumWeight], t[i][sumWeight])
		}
	}
	return t[N][W]
}

func main() {
	scan := newScanner(os.Stdin)
	N, W := scan.Int(), scan.Int()
	wvs := make([][]int, N, N)
	for i := 0; i < N; i++ {
		wvs[i] = []int{scan.Int(), scan.Int()}
	}
	fmt.Println(solve(N, W, wvs))
}


Measured memory_bytes: 82596
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>


double getdist(double p, double q) {
  return p*p+q*q;
}

int main() {
  ll n;
  cin >> n;
  double X, Y;
  vector<pair<ll, ll>> vc(n);
  for (ll i = 0; i < n; i++) {
    cin >> vc[i].first >> vc[i].second;
    X += vc[i].first, Y += vc[i].second;
  }
  X /= n, Y /= n;
  double P = 0.1, d, e;
  for (ll i = 0; i < 20000; i++) {
    ll f = 0;
    d = getdist(X - vc[0].first, Y - vc[0].second);
    for (ll j = 1; j < n; j++) {
      e = getdist(X - vc[j].first, Y - vc[j].second);
      if (d < e) { d = e; f = j; }
    }
    X += (vc[f].first - X)*P;
    Y += (vc[f].second - Y)*P;
    P *= 0.999;
  }
  cout << fixed << setprecision(10) << sqrt(d) << endl;
  return 0;
}


Measured memory_bytes: 384