akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


ll solve(int N, vi& a,vi& b) {
    // 0-1e9, 1-1e9
    ll ofs = 0;
    for(int i=N-1; i>=0; --i) {
        ll ai = a[i] + ofs;
        ll r = ai % b[i];
        if (r == 0) continue;
        ll push = b[i] - r;
        ofs += push;
    }
    return ofs;
}

int main() {
    int N;cin>>N; //1-1e5
    vi a(N),b(N);
    rep(i,N) cin>>a[i]>>b[i];
    cout << solve(N,a,b) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
dd = defaultdict(int)
ans = 0
for i, num in enumerate(a, start = 1):
    dd[i + num] += 1
for i, num in enumerate(a, start = 1):
    ans += dd[i - num]
print(ans)

Measured memory_bytes: 61112
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	nums := make([]int,n)
	max,secMax := 0,0
	for i,_ := range nums {
		fmt.Scan(&nums[i])
		if secMax < nums[i] {
			secMax = nums[i]
		}
		if max < secMax {
			max,secMax = secMax,max
		}
	}
	
	for i,_ := range nums {
		if nums[i] != max {
			fmt.Println(max) 
		} else {
			fmt.Println(secMax)
		}
	}
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc116_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int s;
  cin >> s;

  bool ok = false;
  vector<int> c(0);
  c.push_back(s);

  auto f = [&](int n) -> int {
    if(n % 2 == 0) {
      return n / 2;
    } else {
      return 3 * n + 1;
    }
  };

  int i = 0;
  while (!ok) {
    int next = f(c[i++]);
    for (auto a : c) {
      if (a == next) ok = true;
    }
    if (!ok) c.push_back(next);
    else
      break;
  }

  cout << c.size() + 1 << endl;
}

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


a,b,c,d = map(int,input().split())

if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
S = list(input())

b = []
w = []
num = 1

if len(S) == 1:
    print(0)
    exit()

if S[0] == S[1]:
    Flag = True
else:
    Flag = False

for i in range(1, len(S)):
    if S[i-1] == S[i]:
        Flag = True
        num += 1
    else:
        Flag = False
        if S[i-1] == 'B':
            b.append(num)
        elif S[i-1] == 'W':
            w.append(num)
        num = 1

if S[-1] == 'B':
    b.append(num)
else:
    w.append(num)

if num == len(S):
    ans = 0
else:
    n_b = len(b)
    n_w = len(w)
    n = min(n_b, n_w)

    if (n_b + n_w) % 2 == 0:
        ans = 2 * n - 1
    else:
        ans = 2 * n

print(ans)

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

deque<int> dq;

void push(int d, int x)
{
    if(d == 0)  dq.push_front(x);
    else    dq.push_back(x);
}
void printDQ(int p)
{
    deque<int>::iterator it = dq.begin();
    for(int i = 0; i < p; i++)
        it++;
    cout << *it << endl;
}
void pop(int d)
{
    if(d == 0)  dq.pop_front();
    else    dq.pop_back();
}
int main()
{
    //freopen("output.txt","w+",stdout);
    int q;
    cin >> q;
    getchar();
    while(q--)
    {
        string inp, temp;
        getline(cin, inp);
        //cout << inp;
        vector<int> inps;
        for(int i = 0; i <= inp.size(); i++)
        {
            if(inp[i] == ' ' || i == inp.size())
            {
                //cout << temp << endl;
                int p = stoi(temp);
                inps.push_back(p);
                temp.clear();
            }
            else
                temp += inp[i];
        }
//        for(int i = 0; i < inps.size(); i++)
//            cout << inps[i] << endl;
        if(inps[0] == 0)
        {
            push(inps[1], inps[2]);
            //cout << "push(" << inps[1] << "," << inps[2] << ")";
            //printDQ(dq);
        }
        else if(inps[0] == 1)
        {
            printDQ(inps[1]);
        }
        else
        {
            pop(inps[1]);
        }
//        cout << endl;
    }
    //printDQ(dq);
}



Measured memory_bytes: 4576
from collections import deque
S=list(input())
op_cnt = len(S)-1  # すき間の個数
sum_=0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き
    op=deque(op)
    T=deque()
    #print(op,S)
    for i in range(op_cnt):
        T.append(S[i])
        T.append(op.popleft())
    T.append(S[-1])
    sum_ += eval("".join(T))
print(sum_)

Measured memory_bytes: 39792
import math
def solve():
  n = int(input())
  ans = 0
  for i in range(1,n+1):
    if i % 2 == 1:
      count = 0
      for j in range(1,i+1):
        if i % j == 0:
          count += 1
      if count == 8:
        ans += 1
  print(ans)
solve()

Measured memory_bytes: 2940
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <string>
using namespace std;

int main() {
	string s, ans = "";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if (ans.size() > 0) ans.pop_back();
		}
		else {
			ans.push_back(s[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace stdioTest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            char b = char.Parse(Console.ReadLine());
            char ans = ' ';
            if (b == 'A') ans = 'T';
            else if (b == 'T') ans = 'A';
            else if (b == 'C') ans = 'G';
            else if (b == 'G') ans = 'C';

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
/*
A - Changing a Character

*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int N = 1, K = 3;
 cin >> N >> K;
 int s = (N * 3) / 2;
 int r = (N * 3) % 2;
 //cout << s << '\n';
 K += r;
 //cout << K << '\n';
 int d = K / 2;
 s += d;
 cout << s << '\n';
 return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
if n % 2 == 0 or n % 5 == 0:
  print(-1)
  sys.exit()
p = 7
ans = 1
for i in range(1000000):
  q = p % n
  if q == 0:
    break
  else:
    p = 10 * q + 7
    ans += 1
if q != 0:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >>A >>B;
  if(A*N>B)
  {
    cout << B <<endl;
  }
  else
  {
    cout << N*A <<endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    long long GCD(long long x, long long y){
        while(y != 0){
            long long r = x % y;
            x = y;
            y = r;
        }
        return x;
    }

    int main(){

        long long x, y;
        cin >> x >>y;
        int ans = GCD(x, y);
        cout << ans <<'\n';

        return 0;
    }


Measured memory_bytes: 3124
object Main extends App {
    val in = io.Source.stdin.getLines
    for (x <- in; r@Array(m, nmin, nmax) = x.split(" ").map(_.toInt) if r.exists(_ != 0)) {
        val ps = in.take(m).map(_.toInt)
        println(ps.zipWithIndex.drop(nmin - 1).foldLeft((0, 0, 0)){
            case ((gap, p0, res), (p1, i)) if i <= nmax =>
                if (p0 - p1 >= gap) (p0 - p1, p1, i) else (gap, p1, res)
            case y => y._1
        }._3)
    }
}

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

using namespace std;

#define li long long int

const int N = 1e5 + 5;

int n;
int a[N][3];
int dp[N][4];

int go(int idx, int prev) {
	if (idx > n) return 0;
	if (dp[idx][prev] != -1) return dp[idx][prev];
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (i == prev) continue;
		ans = max(ans, a[idx][i] + go(idx + 1, i));
	}
	return dp[idx][prev] = ans;
}

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	int ans = go(1, 3);
	cout << ans;
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 10752
using System;
using System.Collections.Generic;

namespace abc170_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var X = CIn.ReadInt();
      var Y = CIn.ReadInt();

      for (int i = 0; i <= X; i++)
      {
        if (i * 4 + (X - i) * 2 == Y)
        {
          Console.WriteLine("Yes");
          return;
        }
      }

      Console.WriteLine("No");
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

int main(){
  while(1){
    int n;
    cin >> n;

    if(n==0){
      break;
    }

    int a[n];
    int total=0;
    for(int i=0; i<n; i++){
      cin >> a[i];
      total += a[i];
    }

    int mean=total/n;
    int person=0;
    for(int i=0; i<n; i++){
      if(a[i]<=mean){
        person++;
      }
    }

    cout << person << endl;
  }
}



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

void solve(){
  int n, t, a; cin >> n >> t >> a;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  int mini = 0;
  for(int i = 0; i < n; i++){
    double x = t - h[i] * 0.006;
    if(abs(x - a) < abs(t - h[mini] * 0.006 - a)) mini = i;
  }
  cout << mini + 1 << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


double dist(double x1, double x2, double y1, double y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}
double dist(P &p1, P &p2) {
	double x1 = p1.first, x2 = p2.first, y1 = p1.second, y2 = p2.second;
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

bool comp(const P &p1, const P &p2) {
	return p1.second < p2.second;
}

void solve() {
	int N; cin >> N;
	vector<int>X(N), L(N);
	vector<P>v;
	REP(i, N) {
		cin >> X[i] >> L[i];
		v.push_back({ X[i]-L[i],L[i]+X[i] });
	}
	sort(all(v), comp);
	int res = 0, mx = -2e9;
	REP(i, N) {
		if (v[i].first < mx)res++;
		else mx = v[i].second;
	}
	print(N - res);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 3956
#include "bits/stdc++.h"
using namespace std;
typedef pair<double,string> Pair;
int main() {
	int N;
	while(cin>>N,N) {
		vector<Pair> v;
		for(int i=0;i<N;i++) {
			string L;
			int P,A,B,C,D,E,F,S,M;
			cin>>L>>P>>A>>B>>C>>D>>E>>F>>S>>M;
			int s=S*F,t=A+B+C+D+E;
			for(int i=1;i<M;i++) s+=S*F,t+=D+E;
			v.push_back(Pair(-(double)(s-P)/t,L));
		}
		sort(v.begin(),v.end());
		for(int i=0;i<v.size();i++) {
			cout<<v[i].second<<endl;
		}
		cout<<"#"<<endl;
	}
}

Measured memory_bytes: 3000
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
# include <map>
# include <string>
using namespace std;

int main() {
	string s;
	while (cin >> s) {
		string j;
		int joi = 0, ioi = 0;
		for (int i = 0; i < s.size() - 2; i++) {
			j = s.substr(i, 3);
			if (j == "JOI") {
				joi++;
			}
			if (j == "IOI") {
				ioi++;
			}
		}
		cout << joi << endl << ioi << endl;
	}
}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll x;

    rep (i, 5)
    {
        cin >> x;
        if (!x) { cout << i + 1 << endl; }
    }

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

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


Measured memory_bytes: 3600
S = str(input())
T = str(input())
index = []

for i in range(len(S) - len(T) + 1):
  if (S[i] != T[0]) and (S[i] != "?"):
    continue
  else:
    p = 0
    now = i
    j = 0
    index_i = -1
    while p == 0:
      if (S[now] != T[j]) and (S[now] != "?"):
        p = 1
      else:
        now += 1
        j += 1
      #print(now, j, len(T), index)
      if j == len(T):
        index_i = i
        p = 1
    if index_i != -1:
      index.append(index_i)
      
#print(index)
if (len(index) == 0):
  print("UNRESTORABLE")
else:
  ans_index = index[-1]
  ans = [0] * len(S)
  q = 0
  for i in range(len(S)):
    if i == ans_index:
      ans[i] = T[0]
      q = 1
    elif (q != 0):  
      ans[i] = T[q]
      q += 1
      if q == len(T):
        q = 0
    else:
      if S[i] != "?":
        ans[i] = S[i]
      else:
        ans[i] = "a"
    #print(ans, S)
  
  #print(ans) 
  #print(ans_index)
  for i in range(len(ans)):
    print(ans[i], end = "")
  print("")
  




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mems(x, y)		memset(x, y, sizeof x)
vector < int > v[100000+5];
int dp[100000+5];
int dfs(int i)
{
	if(dp[i] != -1)		return dp[i];
	
	int cost = 0, mx = 0;
	for(int j = 0; j < v[i].size(); j++) {
		int node = v[i][j];
		cost = dfs(node);
		mx = max(mx, cost);
	}
	
	return dp[i] = mx + 1;
}
int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++)	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
	}
	mems(dp, -1);
	int ans = dfs(1);
	for(int i = 1; i <= n; i++) {
		if(dp[i] == -1)		ans = max(ans, dfs(i));
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 8192
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    K=int(input())
    d=deque(['1','2','3','4','5','6','7','8','9'])
    for i in range(K):
        dd=d.popleft()
        if i==K-1:
            print(dd)
        else:
            ddd=dd[-1]
            if int(ddd)==0:
                d.append(dd+str(int(ddd)))
                d.append(dd+str(int(ddd)+1))
            if 1<=int(dd[-1])<=8:
                d.append(dd+str(int(ddd)-1))
                d.append(dd+str(int(ddd)))
                d.append(dd+str(int(ddd)+1))
            if int(dd[-1])==9:
                d.append(dd+str(int(ddd)-1))
                d.append(dd+str(int(ddd)))


resolve()

Measured memory_bytes: 71772
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(Math.min(a, b) + " " + Math.max(0, (a + b) - n));
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    string res;
    if(a > b){
        for(int i=0; i<a; i++){
            res += to_string(b);
        }
    } else {
        for(int i=0; i<b; i++){
            res += to_string(a);
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<ll, ll>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;
#pragma endregion

const int N = 15;
int n, board[3][3], arr[N];

pls give {
    AC;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> board[i][j];
        }
    }
    cin >> n;
    for (int i=0; i<n; i++) cin >> arr[i];
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            for (int k=0; k<n; k++) {
                if (board[i][j] == arr[k]) board[i][j] = -1;
            }
        }
    }
    if (board[0][0] == -1 and board[0][1] == -1 and board[0][2] == -1) cout << "Yes" << nl;
    else if (board[1][0] == -1 and board[1][1] == -1 and board[1][2] == -1) cout << "Yes" << nl;
    else if (board[2][0] == -1 and board[2][1] == -1 and board[2][2] == -1) cout << "Yes" << nl;
    else if (board[0][0] == -1 and board[1][0] == -1 and board[2][0] == -1) cout << "Yes" << nl;
    else if (board[0][1] == -1 and board[1][1] == -1 and board[2][1] == -1) cout << "Yes" << nl;
    else if (board[0][2] == -1 and board[1][2] == -1 and board[2][2] == -1) cout << "Yes" << nl;
    else if (board[0][0] == -1 and board[1][1] == -1 and board[2][2] == -1) cout << "Yes" << nl;
    else if (board[2][0] = -1 and board[1][1] == -1 and board[0][2] == -1) cout << "Yes" << nl;
    else cout << "No" << nl;
}

Measured memory_bytes: 256
n = int(input())
w = [input() for _ in range(n)]

say = []

flag = True

pre = ""

for s in w:
    if pre != "" and pre != s[0]:
        flag = False

    if s in say:
        flag = False
    
    say.append(s)
    pre = s[-1]

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int l[] = new int[N];
        int r[] = new int[N];
        int people = 0;
        
        for (int i=0;i<N;i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
            people += r[i] - l[i] + 1;
        }
        System.out.println(people);
    }
    
}

Measured memory_bytes: 26836
n, k = map(int, input().split())
S = input()
S = list(S)

cnt = 0
s = S[0]
flag = False
for i in range(n):
    if flag and S[i] == s:
        cnt += 1
        flag = False
    if S[i] != s:
        S[i] = s
        flag = True
    if cnt == k:
        break

ans = 0
for i in range(n-1):
    if S[i] == S[i+1]:
        ans += 1

print(ans)


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

typedef long long ll;

int main () {

    int a,b;
    cin >> a >> b;
    if( a==b ) cout << "Draw" << endl;
    else {
	if( a == 1 or b == 1)
	    cout << (a==1? "Alice":"Bob") << endl;
	else
	cout << (a>b? "Alice": "Bob") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math


def update(numlist,i):
  if i<0:
    return
  if i==0:
    numlist[i]=min(numlist[2*i+1],numlist[2*i+2])
    return
  numlist[i]=min(numlist[2*i+1],numlist[2*i+2])
  update(numlist,(i-1)//2)
  return

def find(numlist,x,y,k,minimum,maximum,MAX):
  if x>=maximum or y<minimum:
    return MAX
  if x<=minimum and maximum-1<=y:
    return numlist[k]
  else:
    L=find(numlist,x,y,k*2+1,minimum,(maximum+minimum)//2,MAX)
    R=find(numlist,x,y,k*2+2,(maximum+minimum)//2,maximum,MAX)
    return (min(L,R))
    
  

n,q=map(int,input().split())
L2n=math.ceil(math.log2(n))
zero=2**(L2n)-1
MAX=2**31-1
numlist=[MAX]*(2**(L2n+1)-1)
resultlist=[]

for _ in range(0,q):
  com,x,y=map(int,input().split())
  if com:
    resultlist.append(find(numlist,x,y,0,0,2**L2n,MAX))
  else:
    numlist[zero+x]=y
    update(numlist,(zero+x-1)//2)

for x in resultlist:
  print (x)


Measured memory_bytes: 10584
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char a[20],b[20];
	cin>>a;
	cin>>b;
	int r=0;
	for(int i=0;a[i]!='\0';i++)
	{
		if(a[i]!=b[i])
		r=1;
	}
	if(r==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl; 
	
}

Measured memory_bytes: 3068
a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if a == b:
    print('Draw')
elif l.index(a) < l.index(b):
    print('Bob')
else:
    print('Alice')

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

int main(int argc, const char * argv[]) {
	
	int i,j,n,s,xy[2][100]={0};
	
	scanf("%d",&n);
	
	for(i = 0; i < 2; i++) {
		for(j = 0; j < n ; j++){
			scanf("%d",&xy[i][j]);
		}
	}
	
	//p1
	double p1 = 0;
	for(i = 0 ; i < n ; i++) {
		p1 +=  abs((double)(xy[0][i] - xy[1][i]));
	}
	printf("%f\n",p1);
	
	//p2
	double p2 = 0;
	for(i = 0; i < n; i++){
		p2 += pow(abs((double)(xy[0][i] - xy[1][i])),2);
	}
	
	p2 = sqrt(p2);
	printf("%f\n",p2);
	
	//p3
	double p3 = 0;
	for(i = 0; i < n; i++){
		p3 += pow(abs((double)(xy[0][i] - xy[1][i])),3);
	}
	
	p3 = cbrt(p3);
	printf("%f\n",p3);

	
	//pinf
	double pinf = -1;
	for(i = 0; i < n; i++) {
		if(abs(xy[0][i] - xy[1][i]) > pinf) {
			pinf = abs(xy[0][i] - xy[1][i]);
		}
	}
	printf("%f\n",pinf);
	
	return 0;
	
}

Measured memory_bytes: 708
// ॐ त्र्य॑म्बकं यजामहे सु॒गन्धिं॑ पुष्टि॒वर्ध॑नम् ।
                  //  उ॒र्वा॒रु॒कमि॑व॒ बन्ध॑नान् मृ॒त्योर्मुक्षीय॒ मा ऽमृता॑त् 
                  // ॐ नमः शिवाया ॐ नमः शिवाया | हर हर बोले नमः शिवाया 
                   //रामेश्वरए शिवा रामेश्वरए | हर हर बोले नमः शिवाया |
/******HAPPY CODING******
Codechef: ritik_tanwar
*********WITH************
CodeForces:illuminatiiiii
*********RITIK**********/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi                                         first
#define se                                         second
#define pb                                         push_back
#define int                                        long long int
#define mp                                         make_pair
#define pii                                        pair<int,int>
#define vi                                         vector<int>
#define mii                                        map<int,int>
#define umii                                       unordered_map<int,int>
#define pqmax                                      priority_queue<int>
#define pqmin                                      priority_queue<int,vi,greater<int>>
#define setbits(x)                                 __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                        1000000007
#define inf                                        1e18
#define ps(x,y)                                    fixed<<setprecision(y)<<x
#define dec(arr,n,type)                             type *arr=new type[n]
#define test(t)                                    int t;cin>>t;while(t--)
#define for1(i,n)                                  for(int i=0;i<n;i++)
#define for2(i,n)                                  for(int i=1;i<=n;i++)
#define fio                                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SIZE                                       1000001
#define btw(x)                                     (x).begin(),(x).end()
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
int multiplymod(int a,int b){int res=0;while(b){if(b&1){res+=a;}a*=2;b/=2;res%=mod;a%=mod;}return res;}
int expomod(int a,int b,int  m){int res=1;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b = b>>1;}return res;}


int dp[200005];
int func(int *a,int n,int k){
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=INT_MAX;
        for(int j=1;j<=min(i-1,k);j++){
            int op=dp[i-j]+abs(a[i]-a[i-j]);
            // int op2=dp[i-1]+abs(a[i]-a[i-1]);
            dp[i]=min(dp[i],op);
        }
    }
    return dp[n];
}

void solve(){
    int n,k;
    cin>>n>>k;
    int a[200005];
    memset(dp,-1,sizeof dp);
    for2(i,n) cin>>a[i];
    cout<<func(a,n,k);
}
int32_t main()
{
    fio;
    // test(t){
        solve();
    // }
}

Measured memory_bytes: 5996
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		String[] str = { "JOI", "IOI" };
		while (scanner.hasNext()) {
			String line = scanner.next();
			for (String s : str) {
				int p = 0;
				int ans = 0;
				while (true) {
					p = line.indexOf(s, p) + 2;
					if (p == 1)
						break;
					ans++;
				}
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 19644
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

i64 f(i64 a, i64 b) {
	if(b < a) std::swap(a, b);
	if(b % a == 0) return (b / a * 2 - 1) * a;
	if(a) return 2 * a * (b / a) + f(b % a, a);
	return 0;
}

int main() {
	i64 n, x; cin >> n >> x;
	
	cout << n + f(x, n - x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define input(arr,n) for(int i = 0; i<n; i++) cin>>arr[i]
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,d;
	cin>>n>>d;
	d *= d;
	int cnt = 0;
	ll a, b;
	for(int i = 0; i<n; i++)
	{
		cin>>a>>b;
		ll h = pow(a,2)+pow(b,2);
		if(h<=d) cnt++;
	}
	cout<<cnt;
	return 0;
}

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


bool backto(pair<pair<int, int>, pair<int, int>> left, pair<pair<int, int>, pair<int, int>> right) {
    return left.second.first < right.second.first;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<pair<int, int> ,pair<int, int>>> input(M);
    for (int i = 0; i < M; ++i) {
        cin >> input[i].first.first >> input[i].first.second;
        input[i].second.first = i;
    }
    sort(input.begin(), input.end());
    int temp = 1;
    for (int i = 0; i < M; ++i) {
        if (i > 0) {
            if (input[i - 1].first.first == input[i].first.first) {
                input[i].second.second = temp;
                ++temp;
            } else {
                temp = 1;
                input[i].second.second = temp;
                ++temp;
            }
        } else {
            input[i].second.second = temp;
            ++temp;
        }
    }
    cout << endl;
    sort(input.begin(), input.end(), backto);
    for (int i = 0; i < M; ++i) {
        printf("%06d", input[i].first.first);
        printf("%06d\n", input[i].second.second);
    }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<vector<int>> children(10010,vector<int>());
vector<int> v;
vector<int> c;
void dfs(int now,int parent){
    v[now]=c.back();
    c.pop_back();
    for(int child:children[now]){
        if(child==parent) continue;
        dfs(child,now);
    }
}
int main(){
    int n;
    cin>>n;
    children.resize(n);
    rep(i,0,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        children[a].push_back(b);
        children[b].push_back(a);
    }
    v.resize(n);
    c.resize(n);
    int sum=0;
    rep(i,0,n){
        cin>>c[i];
        sum+=c[i];
    }
    sort(all(c));
    cout<<sum-c[n-1]<<endl;
    dfs(0,-1);
    for(int x:v) cout<<x<<endl;
}


Measured memory_bytes: 1408
from __future__ import print_function
n = int(raw_input())

for i in range(n+1):
    if i != 0 and i % 3 == 0:
        print (" %i" % i, end="")
    elif i != 0 and i % 10 == 3:
        print (" %i" % i, end="")
    else:
        if str(i).find('3') >= 0:
            print (" %i" % i, end="")
print("")

Measured memory_bytes: 6528
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    String U = sc.next();
    
    if(S.equals(U)){
      A -= 1;
      System.out.println(A + " " + B);
    }else{
      B -= 1;
      System.out.println(A + " " + B);
    }
    
}
}


Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>

int main(void) {

	//test??¨
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	int n;
	std::cin >> n;

	std::string str_t, str_h;
	int tarou = 0, hanako = 0;

	for (int i = 0; i < n; i++) {
		std::cin >> str_t >> str_h;

		bool flg = 1;
		int index = 0;

		while (flg && index <= str_t.length() && index <= str_h.length()) {
			if (str_t[index] > str_h[index]) {
				tarou = tarou + 3;
				flg = 0;
			}
			else if (str_t[index] < str_h[index]) {
				hanako = hanako + 3;
				flg = 0;
			}
			else {
				index++;
			}
		}

		if (flg) {
			if (str_t.length() > str_h.length()) {
				tarou = tarou + 3;
			}
			else if (str_t.length() < str_h.length()) {
				hanako = hanako + 3;
			}
			else {
				tarou++;
				hanako++;
			}
		}

	}

	std::cout << tarou << " " << hanako << std::endl;

}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;

    rep(i,9) rep(j,9){
        if(n==(i+1)*(j+1)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, M;
  cin >> N >> M;
  vector<pair<i64, i64>> ans;
  if (N % 2 == 1)
  {
    for (i64 l = 1, r = N - 1; l < r; l++, r--)
      ans.push_back({l, r});
  }
  else
  {
    bool f = false;
    for (i64 l = 1, r = N - 1; l < r; l++, r--)
    {
      if (!f && r - l <= N / 2)
      {
        l++;
        f = true;
      }
      ans.push_back({l, r});
    }
  }
  for (i64 i = 0; i < M; i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}


Measured memory_bytes: 5308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,sum,t;
    while(scanf("%lld%lld%lld",&a,&b,&c)!=EOF)
    {
        t=(a+b+c)/2;
        sum=sqrt(t*(t-a)*(t-b)*(t-c));
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int i,j,n,k,m,g;
int main() 
{
	scanf("%d%d",&n,&k);
	std::vector<int> a(n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<n;i++) m=std::max(m,a[i]);
	if(m<k) 
	{
		puts("IMPOSSIBLE");
		return 0;
	}
	g=a[0];
	for(i=0;i<n;i++) g=std::__gcd(g,a[i]);
	if(k%g==0) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n + 1), b(n);
    REP(i, n + 1) cin >> a[i];
    REP(i, n) cin >> b[i];

    ll ans = 0;
    REP(i, n) {
        ans += min(a[i], b[i]);
        if (a[i] < b[i]) {
            int cnt = min(a[i + 1], b[i] - a[i]);
            a[i + 1] -= cnt;
            ans += cnt;
        }
    }

    cout << ans << ln;
    return 0;
}


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

int main(){
    int A,B,K,i,ans,count=0;
    cin >> A >> B >> K;
    for(i=100;0<i;i--){
        if(A%i == 0 && B%i == 0){
         ans = i;count++;
         }
        if(count == K){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
var n, ans,l,r:int64;
begin
  readln(n);
  l:=1;
  ans:=0;
  while l<=n do begin
    r:=l*10-1;
    if n<=r then
      inc(ans,n-l+1)
    else
      inc(ans,r-l+1);
    l:=l*100
  end;
  writeln(ans);
end.

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)

N = int(input())
paths = [dict() for i in range(N + 1)]
for i in range(N-1):
    u, v, w = map(int,input().split())
    paths[u][v] = w
    paths[v][u] = w

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in paths[now].items():
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])


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

int main(){
  double x = 0, y = 0;
  int angle = 90;

  while(true){
    int d, a; 
    scanf("%d,%d", &d, &a);
    if(d == 0 && a == 0) break;

    x += d * cos(angle*acos(-1)/180.0);
    y += d * sin(angle*acos(-1)/180.0);
    angle -= a;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;
}
  
  


Measured memory_bytes: 3524
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//??????????????¢??????????????¨debug()??????????????????
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A[2];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(A[1] < A[0]){
		int i = A[1];
		A[1] = A[0];
		A[0] = i;
	}
	while(A[1] % A[0]){
		int i = A[1] % A[0];
		A[1] = A[0];
		A[0] = i;
	}
}

void debug(){

}

void answer(){
	cout << A[0] << "\n";
}

int main(){
	for (int i = 0; i < 2; ++i)
	{
		cin >> A[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int a[100100];

int main() {
    #ifdef LOCAL
    assert(freopen("b.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    forn (i, n) {
        cin >> a[i];
        --a[i];
    }
    int res = 0;
    forn (i, n) {
        int x = a[a[i]];
        if (x == i)
            ++res;
    }
    cout << res / 2 << '\n';
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define INF 4000000000000000000
#define EPS 0.0000000000001
vector<pair<long long,pair<long long,long long> > > P;
int main()
{
    pair<long long,pair<long long,long long> > p;
    long long X,A,B,C;
    for(A=1;A<=120;A++)
    {
        for(B=A;A*A*A*A*A-B*B*B*B*B<MOD;B--)
        {
            p.first=A*A*A*A*A-B*B*B*B*B;
            p.second.first=A;
            p.second.second=B;
            P.push_back(p);
        }
    }
    sort(P.begin(),P.end());
    scanf("%lld",&X);
    int i;
    for(i=0;i<P.size();i++)
    {
        if(P[i].first==X)
        {
            printf("%lld %lld",P[i].second.first,P[i].second.second);
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3956
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
 
int main(){
    long long a,b,c,x,y,res;
    long long ans = 0;
    cin >> a >> b >> c >> x >> y;
    if( (a + b) / 2 > c){
        ans += min(x,y)*c*2;
        if(x > y){
            res = x - y;
            ans += res * a;
        }
        else if(y > x){
            res = y - x;
            ans += res * b;
        }
        if(c * max(x,y) * 2 <= ans){
            ans = c * max(x,y) * 2;
        }
    }
    else{
        ans += a * x + b * y;
        if(c * max(x,y) * 2 <= ans){
            ans = c * max(x,y) * 2;
        }
    }
    cout << ans << endl;
}

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

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<size_t> a(n);
  for (auto& ai: a) scanf("%zu", &ai), --ai;

  std::vector<size_t> p(n);
  for (size_t i = 0; i < n; ++i)
    p[a[i]] = i+1;

  for (size_t i = 0; i < n; ++i)
    printf("%zu%c", p[i], i+1<n? ' ': '\n');
}


Measured memory_bytes: 2432
#include <stdio.h>
      
using namespace std;
      
int main(){
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d = static_cast<double>(a);
    b_d = static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    string a,b;
    cin>>a>>b;
    string s="",t="";
    for (int i=0;i<b[0]-'0';i++)
        s+=a;
    for (int i=0;i<a[0]-'0';i++)
        t+=b;
    if (s>=t)
        cout<<t;
    else
        cout<<s;



}

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

using namespace std;

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

typedef long long ll;

const ll mod = 1e9+7;


ll n,i,j,k,t,l,r, c;
ll a[10003],b[10003],sa,sb,ta,tb;
queue<int> va, vb;

int main(){
	scanf("%d", &n);
	sa=sb=0;
	for(i=0;i<n;i++){
		scanf("%d", a+i);
		sa += a[i];
	}
	for(i=0;i<n;i++){
		scanf("%d", b+i);
		sb +=b[i];
	}
	if(sa>sb)
		puts("No");
	else if(sa==sb){
		for(i=0;i<n;i++)
			if(a[i]!=b[i]){
				puts("No");
				return 0;
			}
		puts("Yes");
	}
	else{
		sa = sb = 0;
		for(i=0;i<n;i++){
			if(a[i]<b[i]){
				if(((a[i]&1)^(b[i]&1))){
					a[i] +=2;
					b[i] +=1;
				}
				sa += b[i]-a[i];
				
			}
			else if(a[i]>b[i])
				sb += a[i]-b[i];
		}
		if(sb==0)
			puts("Yes");
		else{
			if(2*sb > sa)
				puts("No");
			else
				puts("Yes");
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n, i;
  cin >> n >> i;
  i--;
  print(n - i);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	double N;
	float sum=0;
	cin >> N;
	float x;
	string u;
	for(int i=0;i<N;i++){
		cin >> x >> u;
		if(u == "JPY"){
			sum += x;
		}else{
			sum += x * 380000.0;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
a_lst = list(map(int, input().split()))
for i in range(n):
    a_lst[i] += 1

max_a = max(a_lst)
count_lst = [0] * (max_a + 2)


for i in range(n):
    a = a_lst[i]
    index1 = a - 1
    index2 = a
    index3 = a + 1

    count_lst[index1] += 1
    count_lst[index2] += 1
    count_lst[index3] += 1

maximum = max(count_lst)
print(maximum)

Measured memory_bytes: 20736
#include<stdio.h>

int main(void)
{
    int H, N, i;
    scanf("%d %d", &H, &N);
    int A[N];
    for(i=0; i<N; i++) {
        scanf("%d", &A[i]);
        H -= A[i];
    }

    if(H <= 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

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

int main(){
    string a;
    cin>>a;
    if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2]){
        cout<<"Yes"<<endl;
    }
    else if(a[0]==a[2]&&a[1]==a[3]&&a[0]!=a[1]){
        cout<<"Yes"<<endl;
    }
    else if(a[0]==a[3]&&a[2]==a[1]&&a[0]!=a[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
H,W,K=map(int,input().split())
c=[list(input()) for i in range(H)]
count=0
for bit_h,bit_w in itertools.product(range(1<<H),range(1<<W)):
    black=0
    for h,w in itertools.product(range(H),range(W)):
        if c[h][w]=="#" and (bit_h>>h)&1 and (bit_w>>w)&1:
            black+=1
    if black==K:
        count+=1
print(count)

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

int top(int A){
    while(A>=10){
        A /= 10;
    }
    return A;
}
int back(int A){
    return A%10;
}
int c[10][10] = {0};

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        int x = top(i);
        int y = back(i);
        c[x][y]++;
    }
    int ans = 0;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            ans += c[i][j] * c[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256