akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int j = 1;
    for (int i = 1; i <= n; i++){
        // 3の倍数の時
        if(i % 3 == 0){
            cout << " " << i ;
        }
        // 3のつく数字の時
        else{
            j = i;
            while(j){
                if(j % 10 == 3){
                    cout << " " << i ;
                    break;
                }
                else{
                    j = j / 10;
                }
            }
        }
    }
    cout << endl;    
    return 0;
}



Measured memory_bytes: 3096
#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 n;
    scanf("%d", &n);
    lint x[n];
    rep(i, n) scanf("%d", &x[i]);
    
    lint ans = 1;
    int d, cnt;
    cnt = 0;
    rep(i, n){
        d = x[i];
        ++cnt;
        if(d < 2*cnt-1) (ans *= (cnt--)) %= mod;
    }
    
    rep(i, cnt) (ans *= 1LL * (i+1)) %= mod;
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

typedef pair<int, int> P;

#define mind(a, b) (a < b ? a : b)
#define maxd(a, b) (a < b ? b : a)
#define N 200005

int dmin[N], dmax[N];

int n, m;
vector<P> ps;

int main() {
    cin >> n >> m;
    for(int i=0; i<m; ++i) {
        int x, y;
        cin >> x >> y;
        ps.push_back(P(x, y));
    }
    sort(ps.begin(), ps.end());

    for(int i=0; i<n; ++i) {
        dmin[i] = dmax[i] = i;
    }

    for(int i=0; i<m; ++i) {
        P p = ps[i];
        int x = p.first, y = p.second;
        dmax[y-1] = dmax[y] = maxd(dmax[y-1], dmax[y]);
        dmin[y-1] = dmin[y] = mind(dmin[y-1], dmin[y]);
    }
    for(int i=0; i<n; ++i) {
        cout << (i ? " " : "") << (dmax[i] - dmin[i] + 1);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 5188
from bisect import bisect_left
N = int(input())
A_list = [0] * N
for i in range(N):
    A_list[i] = int(input())

res_list = [-1] * N
for i in range(N):
    j = bisect_left(res_list, A_list[i])
    res_list[j - 1] = A_list[i]

res = 0
for i in range(N):
    if res_list[i] >= 0:
        res += 1

print(res)


Measured memory_bytes: 48512
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,a[100000],t,tot,dp[18][100000],x,y,L;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<18;i++)dp[i][n-1]=-1;
    cin>>m;
    t=0;
    for(int s=0;s<n-1;s++){
        while(t+1<n&&a[t+1]<=a[s]+m){
            t++;
        }
        if(t==n)dp[0][s]=-1;
        else dp[0][s]=t;
    }
    for(int i=1;i<18;i++){
        for(int j=0;j<n;j++){
            ll L=i;
            ll LL=j;
            for(int k=L-1;k>=0;k--){
                LL=dp[k][LL];
                if(LL==-1){dp[i][j]=-1;break;}
            }
            if(dp[i][j]==0)dp[i][j]=dp[0][LL];
        }
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<n;j++){
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        ll ans=0;
        cin>>x>>y;
        x--,y--;
        if(x>y)swap(x,y);
        while(1){
            if(dp[0][x]>=y||dp[0][x]==-1){
                cout<<ans+1<<endl;break;
            }
            for(int j=1;j<18;j++){
                if(dp[j][x]>=y||dp[j][x]==-1){
                    L=j;
                    break;
                }
            }
            //if(L==0){cout<<ans+1<<endl;break;}
            L--;
            x=dp[L][x];
            ans+=(1<<L);
        }
    }
}


Measured memory_bytes: 15616
# -*- coding: utf-8 -*-

"""
参考：https://www.hamayanhamayan.com/entry/2018/01/28/231916
・深さ優先
・幅優先とほとんど一緒だけど練習用にこっちも書いた。
"""

import sys

# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)

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

l_edges = [[] for i in range(N)]
r_edges = [[] for i in range(N)]
for i in range(M):
    l, r, d = map(int, input().split())
    l_edges[l-1].append((r-1, d))
    r_edges[r-1].append((l-1, d))

# 訪問済メモ
visited = [0] * N

def dfs(cur):
    visited[cur] = 1
    # 左から見た右側を確認
    for r, d in l_edges[cur]:
        # 訪問済なら矛盾がないか検証する
        if visited[r]:
            if pos[r] - pos[cur] != d:
                print('No')
                exit()
        # 未訪問なら今回の情報を記録する
        else:
            visited[r] = 1
            pos[r] = pos[cur] + d
            # 確認した位置を次の現在位置として見に行く
            dfs(r)
    # 右から見た左側を確認
    for l, d in r_edges[cur]:
        if visited[l]:
            if pos[cur] - pos[l] != d:
                print('No')
                exit()
        else:
            visited[l] = 1
            pos[l] = pos[cur] - d
            dfs(l)

for i in range(N):
    # 訪問済(確認済)でなければ走破しに行く
    if not visited[i]:
        # この開始位置を基準とした相対位置を記録する
        pos = {i: 0}
        dfs(i)
        pos = {}
# 最後まで矛盾がなければOK
print('Yes')


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

    int main();
    int operation();
    int judge();

    int main(){
        int count = 0;
        int N;
        int r = 0;
        int j = 1;
  //      printf("%s","Nを入力してください");
         scanf("%d",&N);
   
    int a[N];
    int i = 0;
  //   printf("%s","数列を入力してください\n");
     while(i< N){
          scanf("%d",&a[i]);
          i++;
        }

 
    
    while(j>0){
        i = 0;
        j = 0;
        while(i<N){
            r = r + judge(a[i]);
            a[i] = operation(a[i]);
            j = j + judge(a[i]);
            i++;
        }
    } 
    

    printf("%d%s",r,"\n");
    
}
    
int operation(int a){
      if(a%2 == 0){
          a = a/2;
      }else{
          a = a*3;
      }

     return a;
    
 }

int judge(int a){
    int r = 0;
    if(a%2 == 0){
        r = 1;
    }
    return r;
}

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

int n;
std::vector <int> ve;
std::vector <int> ret;

int main(){
#ifdef Ezio
	freopen("input","r",stdin);
#endif

	scanf("%d",&n);
	for(int i=0,x;i<n;i++){
		scanf("%d",&x);
		ve.push_back(x);
	}

	while(n){
		int i;
		for(i=n-1;~i;i--)
			if(ve[i]==i+1){
				ve.erase(ve.begin()+i);
				ret.push_back(i+1);
				break;
			}
		if(i==-1)return puts("-1"),0;
		n--;
	}

	while(ret.size()){
		printf("%d\n",ret.back());
		ret.pop_back();
	}
	
	return 0;
}


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

using namespace std;
const int N = 1e5 + 3 , OO = 0x3f3f3f3f ;
int arr[N] , mem[N];
int n ;
int solve(int idx){
    if(idx == n-1) return 0;
    int &ret = mem[idx];
    if(~ret) return ret;
    ret = OO;
    if(idx == n -2) ret = min(ret , abs(arr[idx] - arr[idx+1]) + solve(idx +1));
    else
        ret = min(ret , min( abs(arr[idx] - arr[idx+1]) +solve(idx +1) ,  abs(arr[idx] - arr[idx+2])  + solve(idx +2)));
    return ret;
}
int main()
{
    cin >> n;
    for(int i = 0 ; i < n ; ++i) cin >> arr[i];
    memset(mem , -1 , sizeof mem);
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[100000];
ll ans[100000];
ll f(ll n)
{
    if(ans[n]!=-1) return ans[n];
    if(n==0) {ans[0]=0; return ans[0];}
    if(n==1) {ans[1]=abs(a[1]-a[0]); return ans[1];}
    ans[n]=min(f(n-1)+abs(a[n]-a[n-1]),f(n-2)+abs(a[n]-a[n-2]));
    return ans[n];
}

int main() {
    ll n;
    cin>>n;
    for(ll i=0;i<100000;i++) ans[i]=-1;
    for(ll i=0;i<n;i++) cin>>a[i];
    
    cout<<f(n-1);
	
	return 0;
}


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
x = int(input())

for a in range(-118, 120):
    for b in range(-119, 119):
        diff = a**5 - b**5
        # print(diff)
        if diff == x:
            print (str(a) + " " + str(b))
            break
    else:
        continue
    break


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

using namespace std;

typedef long long int ll;

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

  int h, w, n;
  cin >> h >> w >> n;
  vector < ll > cnt(10, 0);
  cnt[0] = (ll)(h - 2) * (w - 2);

  map < pair < int, int >, int > mp;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    for (int p = max(1, a - 2); p <= a && p <= h - 2; p++) {
      for (int q = max(1, b - 2); q <= b && q <= w - 2; q++) {
        cnt[mp[{p, q}]]--;
        mp[{p, q}]++;
        cnt[mp[{p, q}]]++;
      }
    }
  }

  for(int i = 0; i < 10; i++) cout << cnt[i] << '\n';
}


Measured memory_bytes: 56576
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s=0,d=0,f=0,g,h,i,j;
	scanf("%d",&a);
	s=a/15;
	d=a*800;
	f=s*200;
	d=d-f;
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define MAXN (100)
#define LL long long
#define abs(a) (((a) > 0) ? (a) : (-(a)))
using namespace std;
const char print[] = {'.', '#'};
int n;
bool a[MAXN + 5][MAXN + 5], change = false;
int main()
{
	int ta, tb;
	scanf("%d%d", &ta, &tb);
	if (!ta || !tb)
	{
		printf(ta ? "." : "#");
		return 0;
	}
	for (int i = 1; i <= MAXN; i++)
	for (int j = 1; j <= MAXN; j++)
	{
		if (i <= (MAXN / 2))	a[i][j] = false;
		else	a[i][j] = true;
	}
	int cnta = 1, cntb = 1;
	for (int i = 1; i <= MAXN; i += 2)
	{
		for (int j = 1; j <= MAXN; j += 2)
		{
			if (cntb >= tb)
				break;
			a[i][j] = true;
			++cntb;
		}
		if (cntb >= tb)
			break;
	}
	for (int i = MAXN; i >= 1; i -= 2)
	{
		for (int j = MAXN; j >= 1; j -= 2)
		{
			if (cnta >= ta)
				break;
			a[i][j] = false;
			++cnta;
		}
		if (cnta >= ta)
			break;
	}
	printf("%d %d\n", MAXN, MAXN);
	for (int i = 1; i <= MAXN; i++)
	{
		for (int j = 1; j <= MAXN; j++)
			printf("%c", print[a[i][j] ^ change]);
		puts("");
	}
	return 0;
}

/*
#.#.#.
.#.#.#
#.#.#.
......
......
#.#.#.
*/

Measured memory_bytes: 256
import sys

def get_min_cost(n, p):
	m = [[0 for x in range(n+1)] for x in range(n+1)]
	for s in range(n):
		i = 1
		for j in range(s+2, n+1):
			m[i][j] = sys.maxsize
			for k in range(i, j):
				m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
			i+=1	
	return m[1][n]

n = int(input())
p = [0] * (n+1)
j = 0
for i in range(n):
	a = list(map(int, input().split()))
	if i == 0:
		p[j] = a[0]
		j += 1
	p[j] = a[1]
	j += 1
print(get_min_cost(n, p))
		
		


Measured memory_bytes: 5724
#include<string>
#include<list>
#include<iostream>

using namespace std;

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it = data.begin(),l = data.end(); it != l; ++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it = data.begin(), l = --data.end(); it != l; ++it) cout << *it << " ";
  cout << *it << endl;
}



Measured memory_bytes: 34460
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200100;
struct node{
	int p,x;
}a[maxn];
bool cmp(const node &A,const node &B){
	return A.x<B.x;
}
int mp[maxn];
int num;
int L[maxn],R[maxn];
int LL[maxn],RR[maxn];
bool vis[maxn];
int stk[maxn],top;
int xx;
bool dfs(int u){
	if(vis[u]) return 1;
	if(vis[u^1]) return 0;
	stk[++top]=u;
	vis[u]=1;
	for(int i=L[mp[u]];i<=R[mp[u]];i++)
	{
		if(a[i].p==u) continue;
		if(!dfs(a[i].p^1)) return 0;
	}
	return 1;
}
int n;
int c[maxn];
bool pd(int x){
	xx=x;
	int pos=1;
	for(int i=1;i<=num;i++){
		while(a[i].x-a[pos].x>=x) pos++;
		L[i]=pos;
	}
	pos=num;
	for(int i=num;i>=1;i--){
		while(a[pos].x-a[i].x>=x) pos--;
		R[i]=pos;
	}
	for(int i=1;i<=n;i++)
		vis[i<<1|1]=vis[i<<1]=0;
	for(int i=1;i<=n;i++){
		if(vis[i<<1]||vis[i<<1|1]) continue;
		top=0;
		if(!dfs(i<<1)){
			for(int j=0;j<=top;j++)
				vis[stk[j]]=0;
			top=0;
			if(!dfs(i<<1|1)) return 0;
		}
	}
	return 1;
}
int main(){
//	freopen("A.in","r",stdin);
//	freopen("A.out","w",stdout);
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		a[++num]=(node){i<<1,x};
		scanf("%d",&x);
		a[++num]=(node){i<<1|1,x};
	}
	sort(a+1,a+num+1,cmp);
	for(int i=1;i<=num;i++)
		mp[a[i].p]=i;
	int l=0,r=1000000001,mid;
	while(r-l>1)
	{
		mid=(l+r)>>1;
		if(pd(mid)) l=mid;
		else r=mid;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    if (a == b && a != c)
    {
        cout << "Yes\n";
    }
    else if (a == c && a != b)
    {
        cout << "Yes\n";
    }
    else if (b == c && a != b)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		boolean[] isSafe=new boolean[n+1];
		Arrays.fill(isSafe, true);
		
		for(int i=0;i<m;i++) {
			isSafe[sc.nextInt()]=false;
		}
		long dp[] = new long[n+1];
		Arrays.fill(dp, 0);
		dp[0]=1;
		dp[1]=1;
		if(!isSafe[1]) dp[1]=0;
		for(int i=2;i<n+1;i++) {
			if(!isSafe[i])continue;
			dp[i]=(dp[i-1]+dp[i-2])%1000000007;
					 
		}
		System.out.println(dp[n]);
	}
}


Measured memory_bytes: 50292
//
//  main.cpp
//  CppTest
//
//  Created by M_Sugawara on 2019/12/22.
//  Copyright © 2019 Sugawar. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    int count;
    vector<int> bricks;

    int result = 0;

    cin >> count;

    for (int i=0; i<count; i++) {
        int brick;
        cin >> brick;
        bricks.push_back(brick);
    }

    int countOfOrder = 1;
    int countOfKeepBricks = 0;
    for (int i=0; i<bricks.size(); i++) {
        if (bricks[i] == countOfOrder) {
            countOfKeepBricks++;
            countOfOrder++;
        }
    }

    if (countOfOrder != 1) {
        result = int(bricks.size()) - countOfKeepBricks;
    } else {
        result = -1;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1;
	string s2;
	cin>>s1>>s2;
	int a=s1.size();
	int b=s2.size();
	int dp[a+1][b+1];
	pair<int,int> parent[a+1][b+1] ;
	
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			if(i==0 || j==0){dp[i][j]=0;parent[i][j]={-1,-1};}
			else{
				if(s1[a-i]==s2[b-j]){dp[i][j]=1+dp[i-1][j-1];parent[i][j]={i-1,j-1};}
				else{
					if(dp[i-1][j]>dp[i][j-1]){dp[i][j]=dp[i-1][j];parent[i][j]={i-1,j};}
					else{dp[i][j]=dp[i][j-1];parent[i][j]={i,j-1};}
					}
				}
				
			}
		}
	string ans="";
	int i=a;
	int j=b;
	pair<int,int> temp={-1,-1};
	pair<int,int> p=parent[i][j];
	//for(int k1=0;k1<=2;k1++){
		//for(int k2=0;k2<=2;k2++){cout<<parent[k1][k2].first<<" "<<parent[k1][k2].second<<endl;}}
	while(p!=temp){
		pair<int,int> k={i-1,j-1};
		if(p==k){ans+=s1[a-i];tie(i,j)=parent[i][j];p=parent[i][j];}
		else{tie(i,j)=parent[i][j];p=parent[i][j];}
		}
	cout<<ans<<endl;
	
		}
		





Measured memory_bytes: 105856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  ll k = 0;
  for (ll i = 2; i*(i-1)/2 <= n; i++) {
    if (i*(i-1)/2 == n) {
      k = i;
      break;
    }
  }

  if (k == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl << k << endl;
    vector<vl> s(k);
    ll cnt = 1;
    for (ll i = 0; i < k; i++) {
      for (ll j = i+1; j < k; j++) {
        s[i].push_back(cnt);
        s[j].push_back(cnt);
        cnt++;
      }
    }

    rep(i, k) {
      cout << s[i].size() << " ";
      rep(j, s[i].size()) {
        cout << s[i][j] << " \n"[j == s[i].size()-1];
      }
    }
  }
}


Measured memory_bytes: 3200
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let vs = scan!(i64;n);
    let mut dp = (0..n + 1)
        .map(|_| vec![false; n * 100 + 1])
        .collect::<Vec<Vec<_>>>();

    dp[0][0] = true;
    for (i, &v) in vs.iter().enumerate() {
        for j in 0..dp[i].len() {
            if dp[i][j] {
                if (j + v as usize) < dp[i].len() {
                    dp[i + 1][j + v as usize] = true
                }
                dp[i + 1][j] = true
            }
        }
    }

    println!(
        "{}",
        dp[n]
            .iter()
            .enumerate()
            .filter(|&(i, v)| (i == 0 || i % 10 != 0) && *v)
            .last()
            .unwrap()
            .0
    )
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    string a, b, c;
    cin >> a >> b >> c;
    
    cout << (a[a.size()-1] == b[0] && b[b.size()-1] == c[0] ? "YES" : "NO") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        if(a%2){
            cout << 0 << endl;
        }else{
            cout << -1 << endl;
        }
    }else{
        int count = 0;
        while(true){
            if(a % 2 || b % 2 || c % 2) break; 
            int ra = a / 2;
            int rb = b / 2;
            int rc = c / 2;
            a = rb + rc;
            b = ra + rc;
            c = ra + rb;
            count++;
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;

int a, b, c, minv = 1000000;
int n[3];

int main(){
    
    cin >> n[0] >> n[1] >> n[2];
    
    for ( int i = 0; i < 3; i++ ) {
        for ( int j = 0; j < 3; j++ ) {
            if ( i==j ) continue;
            for ( int k = 0; k < 3; k++ ) {
                if ( i==k || j==k ) continue;
                a = n[i]; b = n[j]; c = n[k];
                minv = min( minv, abs(b-a)+abs(c-b));
            }
        }
    }
    cout << minv << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
 
long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}
 
long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}
 
long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}
 
bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}
 
void dfs(const vector<vector<int>> &G, int v, vector<int> &seen) {
    seen[v] = true;
 
    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}
 
void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}
 
 
 
int main() {
  
  int r; cin >> r;
  
  cout << 2 * r * M_PI;
 
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
   long n,a=0,b=0,c=0,d=0;
   cin >> n;
   for (int i=1; i<=n; i++)
    {
        string s;
        cin >> s;
        if (s=="AC")
        {
            ++a;
        }
        if (s=="WA")
        {
            ++b;
        }
        if (s=="TLE")
        {
            ++c;
        }
        if (s=="RE")
        {
           ++d;
    }
       }
        cout << "AC x "<<a<<"\n";
        cout << "WA x "<<b<<"\n";
        cout << "TLE x "<<c<<"\n";
        cout << "RE x "<<d<<"\n";
   return 0;
}

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

using namespace std;

const int N=4010;

int n;
string s;
int qr[N],qg[N],qb[N];
int hr[N],hg[N],hb[N];

int main()
{
	cin>>n;
	cin>>s;
	s=" "+s;
	
	int r=0,g=0,b=0;
	for(int i=1;i<=n;i++) {
		qr[i]=qr[i-1];
		qg[i]=qg[i-1];
		qb[i]=qb[i-1];
		if(s[i-1]=='R') qr[i]=qr[i-1]+1;
		if(s[i-1]=='G') qg[i]=qg[i-1]+1;
		if(s[i-1]=='B') qb[i]=qb[i-1]+1;
	}
	for(int i=n;i>=1;i--) {
		hr[i]=hr[i+1];
		hg[i]=hg[i+1];
		hb[i]=hb[i+1];
		if(s[i+1]=='R') hr[i]=hr[i+1]+1;
		if(s[i+1]=='G') hg[i]=hg[i+1]+1;
		if(s[i+1]=='B') hb[i]=hb[i+1]+1;
	}
//	cout<<"\ngg\n";
//	for(int i=1;i<=n;i++) {
//		cout<<qr[i]<<' '<<qg[i]<<' '<<qb[i]<<'\n';
//	}
//	cout<<"gg\n";
	long long int sum=0,res;
	for(int j=2;j<n;j++) {
		res=0;
		if(s[j]=='G') {
			res+=qr[j]*hb[j];
			res+=qb[j]*hr[j];
		}
		if(s[j]=='B') {
			res+=qr[j]*hg[j];
			res+=qg[j]*hr[j];
		}
		if(s[j]=='R') {
			res+=qg[j]*hb[j];
			res+=qb[j]*hg[j];
		}
		for(int i=j-1,k=j+1;i>=1&&k<=n;i--,k++) {
			if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]&&(j-i)!=(j-k)) res--;
		}
		sum+=res;
	}
	cout<<sum<<'\n';
} 

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();	
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
//ruogu_alter
#define int ll 
const int N = 1005;
int dx[] = {0, 1, -1, 0};
int dy[] = {1, 0, 0, -1};
string hh = "DLRU";
int n, a[N], b[N];
bool flag[2];
string res;
//
signed main() {
  int q = getint();
  rep(i, q) {
    a[i] = getint(), b[i] = getint();
    flag[a[i] + b[i] & 1] = true;
  }
  if (flag[0] && flag[1]) return !printf("%d\n", -1);
  printf("%d\n", 31 + flag[0]);
  rep(i, 31) printf("%d ", (1 << i));
  if (flag[0]) printf("%d ", 1);
  printf("\n");
  rep(iii, q) {
    string res = "";
    int x = a[iii], y = b[iii];
    if (flag[0]) {
      --x; 
      res += 'R';
    }
    for (int i = 30; i >= 0; i--) {
      rep(j, 4) {
        int fx = x + dx[j] * (1 << i), fy = y + dy[j] * (1 << i);
        if (abs(fx) + abs(fy) < (1 << i)) {
          res += hh[j];
          x = fx; y = fy;
          break;
        }
      }
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int maxIdx = 0;
		int min = Integer.MAX_VALUE;
		int minIdx = 0;
		for (int i = 1; i <= n; i++) {
		    int x = sc.nextInt();
		    if (max < x) {
		        max = x;
		        maxIdx = i;
		    }
		    if (min > x) {
		        min = x;
		        minIdx = i;
		    }
		}
		boolean reverse;
		StringBuilder sb = new StringBuilder();
		if (min >= 0) {
		    sb.append(n - 1).append("\n");
		    reverse = false;
		} else if (max <= 0) {
		    sb.append(n - 1).append("\n");
		    reverse = true;
		} else if (Math.abs(min) <= Math.abs(max)) {
		    sb.append(n * 2 - 1).append("\n");
		    for (int i = 1; i <= n; i++) {
		        sb.append(maxIdx).append(" ").append(i).append("\n");
		    }
		    reverse = false;
		} else {
		    sb.append(n * 2 - 1).append("\n");
		    for (int i = 1; i <= n; i++) {
		        sb.append(minIdx).append(" ").append(i).append("\n");
		    }
		    reverse = true;
		}
		if (reverse) {
		    for (int i = n - 1; i >= 1; i--) {
		        sb.append(i + 1).append(" ").append(i).append("\n");
		    }
		} else {
		    for (int i = 2; i <= n; i++) {
		        sb.append(i - 1).append(" ").append(i).append("\n");
		    }
		}
       System.out.print(sb);
   }
}




Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
int n,a[200005];
int now[200005];
vector <int> v;
int main()
{
	scanf("%d",&n);
	bool ok=1;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i-1]>=a[i])
		    ok=0;
	}	   
	if(ok) 
	{
		cout<<1;
		return 0;
	}
	int l=1,r=n+1; 
	while(l+1<r)
	{
		int m=(l+r)/2;
        ok=1;
		int len=0;
		map<int,int>f;
		for(int i=0;i<n;i++)
		{
			if(a[i]>len)
			    len=a[i];
			else
			{
				while(!f.empty()&&f.rbegin()->first>=a[i])
				    f.erase(f.rbegin()->first);
				f[a[i]-1]++;
				int cur=a[i]-1;
				while(f[cur]>=m)
				{
					f.erase(cur);
					cur--;
					f[cur]++;
					if(cur<0)
					    ok=0;					
				}
				if(!ok)
					break;
				len=a[i];
			}			
		}
		if(ok)
		    r=m;
		else
		    l=m;
	}
	cout<<r;
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    vector<P> v;
    for(int i = 0; i < N; i++){
        long long int A;
        cin >> A;
        v.push_back(P(A, i));
    }
    sort(v.begin(), v.end());
    long long int ans = 0;
    for(int i = 0; i < N; i += 2){
        if(v[i].second % 2 == 1){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
X,Y,Z,K=map(int,input().split())
Ax=sorted(list(map(int,input().split())), reverse=True)
By=sorted(list(map(int,input().split())), reverse=True)
Cz=sorted(list(map(int,input().split())), reverse=True)

a=b=c=0
s = set([(a,b,c)])
t = set()
for k in range(K):
    best_value = 0
    best_tuple = None
    for x,y,z in s:
        if (x,y,z) not in t:
            m = Ax[x]+By[y]+Cz[z]
            if m > best_value:
                best_value = m
                best_tuple = (x,y,z)
    print(best_value)

    t.add(best_tuple)
    s.remove(best_tuple)
    x,y,z=best_tuple
    if x < X-1:
        if (x+1,y,z) not in s:
            s.add((x+1,y,z))
    if y < Y-1:
        if (x,y+1,z) not in s:
            s.add((x,y+1,z))
    if z < Z-1:
        if (x,y,z+1) not in s:
            s.add((x,y,z+1))


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

int main() {

	int n; cin >> n;
	const int p = 9;
	string ans = "No";
	for (int i = 1; i <= p; i++) {
		for (int j = 1; j <= p; j++) {
			if (i * j == n) ans = "Yes";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<algorithm>
#include<set>

using namespace std;

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

 int n = 0;
 cin >> n;
 cin.ignore();

 set<string> dic;

 for(int i = 0; i < n; i++){
  string buf;
  getline(cin, buf);
  if(buf[0] == 'i'){
    dic.insert(buf.substr(7));
  }else{
   if(dic.find(buf.substr(5)) != dic.end()){
    cout << "yes" << endl;
   }else{
    cout << "no" << endl;
   }
  }
 }
 return 0;
}

Measured memory_bytes: 27052
def main():
    from collections import deque
    from operator import itemgetter

    s = input()

    tot = 0
    areas = []

    dq = deque()
    for i, c in enumerate(s):
        # print(c, end='')

        if c == '\\':
            dq.append(i)
        elif c == '/':
            if dq:
                j = dq.pop()
                a = i - j
                tot += a

                while areas and areas[-1][0] > j:
                    a += areas.pop()[1]
                areas.append((i, a))

    print(tot)
    print(len(areas), *map(itemgetter(1), areas))


if __name__ == '__main__':
    main()



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    ll n;
    ll num[5];
    cin >> n;
    rep(i, 5) cin >> num[i];

    ll minnum = (ll)(1e16);
    int index;
    rep(i, 5) {
        if (num[i] < minnum) {
            minnum = num[i];
            index = i;
        }
    }

    if (minnum >= n) {
        cout << 5 << endl;
        return 0;
    }

    if (n % minnum == 0) {
        cout << n / minnum + 4 << endl;
    } else {
        cout << n / minnum + 5 << endl;
    }

    return 0;
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, dp[max_n], mx[max_n], p[max_n], tot[max_n];
vector<int> g[max_n], f[max_n];

void dfs0(int v) {
    for (int i = 0; i < g[v].size(); ++i) {
        if (g[v][i] == p[v]) {
            swap(g[v][i], g[v].back());
            g[v].pop_back();
            break;
        }
    }
    for (int i = 0; i < g[v].size(); ++i) {
        p[g[v][i]] = v;
        mx[g[v][i]] = max(mx[v], v);
        dfs0(g[v][i]);
    }
}

int dfs3(int v, int mx) {
    if (v >= mx) {
        return 0;
    }
    int res = 1;
    for (int to : g[v]) {
        res += dfs3(to, mx);
    }
    return res;
}

void dfs1(int v) {
    for (int to : g[v]) {
        dfs1(to);
    }
    f[v].resize(g[v].size());
    if (v < mx[v]) {
        for (int i = 0; i < g[v].size(); ++i) {
            const int to = g[v][i];
            if (to < mx[v]) {
                f[v][i] = tot[to] + 1;
            }
            tot[v] += f[v][i];
        }
    } else {
        for (int i = 0; i < g[v].size(); ++i) {
            f[v][i] = dfs3(g[v][i], mx[v]);
            tot[v] += f[v][i];
        }
    }
    //cout << v << ": " << tot[v] << endl;
}

void dfs2(int v) {
    for (int i = 0; i < g[v].size(); ++i) {
        const int to = g[v][i];
        dp[to] = 1 + dp[v] + tot[to];
        if (to < mx[v]) {
            dp[to] -= f[v][i];
        }
        dfs2(to);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs0(1);
    dfs1(1);
    dfs2(1);
    for (int i = 2; i <= n; ++i) {
        printf("%d ", dp[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 45312
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
#define N 3010
int val[N];
bool win[N];
vector<int> vec[N],ans;
map<int,int> m;
void dfs(int id,int from)
{
	//cout<<id<<" "<<from<<endl;
	for(int i=0;i<vec[id].size();i++)
	{
		int to=vec[id][i];
		if(to==from||val[to]>=val[id]) continue;
		dfs(to,id);
		if(!win[to]) win[id]=true;
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&val[i]);
		//m[val[i]]=i;
	}
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	/*map<int,int>::iterator it=m.end();
	while(true)
	{
		it--;
		int id=(*it).second;
		if(!vis[id]) dfs(id,0);
		if(it==m.begin()) break;
	}*/
	for(int i=1;i<=n;i++)
	{
		memset(win,0,sizeof(win));
		dfs(i,0);
		if(win[i]) ans.push_back(i);
	}
	for(int i=0;i<ans.size();i++) printf("%d ",ans[i]);
}

Measured memory_bytes: 3988
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.

- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:1
*Problem:Shortest Path on a Line
*Date:2019-11-11
*Algorithm:My Set
*Status:Unknown*/

bool debug=false;

template<typename T> struct pq_small{
	priority_queue<T,vector<T>,greater<T> > pq;
	void push(T x){
		pq.push(x);
	}

	void pop(){
		pq.pop();
	}

	int size(){
		return pq.size();
	}

	bool empty(){
		return pq.empty();
	}

	T top(){
		return pq.top();
	}
};

int n,m;

vector<pair<int,ll>> ra[100005];

ll dis[100005];

pq_small<pair<int,ll>> kill;
multiset<ll> val;

const ll inf=1e18;

int main(int argc,char* argv[]){
	qi;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		ra[a].push_back(make_pair(b,c));
	}
	
	for(int i=0;i<n;i++){
		
//		cout<<"Current at "<<i<<endl;
//		for(int j:val){
//			cout<<j<<" ";
//		}
//		cout<<endl;
		
		//value
		if(i==0){
			dis[i]=0;
		}else{
			if(val.empty()){
				dis[i]=inf;
			}else{
				dis[i]=*val.begin();	
			}
			
		}
		
		//remove
		while(!kill.empty()){
			pair<int,ll> last=kill.top();
			if(last.first==i){
				val.erase(val.find(last.second));
//				val.erase(last.second);
				kill.pop();
//				cout<<"Remove:"<<last.second<<endl;
			}else{
				break;
			}
		}
		
		//shoot the bullet
		for(pii x:ra[i]){
			ll v=0ll+x.second+dis[i];
//			cout<<"INsert "<<x.first<<" "<<v<<endl;
			kill.push(make_pair(x.first,v));
			val.insert(v);
		}
		
		
	}
	
	if(dis[n-1]>=inf){
		cout<<"-1";
	}else{
		cout<<dis[n-1]<<endl;	
	}
	
	return 0;
}



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

int main() {
  char str[201];
  int nh, h, is, iis, ih, len;
  while(scanf("%s", str), strcmp(str, "-")) {
    len = strlen(str);
    scanf("%d", &nh);
    for(is = ih = 0; ih < nh; ++ih) {
      scanf("%d", &h);
      is = (is + h) % len;
    }
    for(iis = 0; iis < len; ++iis) printf("%c", str[(is + iis) % len]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 568
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll x,a,b;
        cin>>x>>a>>b;
        ll A=abs(x-a);
        ll B=abs(x-b);
        if(A>B)
        cout<<"B";
        else
        cout<<"A";
    } 
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
int main(void)
{
  int a, b, c, d, e, k;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);
  if(e-a<=k) {
    printf("Yay!");
  }
  else {
    printf(":(");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int rlet;
int n;
int d[255];
vector<int> vec[255],rvec[255];
bool vis[255],rvis[255];

void dfs(int now){
  vis[now]=true;
  for(int i=0;i<vec[now].size();i++){
    if(!vis[vec[now][i]])dfs(vec[now][i]);
  }
}
void rdfs(int now){
  rvis[now]=true;
  for(int i=0;i<rvec[now].size();i++){
    if(!rvis[rvec[now][i]])rdfs(rvec[now][i]);
  }
}

int main(){

  while(1){
    memset(vis,false,sizeof(vis));
    memset(rvis,false,sizeof(rvis));
    cin>>rlet;
    if(!rlet)break;
    cin>>n;
    for(int i=1;i<=n;i++){
      cin>>d[i];
    }

    for(int i=0;i<=n+1;i++){
       vec[i].clear();
       rvec[i].clear();
    }
    /*グラフ化*/
    for(int i=0;i<=n;i++){
      for(int j=1;j<=rlet;j++){
        vec[i].push_back(min(max(i+j+d[i+j],0),n+1));
        rvec[min(max(i+j+d[i+j],0),n+1)].push_back(i);
      }
    }

    dfs(0);
    rdfs(n+1);

    bool ok=true;
    for(int i=0;i<=n;i++){
      if(vis[i]&&!rvis[i])ok=false;
    }

    if(ok)cout<<"OK"<<"\n";
    else cout<<"NG"<<"\n";
  }
  return 0;
}



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

using namespace std;

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") cout << "Cloudy" << endl;
  if (S == "Cloudy") cout << "Rainy" << endl;
  if (S == "Rainy") cout << "Sunny" << endl;

  return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
pt,pa=1,1
N.times do|i|
  t,a=get_i
  dt=(pt+t-1)/t
  da=(pa+a-1)/a
  dm=max(dt,da)
  pt=t*dm
  pa=a*dm
end
puts pt+pa

Measured memory_bytes: 14112
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int a, b;
char c[100][100];
int d[] = { -1,-1,-1,0,0,1,1,1 };
int e[] = { -1,0,1,-1,1,-1,0,1 };
signed main() {
	cout << 100 << " " << 100 << endl;
	cin >> a >> b;
	rep(i, 50) {
		rep(j, 100) {
			c[i][j] = '.';
			c[i + 50][j] = '#';
		}
	}
	int cnt = 0;
	for (int i = 51; i < 100; i++) {
		rep(j, 100) {
			if (cnt == a - 1)goto kaage;
			bool f = false;
			rep(k, 8) {
				if (0 <= i + d[k] && i + d[k] < 100 && 0 <= j + e[k] && j + e[k] < 100 && c[i + d[k]][j + e[k]] == '.')f = true;
			}
			if (f)continue;
			c[i][j] = '.';
			cnt++;
		}
	}
kaage:;
	cnt = 0;
	rep(i, 49) {
		rep(j, 100) {
			if (cnt == b - 1)goto kaage2;
			bool f = false;
			rep(k, 8) {
				if (0 <= i + d[k] && i + d[k] < 100 && 0 <= j + e[k] && j + e[k] < 100 && c[i + d[k]][j + e[k]] == '#')f = true;
			}
			if (f)continue;
			c[i][j] = '#';
			cnt++;
		}
	}
kaage2:;
	rep(i, 100) {
		rep(j, 100)cout << c[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int cnt = 0;
        for(int i=0;i<N;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a==b)cnt++;
            else cnt = 0;
            if(cnt==3) break;
        }
        if(cnt==3) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35980
from collections import Counter


def solve():
    H, W, M = map(int, input().split())
    dh, dw = Counter(), Counter()
    used = set()

    for _ in range(M):
        h, w = map(int, input().split())
        dh[h] += 1
        dw[w] += 1
        used.add((h, w))

    ih = dh.most_common()
    iw = dw.most_common()

    h, counth = ih[0]
    w, countw = iw[0]

    s = counth + countw
    ans = counth + countw - ((h, w) in used)

    for h, counth in ih:
        for w, countw in iw:
            if counth+countw < s or ans == s:
                break
            b = counth + countw - ((h, w) in used)
            ans = max(ans, b)
    print(ans)


solve()

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

int main() {
  
  int N;
  cin >> N;
  
  vector<char> color(N);
  
  for (int i=0;i<N;i++) {
    cin >> color.at(i);
  }
  
  bool which = false;
  
  for (int i=0;i<N;i++) {
    if (color.at(i) == 'Y') {
      which = true;
      break;
    }
  }
  
  if (which)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
    
}

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

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

using namespace std;

using ll = long long;

int cntl[4], cntr[4];
int main(){
    double l, r;
    
    while(cin>>l>>r){
        if(l>=1.09)cntl[0]++;
        else if(l>=0.59)cntl[1]++;
        else if(l>=0.19)cntl[2]++;
        else cntl[3]++;

        if(r>=1.09)cntr[0]++;
        else if(r>=0.59)cntr[1]++;
        else if(r>=0.19)cntr[2]++;
        else cntr[3]++;
    }
    rep(i,4){
        cout<<cntl[i]<<" "<<cntr[i]<<endl;
    }
}


Measured memory_bytes: 3144
//https://atcoder.jp/contests/abc042/tasks/abc042_a
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x,a,b;
  x = a = b = 0;
  for (int i = 0; i < 3; i++)
  {
    cin >> x;
    if (x == 5)a++;
    if (x == 7)b++;
  }
  if (a == 2 && b == 1){
    cout << "YES" << endl;
    }
  else {cout << "NO" << endl;}
  return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    if (1 <= a && a <= 9 && 1 <= b && b <= 9) cout << (a * b);
    else cout << -1;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[tuple(map(int,input().split())) for _ in range(q)]
d={}
for ai in a:
    if ai not in d:
        d[ai]=0
    d[ai]+=1
# print(d)

ans=0
for key in d:
    ans+=key*d[key]

for bi,ci in bc:
    if bi in d:
        tmp=d[bi]
        d[bi]=0
        ans-=bi*tmp
        if ci not in d:
            d[ci]=0
        d[ci]+=tmp
        ans+=ci*tmp
    print(ans)


Measured memory_bytes: 99424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int main() {
    ll n,m;
    cin >> n>>m;
    vector<ll> c;

    rep(i,m){
        ll a;
        cin >> a;
        c.pb(a); 
        
    }
    vector<vector<ll>> dp(m+1,vector<ll> (n+1,INF));
    rep(i,n+1){
        dp[0][0] = 0;
    }
    for(ll i = 1;i <=m;++i){
        rep(j,n+1){
           
            if(j-c[i-1]>=0){
                dp[i][j] = min({dp[i-1][j-c[i-1]]+1,dp[i-1][j],dp[i][j-c[i-1]]+1});
            }else{
                dp[i][j] = dp[i-1][j];
            }
           
        }
    }

    
    cout << dp[m][n] << endl;



    return 0;
    

}


Measured memory_bytes: 11500
n, s = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = i + 1
mod = 998244353

ans = 0
for i in range(n):
    for j in range(s+1):
        if s > j > 0:
            dp[i+1][j] += dp[i][j]
        if j + a[i] <= s:
            dp[i+1][j+a[i]] += dp[i][j]
            dp[i+1][j+a[i]] %= mod

    ans += dp[i+1][s] * (n - i)
    ans %= mod

print(ans)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b,c;
  cin >> a >> b >> c;

  if(a+b == c || b+c == a || c+a == b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(abs(a-b)<=k&&abs(a-c)<=k&&abs(a-d)<=k&&abs(a-e)<=k&&abs(b-c)<=k&&abs(b-d)<=k&&abs(b-e)<=k&&abs(c-d)<=k&&abs(c-e)<=k&&abs(d-e)<=k)printf("Yay!");
	else printf(":(");
	return 0;
} 

Measured memory_bytes: 256