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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string S; cin >> S;
	int K; cin >> K;

	vector<pair<char, int>>v;
	v.emplace_back(S.front(), 1);
	rep(i, 1, S.size()) {
		if (S[i] == v.back().first) {
			v.back().second++;
		}
		else {
			v.emplace_back(S[i], 1);
		}
	}
	dump(v);
	int ans = 0;
	if (v.size() == 1) {
		ans = v.back().second*K / 2;
	}
	else if (v.front().first == v.back().first) {
		rep(i, 1, v.size() - 1) {
			ans += v[i].second / 2;
		}
		dump(ans);
		ans *= K;
		ans += v.front().second / 2;
		ans += v.back().second / 2;
		ans += (v.front().second + v.back().second) / 2 * (K - 1);
	}
	else {
		for (auto x : v) {
			ans += x.second / 2;
		}
		ans *= K;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())
ans = deque(S)
cnt = 0
for i in range(Q):
    qlst = list(map(str, input().split()))
    if qlst[0] == '1':
        cnt += 1
        continue
    else:
        if qlst[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(qlst[2])
            else:
                ans.append(qlst[2])
        else:
            if cnt % 2 == 0:
                ans.append(qlst[2])
            else:
                ans.appendleft(qlst[2])

if cnt % 2 == 1:
    print(''.join(reversed(ans)))
else:
    print(''.join(ans))

Measured memory_bytes: 8692
N=int(input())
# candidate_prime_num = [3,5,7,11,13]
# cnt = 0
# LENGTH_CANDIDADE= len(candidate_prime_num)
# for idx1, x in enumerate(candidate_prime_num):
#
#     if idx1+1 > LENGTH_CANDIDADE:
#         continue
#
#     idx2 = idx1+1
#     for y in candidate_prime_num[idx2:]:
#
#         if idx2 + 1 > LENGTH_CANDIDADE:
#             continue
#         idx3 = idx2 +1
#         for z in candidate_prime_num[idx3:]:
#             if x* y * z <= N:
#                 cnt +=1
# print(cnt)
NUM_YAKUSU = 8
cnt_8_yakusu=0
for n in range(1,N+1,2):

    cnt_yakusu = 0
    for x in range(1,n+1,2):
        if n % x == 0:
            # print(n,x)
            cnt_yakusu+=1
    if cnt_yakusu == NUM_YAKUSU:
        cnt_8_yakusu +=1
print(cnt_8_yakusu)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
  // input
  int n;
  cin >> n;
  int A, B;
  if (n == 1){
    cout << "Hello World" << endl;
  }else if(n==2){
    cin >> A >> B;
    int ans = A + B;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N=int(input())
Ryuka=[]
for i in range(87):
    if i==0:
        Ryuka.append(2)
    elif i==1:
        Ryuka.append(1)
    else:
        Ryuka.append(Ryuka[i-1]+Ryuka[i-2])

print(Ryuka[N])

Measured memory_bytes: 3060
def solve(c, a, n):
  x = min(c, a, n)
  c -= x
  a -= x
  y = min(c // 2, a)
  c -= y * 2
  a -= y
  z = c // 3
  return x + y + z

q = int(input())
for _ in range(q):
  c, a, n = map(int, input().split())
  print(solve(c, a, n))



Measured memory_bytes: 5600
#AGC023 A: 部分和は先頭からの

#AGC023 A
'''
問題
長さNの整数列Aがある
Nは1以上20000以下
Aiは-10**9以上10**9以下
Aの空でない連続する部分列であって，その総和が0であるものの個数は？

考察1
区間[i,j]を取り出して0になるかどうかを試す
これを0<=i<=j<=20000について繰り返す
計算時間はO(N**2)
つまりループ回数が10**10になる->大丈夫?
-> 大丈夫ではない。予想通りTLEになった

考察2
思いつかない...

解説を読んでやり直し
S0 = 0
S1 = A1
S2 = A1 + A2
...
Si = A1 + ... + Ai
とすると, 0<=p<q<=Nとなる(p,q)を選んでSq-Spを計算することによって任意の部分和を構成できる
Sq-Sp=0であればA_(p+1) + ... + Aqの部分和が0である
したがって0<=p<q<=Nとなる(p,q)に対してSp=Sqとなる(p,q)の組を数えればよい
このためにはS0,S1,...をソートして
Siをソートするところがボトルネックとなり, 計算量はO(NlogN)
'''

'''
#考察1は失敗
N = int(input())
A = list(map(int,input().split(' ')))

ans = 0

for i in range(N):
	for j in range(i,N):
		if sum(A[i:(j+1)]) == 0:
			ans += 1
		else:
			continue
			
print(ans)
'''

N = int(input())
A = list(map(int,input().split(' ')))
S = [0]
Scount = [1]
ans = 0

for i in range(N):
	#print(A[0:i+1])
	#S.append(sum(A[0:i+1])) <- これは遅くなるのでNG
	S.append(S[-1]+A[i])
	#print(S)

S = sorted(S)

#for s in list(dict.fromkeys(S)):
	#Scount.append(S.count(s)) <- これも遅くなるのでNG
	
for i in range(N+1):
	if i==0:
		continue
	elif S[i]==S[i-1]:
		Scount[-1] += 1
	else:
		Scount.append(1)

for n in Scount:
	ans += (n*(n-1)/2)

print(int(ans))

Measured memory_bytes: 27132
#include <iostream>
#include<map>
#include<vector>
using namespace std;

const long long MAX = 510000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<long long, int> prime_factor(long long n){
    map<long long, int> ret;
    for(long long i=2; i*i<=n; i++){
        while(n%i==0){
            ret[i]++;
            n /= i;
        }
    }
    if(n!=1) ret[n] = 1;
    return ret;
}

int main() {
    COMinit();

    //input
    long long N, M;
    bool one=0;
    cin >> N >> M;

    //exception
    if(N==1){
        cout << 1 << endl;
        system("pause");
        return 0;
    }

    //calc
    vector<long long> sisu;
    long long sub;
    for(auto p : prime_factor(M)){
        sub=0;
        while(p.second--) sub++;
        sisu.push_back(sub);
    }
    long long ans=1;
    for(long long i=0; i<(long long)sisu.size(); i++){
        ans *= COM(N-1+sisu[i],sisu[i]);
        ans %= MOD;
    }

    //answer
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 15600
import java.util.Scanner;
public class Main {
	
		static void solve() {
			Scanner sc =new Scanner(System.in);
			int n = sc.nextInt();
			int array[] = new int[n];
			int res = 0;
			for(int i = 0;i <n;i++) {
				array[i]=sc.nextInt();
			}
			for(int i = 1;i <n-1;i++) {
				if(array[i]<array[i-1]&&array[i]>array[i+1]||array[i]<array[i+1]&&array[i]>array[i-1]) {
					res++;
				}
			}
			System.out.println(res);
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<long long, long long> P;
//typedef pair<string, long long> Q;
//typedef tuple<string, string, long long> P;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int mx=max(a*10+b+c,a+b*10+c);
    cout<<max(mx,a+b+c*10)<<endl;

}


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

using namespace std;

const int H = 11;
const int W = 1010;

int choco[H][W];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  string temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    for (int j = 0; j < m; j++) {
      choco[i][j] = temp[j] == '1';
    }
  }
  int ans = H * W;
  for (int mask = 0; mask < (1 << (n - 1)); mask++) {
    int res = 0;
    int cnt = 1;
    vector <int> part;
    for (int i = 0; i < n - 1; i++) {
      if ((mask >> i) & 1) {
        part.push_back(cnt);
        cnt = 1;
      }
      else {
        cnt++;
      }
    }
    res += part.size();
    part.push_back(cnt);
    vector <int> sum(part.size(), 0);
    for (int j = 0; j < m; j++) {
      int cur = 0;
      int z = 0;
      vector <int> sumt(part.size(), 0);
      int last = 0;
      for (int x : part) {
        sumt[z] = sum[z];
        for (int i = cur ; i < cur + x; i++) {
          sumt[z] += choco[i][j];    
        }
        cur += x;
        z++;
      }
      vector <int> next(part.size(), 0);
      bool flag = 1;
      for (int x : sumt) {
        if (x > k) {
          flag = 0;
          if (last == j) {
            res = 123456789;
            break;
          }
          else {
            res++;
            for (int y = 0; y < next.size(); y++) next[y] = sumt[y] - sum[y];  
            break;
          }
        }
      }
      if (flag) {
        for (int y = 0; y < next.size(); y++) next[y] = sumt[y];  
      }
      sum = next;
      if (res == 123456789) break;
    }
    /*if (res == 0) {
      cout << mask << endl;
    }*/
    ans = min(ans, res);
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

//#define int long long

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

#define pb push_back
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()

#define INTMAX 2147483647
#define INF 200000000
#define TINT(str) atoi(str.c_str())
#define TSTR(num) to_string(num)

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int>> VII;

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

PII goal[10];
char k[1000][1000];
int fx, fy;
int H,W;

int BFS(int x, int y)
{
    VII cost;
    cost = VII(H, VI(W, INT_MAX));

    cost[fx][fy] = 0;

    queue<PII> q;

    q.push(make_pair(fx, fy));

    while(!q.empty())
    {
        PII now = q.front();
        q.pop();
        int nx = now.first;
        int ny = now.second; 

        if(nx == x && ny == y)
        {
            return cost[nx][ny];
        }

        REP(i, 4)
        {
            if(nx + dx[i] >= H ||
            nx + dx[i] < 0) continue;
            if(ny + dy[i] >= W || 
            ny + dy[i] < 0) continue;

            if(k[nx + dx[i]][ny + dy[i]] != 'X')
            {
                if(cost[nx + dx[i]][ny + dy[i]] > 
                cost[nx][ny] + 1)
                {
                    cost[nx + dx[i]][ny + dy[i]] =
                        cost[nx][ny] + 1;
                    q.push(make_pair(nx + dx[i], ny + dy[i]));
                }
            }
        }
    }

    return -1;
}

signed main()
{
    int N;
    cin >> H >> W >> N;

    char str[1001];
    REP(h, H)
    {
        scanf("%s", str);
        REP(w, W)
        {
            k[h][w] = str[w];
            if(k[h][w] == 'S')
            {
                fx = h;
                fy = w;
            }
            if(k[h][w] != '.' &&
                k[h][w] != 'X')
            {
                goal[k[h][w] - '1'] = make_pair(h, w);
            }
        }
    }
    int ans = 0;

    REP(i, N)
    {
        ans += BFS(goal[i].first, goal[i].second);
        fx = goal[i].first;
        fy = goal[i].second;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 7800
INF = 1e9

n = int(input())

a = []
for i in range(n):
    a.append(list(map(int, input().split())))

def prim(n):
    flag = [0] * n
    d = [INF] * n
    d[0] = 0
    p = [-1] * n

    while True:
        min_cost = INF
        
        for i in range(n):
            if flag[i] != 1 and d[i] < min_cost:
                min_cost = d[i]
                u = i
        if min_cost == INF:
            break
        flag[u] = 1
        
        for v in range(n):
            if flag[v] != 1 and a[u][v] != -1:
                if a[u][v] < d[v]:
                    d[v] = a[u][v]
                    p[v] = u
    return sum(d)

print(prim(n))


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

int main() {
	int		a,b,c,p,i,j,k,n,m,x,y,pena = 0,ans = 0;
	string	str;
	
	cin >> n >> m;
	
	vector<int>  t(n+1); 
	vector<char> tt(n+1);

	for(i=0;i<m;i++) {
		cin >> p;
		cin >> str;
		if (tt[p] == 'A') continue;
		if (str[0] == 'A') {
			tt[p] = 'A';
			ans++;
		} else {
			t[p]++;
		}
	}
	
	for(i=1;i<=n;i++) {
		if (tt[i] == 'A') pena += t[i];
	}
		

	cout << ans << ' ' << pena << endl;

}


Measured memory_bytes: 768
/*-------------------------------"ANJAN AGARWALA"-----------------------------

         _/_/_/_/    _/_/    _/   _/_/_/_/   _/_/_/_/    _/_/    _/   
        _/    _/    _/ _/   _/         _/   _/    _/    _/ _/   _/        
       _/_/_/_/    _/   _/ _/         _/   _/_/_/_/    _/  _/  _/         
      _/    _/    _/    _/_/   _/    _/   _/    _/    _/    _/_/  
     _/    _/    _/      _/   _/_/_/_/   _/    _/    _/      _/   

-------------------------------------@anjn98---------------------------------*/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007

const int N=5e2+99;

int n;
ll dp[N][N],a[N],pf[N];

ll solve(int i,int j)
{
    if(i==j) return 0;
    if(dp[i][j]!=-1) return dp[i][j];

    ll sum=pf[j]-pf[i-1],ans=1e18;

    for(int k=i;k<j;k++)
    {
        ans=min(ans,solve(i,k)+solve(k+1,j));
    }
    ans+=sum;
    return dp[i][j]=ans;
}
int main() 
{
	IO

    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],pf[i]=pf[i-1]+a[i];

    ll ans=solve(1,n);
    cout<<ans<<endl;


}




 

Measured memory_bytes: 3072
from queue import Queue

K = int(input())

# 1 2 3 4 5 6 7 8 9 10 11 12 21 22 23 32 33 34 ... 98 99 100

q = Queue()

for i in range(1, 10):
    q.put(i)

for _ in range(K):
    x = q.get()
    
    if x % 10 != 0:
        q.put(x * 10 + x % 10 - 1)

    q.put(x * 10 + x % 10)

    if x % 10 != 9:
        q.put(x * 10 + x % 10 + 1)

        
print(x)



Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        a=(int)(s[i]-'A');
        a=(n+a)%26;
        s[i]=(char)('A'+a);
    }
    cout<<s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    string S;
    ll answer[MAX_N];
    vector<ll> joint;

    cin >> S;

    ll N = S.length();
    rep(i, N) answer[i] = 0;

    joint.push_back(ll(-1));
    
    rep(i, N - 1){
        if (S[i] != S[i + 1]) joint.push_back(i);
    }
    
    joint.push_back(ll(N - 1));

    ll n_joints = joint.size();

    rep(i, n_joints - 1){
        For(j, joint[i] + 1, joint[i + 1] + 1){
            if (abs(i) % 2 == 0){
                if (abs(joint[i + 1] - j) % 2 == 1) answer[joint[i + 1] + 1] ++;
                else answer[joint[i + 1]] ++;
            }else {
                if (abs(joint[i] - j) % 2 == 1) answer[joint[i] + 1] ++;
                else answer[joint[i]] ++;
            }
        }
    }

    rep(i, N) cout << answer[i] << " ";
    cout << "" << endl;
    
    return 0;
}

Measured memory_bytes: 2296
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define ls i<<1
#define rs ls | 1
#define mid ((ll+rr)>>1)
#define pii pair<int,int>
#define MP make_pair
typedef long long LL;
const long long INF = 1e17+1LL;
const double Pi = acos(-1.0);
const int N = 5e5+10, M = 1e3+20, mod = 1e9+7, inf = 2e9+10;


LL sum ;
int n,a[N],d[N];
int main() {
        scanf("%d",&n);
        for(int i = 1; i <= n; ++i) scanf("%d",&a[i]),sum+=a[i];
        if(sum % (1LL*n*(n+1)/2)) {puts("NO");return 0;}
        for(int i = 1; i <= n; ++i) d[i] = a[i] - a[i-1];
        LL k = sum / (1LL*n*(n+1)/2);
        for(int i = 1; i <= n; ++i) {
            if(((d[i] - k)%n+n)%n && d[i] - k <= 0) {
                puts("NO");return 0;
            }
        }
        puts("YES");
    return 0;
}


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

int main()
{
	int N, K;
	cin >> N >> K;
	double result = 0.0;

	repeat(i, N) {
		int coin = 1;
		int n = i+1;
		if (n < K) {
			for(int j = 1; j <= K; j++) {
				coin = coin << 1;
				if ((n * coin) >= K) break;
			}
		}
		// printf("result: %10f, coin: %d, N: %d, max: %f\n", 1/(double)N * 1/(double)coin, coin, i+1, max);
		result += 1/(double)N * 1/(double)coin;
	}
	cout << fixed << setprecision(10) << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// void initiate_random() { mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count()); }

// /mnt/c/Users/vince/Desktop/POST-IOI/Codeforces/Regular/670

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	int x; scanf("%d", &x);
	printf("%d\n", x^1);
}

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

int main()
{
  int x, n, tmp;
  int ans = x;
  cin >> x >> n;
  vector<bool> p(101, false);
  for (int i = 1; i <= n; i++) {
    cin >> tmp;
    p[tmp] = true;
  }
  for (int i = 0; i <= 100; i++) {
    if (!p[x - i]) {
      ans = x - i;
      break;
    } else if (!p[x + i]) {
      ans = x + i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
x,y,a,b,c=map(int,input().split())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
R=list(map(int,input().split()))
P.sort(reverse=True)
P=P[:x]
Q.sort(reverse=True)
Q=Q[:y]
P=P+Q
P.sort()
R.sort(reverse=True)
for i in range(min(x+y,c)):
    if P[i]<R[i]:
        P[i]=R[i]
    else:
        break
print(sum(P))

Measured memory_bytes: 23328
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}
    mint& operator+=(const mint a) {
	if ((x += a.x) >= mod) x -= mod;
	return *this;
    }
    mint& operator-=(const mint a) {
	if ((x += mod-a.x) >= mod) x -= mod;
	return *this;
    }
    mint& operator*=(const mint a) {
	(x *= a.x) %= mod;
	return *this;
    }
    mint operator+(const mint a) const {
	mint res(*this);
	return res+=a;
    }
    mint operator-(const mint a) const {
	mint res(*this);
	return res-=a;
    }
    mint operator*(const mint a) const {
	mint res(*this);
	return res*=a;
    }
};

mint c[4005][4005];
void init() {
    c[0][0] = 1;
    for (int i = 0; i <= 4000; i++) {
	for (int j = 0; j <= i; j++) {
	    c[i+1][j] += c[i][j];
	    c[i+1][j+1] += c[i][j];
	}
    }
}
mint comb(int n, int k) {
    return c[n][k];
}

int main(void){
    int n, k;
    cin >> n >> k;
    init();
    int all = n - k + 1;
    for(int i = 1; i <= k; i++){
	// mint ans = comb(all, i);
	if(n - i + 1 < i) std::cout << 0 << std::endl;
	else{
	    mint ans;
	    ans = comb(all, i);
	    ans *= comb(k-1, i-1);
	    cout << ans.x << endl;   
	} 
    }
    return 0;
}



Measured memory_bytes: 128984
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v[i];
        v[i]--;
    } 
    bool ok = true;
    rep(i, n-1){
        if(v[i] > v[i+1]) v[i+1]++;
        if(v[i] > v[i+1]) ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

    void solve(Scanner sc) {
        long n = sc.nextLong();
        long m = sc.nextLong();
        if (n == 1 && m == 1) {
            System.out.println(1);
            return;
        }

        if (n == 1) {
            System.out.println(m - 2);
            return;
        }

        if (m == 1) {
            System.out.println(n - 2);
            return;
        }

        System.out.println((n - 2) * (m - 2));
    }
}


Measured memory_bytes: 21716
import qualified Data.Map as M                 

main :: IO ()
main = do
    s <- getLine
    t <- getLine
    putStrLn $ if solve s t then "Yes" else "No"

solve :: String -> String -> Bool
solve s t = go M.empty M.empty s t
  where
    go mpxy mpyx [] [] = True
    go mpxy mpyx (x : xs) (y : ys) | duplicated x y mpxy = False
                                   | duplicated y x mpyx = False
                                   | otherwise = go (M.insert x y mpxy) (M.insert y x mpyx) xs ys 

    duplicated k v mp = case M.lookup k mp of
        Nothing -> False
        Just v' -> v /= v'

Measured memory_bytes: 18812
#include<stdio.h>
int main(void)
{
	int n,i,j,x,y,s,box;
	int a[100];
	scanf("%d",&n);
	x=0;
	y=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]<=a[j]){
				box=a[i];
				a[i]=a[j];
				a[j]=box;
			}
		}
	}
	for(i=0;i<n;i++){
		if(i%2==0){
			x+=a[i];
		}
		else{
			y+=a[i];
		}
	}
	s=x-y;
	if(s<0){
		s=s*-1;
	}
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 128
def main():
    N = int(input())
    A = []
    data = input().split()
    for i in range(N):
        A.append(int(data[i]))
    C = [A[i] - i - 1 for i in range(N)]
    C.sort()
    m = N // 2
    x = C[m]
    left = sum([x - C[i] for i in range(m)])
    right = sum([C[i] - x for i in range(m + 1, N)])
    print(left + right)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 38752
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 0, n){
        int l, r;
        cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;
}

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

int n, m=25000, mi;
double cx, cy, d, mx, p=1.0, x[55], y[55];
double f(double p, double q) {return p*p + q*q;}

int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) {
		cin >> x[i] >> y[i];
		cx += x[i]; cy += y[i];
	}
	cx /= n; cy /= n;
	while(m--) {
		mx = f(cx - x[0], cy - y[0]);
		mi = 0;
		for(i=1; i<n; i++) {
			d = f(cx - x[i], cy - y[i]);
			if(d > mx) mx = d, mi = i;
		}
		cx += (x[mi] - cx) * p;
		cy += (y[mi] - cy) * p;
		p *= 0.999;
	}
	printf("%.9f", sqrt(mx));
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(b-1, n);
  cout << (a*x)/b - a *(x/b) << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    double r;
    cin >> r;
    double pi = acos(-1);

    cout << pi * r * r << " " << 2 * pi * r << endl;
}


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

typedef long long ll;

int main() {
  ll n, k;
  cin >> n >> k;

  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);

  for (ll i = k; i < n; i++) {
    if (a.at(i) > a.at(i - k)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = 0.0;
    ans = W * H / 2.0;
    printf("%lf ", ans);

    double centx = 0;
    double centy = 0;

    centx = W / 2.0;
    centy = H / 2.0;
    if(centx == x && centy == y) {
        cout << 1 << endl;
    }else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int k,length,i;
    char s[102]={},ans[105]={};
    scanf("%d %s",&k,s);
    length=strlen(s);
    if(length<=k){
        printf("%s",s);
        return 0;
    }
    for(i=0; i<k; i++){
        ans[i]=s[i];
    }
    ans[k]='.';
    ans[k+1]='.';
    ans[k+2]='.';
    printf("%s",ans);
    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int min(int m, int a) {
	if (m > a) {
		m = a;
	}

	return m;
}

int main(void) {
	int i, j, k, l, num, n;
	int a[200];
	int m[200][200];

	scanf("%d", &num);

	for (i = 0; i < num; i++) {
		scanf("%d %d", &a[i], &a[i + 1]);
	}

	for (l = 2; l <= num; l++) {
		for (i = 1; i <= num - l + 1; i++) {
			j = i + l - 1;
			m[i][j] = 1000000;
			
			for (k = i; k <= j - 1; k++)  {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + a[i - 1] * a[k] * a[j]);
			}
		}
	}

	printf("%d\n", m[1][num]);	 

	return 0;
}


Measured memory_bytes: 2068
n = int(input())
a = [int(input()) for i in range(n)]

sorted_a = sorted(a, reverse=True)


for i in range(n):
	if sorted_a[0] != sorted_a[1]:
		if a[i] != sorted_a[0]:
			print(sorted_a[0])
		else:
			print(sorted_a[1])
	else:
		print(sorted_a[0])


Measured memory_bytes: 14112
s = input().rstrip()
t = input().rstrip()

ans = len(t)
for i in range(len(s)):
    n = 0
    for j in range(len(t)):
        if i + j >= len(s):
            n = 0
            break
        if s[i + j] == t[j]:
            n += 1
    ans = min(ans, len(t) - n)
print(ans)


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;

int divCeil(int a, int b){
    return (a+b-1)/b;
}
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int tot = 0;
    rep(i,n) {
        cin >> a[i];
        tot+=a[i];
    }
    int mn = divCeil(tot, 4*m);
    sort(a.begin(),a.end(),greater<int>());
    if(a[m-1]>=mn){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
if a%2==1 or b%2==1 or c%2==1:
  print(0)
else:
  for i in range(40):
    a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
    if a%2==1 or b%2==1 or c%2==1:
      print(i+1)
      break
  else:
    print(-1)

Measured memory_bytes: 3060
import java.util.Scanner;

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

		while(true){
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();

			if(op.equals("?")){break;}

			System.out.println(calc(a,op,b));
		}
	}

	/**
	 * ?¨?????????????????????????????????????
	 * @param a int ???
	 * @param op String ?????????
	 * @param b int ???
	 * @return int?????§?¨???????????????????
	 */
	private static int calc(int a,String op,int b){
		int result = 0;

		//op????????£?????????????????????
		switch(op){
		case "+":
			result = a + b;
			break;
		case "-":
			result = a - b;
			break;
		case "*":
			result = a * b;
			break;
		case "/":
			result = a / b;
			break;
		}
		return result;
	}

}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll n;
const ll inf=1e10;
const int maxn=2e5+5;
vector<ll> ans(maxn,0);
vector<ll> a(maxn);
vector<ll> adj[maxn];
vector<ll> dp(maxn,inf);
void dfs(ll u,ll p)
{
    ll i=lower_bound(dp.begin(),dp.end(),a[u]) - dp.begin();
    ll old=dp[i];
    dp[i]=a[u];
    ans[u]=lower_bound(dp.begin(),dp.end(),INF) - dp.begin() - 1;
    for(auto v:adj[u])
    {
        if(v==p) continue;
        dfs(v,u);
    }
    dp[i]=old;
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>n;
    repA(i,1,n) cin>>a[i];
    repA(i,1,n-1)
    {
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dp[0]=-inf;
    dfs(1,0);
    repA(i,1,n) cout<<ans[i]<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 30296
#include <bits/stdc++.h> 
#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif


using namespace std;
#define M 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define sz(a) (int)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<int>());
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define fi first
#define se second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair
#define endl "\n" 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c,k;;
    cin>>a>>b>>c>>k;
    while(b<=a&&k>0){
        b*=2;
        --k;
    }
    while(c<=b&&k>0){
        c*=2;
        --k;
    }
    if(b>a&&c>b)
    cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;

    }
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N; cin >> N;
    vector<pair<ll, ll>> v(N);
    for (int i = 0; i < N; i++) cin >> v[i].second >> v[i].first;

    sort(v.begin(), v.end());

    ll sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += v[i].second;
        if (sum > v[i].first) 
        {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
def main():
  s = input().strip() + 'R'
  ans = [0 for _ in range(len(s)-1)]
  mode = 'R'
  rc, lc = 0, 0
  spli = 0
  for i, _s in enumerate(s):
    if mode == 'R':
      if _s == 'R':
        rc += 1
      else:
        spli = i
        lc += 1
        mode = 'L'
    else:
      if _s == 'L':
        lc += 1
      else:
        if rc % 2 == 0:
          ans[spli-1] += rc // 2
          ans[spli] += rc // 2
        else:
          ans[spli-1] += rc // 2 + 1
          ans[spli] += rc // 2
        if lc % 2 == 0:
          ans[spli-1] += lc // 2
          ans[spli] += lc // 2
        else:
          ans[spli-1] += lc // 2
          ans[spli] += lc // 2 + 1
        mode = 'R'
        rc, lc = 1, 0
  print(*ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  int X = 0;
  
  for (int N = A; N <= B; N++) {
    int man = N / 10000;
    int sen = (N % 10000) / 1000;
    int juu = (N % 100) / 10;
    int ichi = (N % 10);
    
    if (man == ichi && sen == juu) {
      X++;
    }
  }
  
  cout << X << endl;
  
}

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

int main(){
    long long a, b;
    int k;
    cin >> a >> b >> k;
    int f = 1;
    for(int i = 0; i < k; i++){
        if(f){
            if(a % 2 == 1) a--;
            b += a / 2;
            a /= 2;
            f = 0;
        }else{
            if(b % 2 == 1) b--;
            a += b / 2;
            b /= 2;
            f = 1;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a, ans = 1;
bool ok = true;
const ll inf = 1000000000000000000;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (a > (inf + ans - 1) / ans)ok = false;
		if (ok)ans *= a;
		if (ans > inf)ok = false;
		if (a == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	if (ok) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (1000000007) // 1e9+7

ll power(ll base, ll exponent, ll modx = mod) 
{
    ll ret = 1 % modx;
    base %= modx;
    while(exponent) 
    {
        if(exponent & 1) 
        {
            ret = (ret * base) % modx;
        }
        base = (base * base) % modx;
        exponent >>= 1;
    }
    return ret;
}

int main()
{
	NeedForSpeed();
	ll n,k; cin>>n>>k; ll ans = 0;
	ll dp[k+1] = {0}; 
	for(int i=1; i<=k; i++) dp[i] = power((k/i),n);
	for(int i=k; i>=1; i--)
	{
		for(int j=(k/i)*i; j>i; j-=i)
		{
			dp[i] -= dp[j]; 
			dp[i] += mod;
			dp[i] %= mod;
		}
	}
	for(int i=1; i<=k; i++)
	{
		ans += (i*dp[i]);
		ans %= mod;
	}
	cout<<ans<<endl;		
	return 0;
}

Measured memory_bytes: 4324
#include <stdio.h>
#include <math.h>


int main(){
	double x = 0,y = 0;
	int tmp_x,tmp_y,degree=90;

	while(true){
		scanf("%d,%d",&tmp_x,&tmp_y);
		if(tmp_x == 0 && tmp_y == 0)break;
		x += tmp_x*cos(degree*M_PI/180);
		y += tmp_x*sin(degree*M_PI/180);
		degree -= tmp_y;
	}

	printf("%d\n",(int)x);
	printf("%d\n",(int)y);

    return 0;
}

Measured memory_bytes: 2848
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		scan.close();
		int a = Integer.parseInt(n);
		for(int i = a; i <= 999; i++) {
			String k = Integer.toString(i);
			char c0 = k.charAt(0);
			char c1 = k.charAt(1);
			char c2 = k.charAt(2);
			if(c0 == c1 && c1 == c2) {
				System.out.println(k);
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

const pair<LL, LL> HMOD = MP(998244353, 1004535809), HRAD = MP(243, 19683), HIRAD = MP(607984215, 858522653);
map<pair<LL, LL>, int> S;
int n;
char ch[250005];

int main()
{
	scanf("%d%s", &n, &ch);
	pair<LL, LL> cur = MP(1, 1), cnt = MP(0, 0);
	rep(i, n) {
		if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
		if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first;
		if(ch[i] == '<') cur.first = cur.first * HIRAD.first % HMOD.first;
		if(ch[i] == '>') cur.first = cur.first * HRAD.first % HMOD.first;
		if(ch[i] == '+') cnt.second = (cnt.second + cur.second) % HMOD.second;
		if(ch[i] == '-') cnt.second = (cnt.second - cur.second + HMOD.second) % HMOD.second;
		if(ch[i] == '<') cur.second = cur.second * HIRAD.second % HMOD.second;
		if(ch[i] == '>') cur.second = cur.second * HRAD.second % HMOD.second;
		S[cnt] ++;
	}
	pair<LL, LL> ss = cnt;
	LL ans = S[ss];
	cur = MP(1, 1); cnt = MP(0, 0);
	rep(i, n) {
		if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
		if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first;
		if(ch[i] == '<') cur.first = cur.first * HIRAD.first % HMOD.first;
		if(ch[i] == '>') cur.first = cur.first * HRAD.first % HMOD.first;
		if(ch[i] == '+') cnt.second = (cnt.second + cur.second) % HMOD.second;
		if(ch[i] == '-') cnt.second = (cnt.second - cur.second + HMOD.second) % HMOD.second;
		if(ch[i] == '<') cur.second = cur.second * HIRAD.second % HMOD.second;
		if(ch[i] == '>') cur.second = cur.second * HRAD.second % HMOD.second;
		S[cnt] --;
		ans += S[MP((cnt.first + cur.first * ss.first) % HMOD.first, (cnt.second + cur.second * ss.second) % HMOD.second)];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31744
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <boost/range/algorithm.hpp>
#include <boost/integer/common_factor_rt.hpp>

using namespace std;

int N, A, B, C, D;
string S;

int main() {

    while (cin >> N >> A >> B >> C >> D) {
        cin >> S;
        bool ret = true, rock = false;
        for (int i = A - 1; i < C - 1; i++) {
            if (S.at(i) == '#') {
                if (rock) {
                    ret = false;
                    break;
                } else {
                    rock = true;
                }
            } else {
                rock = false;
            }
        }
        rock = false;
        for (int i = B - 1; i < D - 1; i++) {
            if (S.at(i) == '#') {
                if (rock) {
                    ret = false;
                    break;
                } else {
                    rock = true;
                }
            } else {
                rock = false;
            }
        }
        if (D < C) {
            string substr = S.substr(B - 2, D - B + 3);
            ret &= substr.find("...") != string::npos;
        }
        cout << (ret ? "Yes" : "No") << endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int s ;
    cin >> s;
    int s1, s2, s3;
    s1 = s / 100 % 10;
    s2 = s / 10 % 10 ;
    s3 = s % 10;
    cout << s1 + s2 + s3 << endl;
}

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

int main() {
    int n; cin >> n;
    int a[9][9];
    for(int j = 1; j < 10; j++){
        for(int k = 1; k < 10; k++){
            a[j-1][k-1] = j*k;
            // cout << a[j-1][k-1] << endl;
        }
    }

    bool check = false;
    for(int j = 1; j < 10; j++){
        for(int k = 1; k < 10; k++){
            if(n == a[j-1][k-1]) check = true;
        }
    }

    cout << (check? "Yes": "No") << endl;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *vertex=(int *)malloc(sizeof(int)*m);
  int *next=(int *)malloc(sizeof(int)*m);
  int64 *cost=(int64 *)malloc(sizeof(int64)*m);
  int *start=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) start[i]=-1;
  for(i=0;i<m;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a--;
    b--;
    vertex[i]=b;
    next[i]=start[a];
    start[a]=i;
    cost[i]=-c;
  }
  int64 *dp=(int64 *)malloc(sizeof(int64)*n);
  const int64 inf=1000000001LL*10000;
  for(i=0;i<n;i++) dp[i]=inf;
  dp[0]=0;
  for(i=0;i<n;i++){
    int j;
    for(j=0;j<n;j++){
      if(dp[j]==inf) continue;
      int p;
      for(p=start[j];p!=-1;p=next[p]){
	int v=vertex[p];
	dp[v]=MIN(dp[v],dp[j]+cost[p]);
      }
    }
  }
  int *flag=(int *)calloc(n,sizeof(int));
  for(i=0;i<n;i++){
    if(dp[i]==inf) continue;
    int p;
    for(p=start[i];p!=-1;p=next[p]){
      int v=vertex[p];
      if(dp[v]>dp[i]+cost[p]){
	flag[i]=1;
      }
    }
  }
  for(i=0;i<n;i++){
    int j;
    for(j=0;j<n;j++){
      if(dp[j]==inf) continue;
      if(flag[j]==0) continue;
      int p;
      for(p=start[j];p!=-1;p=next[p]){
	int v=vertex[p];
	flag[v]=1;
      }
    }
  }

  if(flag[n-1]){
    printf("inf\n");
  } else {
    printf("%lld\n",-dp[n-1]);
  }
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s="";
int main(void){
    ll n;
    cin>>n;
    while(n){
        n--;
        s+=char('a'+n%26);
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 3608
import sys


def evaluate(m, f, r):
    if m == -1 or f == -1:
        return 'F'

    total = m + f

    if total >= 80:
        return 'A'
    if total >= 65:
        return 'B'
    if total >= 50:
        return 'C'
    if total >= 30:
        return 'C' if r >= 50 else 'D'
    return 'F'


for line in sys.stdin:
    m, f, r = map(int, line.strip().split())
    if m == f == r == -1:
        break
    print(evaluate(m, f, r))



Measured memory_bytes: 5604