akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int a[10010], next[10010];
int main(void)
{
    int n, k, m;
    while (scanf("%d%d%d", &n, &k, &m), n) {
        int i, j;
        for(i=0;i<n;++i) {
            a[i]=0;
            next[i]=(i+1)%n;
        }
        --m;
        for(i=0;i<n-1;++i) {
            a[m]=1;
            for(j=0;j<k;++j) {
                int t=m;
                m=next[m];
                while (a[m]) {
                    m=next[m];
                }
                next[t]=m;
            }
        }
        printf("%d\n", m+1);
    }
    return 0;
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
using namespace std;
const int N=605,mod=1e9+7;

int n,m,dp[N][N],ss[N],f[N],to[N],ans;

inline int mul(int x,int y){return 1ll*x*y%mod;}
inline int dc(int x,int y){x-=y;return x<0?x+mod:x;}
inline int ad(int x,int y){x+=y;return x>=mod?x-mod:x;}

int main(){
	int i,j,k,t,x,y,res;
	scanf("%d%d",&n,&m);
	n<<=1;f[0]=1;
	for(i=2;i<=n;i+=2) f[i]=mul(f[i-2],i-1);
	for(;m;--m){
		scanf("%d%d",&x,&y);
		to[x]=y;to[y]=x;
		ss[x]=ss[y]=1;
	}
	for(i=1;i<=n;++i) ss[i]=ss[i-1]+(ss[i]^1);
	for(i=1;i<n;++i){
		for(j=i+1;j<=n;j+=2){
			res=ss[j]-ss[i-1];
			if(res&1) continue;
			for(t=0,k=i;k<=j;++k)
			 if(to[k] && (to[k]<i || to[k]>j)) {t=1;break;}
		    if(t) continue;
		    res=f[res];x=ss[j];
		    for(k=i+1;k<j;k+=2){
		    	t=x-ss[k];if(t&1) continue;
		    	res=dc(res,mul(dp[i][k],f[t]));
		    }
		    dp[i][j]=res;ans=ad(ans,mul(res,f[ss[i-1]+ss[n]-ss[j]]));
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>

const int N=200005;
int n,cnt[26];
char a[N];

int main(){
	scanf("%s",a+1);
	n=strlen(a+1);
	long long ans=n*(n-1ll)/2;
	for(int i=1;i<=n;i++)cnt[a[i]-'a']++;
	for(int i=0;i<26;i++)ans-=cnt[i]*(cnt[i]-1ll)/2;
	printf("%lld\n",ans+1);
	return 0;
}


Measured memory_bytes: 384
import itertools
S=input()
max_plus_number=len(S)-1

def convert_sum(l):
    sums=0
    start=0
    for i in l:
        sums+=int(S[start:i+1])
        start=i+1
    return sums+int(S[i+1:])

total_1=int(S)
for i in range(1,max_plus_number+1):
    places=list(itertools.combinations(range(len(S)-1),i))
    total_2=0
    for p in places:
        total_2+=convert_sum(list(p)) 
    total_1+=total_2

print(total_1)

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

int main(){
  int D, L;
  cin >> D >> L;
  int nowDistance = 0,
      Count = 0;
  while(nowDistance < D){
    if((nowDistance + L) <= D){
      nowDistance += L;
      Count++;
    }else{
      nowDistance++;
      Count++;
    }
  }

  cout << Count << endl;
}


Measured memory_bytes: 3092
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    print(int(input()) ** 3)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
a,b,c,d = map(int,input().split())
cnt = 0
cc = c
dd = d
cd = lcm(c,d)
cdcd = lcm(c,d)

if a % c == 0:
  minc = a // c
else:
  minc = a // c + 1
maxc = b // c
if a < c:
  lenc = maxc
else:
  lenc = maxc - minc + 1
  
if a % d == 0:
  mind = a // d
else:
  mind = a // d + 1
maxd = b // d
if a < d:
  lend = maxd
else:
  lend = maxd - mind + 1

if a % cd == 0:
  mincd = a // cd
else:
  mincd = a // cd + 1
maxcd = b // cd
if a < cd:
  lencd = maxcd
else:
  lencd = maxcd - mincd + 1
#print(lenc)
#print(lend)
#print(lencd)
print(b-a+1-lenc-lend+lencd)



Measured memory_bytes: 63852
from collections import Counter

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

cou = Counter(a)
s = sum(a)

for b, c in bc:
    s = s + cou[b]*(c-b)
    cou[c] += cou[b]
    cou[b] = 0
    print(s)

Measured memory_bytes: 40412
#! /usr/bin/env python3
# coding: utf-8

import math
from fractions import gcd
from functools import reduce

MOD = 10**9 + 7

def lcm(a, b):
  return a * b // gcd(a, b)

n = int(input())
a = list(map(int, input().split()))
g = reduce(lcm, a)

ans = sum(list(map(lambda x:g//x, a)))
print(ans%MOD)

Measured memory_bytes: 264700
N = int(input())
a = list(map(int, input().split()))
dp = [[0] * (N + 1) for i in range(N + 1)]
for k in range(1, N + 1):
    for l in range(N - k + 1):
        r = l + k
        if (N - k) % 2 == 0:
            dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1])
        else:
            dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1])

print(dp[0][N])



Measured memory_bytes: 113884
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    string s,t;
    cin>>s>>t;
    s=" "+s;
    t=" "+t;
    int dp[s.size()][t.size()];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<s.size();i++)
    {
        for(int j=1;j<t.size();j++)
        {
            if(s[i]==t[j])
            {
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    int x=s.size()-1,y=t.size()-1;
    string ans;
    while(x&&y)
    {
        if(s[x]==t[y])
        {
            ans.push_back(s[x]);
            x--;
            y--;
        }
        else
        {
            if(dp[x][y-1]>dp[x-1][y])
                y--;
            else
                x--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 70656
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
vector<int> G[200005];
int cnt[200005]={};
void dfs(int u,int p,int s) {
  cnt[u]+=s;
  for(auto v:G[u]) {
    if(v!=p) {
      dfs(v,u,cnt[u]);
    }
  }
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,q,a,b,p,x;
  cin >> n >> q;
  for(int i=0; i<n-1; i++) {
    cin >> a >> b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0; i<q; i++) {
    cin >> p >> x;
    p--;
    cnt[p]+=x;
  }
  dfs(0,-1,0);
  for(int i=0; i<n; i++) {
    cout << cnt[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 23552
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key


signed main() {
   tezz
    
    int n,k;
    cin >> n >> k;
    int c=0;
    while(n>0){
        c++;
        n/=k;
    }
    cout << c << endl;
    
   return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char line[1025];
    char sign[4]=" ,.";
    char *ans;
    int i=0,len,sign1=0;
    fgets(line,1025,stdin);
    while(line[i++]);
    line[i-2]=0;
    ans=strtok(line,sign);
    while(ans){
        len=strlen(ans);
        if(len >= 3 && len <= 6){
            if(sign1)
                printf(" ");
            else
                sign1=1;
            printf("%s",ans);
        }
        ans=strtok(NULL,sign);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 524
import math
n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

def count(r):
    c = 0
    li = list(range(1,n+1))
    for i in range(n-1):
        c+=li.index(r[i])*math.factorial(n-i-1)
        li.remove(r[i])
    return c

print(abs(count(p)-count(q)))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int K; cin >> K;
	
	int N = (1 << K);
	
	multiset<int> data;
	
	F0R(i, N) {
		int cur; cin >> cur; data.insert(cur*-1);
	}
	
	vi vals;
	vals.pb(*data.begin());
	data.erase(data.begin());
	
	F0R(iteration, K) {
		vi newVals;
		F0R(i, sz(vals)) {
			if (data.upper_bound(vals[i]) == data.end()) {
				cout << "No" << endl; return 0;
			}
			newVals.pb(*(data.upper_bound(vals[i])));
			data.erase(data.upper_bound(vals[i]));
		}
		
		F0R(i, sz(newVals)) {
			vals.pb(newVals[i]);
		}
		//sort(all(vals));
	}
	
	cout << "Yes" << endl; return 0;	
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 13984
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {
	struct Dice {
		int suf[7];
	};

	string s;
	Dice d1;
	int tmp;

	FOR(i, 1, 6) {
		cin >> d1.suf[i];
	}
	cin >> s;

	FOR(i, 0, s.size() - 1) {
		switch (s[i]) {
		case 'N':
			tmp = d1.suf[1];
			d1.suf[1] = d1.suf[2];
			d1.suf[2] = d1.suf[6];
			d1.suf[6] = d1.suf[5];
			d1.suf[5] = tmp;
			break;
		case 'E':
			tmp = d1.suf[1];
			d1.suf[1] = d1.suf[4];
			d1.suf[4] = d1.suf[6];
			d1.suf[6] = d1.suf[3];
			d1.suf[3] = tmp;
			break;
		case 'W':
			tmp = d1.suf[1];
			d1.suf[1] = d1.suf[3];
			d1.suf[3] = d1.suf[6];
			d1.suf[6] = d1.suf[4];
			d1.suf[4] = tmp;
			break;
		case 'S':
			tmp = d1.suf[1];
			d1.suf[1] = d1.suf[5];
			d1.suf[5] = d1.suf[6];
			d1.suf[6] = d1.suf[2];
			d1.suf[2] = tmp;
			break;
		}
	}
	cout << d1.suf[1] << endl;
	return 0;
}


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

typedef long long ll;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> s(M);
  for(int i=0; i<M; i++){
    cin >> p[i] >>s[i];
  }
  vector<int> WA(N);
  vector<bool> AC(N);
  int penal=0;
  int correc=0;
  for(int i=0; i<M; i++){
    if(s[i]=="WA"){
      WA[p[i]-1]++;
    }else{
      if (AC[p[i]-1]) continue;
      else{
        AC[p[i]-1]=true;
        correc++;
        penal+=WA[p[i]-1];
      }
    }
  }
  cout<< correc<<" "<<penal<<endl;
}

Measured memory_bytes: 6528
b = input()
ans = ""
for i in b:
    if i == 'A':
        ans = ans + 'T'
        continue
    if i == 'C':
        ans = ans + 'G'
        continue
    if i == 'G':
        ans = ans + 'C'
        continue
    if i == 'T':
        ans = ans + 'A'
        continue
print(ans)


Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int tmp = a % b;
    int i = 2;
    if(tmp==c){
        cout << "YES" << endl;
        return 0;
    }
    while(tmp!=(a*i)%b){
        if(((a*i)%b)==c){
            cout << "YES" << endl;
            return 0;
        }
        i++;
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 1> { using type = vector<T>; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

using P = pair<int, int>;
#define fst first
#define snd second

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<P> ps(M);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      ps[i] = P(a, b);
    }
    sort(ps.begin(), ps.end(),
         [&](const P& a, const P& b) { return a.snd < b.snd; });
    int last = -1;
    int res = 0;
    for (auto& p : ps) {
      int s = p.fst, t = p.snd;
      if (s < last) {
        continue;
      }
      ++res;
      last = t;
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < 50001; ++i) {
        if ((int)(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<map>
#define RG register
#define LL long long
using namespace std;
const int N=405; 
int n,c[4][N];
LL ans,id[N],re[4];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
map<LL,int> num;
inline LL getid(LL aa,LL bb,LL cc,LL dd){
	return aa<<30|bb<<20|cc<<10|dd;
}
inline void rot(LL st,int kk) {
	for(RG int i=0;i<4;i++) {
		st=((st>>10)|(st&1023)<<30);
		num[st]+=kk;
	}
}
int main()
{
//	freopen("Building Cubes with AtCoDeer.in","r",stdin);
	read(n);
	for(RG int i=1;i<=n;i++)
	{
		read(c[0][i],c[1][i],c[2][i],c[3][i]);
		id[i]=getid(c[0][i],c[1][i],c[2][i],c[3][i]);
		rot(id[i],1);
	}
	for(RG int i=1;i<n-4;i++)
	{
		rot(id[i],-1);
		for(RG int j=i+1;j<=n;j++)
		{
			rot(id[j],-1);
			for(RG int l=0;l<4;l++)
			{
				LL tt=1;
				re[0]=getid(c[1][i],c[0][i],c[(l+1)%4][j],c[(l)%4][j]); if(!num[re[0]]) continue;
				re[1]=getid(c[2][i],c[1][i],c[(l)%4][j],c[(l+3)%4][j]); if(!num[re[1]]) continue;
				re[2]=getid(c[3][i],c[2][i],c[(l+3)%4][j],c[(l+2)%4][j]); if(!num[re[2]]) continue;
				re[3]=getid(c[0][i],c[3][i],c[(l+2)%4][j],c[(l+1)%4][j]); if(!num[re[3]]) continue;
				for(RG int k=0;k<4;k++)
				{
					tt*=num[re[k]];
					rot(re[k],-1);
				}
				for(RG int k=0;k<4;k++) rot(re[k],1);
				ans+=tt;
			}
			rot(id[j],1);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 20352
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}
dp = Array.new(n).map{Array.new(3, 0)}
dp[0] = a[0]
(1...n).each do |i|
  dp[i][0] = [dp[i-1][1], dp[i-1][2]].max + a[i][0]
  dp[i][1] = [dp[i-1][0], dp[i-1][2]].max + a[i][1]
  dp[i][2] = [dp[i-1][0], dp[i-1][1]].max + a[i][2]
end
puts dp.last.max


Measured memory_bytes: 16892
import Data.Char
main = do
  [a,b] <- fmap (map read . words) getLine
  str <- getLine
  let isFormal = and( map isNumber (take a str ++ drop(a+1) str)) && length str == a+b+1 && str!!a == '-'
  putStrLn $ if isFormal then "Yes" else "No"

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

int main() {
    string s; cin >> s;
    int n = s.size();
    vector<int> cnt(n, 1);
    for (int i = 0; i + 2 < n; i++) {
        if (s[i] == 'R' && s[i + 1] == 'R') {
            cnt[i + 2] += cnt[i], cnt[i] = 0;
        }
    }
    reverse(s.begin(), s.end());
    reverse(cnt.begin(), cnt.end());
    for (int i = 0; i + 2 < n; i++) {
        if (s[i] == 'L' && s[i + 1] == 'L') {
            cnt[i + 2] += cnt[i], cnt[i] = 0;
        }
    }
    reverse(s.begin(), s.end());
    reverse(cnt.begin(), cnt.end());
    for (int i = 0; i < n; i++) cout << cnt[i] << " \n"[i == n - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N(0), K(0);
  cin >> N >> K; 
  
  int res = 1;
  for(int i = 0; i < N; i++)
  {
	res = std::min( res * 2, res + K);
  }
  cout << res << endl;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, x[100], y[100], h[100];
int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> x[i] >> y[i] >> h[i];
  for(int cx=0;cx<=100;cx++){
    for(int cy=0;cy<=100;cy++){
      int ma = INT_MAX, mi = 0;
      for(int i=0;i<n;i++){
        int ma2 = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
        int mi2 = (h[i]==0) ? 1 : ma2;
        ma = min(ma, ma2);
        mi = max(mi, mi2);
      }
      if (ma < mi || ma<=0) continue;
      cout << cx << " " << cy << " " << ma << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
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;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    string S; cin >> S;
    bool OK = true;
    
    if(S[0] != 'A') OK = false;
    
    int count_C = 0;
    for(int i = 2; i < S.size() - 1; i++){
        if(S[i] == 'C') count_C++;
    }
    if(count_C != 1) OK = false;
    
    for(int i = 0; i < S.size(); i++){
        if(i == 0) continue;
        if(S[i] == 'C') continue;
        if( (S[i] >= 'A') && (S[i] <= 'Z') ) OK = false;
    }
    
    if(OK) cout << "AC" << endl;
    else cout << "WA" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> x(N),y(N),v(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i) >> y.at(i);
    v.at(i) = i;
  }
  double dist = 0;
  double count = 0;
  do {
    for(int i=1;i<N;i++){
      int x_dist = x.at(v.at(i)) - x.at(v.at(i-1));
      int y_dist = y.at(v.at(i)) - y.at(v.at(i-1));
      dist += sqrt( pow(x_dist, 2) + pow(y_dist, 2) );
    }
    count++;
  } while( next_permutation(v.begin(), v.end()) );
  cout << fixed;
  cout << setprecision(10) << dist/count << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = math.MaxInt64 / 4

func main() {
	sc.Split(bufio.ScanWords)
	N, M, X := getInt(), getInt(), getInt()
	c := make([]int, N)
	a := make([][]int, N)
	for i := 0; i < N; i++ {
		c[i] = getInt()
		a[i] = make([]int, M)
		for j := 0; j < M; j++ {
			a[i][j] = getInt()
		}
	}

	// out(c)
	// out(a)
	n := 1 << uint(N)
	ans := inf
	for i := 0; i < n; i++ {
		b := make([]int, N)
		cnt := i
		idx := N - 1
		for cnt > 0 {
			b[idx] = cnt % 2
			cnt /= 2
			idx--
		}
		// out(b)

		cash := 0
		sum := make([]int, M)
		for j := 0; j < N; j++ {
			if b[j] == 1 {
				cash += c[j]
				for k := 0; k < M; k++ {
					// out(j, k)
					sum[k] += a[j][k]
				}
			}
		}
		flg := true
		for j := 0; j < M; j++ {
			if sum[j] < X {
				flg = false
				break
			}
		}
		if flg {
			ans = min(ans, cash)
		}
	}

	if ans == inf {
		out(-1)
		return
	}
	out(ans)

}


Measured memory_bytes: 2568
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) {
            continue;
        }
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) {
        res.push_back({N, 1});
    }
    return res;
}

void Main() {
    long long N;
    int count = 0;
    int num, index;

    cin >> N;
    vector<pair<long long, long long>> results = prime_factorize(N);

    REP(i, results.size()) {
        num = results[i].second;
        index = 1;
        while (num >= index) {
            count++;
            num = num - index;
            index++;
        }
    }
    cout << count << endl;
}
 
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



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

int main() {
    string ognl; cin >> ognl;
    string ans = "";
    for (int i = 0; i < (int)ognl.size(); ++i) {
        if (i % 2 == 0) ans.push_back(ognl[i]);
    }
    cout << ans << endl;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define INF 1e18
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    cout<<(n-2)*180;
}

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

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

    string s, t;
    cin >> s;
    cin >> t;
    if(s.length()+1 != t.length()){
        cout << "No" << endl;
    }
    else{
        t = t.substr(0,s.length());
        if(s==t){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    lint c[10][10];
    rep(i, 10)rep(j, 10) scanf("%lld", &c[i][j]);
    
    rep(k, 10)rep(i, 10)rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    
    lint ans = 0;
    rep(i, h)rep(j, w){
        int a;
        scanf("%d", &a);
        if(a >= 0) ans += c[a][1];
    }
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){

ios::sync_with_stdio(false);
cin.tie(0);
long long int a,b,c;
cin>>a>>b>>c;

swap(a,b);swap(a,c);

cout<<a<<" "<<b<<" "<<c<<endl;


}


Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Feb  9 21:11:40 2019
//
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	num := 0
	for i := 1; i <= N; i += 2 {
		num++
	}
	if num >= K {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------






int main(void)
{
	float n;
	cin >> n;

	cout <<ceil( n / 2) << endl;
	
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int a,b,c;
  int sw;

  scanf("%d %d %d",&a,&b,&c);

  if(a > b){
    sw = a;
    a = b;
    b = sw;
  }

  if(a > c){
    sw = a;
    a = c;
    c = sw;
  }

  if(b > c){
    sw = b;
    b = c;
    c = sw;
  }

  printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2096
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

bool ok(bool field[21][21]){
    for(int i=0; i<21; i++){
        for(int j=0; j<21; j++){
            if(!field[i][j]){
                return false;
            }
        }
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    map<char, int> dh = {{'N',1}, {'S',-1}, {'W',0}, {'E',0}};
    map<char, int> dw = {{'N',0}, {'S',0}, {'W',-1}, {'E',1}};
    
    int N, M;
    while(cin>>N, N){
        bool field[21][21];
        memset(field, true, sizeof(field));
        
        for(int i=0; i<N; i++){
            int h, w;
            cin >> w >> h;
            field[h][w] = false;
        }
        
        int h = 10, w = 10;
        
        cin >> M;
        for(int i=0; i<M; i++){
            char c;
            int d;
            cin >> c >> d;
            for(int j=0; j<d; j++){
                h += dh[c];
                w += dw[c];
                field[h][w] = true;
            }
        }
        
        cout << (ok(field) ? "Yes" : "No") << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1200
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let (n,k) = read!(usize,usize);
    let mut seen = vec![false;n];
    for i in 0..k {
        let d = read!(usize);
        let a = read!([usize]);
        for j in a {
            seen[j-1] = true;
        }
    }
    let mut ans = 0;
    for i in 0..n {
        if !seen[i]{
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn run() {
    solve();
}


Measured memory_bytes: 2236
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let A = (0..N).map(|_| buf_it.next().unwrap().parse::<usize>().unwrap()).collect::<Vec<_>>();

    let m = 10000;
    let mut ans = 0;
    let primes = get_primes(m);
    for &a in &A{
        if a <= m{
            if primes.contains(&a) { ans += 1;}
        } else {
            let mut check = true;
            for &p in &primes{
                if a%p==0{
                    check = false;
                    break;
                }
            }
            if check {ans += 1;}
        }
    }
    println!("{}",ans);

}

fn get_primes(n:usize)->HashSet<usize>{
    let mut ret = HashSet::new();
    let mut checked = vec![false;n+1];
    for i in 2..n+1{
        if checked[i] {continue;}
        ret.insert(i);
        for j in 1..(n/i)+1{
            checked[i*j] = true;
        }
    }
    ret
}


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

int main(int argc, char **argv)
{
    long long N, K;
    std::cin >> N >> K;
    std::vector<int> A(N);

    for(int i = 0; i < N; i++){
        std::cin >> A.at(i);
    }

    std::vector<bool> B(N, false);

    //std::cout << "K=" << K << std::endl;
    //std::cout << "A.size=" << A.size() << std::endl;
    //std::cout << "B.size=" << B.size() << std::endl;
    
    int pt = 1;
    int loop_top = 0;
    long long prefix = 0;
    for(;;){
        //std::cout << " " << pt << std::endl;
        B.at(pt-1) = true;
        pt = A.at(pt-1);
        prefix++;
        if(B.at(pt-1) == true){
            loop_top = pt;
            break;
        }
    }

    //std::cout << "loop:" << loop_top << std::endl;
    //std::cout << "prefix:" << prefix << std::endl;

    if(K <= prefix){
        int pt = 1;
        for(int i = 0; i < K; i++){
            pt = A.at(pt-1);
        }
        std::cout << pt << std::endl;
        return 0;
    }

    std::vector<int> loop;
    std::vector<bool> C(N, false);
    int li = loop_top;
    for(;;){
        C.at(li-1) = true;
        li = A.at(li-1);
        loop.push_back(li);
        if(C.at(li-1) == true){
            break;
        }
    }
    
    //for(int i = 0; i < loop.size(); i++){
    //   std::cout << " " << loop.at(i);
    //}
    //std::cout << std::endl;
    
    long long rest = K - prefix;
    long long index = (rest-1) % loop.size();

    //std::cout << "index=" << index << std::endl;

    std::cout << loop.at(index) << std::endl;
    
}


Measured memory_bytes: 4584
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

double radius(vector<double> center, vector<double> xy){
    double x, y;
    x = xy[0] - center[0];
    y = xy[1] - center[1];
    return sqrt(pow(x,2) + pow(y,2));    
}

vector<double> center(vector<double> coo){
    double a1, b1, c1, a2, b2, c2, x, y;
    a1 = 2 * (coo[2] - coo[0]);
    b1 = 2 * (coo[3] - coo[1]);
    c1 = pow(coo[0],2) - pow(coo[2],2) + pow(coo[1],2) - pow(coo[3],2); 
    
    a2 = 2 * (coo[4] - coo[0]);
    b2 = 2 * (coo[5] - coo[1]);
    c2 = pow(coo[0],2) - pow(coo[4],2) + pow(coo[1],2) - pow(coo[5],2);
    
    x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
    y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
    
    vector<double> cent = {x,y};
    double rad = radius(cent, coo);
    return {x,y, rad};
    
}



int main(){
    int n;
    vector<double> v = {0,0,0,0,0,0};
    cin >> n;
    while(cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5]){
        vector<double> c = center(v);
        cout << fixed << setprecision(3) << c[0] << " " << c[1] << " " << c[2] << endl;
    }
}

Measured memory_bytes: 3148
n,m,r=map(int,input().split())
road=list(map(int,input().split()))
cost=[[float("inf")]*n for i in range(n)]
for i in range(n):
    cost[i][i]=0
for i in range(m):
    
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    cost[a][b]=c
    cost[b][a]=c
for k in range(n):
    for i in range(n):
        for j in range(n):
            cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
import itertools
ans=float("inf")
for i in itertools.permutations(road):
    tmp=0
    for j in range(len(i)-1):
        tmp+=cost[i[j]-1][i[j+1]-1]
    if tmp<ans:
        ans=tmp
print(ans)

Measured memory_bytes: 75732
#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(){
    ll h, w;
    cin >> h >> w;
    ll ans = 0;
    
    if(h == 1){
        cout << 1 << endl;
        return 0;
    }
    if(w == 1){
        cout << 1 << endl;
        return 0;
    }

    ans += (h/2 + h%2) * (w/2 + w%2);
    ans += (h/2) * (w/2);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
int main(void){
    int N;
    int K;
    int height;
    int count=0;
    scanf("%d",&N);
    scanf("%d",&K);
    for(int i=0;i<N;i++)
    {
        scanf("%d",&height);
        if(height>=K)
        {
            count++;
        }
    }
    printf("%d",count);
    

   return 0;
}

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

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  
  int max=H;
  int min=W;
  if(max<W){
    max=W;
    min=H;
  }
  for(int i=1;i<min+1;i++){
    if(max*i>=N){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;


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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    string s;
    cin >> s;

    string s2 = "";
    trav(ch,s){
        if(ch == 'P'){
            s2 += 'P';
        }
        else{
            s2 += 'D';
        }
    }

    cout << s2 << "\n";

    return 0;
}


Measured memory_bytes: 3896
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  Node y;
  y=x;
  while(y->left!=NIL) y=y->left;

  return y;

}

Node treeMaximum(Node x){
 Node y;
  y=x;
  while(y->left!=NIL) y=y->right;

  return y;

}

Node treeSearch(Node u, int k){
  Node x;
  x=u;

  while(x!=NIL && k!=x->key){
    if(k < x->key)x=x->left;
    else x=x->right;
  }

  return x;

}

Node treeSuccessor(Node x){
  Node y;

  if(x->right!=NIL)return treeMinimum(x->right);

  y=x->p;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->p;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->p=y->p;
  if(y->p==root)root=x;
  else if(y == y->p->left)y->p->left=x;
  else y->p->right=x;

  if(y!=z) z->key=y->key;
  free(y);

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(k < x->key)x=x->left;
    else x=x->right;
  }
  z->p=y;

  if(y==NIL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right=z;

}

void inorder(Node u){
  if (u==NIL)return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
if (u==NIL)return;

 printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  Node t;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
       t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");

    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 20536
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<pair<int, int> , pair<int, int> > PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N;
char s[1000];

signed main()
{
    cin >> N;
    bool flag = false;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        if(s[i] == 'Y'){
            flag = true;
        }
    }
    if(flag){
        printf("Four\n");
    }
    else{
        printf("Three\n");
    }

    return 0;
}
/*


*/


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

int main(void)
{
    int n;
    vector<P> a;
    int i;

    cin >> n;

    a.resize(n);

    rep(i, 0, n)
    {
        cin >> a[i].first;
        a[i].second = i + 1;
    }

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

    rep(i, 0, n)
    {
        cout << a[i].second << endl;
    }
}

Measured memory_bytes: 2432
import fractions
A,B,C,D = map(int,input().split())
F = fractions.gcd(C,D)
E = C*D//F
if (A%C == 0) or (A%D == 0) :
  print((B-A)-(B//C)-(B//D)+(B//E)+(A//C)+(A//D)-(A//E))
else :
  print((B-A+1)-(B//C)-(B//D)+(B//E)+(A//C)+(A//D)-(A//E))



Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N=0;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<vec.size();i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  int count=0;
  for (int i=0; i<vec.size()-1;i++){
    if(vec.at(i)==vec.at(i+1)){
      count++;
    }
  }
  
  cout << N - count << endl;
}

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

Measured memory_bytes: 26236
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 1000000010

signed main() {
    string s; cin >> s;
    int d = s.size();

    if(d == 1) {
        cout << s[0] - '0' << endl;
        return 0;
    }

    int ans = 0;
    int a = s[0] - '0';
    ans += (a - 1) + 9 * (d - 1);

    string t = s.substr(1, d - 1);
    sort(t.begin(), t.end());
    t.erase(unique(t.begin(), t.end()), t.end());
    if(stoi(t) == 9) {
        cout << a + 9 * (d - 1) << endl;
        return 0;
    }

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


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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

const int maxn = 5e5 + 233;
char s[maxn];
int n;
int res[maxn];

int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    int sum = 0;
    for(int i = 1; i <= n; i++){
        if(s[i] == '<') sum++;
        else sum = 0;
        res[i + 1] = max(res[i + 1], sum);
    }
    sum = 0;
    for(int i = n; i >= 1; i--){
        if(s[i] == '>') sum++;
        else sum = 0;
        res[i] = max(res[i], sum);
    }
    ll ans = 0;
    for(int i = 1; i <= n + 1; i++) ans += res[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2688
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String hi = scanner.next();
        Matcher m = Pattern.compile("[\\s\\S]{1,2}").matcher(hi);
        boolean a = true;
        while (m.find()) {
            if (!m.group().equals("hi")) {
                a = false;
                break;
            }
        }
        if (a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21204