akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long
//cout << fixed << setprecision (10);   小数点以下１０桁まで

int main() {
  char a;
  cin >>a;

  if(a=='A') puts("T");
  if(a=='T') puts("A");
  if(a=='C') puts("G");
  if(a=='G') puts("C");
  
}



Measured memory_bytes: 256
process_num, qms = map(int, input().split())
raw_procs = [input() for i in range(process_num)]


if __name__ == '__main__':
    procs = []
    for row in raw_procs:
        name, time = row.split()
        procs.append({
            "name": name,
            "time": int(time),
        })

    total_time = 0
    current_proc = 0
    while len(procs) > 0:
        if procs[current_proc]["time"] > qms:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc == len(procs):
                current_proc = 0


Measured memory_bytes: 24388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  int ans1 = 0;
  int ans2 = 0;
  long double mx = -1.0;
  for (int i = 0; i <= 60; i++) {
    for (int j = 0; j <= 60; j++) {
      if ((A * i * 100) + (B * j * 100) <= F && (A * i * 100) + (B * j * 100) != 0) {
        
      } else {
        continue;
      }
      for (int k = 0; k <= 2500; k++) {
        for (int l = 0; l <= 2500; l++) {
          if ((A*i*100) + (B*j*100) + (C*k) + (D*l) <= F && ((A*i)+(B*j)) * E >= (C*k) + (D*l)) {
            if ((long double)((C*k) + (D*l)) / (long double)((A*i*100) + (B*j*100) + (C*k) + (D*l)) > mx) {
              ans1 = (A*i*100) + (B*j*100) + (C*k) + (D*l);
              ans2 = (C*k) + (D*l);
              mx = (long double)((C*k) + (D*l)) / (long double)((A*i*100) + (B*j*100) + (C*k) + (D*l));
            }
          }
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int X;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.X = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
        
        if (400 <= X && X <= 599) {
        	answer = 8;
        } else if (600 <= X && X <= 799) {
        	answer = 7;
        } else if (800 <= X && X <= 999) {
        	answer = 6;
        } else if (1000 <= X && X <= 1199) {
        	answer = 5;
        } else if (1200 <= X && X <= 1399) {
        	answer = 4;
        } else if (1400 <= X && X <= 1599) {
        	answer = 3;
        } else if (1600 <= X && X <= 1799) {
        	answer = 2;
        } else if (1800 <= X && X <= 1999) {
        	answer = 1;
        }
        
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


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

int32_t main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  
  int l = 1, r = 1e9;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  auto cnt = [&](int x) {
    int ret = 0;
    for (int i = 0; i < n; ++i) {
      ret += (a[i]-1) / x;
    }
    return ret;
  };

  while (l < r) {
    int mid = (l + r) / 2;
    if (cnt(mid) <= k) r = mid;
    else l = mid + 1;
  }
  cout << r << '\n';
}


Measured memory_bytes: 4784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		//??£?¨???????
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){

			//????????¨????????????????????????
			int[][] sima = new int[12][12];
			int count = 0;

			//????????????????????????
			//????????§nextLine???????????¨hasNext??§?????£????????????????????????
			//????????????????????????????????£????????????
			for(int i = 0; i < 12 ; i ++){
				String str = sc.next();

				//??????????????????int????????´?????????????????\??????
				for(int j = 0; j < 12; j ++){
					String[] s = str.split("");
					sima[i][j] = Integer.parseInt(s[j]);
				}
			}

			//??¨??¨?????????????????????
			//?????????12???
			for(int i = 0; i < 12; i++){
				//??¨??????12???
				for(int j = 0; j < 12; j++){
					//?????????(1?????£??????)
					if(sima[i][j] == 1){

						//IslandMap???check?????????????????????
						IslandMap.check(i, j, sima);
						//??°??£????????????(??????????????¨???0????????????????????????)
						//??????count???+1?????????
						count++;
					}
				}
			}
			//????????°???????????????
			System.out.println(count);
		}
		//????????£????????????????????????
		sc.close();
	}
}

//???????????????????????£?¨?
class IslandMap{
	int[][] sima;
	int tate;
	int yoko;


	//????????\??????
	private IslandMap(int i, int j, int[][] sima2) {
		this.tate = i;
		this.yoko = j;
		this.sima = sima2;
	}


	public static void check(int tate , int yoko, int[][] sima){

		//1??????????????\??£??????????????????0????????????
		sima[tate][yoko] = 0;

		//???
		//12??12???????????????
		if(tate+1 < 12){
			//????????£????????¨???????????§????????????
			if(sima[tate+1][yoko] == 1){
				//check?????????????????\?????¨0??????????????????
				check(tate+1 , yoko , sima);
			}
		}//?????°????????????

		//???
		if(yoko+1 < 12){
			if(sima[tate][yoko+1] == 1){
				check(tate , yoko+1 , sima);
			}
		}
		//???
		if(tate-1 > -1){
			if(sima[tate-1][yoko] == 1){
				check(tate-1 , yoko , sima);
			}
		}
		//???
		if(yoko-1 > -1){
			if(sima[tate][yoko-1] == 1){
				check(tate , yoko-1 , sima);
			}
		}
	}
}

Measured memory_bytes: 30472
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        if self.root[x] > self.root[y]:
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x 
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x): # xが属するグループのサイズを返す
        return -self.root[self.Find_Root(x)]
    def Members(self, x): # xが属するグループに属する要素をリストで返す
        return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
    def Roots(self): # 全ての根の要素をリストで返す
        return [i for i, x in enumerate(self.root) if x < 0]
    def Group_Count(self): # グループの数を返す
        return len(self.Roots())

n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]
uf = UnionFind(n+1)
for x, y in xy:
    uf.Unite(p[x-1], p[y-1])
ans = 0
for i in range(n):
    if uf.isSameGroup(i+1, p[i]):
        ans += 1
print(ans)

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

vector<vector<int>> v(100010);
int c[100010];
bool used[100010];
int ans=0;
map<int,int> mp[100010];
void dfs(int p,int pc){
    used[p]=1;
    int now=1;
    for(auto i:v[p]){
        if(!used[i]){
            if(now!=pc){
                mp[min(i,p)][max(i,p)] = now;
                dfs(i,now);
            }
            else{
                now++;
                mp[min(i,p)][max(i,p)]=now;
                dfs(i,now);
            }
            now++;
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n;
    cin>>n;
    int s[n],t[n];
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        s[i]=min(a,b),t[i]=max(b,a);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<n;i++) ans = max(ans,(int)v[i].size());
    cout << ans << "\n";
    dfs(0,0);
    for(int i=0;i<n-1;i++){
        cout << mp[s[i]][t[i]] << "\n";
    }


}

Measured memory_bytes: 17920
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = []
cnt = 0

for i in range(n):
    a.append(list(map(int,input().split())))
    tmp = 0
    for j in range(m):
        tmp += a[i][j]*b[j]
    if tmp + c > 0 :
        cnt += 1

print(cnt)

Measured memory_bytes: 9036
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int tmp = 0;
	rep(i, n)tmp = a[i] - tmp;
	rep(i, n)a[i] *= 2;
	rep(i, n) {
		if (i == 0)cout << tmp << endl;
		else {
			cout << tmp << endl;
		}
		tmp = a[i] - tmp;
	}
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  ll x=min(n,b-1);
  cout<<a*x/b<<endl;
  return(0);
}


Measured memory_bytes: 3624
// AOJ 2376 DisconnectedGame
// 2018.2.24 bal4u

#include <stdio.h>
#include <stdlib.h>

int  n;
char map[1003][1003];
char mk[1003];
int  x, f[2];

void dfs(int r)
{
	int c;

	if (mk[r]) return;
	mk[r] = 1;
	x++;
	for (c = 0; c < n; c++) if (map[r][c] & 1) dfs(c);
}

int main()
{
	int r, c, cnt;
	char buf[10], *p;

	fgets(buf, 10, stdin), n = atoi(buf);
	cnt = (n*(n-1)) >> 1;
	for (r = 0; r < n; r++) {
		fgets(p=map[r], 1003, stdin);
		for (c = 0; c < r; c++) cnt -= (*p++ == 'Y');
	}

	for (r = 0; r < n; r++) {
		if (mk[r]) continue;
		x = 0, dfs(r), f[x & 1]++;
	}

	if ((f[0] == 1 && f[1] == 2) || (cnt & 1) == (f[0] || f[1] != 2)) puts("Taro");
	else puts("Hanako");
	return 0;
}


Measured memory_bytes: 2544
#include<stdio.h>
#include<string.h>

int main(void){
  char s[100001];
  scanf("%s",s);
  int n=strlen(s);
  int red=0,blue=0;
  for(int i=0;i<n;i++){
    if(s[i]=='0'){
      red++;
    }else{
      blue++;
    }
  }
  if(red<blue){
    printf("%d",red*2);
  }else{
    printf("%d",blue*2);
  }
  return(0);
}

Measured memory_bytes: 256
function main(input) {
  const arg = input.split(' ')
  const a = parseInt(arg[0], 10)
  const b = parseInt(arg[1], 10)
  console.log(Math.floor(a/b)+(a%b!=0?1:0))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	std::string a;
	long long r = 0, g = 0, b = 0;
	std::cin >> n;
	std::cin >> a;
	for (auto p : a) {
		if (p == 'R') r++;
		else if (p == 'G') g++;
		else b++;
	}
	long long ans = (long long)r * g * b;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] == a[j]) continue;

			int k = 2 * j - i;

			if (k < n && a[i] != a[k] && a[j] != a[k]) ans--;
		}
	}
	std::cout << ans <<  "\n";
	return 0;
}


Measured memory_bytes: 3664
n = int(input())
h = list(map(int, input().split()))

sage = True
mono = True
for i in range(n-1):
    if h[i+1] - h[i] > 0:
        sage = True
    elif h[i+1] - h[i] == 0:
        pass
    elif h[i+1] - h[i] == -1:
        if sage == True:
            sage = False
        else:
            mono = False
    else:
        mono = False
        
if mono == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long n)
{
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p)
  {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0)
    {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}
//

int main()
{
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double rad = 2 * PI * ((long double)h / 12.0 + (long double)(m / 60.0) / 12.0 - (long double)m / 60.0);
  long double c2 = a * a + b * b - 2 * a * b * cosl(rad);
  cout << setprecision(20) << sqrtl(c2) << endl;
  return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, m;
	cin >> n >> m;
	vector<long long> a(n);
	long long b = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < m; i++) {
		int t;
		cin >> t;
		b += t;
	}
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		ans += a[i] * b;
	}
	cout << ans << endl;
	
	return 0;	
}



Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;

long long n;

int div_count(long long n)
{
	int ans=0;
	bool prime=true;
	for(int i=1;1ll*i*i<=n;i++)
	{
		if(n%i==0)
		{
			ans+=2;
			if(1ll*i*i==n) ans--;
			prime=false;
		}
	}
	return ans+prime-1;
}

bool ok(long long i)
{
	long long m=n;
	while(m%i==0) m/=i;
	return m%i==1;
}

int main()
{
	cin>>n;

	int ans=div_count(n-1);
	for(int i=2;1ll*i*i<=n;i++)
	{
		if(n%i) continue;
		ans+=ok(i);
		if(1ll*i*i!=n) ans+=ok(n/i);
	}
	cout<<ans+1;
}

Measured memory_bytes: 3624
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

# sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
# N = int(input())
# A,B,C = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N, M = [int(x) for x in input().split()]
A = [int(input()) for _ in range(M)]
A = set(A)

dp = [0] * (N + 1000)
dp[0] = 1

for i in range(N):
    if i + 1 not in A:
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD
    if i + 2 not in A:
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD

print(dp[N] % MOD)


Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> cnt(N);
	rep(i,M) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	bool flg = true;
	rep(i,N) {
		if(cnt[i] % 2) flg = false;
	}
	if(flg)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

char T[1010];
char P[1010];

void solve()
{
    int i = 0;
    char *t = T;
    char *p = P;
    while (*t != '\0') {
        while (*t == *p) {
            if (*(p+1) == '\0') {
                printf("%d\n", i);
                break;
            }
            p++;
            t++;
        }
        i++;
        p = P;
        t = T+i;
    }
}


int main()
{
    scanf("%s", T);
    scanf("%s", P);
    
    solve();
    
    return 0;
}

Measured memory_bytes: 536
#include <iostream>

using namespace std;

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

    int res = N;

    for (int i = 0; i <= N; i++){
        int cc = 0;
        int t = i;
        while (t > 0){
            cc += t % 6;
            t /= 6;
        }
        t = N - i;
        while (t > 0){
            cc += t % 9;
            t /= 9;
        }
        if (res > cc){
            res = cc;
        }
    }
    
    cout << res << endl;

    return 0;
}

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

using namespace std;

const int N=2e5+5;

template <typename T>
class arr {
public:
  int n;
  T *a;
  void raise(int x) {
    T *b=a;
    a=new T[x];
    copy(b,b+n,a);
    delete b;
  }
  T& operator << (T x) {
    if ((n&-n)==n) {
      raise(n<<1);
    }
    a[n++]=x;
  }
  T* begin() {
    return a;
  }
  T* end() {
    return a+n;
  }
  int size() {
    return n;
  }
  arr() {
    n=0;
    a=NULL;
  }
  void resize(int x) {
    if (n<x) {
      raise(1<<(32-__builtin_clz(x)));
    }
    n=x;
  }
  T& operator [] (int x) {
    return a[x];
  }
};
    
int n;
int a[N];

class seg {
public:
  struct node {
    node *l;
    node *r;
    int bmx;
    int wmx;
    int rev;

    void update() {
      bmx=min(l->bmx,r->bmx);
      wmx=min(l->wmx,r->wmx);
    }
    void set() {
      rev^=1;
      swap(bmx,wmx);
    }
    void push() {
      if (rev) {
        l->set();
        r->set();
        rev=0;
      }
    }
  };

  arr<node> tree;

  void build(int ll,int rr,int o=1) {
    node *t=&tree[o];
    t->rev=0;
    if (ll==rr) {
      if (ll&1) {
        t->bmx=a[ll];
        t->wmx=n;
      } else {
        t->wmx=a[ll];
        t->bmx=n;
      }
      return;
    }
    t->l=&tree[o+o];
    t->r=&tree[o+o+1];
    int mid=(ll+rr)/2;
    build(ll,mid,o+o);
    build(mid+1,rr,o+o+1);
    t->update();
  }

  int n;

  void flip(int l,int r,int ll,int rr,node *t) {
    if (ll!=rr) {
      t->push();
    }
    if (ll>=l&&rr<=r) {
      t->set();
      return;
    }
    int mid=(ll+rr)/2;
    if (l<=mid) {
      flip(l,r,ll,mid,t->l);
    }
    if (r>mid) {
      flip(l,r,mid+1,rr,t->r);
    }
    t->update();
  }

  void remove(int x,int ll,int rr,node *t) {
    if (ll!=rr) {
      t->push();
    }
    if (ll==rr) {
      t->bmx=t->wmx=n;
      return;
    }
    int mid=(ll+rr)/2;
    if (x<=mid) {
      remove(x,ll,mid,t->l);
    }
    if (x>mid) {
      remove(x,mid+1,rr,t->r);
    }
    t->update();
  }

  void flip(int l,int r) {
    flip(l,r,0,n-1,&tree[1]);
  }

  void remove(int x) {
    remove(x,0,n-1,&tree[1]);
  }

  int query(node *o,int ll,int rr,int l,int r) {
    if (ll!=rr) {
      o->push();
    }
    if (ll>=l&&rr<=r) {
      return o->bmx;
    }
    int res=n;
    int mid=(ll+rr)/2;
    if (l<=mid) {
      res=min(res,query(o->l,ll,mid,l,r));
    }
    if (r>mid) {
      res=min(res,query(o->r,mid+1,rr,l,r));
    }
    o->update();
    return res;
  }

  int query(int l,int r) {
    return query(&tree[1],0,n-1,l,r);
  }
  
  seg(int x) {
    n=x;
    tree.resize(x<<2);
    build(0,n-1);
  }
};

int main() {
  scanf("%d",&n);
  arr<int> pos;
  pos.resize(n);
  for (int i=0;i<n;++i) {
    scanf("%d",&a[i]);
    --a[i];
    pos[a[i]]=i;
  }
  seg t(n);
  set<int> s;
  s.insert(n);
  for (int i=0;i<n/2;++i) {
    int b=t.tree[1].wmx;
    int a=t.query(pos[b],*(s.lower_bound(pos[b])));
    printf("%d %d ",b+1,a+1);
    a=pos[a];
    b=pos[b];
    s.insert(a);
    s.insert(b);
    t.remove(a);
    t.remove(b);
    t.flip(a,n-1);
    t.flip(b,n-1);
  }
  puts("");
  return 0;
}


Measured memory_bytes: 30720
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100001
vector<vector<pair<ll, ll> > > vec(MAXN);
bool white[MAXN];
bool used[MAXN];
void dfs(int x, bool is_white) {
    used[x] = true;
    white[x] = is_white;
    for (int i = 0; i < vec[x].size(); i++) {
        if (!used[vec[x][i].first]) {
            if (vec[x][i].second % 2) {
                dfs(vec[x][i].first, !is_white);
            }
            else {
                dfs(vec[x][i].first, is_white);
            }
        }
    }
    used[x] = false;
}
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
        ll u, v, w;
        cin >> u >> v >> w;
        vec[u].push_back(make_pair(v, w));
        vec[v].push_back(make_pair(u, w));
    }
    memset(used, false, sizeof(used));
    dfs(1, true);
    for (int i = 1; i <= n; i++) {
        if (white[i]) {
            cout << '0' << endl;
        }
        else {
            cout << '1' << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 13912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[N];
    rep(i , N) cin >> a[i];
    int count4 = 0;
    int count2 = 0;
    rep(i, N){
        if (a[i] % 4 == 0) count4++;
        else if(a[i] % 2 == 0) count2++;
    }
    if(count2 == 0 && N % 2 == 1) N--;  
    if( (count4*2 + count2) >= N ) cout << "Yes" << endl;
    else cout <<"No" << endl;

    return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = a + b + c + max({a, b, c}) * (pow(2, k) - 1);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<int> B;
	rep(i, 0, N) {
		int A; cin >> A;
		if (A % 2 == 0)B.push_back(A);
	}
	bool flag = true;
	rep(i, 0, B.size()) {
		if (B[i] % 3 != 0 && B[i] % 5 != 0) {
			flag = false;
			break;
		}
	}
	cout << (flag ? "APPROVED" : "DENIED") << endl;

	return 0;
}


Measured memory_bytes: 256
def check(si, checked):
    xs = {si: 0}
    q = {si}
    while q:
        i = q.pop()
        xi = xs[i]
        for j, d in links[i]:
            if checked[j]:
                continue
            if j not in xs:
                xs[j] = xi + d
            elif xi + d != xs[j]:
                return False
            q.add(j)
        checked[i] = True
    return True


def solve():
    checked = [False] * n
    return all(checked[i] or check(i, checked) for i in range(n))


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')


Measured memory_bytes: 95932
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define MAX 11111111


typedef struct point{
  double x;
  double y;
} node;

void az(int n, node c, node d){
  node a1,a2,a3;
  double r = M_PI / 3.0;

  if(n == 0){
    printf("%.8f %.8f\n",c.x,c.y);
    return;
  }

  a1.x = (2.0 * c.x + 1.0 * d.x) / 3.0;
  a1.y = (2.0 * c.y + 1.0 * d.y) / 3.0;
  a3.x = (1.0 * c.x + 2.0 * d.x) / 3.0;
  a3.y = (1.0 * c.y + 2.0 * d.y) / 3.0;
  a2.x = (a3.x - a1.x) * cos(r) - (a3.y - a1.y) * sin(r) + a1.x;
  a2.y = (a3.x - a1.x) * sin(r) + (a3.y - a1.y) * cos(r) + a1.y;

  az(n - 1, c, a1);
  az(n - 1, a1, a2);
  az(n - 1, a2, a3);
  az(n - 1, a3, d);
}



int main(){
  int n;
  node a,b;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  
  az(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}




Measured memory_bytes: 2060
#include <iostream>

using namespace std;

int N, T;
int t[200000];

int main(){

    cin >> N >> T;

    for(int i = 0; i < N; i++)
        cin >> t[i];

    int ans = T;

    for (int i = 0; i < N - 1; i++)
        ans += min(t[i + 1] - t[i], T);
    
    cout << ans << '\n';

}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < n - 1; i++) {
        if(h[i] >= h[i + 1]) {
            tmp++;
        }
        else {
            tmp = 0;
        }
        
        ans = max(ans, tmp);
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 640
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val h = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()

    if (n == 1) {
        println("Yes")
        return
    }

    var c = 0

    for (i in n - 2 downTo 0) {

        if(h[i] <= h[i+1]) continue

        if (h[i] - h[i+1] == 1){
            h[i] -= 1
            continue
        }

        c++
        break
    }

    if (c == 1) println("No") else println("Yes")
}


Measured memory_bytes: 59600
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
     cin>>s;
     int count=0;
  int max_count=INT_MIN;
     for(int i=0;i<s.length();i++){
       if(s[i]=='R')
       {
         count++;
         max_count=max(max_count,count);
       }
       else{
       count=0;
       }
     }
     if(max_count==INT_MIN)
       cout<<0<<endl;
       else
  cout<<max_count<<endl;
  
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
	int w,a,b,c,d,e;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	if(a<40){a=40;}
	if(b<40){b=40;}
	if(c<40){c=40;}
	if(d<40){d=40;}
	if(e<40){e=40;}
	w=(a+b+c+d+e)/5;
	printf("%d\n",w);
	return 0;
}

Measured memory_bytes: 600
N, M = [int(x) for x in input().split()]
L, R = zip(*( [[int(x) for x in input().split()] for _ in range(M)]))

l = 0
r = 10 ** 5 + 1
for i in range(M):
    l = max(l, L[i])
    r = min(r, R[i])

print( max(r - l + 1, 0))


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

int main(){
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  int E=max(C,D);
  int flag=0;
  for(int i=B-2; i<D-2; i++){
    if(S.at(i)=='.' && S.at(i+1)=='.' && S.at(i+2)=='.') flag=1;
  }
  string ans="Yes";
  for(int i=A; i<E-1; i++){
    if(S.at(i)=='#' && S.at(i+1)=='#') ans="No";
    else if(C>D){
      if(S.at(D)=='#' or S.at(D-2)=='#'){
        if(flag==1) ans="Yes";
        else ans="No";
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
using namespace std;
long long int gcd(long long int a,long long int b){
  if(a%b==0){
    return b;
  }
  return gcd(b, a%b);
}
long long int lcm(long long int a,long long int b){
  long long int re=a/gcd(a,b);
  re*=b;
  return re;
}
int main(void){
  int n;
  cin>>n;
  vector<long long int> t(n);
  for(long long int i=0; i<n; i++){
    cin>>t.at(i);
  }
  sort(t.begin(),t.end());
  long long int  ans=1;
  for(int i=n-1; i>=0; i--){
    ans=lcm(ans,t.at(i));
  }
  cout<<ans<<endl;
}

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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll BIG_MOD = ll(1e9)+7;
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = BIG_MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= BIG_MOD;
	if (u < 0) { u += BIG_MOD; }
	return u;
}
// 順列
ll permutation(ll n, ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % BIG_MOD; }
	return result;
}
// 組み合わせ
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) { div = (div * i) % BIG_MOD; }
	return (p * modinv(div)) % BIG_MOD;
}

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

	map<int, int> m;
	repeat(i, N-1) {
		int n = 0;
		cin >> n;
		m[n-1] += 1;
	}

	repeat(i, N) {
		cout << m[i] << endl;
	}
  return 0;
}


Measured memory_bytes: 13008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define _IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll N=1e5+9,mod=1e9+7,inf=1e18;

vector<ll>vc[N];
bool vis[N];

void dfs(int a)
{
    vis[a]=true;
    for(auto x: vc[a]) if(!vis[x])dfs(x);
}

int main()
{
    _IO;
    int n,m;cin>>n>>m;
    while(m--)
    {
        int a,b;cin>>a>>b;
        vc[a].pb(b);
        vc[b].pb(a);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)if(!vis[i]){dfs(i);cnt++;}
    cout<<cnt-1<<"\n";

}



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


using namespace std;

struct D{
	int size;
	vector<int> num;

	D(){
		size = 6;
		num = vector<int>{1,2,3,4,5,6};
	}
	D(vector<int> _num){
		size = _num.size();
		num = _num;
	}
	void change(vector<int> idx){
		auto ret(num);
		for(int i = 0; i < size; i++){
			ret[i] = num[idx[i]];
		}
		swap(ret,num);
	}
	void roll(char c){
		vector<int> idx{0,1,2,3,4,5};
		switch(c){
			case 'S':
				idx = vector<int>{4,0,2,3,5,1};
				break;
			case 'N':
				idx = vector<int>{1,5,2,3,0,4};
				break;
			case 'W':
				idx = vector<int>{2,1,5,0,4,3};
				break;
			case 'E':
				idx = vector<int>{3,1,0,5,4,2};
				break;
		}
		change(idx);
	}
	void roll(int top, int front){
		int topidx,frontidx;
		for(int i = 0; i < size; i++){
			if(num[i] == top){
				topidx = i;
			}
		}
		switch(topidx){
			case 1:
				roll('N');
				break;
			case 2:
				roll('W');
				break;
			case 3:
				roll('E');
				break;
			case 4:
				roll('S');
				break;
			case 5:
				roll('S');
				roll('S');
				break;
		}
		vector<int> idx = {0,1,2,3,4,5};
		for(int i = 0; i < size; i++){
			if(num[i] == front){
				frontidx = i;
			}
		}
		switch(frontidx){
			case 1:
				break;
			case 2:
				idx = vector<int>{0,2,4,1,3,5};
				break;
			case 3:
				idx = vector<int>{0,3,1,4,2,5};
				break;
			case 4:
				idx = vector<int>{0,4,3,2,1,5};
				break;
		}
		change(idx);
	}
};
				

int main(){
	vector<int> a(6);
	for(auto &e : a)cin >> e;
	D dice(a);
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		D temp = dice;
		int top,front; cin >> top >> front;
		temp.roll(top,front);
		cout << temp.num[2] << endl;
	}
	return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p)
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    string a;
    ci>>n>>a;
    c=1;
    for(ll i=1;i<n;i++)
    {
        if(a[i]!=a[i-1]) c++;
    }
    co<<c;
}


Measured memory_bytes: 3708
#include <stdio.h>

int main(void)
{
	char str[3];
	int a[4];
	int z, zz;
	
	for (z = 0; z < 4; z++) {
		a[z] = 0;
	}
	while (scanf("%d,%s", &z, &str) != EOF){
		if (str[0] == 'A' && str[1] == 'B') {
			a[0]++;
		}
		else if (str[0] == 'A') {
			a[1]++;
		}
		else if (str[0] == 'B') {
			a[2]++;
		}
		else if (str[0] == 'O') {
			a[3]++;
		}
	}
	
	printf("%d\n%d\n%d\n%d\n", a[1], a[2], a[0], a[3]);
	
	return (0);
}	

Measured memory_bytes: 592
#include <iostream>
using namespace std;
typedef long long ll;
int k, q;
int d[5000];

int main() {
  cin >> k >> q;
  for (int i = 0; i < k; i++)
    cin >> d[i];
  for (int qi = 0; qi < q; qi++) {
    ll n, x, m;
    cin >> n >> x >> m;
    ll last = x;
    ll eq = 0;
    for (int i = 0; i < k; i++) {
      ll cnt = (n - 2 - i + k) / k;
      last += ((ll)d[i] % m) * cnt;
      if (d[i] % m == 0) eq += cnt;
    }
    ll ans = (n - 1) - (last / m - x / m) - eq;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  Vi V(3);
  VIN(V)
  SORT(V);
  if((V[0]*V[1]*V[2])%2==1) OUT(V[0]*V[1]);
  else OUT(0);
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            StringBuilder sb = new StringBuilder();
            int n = in.nextInt();
            String s = in.next();
            String res;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                c = (char) ((c - 'A' + n) % 26 + 'A');
                sb.append(c);
            }
            res = new String(sb);
            out.println(res);
        }

    }
}



Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, t, a[], min, max = 0, count = 1;
		
		n = sc.nextInt();
		t = sc.nextInt();
		a = new int[n];
		
		for(int i = 0; i < n; ++i)a[i] = sc.nextInt();
		
		min = 2000000000;
		for(int i = 0; i < n; ++i) {
			if(min > a[i]) {
				min = a[i];
			}
			if(max < a[i] - min) {
				count = 1;
				max = a[i] - min;
			}
			else if(max == a[i] - min)++count;
		}
		
		System.out.println(count);
		
		sc.close();
	}

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int n, y;
    cin >> n >> y;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            int k = n - i - j;
            if(k < 0)break;
            if(1000 * i + 5000 * j + 10000 * k == y){
                cout << k << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
using namespace std;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << H*W - W*h - H*w + h*w;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int a, b;
  cin >> a >> b;
  cout << (a+b) % 24 << LF;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int lcs(char x[], char y[]){
  int m,n;
  int i,j;
  int c[1001][1001];

  m = strlen(x);
  n = strlen(y);

  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=0;j<=n;j++) c[0][j] = 0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]) c[i][j] = c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }
  return c[m][n];
}

int main(){
  int q,i;
  char x[1000],y[1000];

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",x);
    scanf("%s",y);
    printf("%d\n",lcs(x,y));
  }


  return 0;
}


Measured memory_bytes: 5620
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));
long long gcd(long long a,long long b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}
 

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(int argc, const char *argv[])
{
    //ABC142

    long long A,B;
    cin>>A>>B;
    long long GCD;
    GCD = gcd(A,B);



    long long count = 1;
    // map<int64_t,int> fact;
    // fact = prime_factor(GCD);

    // for (int i = 0; i <= GCD; i++)
    // {
    //     if(fact[i] > 0)
    //     {
    //         count++;
    //     }
    // }
    for (long long i = 2; i*i <= GCD; i++)
    {
        if(GCD%i == 0)
        {
            count++;
            while(GCD%i == 0)
            {
                GCD = GCD/i;
            }
        }
    }

    if(GCD != 1)
    {
        count++;
    }
    

    

    
    cout<<count;
    return 0;
}


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

int main() {
  std::string S;
  std::cin >> S;

  if (S == "Sunny") {
    std::cout << "Cloudy" << std::endl;
  } else if (S == "Cloudy") {
    std::cout << "Rainy" << std::endl;
  } else {
    std::cout << "Sunny" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
void solve(){
  int x;
  cin>>x;
  if(x==7||x==5||x==3)cout<<"YES";
  else cout<<"NO";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	//cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

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

		while (n>=500) {
			n = n - 500;
		}

		System.out.println (n-a <= 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 35696