akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    string s;
    cin >> s;
    bool flag=true;
    rep(i, s.size()-1)
    {
        if(s[i]==s[i+1]){
            flag = false;
        }
    }
    if(flag){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def resolve():
    N, M = map(int, input().split())
    if N%2==1:
        for i in range(1, M+1):
            a, b = i, N-i
            print(a, b)
    else:
        for i in range(1, M+1):
            a, b = i, N - i
            # 円として配置したとき、b-aが半分以上になったら片方だけ進める
            if b-a <= N//2:
                a += 1
            print(a, b)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9096
#!/usr/bin/env python3
import sys


def solve(K: int, A: int, B: int):
    for i in range(A, B+1):
        if i % K == 0:
            print("OK")
            exit()
    print("NG")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61740
#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

S=get_nsp
T=get_nsp
N=S.size
flag=true
exc_s={}
exc_t={}
N.times do|i|
    if exc_s[S[i]].nil?
        exc_s[S[i]]=T[i]
    elsif exc_s[S[i]]!=T[i]
        flag=false
        break
    end
    if exc_t[T[i]].nil?
        exc_t[T[i]]=S[i]
    elsif exc_t[T[i]]!=S[i]
        flag=false
        break
    end
end
puts yn_judge(flag)

Measured memory_bytes: 35208
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = Integer.parseInt(sc.next());
            int count = 0; String result = "No";
            for (int i = 0; i < N; i++) {
                int d1 = Integer.parseInt(sc.next());
                int d2 = Integer.parseInt(sc.next());
                if (d1 == d2) {
                    count++;
                } else {
                    count = 0;
                }
                if (count == 3) {
                    result = "Yes";
                    break;
                }
            }
            System.out.println(result);
        }
    }

}

Measured memory_bytes: 35704
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int w, a, b;

int main(){
    cin >> w >> a >> b;
    if(a > b)swap(a, b);
    cout << max(0, b - (a + w)) << endl;
}

Measured memory_bytes: 256
a,b,h,m=map(int,input().split())
import math

#print(360*(60*h+m)/(12*60)-360*m/60)
rad=math.radians((360*(60*h+m)/(12*60)-360*m/60))
#print(rad)
c=(a**2+b**2-2*a*b*math.cos(rad))**(1/2)
print(c)

Measured memory_bytes: 9512
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int main()
{
    string a, b; cin >> a >> b;
    reverse(b.begin(), b.end());
    string ans = a == b ? "YES" : "NO";
    cout << ans << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string s, str;
  for(int j=0; j<=W+1; j++){
    s += "X";
  }
  for(int i=1; i<H+1; i++){
      cin >> str;
      s += "Y";
      s += str;
      s += "Z";
  }
  for(int j=0; j<=W+1; j++){
    s += "A";
  }
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
      int n = 0;
      if(s.at(i*(W+2)+j)!='#'){
        for(int k=0; k<3; k++){
          if(s.at((i-1)*(W+2)+j+k-1)=='#'){
            n++;
          }
        }
        for(int k=0; k<3; k+=2){
          if(s.at(i*(W+2)+j+k-1)=='#'){
            n++;
          }
        }
        for(int k=0; k<3; k++){
          if(s.at((i+1)*(W+2)+j+k-1)=='#'){
            n++;
          }
        }
        cout << n;
      }else{
        cout << '#';
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int a,b;

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

	if(a < b){
		printf("a < b\n");
	}else if (a > b){
		printf("a > b\n");
	}else if (a == b){
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m), r;
  vector<pair<int, int>> c(m);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i = 0; i < m; i++) {
    cin >> b.at(i) >> c.at(i).first;
    c.at(i).second = i;
  }
  sort(c.begin(), c.end(), greater<pair<int, int>>());
  int ind = 0, cnt = 0;
  for(int i = 0; i < n; i++) {
    r.push_back(c.at(ind).first);
    cnt++;
    if(b.at(c.at(ind).second) == cnt) {
      cnt = 0;
      ind++;
      if(ind == c.size())
        break;
    }
  }
  for(int i = 0; i < r.size(); i++) {
    if(a.at(i) < r.at(i))
      a.at(i) = r.at(i);
    else
      break;
  }
  ll o = 0;
  for(int i = 0; i < n; i++)
    o += a.at(i);
  cout << o << endl;
}

Measured memory_bytes: 2428
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    lrc = sorted([LI() for _ in range(m)], key=lambda x: (x[0],x[2],-x[1]))
    lrc.append([inf,inf,inf])
    i = 0
    q = [(1,0),(inf,inf)]
    for l in range(1,n):
        while lrc[i][0] < l:
            i += 1
        while lrc[i][0] == l:
            _,r,c = lrc[i]
            i += 1
            qi = bisect.bisect_left(q, (l,-1))
            _, cc = q[qi]
            t = (r, cc+c)
            ti = bisect.bisect_left(q, t)
            if q[ti][1] > t[1] and q[ti-1][0] < r:
                if q[ti][0] == r:
                    q[ti] = t
                else:
                    q.insert(ti, t)
                while q[ti-1][1] > t[1]:
                    del q[ti-1]
                    ti -= 1

    t = q[-2]
    if t[0] < n:
        return -1

    return t[1]


print(main())





Measured memory_bytes: 45648
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;


int main(void){
	int k,x;
	cin >> k >> x;

	for(int i = x - k + 1; i <= x + k - 1; i++){
		cout << i << ' ';
	}
}


Measured memory_bytes: 256
s = [i for i in input()]
s_len = len(s)
list1 = []
list2 = []
for j in range(0, s_len, 2):
    for even in s[j]:
        list1.append(even in ['R', 'U', 'D'])
for k in range(1, s_len, 2):
    for odd in s[k]:
        list2.append(odd in ['L', 'U', 'D'])

if False in list1:
    print('No')
elif False in list2:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 8960
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

int main(){
  long long N;
  cin >> N;
  vector<pair<long long, long long>> R(N);
  for(int i = 0; i < N; i++){
    long long X, L;
    cin >> X >> L;
    R.at(i) = make_pair(X + L, X - L);
  }
  sort(R.begin(), R.end());

  long long cnt = 1;
  for(int i = 1; i < N; i++){
    if(R.at(i).second < R.at(i - 1).first){
      R.at(i).first = R.at(i - 1).first;
      R.at(i).second = R.at(i - 1).second;
    }
    else cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

bool solve(){
    int n;
    cin >>n;

    vector<int> t(n);
    vector<pi> p(n);
    rep(i,n) cin >>t[i] >>p[i].fi >>p[i].se;

    auto dist = [&](pi a, pi b){
        return abs(a.fi-b.fi) + abs(a.se-b.se);
    };

    int T = 0;
    pi now = {0,0};
    rep(i,n){
        int pt = (p[i].fi+p[i].se)%2;
        if(pt%2 != t[i]%2) return false;

        int d = dist(now,p[i]);
        if(d > t[i]-T) return false;
        T = t[i];
        now = p[i];
    }
    return true;
}

int main(){
    cout << (solve()?"Yes":"No") << endl;
    return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int a, b, h; cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}


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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int ans = 0;
    while (true) {
      int cnt[110] = {};
      vector<int> ns(n);
      for (int i = 0; i < n; i++) {
        cnt[s[i]]++;
      }
      for (int i = 0; i < n; i++) {
        ns[i] = cnt[s[i]];
      }
      if (s == ns) break;
      ans++;
      swap(s, ns);
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) {
      cout << s[i] << " \n"[i + 1 == n];
    }
  }

  return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int X;
  cin >> X;
  int num=X%100/5;
  if(X%100%5)num++;
  if(num<=X/100) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3600
Character = ("a".."z").to_a + ["ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts"]
count = Hash.new {|hash, key| hash[key] = Hash.new}
Character.each do |first|
  Character.each do |second|
    count[first][second] = 0
  end
end
gets.to_i.times do
  gets.chomp.split.each do |word|
    first = Character.index(word[0, 2]) ? word.slice!(0, 2) : word.slice!(0)
    while word.size != 0 do
      second = Character.index(word[0, 2]) ? word.slice!(0, 2) : word.slice!(0)
      count[first][second] += 1
      first = second
    end
  end
end
count.each do |first, hash|
  second = "a"
  max = 0
  hash.each do |key, value|
    next if (max >= value) && (max >= value)
    next if max >= value
    max = value
    second = key
  end
  print "#{first} #{second} #{max}\n"
end

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

int main() {
  string n;
  cin >> n;
  
  int l = n.size();
  int ans = 0;
  for(int i = 0; i < l; i++){
    int k = n.at(i) - '0';
    ans += k;
  }
  
  if(ans % 9) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll i=1;
    while(true){
        if(i%2==1){
            c=c-b;
            if(c<=0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }else{
            a=a-d;
            if(a<=0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        i++;
    }
    
}


Measured memory_bytes: 3620
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;


    int main(){
      int n,m;
      cin>>n>>m;
      int MX = 0,MN = INF;
      rep(i,m){
        int a,b;
        cin>>a>>b;
        MN = min(b,MN);
        MX = max(a,MX);
      }
      int ans = max(MN-MX+1,0);
      cout<<ans<<endl;
    }
      


Measured memory_bytes: 256
x, n = map(int, input().split())
p_list = list(map(int, input().split()))

ans1, ans2 = 999, 999
for i in range(x, x + 200, 1):
  if not i in p_list:
    ans1 = i
    delta1 = abs(i - x)
    break
  
for j in range(x, x - 200, -1):
  if not j in p_list:
    ans2 = j
    delta2 = abs(j - x)
    break 

if delta1 > delta2:
  print(ans2)
elif delta1 < delta2:
  print(ans1)
else:
  print(min(ans1, ans2))

Measured memory_bytes: 9212
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e6+2;
const ll mod = 1e9+7;



int main(){ 
	speedhack()
	int n; cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		int curn = log10(i)+1;
		if(curn%2 == 1){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    
    like=[False]*(n+1)
    for i in range(1,n+1,2):
        if(is_prime[i]==False):
            continue
        else:
            if(is_prime[int((i+1)/2)]==True):
                like[i]=True
            
    return  like
    #return [i for i in range(n + 1) if is_prime[i]]
q=int(input())
table=primes(10**5+10)
accum=[0]
for i in range(1,10**5+5):
        if(table[i]==True):
            accum.append(accum[i-1]+1)
        else:
            accum.append(accum[i-1])
for i in range(q):
    l,r=map(int,input().split())
    print(accum[r]-accum[l-1])

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

const int Maxn=1e6+10; 

int k,n;
int a[Maxn]; 

int sum[Maxn];

int main() 
{
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>k>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    int sum=0,mx=0;
    for(int i=1;i<n;i++)
    {
    	sum+=(a[i+1]-a[i]);
    	checkmax(mx,a[i+1]-a[i]);
	}
	int tmp=k-a[n]+a[1];
    cout<<min(sum,sum+tmp-mx)<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }


std::vector<bool> IsPrime;


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> s;
	int a = 1;
	while (a*a<=m) {
		if (m % a == 0) {
			s.push_back(a);
		}
		a++;
	}
	for (int i = s.size() - 1; i >= 0; i--) {
		s.push_back(m / s[i]);
	}
	rep(i, s.size()) {
		if (s[i] >= n) {
			cout << s[s.size() - i - 1] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
const int IINF = 1 << 30;
const long LINF = 1LL << 60;
const int MOD = (int) 1e9 + 7;
// const int MOD = 998244353;

int main(){
    long x;
    cin >> x;
    long ans = 0;
    int y = x / 500;
    ans += 1000 * y;
    x -= 500 * y;
    ans += 5 * (x / 5);
    cout << ans << "\n";
}

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N),Q(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
    Q.at(i) = P.at(i);
  }
  sort(Q.begin(),Q.end());
  int count = 0;
  for(int i=0;i<N;i++){
    if(Q.at(i) == P.at(i)){
    }
    else
      count++;
  }
  if(count == 2||count == 0)
    cout << "YES";
  else
    cout << "NO";
}

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

using namespace std;

int main()
{
	int n;
	map<string, int> memo;
	cin >> n;
	string s;
	int m = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		memo[s] += 1;
	}
	
	for (auto &x : memo)
	{
		int v = x.second;
		m = max(v, m);
	}
	
	for (auto it = memo.begin(); it != memo.end(); it++)
	{
		if (it->second == m)
		{
			cout << it->first << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lsb(x) (x & (-x))

using namespace std;

const int MAXN = 17;

inline int get(int x) {
    return __builtin_popcount(x);
}

int sol[1 << MAXN], n;

void solve(int l, int r, int a, int b) {
    if(r - l == 1) {
        sol[l] = (a & 1);
        sol[r] = (b & 1);
        return ;
    }
    int mid = (l + r) / 2;
    for(int bit = 0; bit < n; bit++) {
        if((a & (1 << bit)) != (b & (1 << bit))) {
            int cura = ((a >> (bit + 1)) << bit) + (a & ((1 << bit) - 1));
            int curb = ((b >> (bit + 1)) << bit) + (b & ((1 << bit) - 1));
            int cur = (cura ^ 1);
            solve(l, mid, cura, cur);
            solve(mid + 1, r, cur, curb);
            int val = 0;
            if(a & (1 << bit)) {
                val = 1;
            }
            for(int i = l; i <= mid; i++) {
                sol[i] = (sol[i] & ((1 << bit) - 1)) + ((sol[i] >> bit) << (bit + 1)) + val * (1 << bit);
            }
            for(int i = mid + 1; i <= r; i++) {
                sol[i] = (sol[i] & ((1 << bit) - 1)) + ((sol[i] >> bit) << (bit + 1)) + (1 - val) * (1 << bit);
            }
            return ;
        }
    }
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, a, b;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> a >> b;
    if(abs(get(a) - get(b)) % 2 == 0) {
        cout << "NO";
        return 0;
    }
    cout << "YES\n";
    solve(0, (1 << n) - 1, a, b);
    for(i = 0; i < (1 << n); i++) {
        /*for(int j = n - 1; j >= 0; j--) {
            cerr << ((sol[i] & (1 << j)) > 0);
        }
        cerr << "\n";*/
        cout << sol[i] << " ";
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC041
{
    public class A
    {
        static void Main()
        {
            string[] lineRecord = Console.ReadLine().Trim().Split(' ');

            var N = long.Parse(lineRecord[0]);
            var A = long.Parse(lineRecord[1]);
            var B = long.Parse(lineRecord[2]);

            var answer = CalcCount(N, A, B);
            Console.WriteLine(answer);
        }

        private static long CalcCount(long N, long A, long B)
        {
            //常にA<Bとする
            if (B < A) return CalcCount(N, B, A);

            long result = 0;

            if ((B - A) % 2 == 0)
            {
                result = (B - A) / 2;
            }
            else
            {
                if (N - A < B - 1)
                {
                    result = N - B + 1 + ((B - 1 - A) / 2);
                }
                else
                {
                    result = A + ((B - A - 1) / 2);
                }
            }
            return result;
        }
    }
}


Measured memory_bytes: 11092
program rabbit_exercise
  implicit none
  integer :: n, m, a(100000) = 0, b(100000) = 0, tmp, i, j
  integer :: c(100000) = 0, idx(100000) = 0
  integer(8) :: k, x(100000) = 0_8, dx(100000) = 0_8, s
  read(*,*) n
  read(*,*) x(1:n)
  read(*,*) m, k
  read(*,*) a(1:m)
  do i = 1, n-1
    dx(i) = x(i+1)-x(i)
    b(i) = i
    idx(i) = i
  end do
  do i = 1, m
    tmp = b(a(i)-1)
    b(a(i)-1) = b(a(i))
    b(a(i)) = tmp
  end do
  do j = 0, 62
    if (btest(k,j)) then
      do i = 1, n
        c(i) = idx(b(i))
      end do
      idx(1:n) = c(1:n)
    end if
    do i = 1, n
      c(i) = b(b(i))
    end do
    b(1:n) = c(1:n)
  end do
  s = x(1)
  do i = 1, n
    write(*,'(i0)') s
    s = s+dx(idx(i))
  end do
  stop
end program rabbit_exercise

Measured memory_bytes: 4992
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        d: usize,
        n: usize,
    }

    let mut base = 1;
    for _ in 0..d {
        base *= 100;
    }

    let ans = if n < 100 {
        base * n
    } else {
        base * (1 + n)
    };

    println!("{}", ans);
}


Measured memory_bytes: 2120
W, H, N = map(int, input().split())

sum = W*H

X1 = [0]
X2 = [W]
Y1 = [0]
Y2 = [H]
for i in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        X1.append(x)
    elif a == 2:
        X2.append(x)
    elif a == 3:
        Y1.append(y)
    else:
        Y2.append(y)

left = max(X1)
right = min(X2)
bottom = max(Y1)
top = min(Y2)

if left >= right or bottom >= top:
    print(0)
else :
    print((right-left)*(top-bottom))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#define INF (__INT32_MAX__ / 2)

using namespace std;

int main(int argc, char **argv) {
    int H, W, h, w;
    scanf("%d %d %d %d", &H, &W, &h, &w);
    printf("%d\n", H * W - (h * W + H * w - h * w));
}

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

deque<int> ans;
deque<int>::iterator it;

deque<int> next_good(deque<int> s){
	int p=s.size()-1;
	while (p>=0 && s[p]==9){
		s[p]=0;
		p--;
	}
	if (p==-1) s.push_front(1);
	else s[p]++;
	while (true){
		int b=-1;
		for (int i=0;i<s.size()-1;i++)
			if (abs(s[i]-s[i+1])>1){
				b=i;
				break;
			}
		if (b==-1) break;
		if (s[b+1]>s[b]) s[b]++;
		int l=max(s[b]-1,0);
		for (int i=b+1;i<s.size();i++){
			s[i]=l;
			l=max(l-1,0);
		}
	}
	return s;
}

int main(){
	int k;
	cin>>k;
	for (int i=0;i<k;i++) ans=next_good(ans);
	for (it=ans.begin();it!=ans.end();it++) cout<<*it;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int> , null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
// #define endl '\n'
#define int long long
#define double long double
#define fdt fuck donald trump
mt19937 rnd(time(0));
const int MAXN = 100001;

int k;
int cnt = 0;
void back(int pos, int lim, int cur, int last){
	// cout << pos << " " << lim << " " << cur << " " << last << endl;
	if(pos == lim + 1){
		cnt ++;
		if(cnt == k){
			cout << cur;
			exit(0);
		}
		return;
	}
	for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
		back(pos + 1, lim, cur*10 + i, i);
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	// freopen("FDT.txt","r",stdins);
	cin >> k;
	for(int i = 1; ; i ++)
		for(int j = 1; j <= 9; j ++)
			back(2, i, j, j);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int i,len;
	string a,b;
	cin>>a>>b;
	len=a.size()+b.size();
	for(i=1;i<=len;i++)
	{
		if(i%2)
			cout<<a[i/2];
		else
			cout<<b[i/2-1];
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	for(int q=0;q<3;q++){
		int a,b,c,d,e,f;
		scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
		int g,h,i;
		g=d-a;
		h=e-b;
		i=f-c;
		if(i<0){h--;i+=60;}
		if(h<0){g--;h+=60;}
		printf("%d %d %d\n",g,h,i);
	}
}


Measured memory_bytes: 2732
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
	double x1, x2, y1, y2, p1 , p2 , x ;
	cin >> x1 >> y1 >> x2 >> y2;
	p1 = x2 - x1;
	p2 = y2 - y1;
	x = p1*p1 + p2*p2;
	x = sqrt(x);
	printf("%.8lf\n ", x);
	return 0;
}

Measured memory_bytes: 3284
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<lli,pi>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 5;
int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		string s;
		cin >> s;
		if(s == "ABC") cout << "ARC";
		else cout << "ABC";
		
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    ll n;
    cin >> n;
    ll arr[n];
    for (ll i=0;i<=n-1;i++)
    {
        cin >> arr[i];
    }

    ll before[n];
    ll after[n];
    
    before[0]=arr[0];
    for (ll i=1;i<=n-1;i++)
    {
        before[i]=__gcd(before[i-1],arr[i]);
    }

    after[n-1]=arr[n-1];
    for (ll i=n-2;i>=0;i--)
    {
        after[i]=__gcd(after[i+1],arr[i]);
    }


    ll ans_first=after[1];
    ll ans_second=before[n-2];
    ll ans=max(ans_first,ans_second);

    for (ll i=1;i<=n-2;i++)
    {
        ll local=__gcd(before[i-1],after[i+1]);
        ans=max(ans,local);
    }

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

Measured memory_bytes: 5940
using System;

namespace AtCoderABC132B
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            int N = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');

            int[] P = new int[N];

            for (int i = 0; i < N; i++)
            {
                P[i] = int.Parse(s[i]);
            }

            for(int i=2;i<N;i++)
            {
                if (checkMid(P[i - 2], P[i - 1], P[i]))
                    ans++;
            }

            Console.WriteLine(ans.ToString());
        }

        static bool checkMid(int a,int b,int c)
        {
            if(a < b)
            {
                if (b < c)
                    return true;
                else
                    return false;
            }
            else
            {
                if (b > c)
                    return true;
                else
                    return false;
            }

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
int main(void){
    int n,a,b,c=0,d=0;
    while(true){
        std::cin>>n;
        if(n==0){
            break;
        }
        else{
            for(int i=0;i<n;++i){
                std::cin>>a>>b;
                if(a>b){
                    c=c+a+b;
                }
                else if(b>a){
                    d=d+a+b; 
                }
                else{
                    c=c+a;
                    d=d+b;
                }
            }
        }
        std::cout<<c<<" "<<d<<std::endl;
        c=0;
        d=0;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;


int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<string> c(H);
  for (int i = 0; i < H; ++i) cin >> c[i];

  int total = 0;
  REP(h, (1<<H)) {
    REP(w, (1<<W)) {
      bitset<6> bh(h), bw(w);
      int cnt = 0;
      REP(y, H) {
        if (!bh.test(y)) continue;
        REP(x, W) {
          if (!bw.test(x)) continue;
          if (c[y][x] == '#') ++cnt;
        }
      }
      if (cnt == K) ++total;
    }
  }
  cout << total << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, a, cnt = 0;
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a;
		if(a == i){
			cnt++;
			cin >> a;
			i++;
		}
	}
	cout << cnt;
}


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

int main(void) {
    string S;cin>>S;
    int mi = 10000;
    for (int i = 0; i < S.size() - 2; i++) {
        int cur = stoi(S.substr(i, 3));
        int a = abs(cur - 753);
        if (a < mi) mi = a;
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;
    vector<int> A(N);
    A[0] = 0;
    for(int i = 0; i < N - 1; i++) {
        A[i + 1] = A[i];
        if(S.substr(i, 2) == "AC") A[i + 1]++;
    }
    for(int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        cout << A[r] - A[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
<?php
fscanf(STDIN, "%d %d", $n, $x);
$ans = $n;
$y = 0;
$z = 0;
$y = $n - $x;
if ($x == $y) {
  $ans += $y;
} else {
  /*
  if (($n - $y) / $n >= 1) {
    if (($n - $y) % $n == 0) {
      $ans += (($n - $y) / $y) * $y * 2 - $y;
      echo $ans."\n";
      echo "a";
      exit;
    }
    $ans += (floor($n / $y)- 1 ) * $y * 2;
    $z = $n - (floor($n / $y) * $y);
  } else { */
    $z = $n - $y;
  //}
  while ($y % $z != 0) {
    $ans += floor($y / $z)  * $z * 2;
    $a = $z;
    $z = $y % $z;
    $y = $a;
  }
    $ans += ($y / $z - 1) * $z * 2 + $z;
}
echo $ans."\n";


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

constexpr int MAX = 100000;

vector<vector<pair<int, int>>> al(MAX);
vi dist(MAX, -inf);
vb visited(MAX);

bool bfs(int i, int d) {
	if (visited[i] && d == dist[i]) return true;
	if (visited[i] && d != dist[i]) return false;

	visited[i] = true;
	dist[i] = d;
	rep(j, al[i].size()) {
		if (!bfs(al[i][j].first, d + al[i][j].second)) return false;
	}
	return true;
}

int main() {
	int n, m;
	cin >> n >> m;

	rep(i, m) {
		int l, r, d;
		cin >> l >> r >> d;

		l--, r--;
		al[l].push_back({ r, d });
		al[r].push_back({ l, -d });
	}

	rep(i, n) {
		if (!visited[i]) {
			if (!bfs(i, 0)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 11008
N = int(input())
a = list(map(int, input().split()))

x4 = [x for x in a if x % 4 == 0]
x2 = [x for x in a if x % 4 != 0 and x % 2 == 0]

if len(x4) >= N // 2:
    ans = 'Yes'
else:
    if len(a) - len(x4) - len(x2) <= len(x4):
        ans = 'Yes'
    else:
        ans = 'No'
print(ans)

Measured memory_bytes: 14252
n = int(input())
s_list = list(input())
def main():
  animal_list = [None] * n
  sonzai = False
  #SS
  if not sonzai:
    animal_list[0] = True
    animal_list[1] = True
    animal_list = create_animal_list(animal_list)
    sonzai = is_valid_list(animal_list)
  if not sonzai:
    animal_list[0] = True
    animal_list[1] = False
    animal_list = create_animal_list(animal_list)
    sonzai = is_valid_list(animal_list)
  if not sonzai:
    animal_list[0] = False
    animal_list[1] = False
    animal_list = create_animal_list(animal_list)
    sonzai = is_valid_list(animal_list)
  if not sonzai:
    animal_list[0] = False
    animal_list[1] = True
    animal_list = create_animal_list(animal_list)
    sonzai = is_valid_list(animal_list)
  if not sonzai:
    print(-1)
  else:
    animal_list2 = []
    for animal in animal_list:
      if animal:
        animal_list2.append("S")
      else:
        animal_list2.append("W")
    animal_list2 = "".join(animal_list2)
    print(animal_list2)
def is_valid_list(animal_list):
  return is_ok(animal_list, 0) and is_ok(animal_list,-1)
  
def is_ok(animal_list, index):
  if animal_list[index%n]:
    if s_list[index%n] == "o":
      return animal_list[(index+1)%n] == animal_list[index-1]
    else:
      return not (animal_list[(index+1)%n] == animal_list[index-1])
  else:
    if s_list[index%n] == "o":
      return not (animal_list[(index+1)%n] == animal_list[index-1])
    else:
      return (animal_list[(index+1)%n] == animal_list[index-1])
def create_animal_list(animal_list):
  for index in range(2, len(animal_list)):
    if animal_list[index-1]:
      if s_list[index-1] == "o":
        animal_list[index] = animal_list[index-2]
      else:
        animal_list[index] = not animal_list[index-2]
    else:
      if s_list[index-1] == "o":
        animal_list[index] = not animal_list[index-2]
      else:
        animal_list[index] = animal_list[index-2]
  return animal_list
main()

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

int main(void){
    int n, x=0, y=0;
    cin>>n;
    int V[n];
    int C[n];
    int ret=0;
    for(int i=0;i<n;i++){
        cin>>V[i];
    }
    for(int i=0;i<n;i++){
        cin>>C[i];
    }
    for(int i=0;i<n;i++){
        x += V[i];
        y += C[i];
    }


    for(int i=0;i<n;i++){
        int cost = V[i] - C[i];
        if(cost>0){
            ret+=cost;
        }
    }

    cout<<ret;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int n3 = sc.nextInt();
		sc.close();
		boolean rtnFlag = false;
		int count = 0;
		int temp1 = 0;
		int temp2 = 0;
		int temp3 = 0;
		
//		int arrayLength = 0;
		ArrayList<int[]> list = new ArrayList<int[]>();
//		int[][] intArray = new int[arrayLength][3];
//		int[] tempArray = {n1, n2, n3};
//		Arrays.sort(tempArray);
//		list.add(tempArray);
//		intArray[0][0] = n1;
//		intArray[0][1] = n2;
//		intArray[0][2] = n3;
//		arrayLength++;
//		Arrays.sort(intArray[0]);
		while (!rtnFlag) {
			if (n1 % 2 != 0 || n2 % 2 != 0 || n3 % 2 != 0 ) {
				rtnFlag = true;
			} else {
				int[] tempArray = new int[3];
				tempArray[0] = n1;
				tempArray[1] = n2;
				tempArray[2] = n3;
				Arrays.sort(tempArray);
//					if (Arrays.binarySearch(intArray, tempArray) >= 0) {
//						count = -1;
//						rtnFlag = true;
//					} else {
//						intArray[arrayLength++] = tempArray;
//					}
				
				if (isExisted(list, tempArray)) {
					count = -1;
					rtnFlag = true;
					break;
				} else {
					list.add(tempArray);
				}
				temp1 = n1 / 2;
				temp2 = n2 / 2;
				temp3 = n3 / 2;
				n2 = n2 / 2 + temp1;
				n3 = n3 / 2 + temp2;
				n1 = n1 / 2 + temp3;
				count++;
			}
		}
		System.out.println(count);
	}
	
	private static boolean isExisted(ArrayList<int[]> list, int[] intArray) {
		boolean rtnFlag = false;
		for (int[] temp : list) {
			if (Arrays.equals(temp, intArray)) {
				rtnFlag = true;
				break;
			}
		}
		return rtnFlag;
	}
}

Measured memory_bytes: 20820
#include <iostream>
#include <algorithm>
#define N 1001
using namespace std;
struct d{
  int h;
  int p;
  int q;
};
int main(){
  int n,m,a,i,j,l;
  struct d data[N];
  while(1){
    cin >> n >> m >> a;
    if(n==0&&m==0&&a==0) break;
    for(i=0;i<m;i++){
      cin >> data[i].h >> data[i].p >> data[i].q;
    }
    for(i=0;i<m;i++){
      for(j=1;j<m;j++){
    if(data[j].h>data[j-1].h) swap(data[j],data[j-1]);
      }
    }
    l=a;
    for(i=0;i<m;i++){
      if(data[i].p==l-1) l-=1;
      else if(data[i].q==l+1) l+=1;
      if(i==m-1){
    cout << l << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1168
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[]
for i in range(n):
    l.append(lmp())
l=sorted(l,key=lambda x:x[1])
t=0
for i in range(n):
    t+=l[i][0]
    if t>l[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 49796
N = int(input())
A = list(map(int, input().split()))
Sum = 0
Temp = 0
for a in A:
    Sum += a
for i in range(N):
    Temp += A[i]
    if Temp > Sum//2:
        index = i
        break

print(min(abs(Sum-2*Temp), abs(Sum-2*(Temp-A[index]))))

Measured memory_bytes: 31680
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n,m,L;
int q;
int dist[310][310];
int okdist[310][310];
int s[100010],t[100010];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	for(int i=0;i<310;i++)for(int j=0;j<310;j++)dist[i][j]=((i!=j)*1000000007);
	for(int i=0;i<310;i++)for(int j=0;j<310;j++)okdist[i][j]=((i!=j)*1000000007);
	
	cin>>n>>m>>L;
	for(int i=0;i<m;i++)
	{
		int x,y,d;
		cin>>x>>y>>d;
		
		dist[x][y]=dist[y][x]=d;
	}
	
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)for(int k=1;k<=n;k++)dist[j][k]=min(dist[j][k],dist[i][j]+dist[i][k]);
	
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(dist[i][j]<=L)okdist[i][j]=1;
	
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)for(int k=1;k<=n;k++)okdist[j][k]=min(okdist[j][k],okdist[i][j]+okdist[i][k]);
	
	cin>>q;
	
	for(int i=0;i<q;i++)cin>>s[i]>>t[i];
	
	for(int i=0;i<q;i++)cout<<((okdist[s[i]][t[i]]!=1000000007)*okdist[s[i]][t[i]])-1<<endl;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 2048
// C

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int H,W,K;
  string s[300];
  int group[300][300] = {0};
  int dp[300][300] = {0};
  cin>>H>>W>>K;
  int emp[300] = {0};
  for (int i(0);i<H;i++) cin>>s[i];
  for (int y(0);y<H;y++){
    int cnt(0);
    for (int x(0);x<W;x++){

      if (s[y][x] == '#'){
        cnt++;
      }
      if (cnt == 0) dp[y][x] = 1;
      else{
        dp[y][x] = cnt;
        emp[y] = 1;
      }
    }
  }
  ll g_cnt(1);
  for (int y(0);y<H;y++){
    if (emp[y] == 1){
      group[y][0] = g_cnt;
      for (int x(1);x<W;x++){
        if (dp[y][x] == dp[y][x-1]){
          group[y][x] = g_cnt;
        }else{
          g_cnt++;
          group[y][x] = g_cnt;
        }
      }
      g_cnt++;
    }
  }
  ll t_cnt(0);
  bool flag = false;
  int h_g[300] = {0};
  int ko[300][300] = {0};
  for (int y(0);y<H;y++){
    if (emp[y] == 1){
      if (flag == true){
        t_cnt++;
      }
      flag = true;
      for (int x(0);x<W;x++){
        ko[t_cnt][x] = group[y][x];
      }
    }
    h_g[y] = t_cnt;
  }

  for (int y(0);y<H;y++){
    if (emp[y] == 0){
      for (int x(0);x<W;x++){
        group[y][x] = ko[h_g[y]][x];
      }
    }
  }

  for (int y(0);y<H;y++){
    //cout << h_g[y] << ":";
    for (int x(0);x<W;x++){
      cout << group[y][x] <<" ";
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;

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

    if (abs(a-c) <= d) {
        cout << "Yes" << endl;
    } else if ((abs(b-a) <= d) && (abs(c-b) <= d)) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
int main() {
	// vector<string> alpha(26,0);
	vector<string> alpha = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
	string c;
	cin >> c;
	int cnt = 0;
	for (int i=0; i<alpha.size(); i++) {
		if (alpha[i] == c){
			cout << alpha[i+1] << endl;
			break;
		}
		cnt++;
	}
	return 0;
}

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

using namespace std;
typedef long long LL;

int main() {
    string n;

    cin>>n;
    int tot = 0;
    for(char c : n){
        tot += c - '0';
    }

    tot % 9 == 0 ? cout<<"Yes":cout<<"No";
    return 0;
}

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

using namespace std;

int main(void){
  string num;
  int count = 0;
  
  cin >> num;
  
  for(int i = 0 ; i < 4 ; i++){
    if(num[i] == '2') count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256