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

using namespace std;
bool added_vertical[1000000];
bool added_horizontal[1000000];
int main() {
	unsigned long long W, H;
	cin >> W >> H;
	vector<unsigned long long> p(W), q(H);
	unsigned long long psum = 0;
	unsigned long long qsum = 0;
	for (unsigned long long i = 0; i < W; i++) {
		cin >> p[i];
		psum += p[i];
	}
	for (unsigned long long i = 0; i < H; i++){
	 cin >> q[i];
	 qsum += q[i];

	}
	sort(q.begin(), q.end());
	sort(p.begin(), p.end());
	p.push_back(1000000000000LL);
	q.push_back(1000000000000LL);
	unsigned long long QC = H+1;
	unsigned long long PC = W+1;
	unsigned long long qp = 0;
	unsigned long long pp = 0;
	unsigned long long ans = 0;
	unsigned long long ah = 0, av = 0;
	unsigned long long edges = 0;
	while (pp < p.size() && qp < q.size() && (edges < (H + 1) * (W + 1) - 1)) {
		if (p[pp] < q[qp]) {
			added_vertical[pp] = true;
			av++;
			edges += H+1-ah;
			ans += (H+1 - ah) * p[pp];
			pp++;
		} else {
			added_horizontal[qp] = true;
			ah++;
			edges += W+1-av;
			ans += (W+1 - av) * q[qp];
			qp++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll L, R, d, cnt = 0;
  cin >> L >> R >> d;
  for(ll i = L; i <= R; i++) {
    if(i % d == 0) cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;

int main()
{
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	cout << (std::abs(a - b) <= t * (v - w) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3624
<?php
$n = trim(fgets(STDIN));
list($m, $M) = explode(" ", trim(fgets(STDIN)));
$a = explode(" ", trim(fgets(STDIN)));
$c[0] = $c[1] = $c[2] = 0;
foreach($a as $b){
  if($b <= $m){
    $c[0]++;
  }elseif($b <= $M){
    $c[1]++;
  }else{
    $c[2]++;
  }
}
echo min($c);

Measured memory_bytes: 4604
from sys import stdin
from collections import deque

N = int(stdin.readline())
A = sorted([int(stdin.readline()) for i in range(N)])
ans1 = deque([A[N-1]])
ans2 = deque([A[0]])

f = 0
f2 = 1
b = N - 2
b2 = N - 1
s = True
while f <= b:
    if s:
        ans1.append(A[f])
        f += 1
        if f <= b:
            ans1.appendleft(A[f])
            f += 1
        ans2.append(A[b2])
        b2 -= 1
        if f2 <= b2:
            ans2.appendleft(A[b2])
            b2 -= 1
    else:
        ans1.append(A[b])
        b -= 1
        if f <= b:
            ans1.appendleft(A[b])
            b -= 1
        ans2.append(A[f2])
        f2 += 1
        if f2 <= b2:
            ans2.appendleft(A[f2])
            f2 += 1
    s = not s

a1 = a2 = 0
ans1 = list(ans1)
ans2 = list(ans2)
for i in range(N-1):
    a1 += abs(ans1[i] - ans1[i+1])
    a2 += abs(ans2[i] - ans2[i+1])

print(max(a1, a2))


Measured memory_bytes: 52316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int x;
	cin >> x;

	int now = 0;
	int ans = 0;
	for(int i=1;i<=33;i++) {
		for(int j=2;j<=33;j++) {
			now = pow(i, j);
			if (now <= x) {
				ans = max(now, ans);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main()
{
  int n,t,u,v,i,j,k,res=0;
  string s;
  vector<int> a[10];
  vector<int>::iterator it;
  cin >> n;
  cin >> s;
  for(i=0;i<n;i++){
    t=stoi(s.substr(i,1));
    a[t].push_back(i);
  }
  for(i=0;i<10;i++){
    if(a[i].empty())
      continue;
    t=a[i][0];
    for(j=0;j<10;j++){
      it=upper_bound(a[j].begin(),a[j].end(),t);
      if(it==a[j].end()){
        continue;
      }
      u=*it;
      for(k=0;k<10;k++){
        it=upper_bound(a[k].begin(),a[k].end(),u);
        if(it!=a[k].end())
          res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[] = new int[n];
		int sum=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		double d=(double)sum/n;
		int p=(int)Math.round(d);
		int sum1=0;
		for(int i=0;i<n;i++)
			sum1=sum1+((a[i]-p)*(a[i]-p));
		System.out.println(sum1);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  if (s.size() < 26) {
    s.resize(n + 1);
    vi was(256);
    for (int i = 0; i < n; ++i) was[s[i]] = 1;
    for (char x = 'a'; x <= 'z'; ++x) if (!was[x]) {
      was[x] = 1;
      s[n] = x;
      break;
    }
    cout << s << endl;
    return 0;
  }
  for (int i = n - 1; i >= 0; --i) {
    for (char x = s[i] + 1; x <= 'z'; ++x) {
      bool ok = 1;
      for (int j = 0; j < i; ++j) if (s[j] == x) ok = 0;
      if (ok) {
        s[i] = x;
        s.resize(i + 1);
        cout << s << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        string line = System.Console.ReadLine();
        while(line != null)
        {
            string[] num = line.Split(' ');
            int a = int.Parse(num[0]);
            int b = int.Parse(num[1]);
            System.Console.WriteLine((a + b).ToString().Length);
            line = System.Console.ReadLine();
        }
    }
}

Measured memory_bytes: 5640
#include <stdio.h>
 
int main() {
  char less[] = "a < b";
  char more[] = "a > b";
  char equal[] = "a == b";
  char *result;
  int a;
  int b;
  scanf("%d %d", &a, &b);
  if (a < b) {
    result = less;
  } else if (a > b) {
    result = more;
  } else {
    result = equal;
  }
  printf("%s\n", result);
  return 0;
}

Measured memory_bytes: 580
import java.util.*;
public class Main{
    public static void main(String args[]) {
    //scanner型の変数sに入力文字を格納
       // System.out.println("1番目の入力してください");
        Scanner s = new Scanner(System.in);
        //System.out.println("2番目の入力してください");
        //Scanner s2 = new Scanner(System.in);
        //sをinteger型に変換
        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());

        //System.out.println("掛け算の結果");
        System.out.println(a*b);

    }
}

Measured memory_bytes: 35696
while 1:
    m, f, r = map(int, input().split())
    if(m == -1 and f == -1 and r == -1):
        break
    if(m == -1 or f == -1):
        print('F')
    elif(m+f >= 80):
        print('A')
    elif(m+f >= 65 and m+f < 80):
        print('B')
    elif(m+f >= 50 and m+f < 65):
        print('C')
    elif(m+f >= 30 and m+f < 50):
        if(r >= 50):
            print('C')
        else:
             print('D')
    else:
        print('F')



Measured memory_bytes: 5596
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define vi vector < ll  int >
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007`
using namespace std;

void solve() {
    ll n,m,i,j,k,f1=1,f2=2,y=0,k1=0,k2=0,k3=0,x;
    cin>>n;
    string s;
    map < string , ll > M;
    rep(i,0,n)
      {
          cin>>s;
          sort(all(s));
          M[s]++;
      }
      map < string , ll > :: iterator it;
    for(it=M.begin();it!=M.end();++it)
    {
        if((it->second)>1) y+=((it->second)*(it->second-1)/2);
    }
    cout<<y;

}



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


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

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

    cout << 3*pow(r,2) << endl;

    return 0;
    




}


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

typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    map<char, int> point{{'r', p}, {'s', r}, {'p', s}};
    vector<bool> win(n);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i - k + 1 <= 0) {
            ans += point[t[i]];
            win[i] = true;
        } else {
            if (t[i-k] == t[i] && win[i-k]) win[i] = false;
            else {
                ans += point[t[i]];
                win[i] = true;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0013
{
    class Program
    {
        static List<int> _garage = new List<int>();
        static void Main(string[] args)
        {
            string trainNum = "";
            while ((trainNum = Console.ReadLine()) != null)
            {
                if (trainNum == "0")
                {
                    Console.WriteLine(_garage[_garage.Count - 1]);
                    _garage.Remove(_garage[_garage.Count - 1]);
                }
                else
                {
                    _garage.Add(int.Parse(trainNum));
                }
            }
        }
    }
}



Measured memory_bytes: 17820
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s,t;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0' || s[i]=='1'){
			t.push_back(s[i]);
		}
		else if(s[i]=='B' && t.size()!=0){
			t.pop_back();
		}
	}
	
	cout<<t<<endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
   for (int i = 0; i < M; i++) {
     int a, b;
     cin >> a >> b;
     vec.at(a-1) ++;
     vec.at(b-1) ++;
   }
   for (int i = 0; i < N; i++) {
     cout << vec.at(i) << endl;
   }
}

Measured memory_bytes: 3636
n = int(input())
query = []
query0 = []
for i in range(n):
    x, y, h = map(int, input().split())
    if h > 0:
        query.append([x, y, h])
    else:
        query0.append([x, y, h])

for cx in range(101):
    for cy in range(101):
        res = []
        for i in range(len(query)):
            x, y, h = query[i]
            p = abs(x - cx) + abs(y - cy)
            H = h + p
            if h != 0:
                res.append(H)

        if len(set(res)) == 1:
            H = res[0]
            for j in range(len(query0)):
                x0, y0, _ = query0[j]
                if 0 < H - abs(x0 - cx) - abs(y0 - cy):
                    break
            else:
                print(cx, cy, H)
                exit()


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int a[100001];
long long ans[100001];

int main() {
    int n, x, c = 0, i;
    long long sum = 0;
    vector <pair<int, int> > v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i + 1]);
        
        v.push_back(make_pair(a[i + 1], i + 1));
    }
    
    v.push_back(make_pair(0, 0));
    
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    x = v[0].second;
    c++;
    sum += v[0].first;
    
    for (i = 1; i < v.size(); i++) {
        int y = v[i].second;
        
        if (y < x) {
            ans[x] = sum - (long long)a[y] * c;
            sum -= ans[x];
        }
        
        x = min(x, y);
        c++;
        sum += a[y];
    }
    
    for (i = 1; i <= n; i++) printf("%lld\n", ans[i]);
    
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;
int m, nmin, nmax;

int main() {
    int n, m;
    while(cin >> n >> m, n&&m){
        vector<int> v;
        int sumA=0, sumB=0, sum=0;
        for(int i=0; i<n+m; ++i){
            int a; cin >> a;
            v.push_back(a);
            sum += a;
        }
        bool ok=false;
        pair<int, int> ans;
        int minV = 10000;
        sumA = accumulate(v.begin(), v.begin()+n, 0);
        sumB = sum - sumA;
        if(sumB>sumA){
            for(int i=0; i<n; ++i){
                for(int j=0; j<m; ++j){
                    if(sumB-sumA == 2*(v[j+n]-v[i])){
                        if(minV >= v[j+n]+v[i]){
                            minV = v[j+n]+v[i];
                            ans.first=v[i]; ans.second=v[j+n];
                        }
                        ok = true;
                    }
                }
            }
        }else if(sumA > sumB){
            for(int i=0; i<n; ++i){
                for(int j=0; j<m; ++j){
                    if(sumA-sumB == 2*(v[i]-v[j+n])){
                        if(minV >= v[j+n]+v[i]){
                            minV = v[j+n]+v[i]; 
                            ans.first=v[i]; ans.second=v[j+n];
                        }
                        ok = true;
                    }
                }
            }
        }else if(sumA==sumB){
            for(int i=0; i<n; ++i){
                for(int j=0; j<m; ++j){
                    if(v[i]==v[j+n]&&minV > v[i]+v[j+n]){
                        minV = v[i]+v[j+n];
                        ans.first=v[i]; ans.second=v[j+n];
                    }
                }
            }
            ok = true;
        }
        if(!ok||ans.first==0&&ans.second==0) cout << -1 << endl;
        else cout << ans.first << " " << ans.second << endl;
    }
    return 0;
}


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

void chmax(int& a, int b){
    a = max(a, b);
}

int main(){
    int N, T;
    cin >> N >> T;
    int A[3000], B[3000];
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];

    static int dp[3001][6001][3];
    for(int i=0; i<N; i++) for(int j=0; j<T; j++) for(int k=0; k<2; k++) for(int l=0; l<2; l++){
        chmax(dp[i+1][j][k], dp[i][j][k]);
        chmax(dp[i+1][j+(1-l)*A[i]][k+l], dp[i][j][k] + B[i]);
    }
    int ans = 0;
    for(int j=0; j<T; j++) for(int k=0; k<2; k++) chmax(ans, dp[N][j][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 211200
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll N,D;
  	cin >> N >> D;
	int count=0;	
	for(ll i=0;i<N;i++){
    	ll x,y;
	    cin >> x >> y;
    	if(x*x + y*y <= D*D){
        	count+=1;
        }
    }
	cout << count << endl;
}

Measured memory_bytes: 3588
N, Q = map(int, input().split())
s = input()

t = []
d = []
for i in range(Q):
    t_i, d_i = input().split()
    t.append(t_i)
    d.append(d_i)


def calc_group(n):
    for i in range(Q):
        if s[n] == t[i]:
            if d[i] == 'L':
                n -= 1
                if n == -1:
                    return -1
            elif d[i] == 'R':
                n += 1
                if n == N:
                    return 1
    return 0


l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == -1:
        l = n
    else:
        r = n
    n = (l + r) // 2
l_max = l

l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == 1:
        r = n
    else:
        l = n
    n = (l + r) // 2
r_min = r

if r_min == l_max:
    count = 0
else:
    count = r_min - l_max - 1
print(count)

Measured memory_bytes: 6680
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    enemy_hp = int(input())
    enemy_count=1
    attack_count=1

    if enemy_hp==1:
        print(1)
        exit()
    else:
        while enemy_hp >1:
            enemy_hp = int(enemy_hp/2)
            enemy_count*=2
            attack_count+=enemy_count
            
    print(attack_count)

if __name__=="__main__":
    main()

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

int main(){
  ll n, m;
  cin >> n >> m;
  priority_queue<ll> que;
  for(ll i=0; i<n; i++){
    ll tmp;
    cin >> tmp;
    que.push(tmp);
  }
  
  for(ll i=0; i<m; i++){
  	ll tmp = (ll)(que.top()/2);
    que.pop();
    que.push(tmp);
  }
  
  ll ans = 0;
  for(ll i=0; i<n; i++){
  	ans += que.top();
    que.pop();
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

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

        int ans = 0;
        for(int i = 0; i< n;i++){
            ans += sc.nextInt() >= k ? 1 : 0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 47728
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

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

  int a[n];

  forf(i,0,n) cin >> a[i];

  if(n==2)
  {
    cout<<a[1]<<" "<<a[0]<<endl;
    return ;
  }

  int XOR = 0;

  for(int i=0;i<n;i+=2)
  {
    XOR = ( XOR xor (a[i] xor a[i+1]));
  }
  
  for(int i=0;i<n;i++)
  {
    cout<<( a[i] xor XOR)<<" ";
  }

}


int32_t main()
{
 // pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 5212
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  size_t n;
  cin >> n;
  int S[10010];
  for (size_t i = 0; i < n; i++) {
    cin >> S[i];
  }
  sort(S, S + n);

  size_t q;
  cin >> q;
  int T[510];
  for (size_t i = 0; i < q; i++) {
    cin >> T[i];
  }
  sort(T, T + q);

  int c = 0;
  size_t k = 0;
  for (size_t i = 0; i < q; i++) {  // T[i]
    while (S[k] < T[i] && k < n) {
      // printf("skip: %d, %d\n", S[k], T[i]);
      k++;
    }
    // while (S[k] == T[i] && k < n) {
    //   printf("yes: %d, %d\n", S[k], T[i]);
    //   k++;
    //   c++;
    // }
    if (S[k] == T[i]) {
      c++;
    }
  }

  printf("%d\n", c);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  bool flg = false;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[2] == s[3] && s[1] == s[2]))
    flg = true;

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){
  int a[50]={};
  int m=30,l=30;

  rep(i,n){
    char c;
    cin>>c;
    int b = c-'A';
    a[b]++;
    rep(j,30){
      if(a[m]<a[j]){
        l = m;
        m = j;
      }
    }
    rep(j,30){
      if(j!=m&&a[l]<a[j]) l=j;
    }
    if(a[m]>a[l]+n-i-1){
      FOR(j,i+1,n) cin>>c;
      c = m+'A';
      cout<<c<<' '<<i+1<<endl;
      return;
    }
  }
  
    cout<<"TIE"<<endl;
  
}



int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    f(n);
  }


  return 0;
}


Measured memory_bytes: 3056
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,k,a[202020],sum;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=k;i<n;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int32_t main()
{
	FIO;
	int x; cin >> x;

	x ^= 1;

	cout << x << '\n';
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, q;
string s;
vector<set<int>> vs;

int main() {
    cin >> n >> s >> q;
    vs.resize(26);
    rep(i, n) {
        vs[s[i] - 'a'].insert(i);
    }

    rep(i, q) {
        int t; cin >> t;
        if (t == 1) {
            int iq; char cq;
            cin >> iq >> cq;
            iq--;
            vs[s[iq]-'a'].erase(iq);
            s[iq] = cq;
            vs[cq-'a'].insert(iq);
        } else {
            int l, r; cin >> l >> r;
            l--;
            int cnt = 0;
            rep(j, 26) {
                if (vs[j].lower_bound(l) != vs[j].lower_bound(r)) cnt++;
            }
            cout << cnt << endl;
        }
    }
}


Measured memory_bytes: 26244
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    int res = n;
    for( int i = 0; i <= n; ++i ) {
        int c = 0;
        int t = i;
        while( t > 0 ) {
            c += t % 6;
            t /= 6;

        }
        t = n - i;
        while( t > 0 ) {
            c += t % 9;
            t /= 9;

        }
        res = min( res, c );

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
a = gets.chomp.to_i
b = gets.chomp.to_i

if a == 1
    if b == 2
        puts 3
    else b == 3
        puts 2
    end
elsif a == 2
    if b == 1
        puts 3
    else
        puts 1
    end
elsif a == 3
    if b == 1
        puts 2
    else
        puts 1
    end
end

Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, h[112345];

    cin >> n;
    REP(i, n)
    cin >> h[i];

    ll res = 0;

    ll dp[112345];

    dp[1] = 0;
    dp[2] = abs(h[1] - h[0]);

    for (int i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i - 2] + abs(h[i - 1] - h[i - 1 - 2]), dp[i - 1] + abs(h[i - 1] - h[i - 1 - 1]));
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1408
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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

ll dp[20][20];

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

    int N;
    cin >> N;

    string str;
    cin >> str;

    string LHS = str.substr(0, N);
    string RHS = str.substr(N, N);
    reverse(allof(RHS));
    
    ll ans = 0;

    for(int mask = 0; mask < (1 << N); mask++){
        string lft;
        string extra;
        for(int a = 0; a < N; a++){
            if(mask & (1 << a)){
                lft += str[a];
            } else {
                extra += str[a];
            }
        }

        memset(dp, 0, sizeof dp);
        dp[0][0] = 1;
        for(int a = 0; a < N; a++){
            for(int b = 0; b <= (int)lft.size(); b++){
                int c = a - b;
                if(0 <= c && c <= (int)extra.size()){
                    if(b < (int)lft.size() && RHS[a] == lft[b]){
                        dp[b + 1][c] += dp[b][c];
                    }
                    if(c < (int)extra.size() && RHS[a] == extra[c]){
                        dp[b][c + 1] += dp[b][c];
                    }
                }
            }
        }
        ans += dp[lft.size()][extra.size()];
    }
    cout << ans;
}


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

int main(){
  string a,b;
  cin >> a >> b;
  
  string ab = a + b;
  double abkazu = stoi(ab);
  
  double abkazusqrt = sqrt(abkazu);
  double abkazuaqrtkirisute = floor(abkazusqrt);
  
  if(abkazusqrt == abkazuaqrtkirisute)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,q;cin>>n>>m>>q;
    int train[512][512]={};
    for(int i=0;i<m;i++){
        int l,r;cin>>l>>r;
        train[l][r]++;
    }
    int ans[512][512]={};
    for(int l=n;l>0;l--){
        for(int r=l;r<n+1;r++){
            ans[l][r]=ans[l][r-1]+ans[l+1][r]-ans[l+1][r-1]+train[l][r];
        }
    }
    for(int i=0;i<q;i++){
        int l,r;cin>>l>>r;
        cout<<ans[l][r]<<endl;
    }
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int h,r;
    while(cin >> h >> r,h){
        vector<string> s(h);
        for (int i = 0; i < h; i++) {
            cin >> s[i];
        }
        string t;cin >> t;
        int y=0,x=0;
        int ans=0;
        for (int k = 0; k < t.length(); k++) {
            bool f=false;
            for (int i = 0; i < h; i++) {
                if(f) break;
                for (int j = 0; j < r; j++) {
                    if(s[i][j]==t[k]){
                        ans+=abs(i-y)+abs(j-x);
                        x=j,y=i;
                        f=true;
                        break;
                    }
                }
            }
        }
        cout << ans+t.length() << endl;
    }
    return 0;
}



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

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  int i, j;
  vector<long long> a(n);
  vector<long long> k(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    k[a[i] - 1]++;
  }
  long long as = 0;
  vector<long long> s(n);
  for (i = 0; i < n; i++) {
    s[i] = k[i] * (k[i] - 1) / 2;
    as += s[i];
  }
  for (i = 0; i < n; i++) {
    cout << as - s[a[i] - 1] + (k[a[i] - 1] - 1) * (k[a[i] - 1] - 2) / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 7296
def solve():
    N, *X = map(int, open(0).read().split())
    
    ans = 10 ** 8
    for p in range(1, 101):
        sm = 0
        for xi in X:
            sm += (xi - p) ** 2
        ans = min(ans, sm)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    string c,d,e;
    c=to_string(a);
    d=to_string(b);
    e = c+d;
    int f;
    f=stoi(e);
    int k = sqrt(f);
    if(f==k*k){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

ans = ''
dx = tx - sx
dy = ty - sy
ans += 'R' * dx
ans += 'U' * dy
ans += 'L' * dx
ans += 'D' * dy
ans += 'D'
ans += 'R' * (dx + 1)
ans += 'U' * (dy + 1)
ans += 'LU'
ans += 'L' * (dx + 1)
ans += 'D' * (dy + 1)
ans += 'R'
print(ans)


Measured memory_bytes: 38384
import math
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=min(a,min(b,min(c,min(d,e))))
i=math.ceil(n/k)
while i*k<n:
  i+=1
print(4+i)


Measured memory_bytes: 61996
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
   int n,ch;
   cin>>n;
   bool f=true;
   map<string,int> dict;
   vector<string> ans;
   for(string x; n--; dict[x]++){
       cin>>x;
   }
   struct Word{
       string s;
       int v;
   };
   vector<Word> w;
   for(auto itr=dict.begin();itr!=dict.end();++itr)
        w.push_back({itr->first,itr->second});
    sort(w.begin(),w.end(),[](const Word &a,const Word &b){return a.v>b.v;});
    for(Word a: w){
        if(f){
            ch=a.v;
            f=false;
        }
        if(a.v==ch)
            ans.push_back(a.s);
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 33644
import math

a, b, x = (int(i) for i in input().split())
ma = a*a*b
if ma >= 2*x:
    l = 2*x/(a*b)
    print(math.degrees(math.atan(b/l)))
else:
    l = 2*(a*a*b-x)/(a*a)
    print(math.degrees(math.atan(l/a)))

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  rep(i, 9){
    if(111*(i+1)>=N){
      cout << 111*(i+1);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
bool dp[81][81][25600];
signed main(){
    int h,w,a[80][80],b;
    cin>>h>>w;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>b,a[i][j]-=b;
    dp[1][0][12800]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<25600;k++){
                if(dp[i][j+1][k]){
                    dp[i+1][j+1][k+a[i][j]]=1;
                    dp[i+1][j+1][k-a[i][j]]=1;
                }
                if(dp[i+1][j][k]){
                    dp[i+1][j+1][k+a[i][j]]=1;
                    dp[i+1][j+1][k-a[i][j]]=1;
                }
            }
        }
    }
    int ans=mod;
    for(int i=0;i<25600;i++)
        if(dp[h][w][i])
            ans=min(ans,max(i-12800,12800-i));
    cout<<ans<<endl;
}


Measured memory_bytes: 162304
num = [0] * 4
for i in range(3):
	a,b = map(int,input().split())
	num[a-1]+=1
	num[b-1]+=1
if num[0] == 1 and num[1] == 2 and num[2] == 2 and num[3] == 1:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    cin >> H >> W;
    int a,b; cin >> a >> b;
    cout << H * W - H*b - a*W + a*b << endl;
}



Measured memory_bytes: 256
use proconio::input;

#[proconio::fastout]
pub fn main() {
    const M: i64 = 1000000007;
    input! {
    n:usize,
    k:usize,
    a:[i64;n],
    }
    let mut apos: Vec<i64> = a.iter().filter(|&x| x >= &0).cloned().collect();
    let mut aneg: Vec<i64> = a.iter().filter(|&x| x <= &0).cloned().collect();
    let ans = if n == k {
        a.iter().fold(1, |pr, v| (pr * v).rem_euclid(M))
    } else if apos.len() == 0 && k % 2 == 1 {
        //必ず非正。絶対値を最小化したい
        aneg.sort_by_key(|&x| std::cmp::Reverse(x));
        aneg.iter().take(k).fold(1, |pr, v| (pr * v).rem_euclid(M))
    } else {
        //必ず非負
        apos.sort();
        let mut tmp = 1;
        if k % 2 == 1 {
            tmp *= apos.pop().unwrap();
        }
        aneg.sort();
        let mut aall: Vec<i64> = apos.rchunks_exact(2).map(|c| c[0] * c[1]).collect();
        let mut aneg: Vec<i64> = aneg.chunks_exact_mut(2).map(|c| c[0] * c[1]).collect();
        aall.append(&mut aneg);
        aall.sort_by_key(|&x| std::cmp::Reverse(x));
        tmp *= aall.iter().take(k / 2).map(|&v| v.rem_euclid(M)).fold(1, |pr, v| (pr * v).rem_euclid(M));
        tmp.rem_euclid(M)
    };
    println!("{}", ans);
}


Measured memory_bytes: 9484
#include <stdio.h>

int main(void) {
  int a, b;
  char op;
  scanf ("%d %c %d", &a, &op, &b );
  while(op != '?'){
    if ( op == '+' ) printf("%d\n", a + b);
    else if ( op == '-' ) printf("%d\n", a - b);
    else if ( op == '*' ) printf("%d\n", a * b);
    else if ( op == '/' ) printf("%d\n", a / b);
    else printf("Unexpexted syntax!! ERROR!!!\n");
    scanf ("%d %c %d", &a, &op, &b );
  }
  return 0;
}



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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u)
        a--;
    else
        b--;
    print(a, b);

    return 0;
}


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

int main() {
	int n;
	cin>>n;
	int ya=0;
	int co=0;
	for(int i=1;i<n+1;i+=2){
		co=0;
		for(int j=1;j<i+1;j++){
			if(i%j==0){
				co++;
			}
		}
		if(co==8){
			ya++;
		}
	}
	cout<<ya<<endl;
}

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

using namespace std;

int main()
{
	string s[2];
	cin >> s[0] >> s[1];
	reverse(s[1].begin(), s[1].end());

	if (s[0] == s[1]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;


int N;
string A, B, C;

int main() {
	cin >> N >> A >> B >>C;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int cnt;
		if (A[i] == B[i]) {
			if (B[i] == C[i]) {
				cnt = 0;
			}
			else {
				cnt = 1;
			}
		}
		else {
			if (A[i] == C[i] or B[i] == C[i]) {
				cnt = 1;
			}
			else {
				cnt = 2;
			}
		}
		ans += cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int K;
  cin >> K;
  int64_t dp[S.size()+1][4][2];
  for(int i=0; i<S.size()+1; i++){
    for(int j=0; j<4; j++){
      for(int k=0; k<2; k++){
        dp[i][j][k] = 0;
      }
    }
  }
  dp[0][0][0] = 1;
  
  for(int i=0; i<S.size(); i++){
    int x = S.at(i) - '0';
    for(int j=0; j<4; j++){
      for(int k=0; k<2; k++){
        for(int a=0; a<10; a++){ //次の桁をどうするか
          int ni = i+1;
          int nj = j;
          int nk = k;  //遷移先
          if(a != 0){
            nj++;
          }
          if(nj > K){
            continue;
          }
          if(x > a && k == 0){
            nk = 1;
          }
          if(x < a && k == 0){
            continue;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  
  cout << dp[S.size()][K][0] + dp[S.size()][K][1] << endl;
}

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

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    int a[100002];
    int b[100002] {0};
    for(int i = 0; i < q; i++){
        cin >> a[i];
        b[a[i]]++;
    }
    for(int i = 1; i <= n; i++){
        if(k + b[i] > q) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408