akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int a,b,d,r;
  double f;

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

  d=a/b;
  r=a%b;
  f=(double)a/b;

  printf("%d %d %f\n",d,r,f);

  return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;
import java.util.TreeMap;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int D = Integer.parseInt(scanner.next());
        int A = Integer.parseInt(scanner.next());
        TreeMap<Integer, Integer> m = new TreeMap<>();
        for (int i = 0; i < N; i++) {
            Integer x = Integer.parseInt(scanner.next());
            Integer h = Integer.parseInt(scanner.next());
            m.put(x, h);
        }

        // TreeMap<Integer, Integer> bomb = new TreeMap<>();
        DynamicSegTree bomb = new DynamicSegTree(2_000_000_000);

        long ans = 0;
        while (!m.isEmpty()) {
            Integer at = m.firstKey();
            Integer v = m.firstEntry().getValue();
            int prev = (int) bomb.query(at - D, at + D);
            v -= A * prev;
            if (v <= 0) {
                m.remove(at);
                continue;
            }
            Integer cnt = v / A + (v % A == 0 ? 0 : 1);
            ans += cnt;
            bomb.update(at + D, cnt);
            m.remove(at);
        }

        System.out.println(ans);
    }
}


class DynamicSegTree {
    class Node {
        Node left;
        Node right;
        long val;
    }

    Node root;
    long size;

    public DynamicSegTree(long size) {
        this.size = Long.highestOneBit(size);
        if (size > this.size) {
            this.size <<= 1;
        }
        root = new Node();
    }

    void update(int index, long x) {
        Node curr = root;
        long l = 0, r = size;
        curr.val += x;
        while (r - l > 1) {
            long mid = (l + r) >>> 1;
            if (index < mid) {
                if (curr.left == null)
                    curr.left = new Node();
                curr = curr.left;
                r = mid;
            } else {
                if (curr.right == null)
                    curr.right = new Node();
                curr = curr.right;
                l = mid;
            }
            curr.val += x;
        }
    }

    long query(int a, int b) {
        return query(a, b, root, 0, size);
    }

    private long query(int a, int b, Node curr, long l, long r) {
        if (a <= l && r <= b) {
            return curr.val;
        }
        if (r <= a || b <= l) {
            return 0;
        }

        long left = curr.left == null ? 0 : query(a, b, curr.left, l, (l + r) >>> 1);
        long right = curr.right == null ? 0 : query(a, b, curr.right, (l + r) >>> 1, r);
        return left + right;
    }
}



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

using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	int res[n][3];
	res[0][0]=max(b[0],c[0]);
	res[0][1]=max(a[0],c[0]);
	res[0][2]=max(a[0],b[0]);
	for(int i=1; i<n; i++){
		res[i][0]=max(res[i-1][1]+b[i], res[i-1][2]+c[i]);
		res[i][1]=max(res[i-1][0]+a[i], res[i-1][2]+c[i]);
		res[i][2]=max(res[i-1][1]+b[i], res[i-1][0]+a[i]);
	}
	cout<<max(res[n-1][0],max(res[n-1][1],res[n-1][2]));
}	

Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a*b >= c*d){
        cout<<a*b<<endl;
    }
    else{
        cout<<c*d<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616
import bisect
n = int(input())
*a, = sorted(map(int, input().split()))
*b, = sorted(map(int, input().split()))
*c, = sorted(map(int, input().split()))

ans = 0
for _b in b:
    _a = bisect.bisect_left(a, _b)
    _c = bisect.bisect_right(c, _b)

    ans += _a*(len(c)-_c)

print(ans)


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

int x[100010],y[100010];
int c(const void*p,const void*q){
	if(x[*(int*)p]<x[*(int*)q])return -1;
	if(x[*(int*)p]>x[*(int*)q])return 1;
	if(y[*(int*)p]<y[*(int*)q])return -1;
	return 1;
}
int idx[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d",x+i,y+i);
	for(int i=0;i<n;i++)idx[i]=i;
	qsort(idx,n,sizeof(int),c);
	for(int i=0;i<n;i++)printf("%d %d\n",x[idx[i]],y[idx[i]]);
}


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
long long n,k,ans;
int main()
{
    cin>>n>>k;
    ans=(n/k)*(n/k)*(n/k);
    if(k%2==0)
    {
        long long t=n/k+(n%k>=k/2);
        ans+=t*t*t;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize ("trapv") // kills the program on integer overﬂows (but is really slow).
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"

#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

const ll mod = 1e9 + 7;
const ll N = 3e3 + 6;
const ll maxN = 1e4 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in4.txt", "r", stdin);
	freopen("out3.txt", "w", stdout);
#endif
	FIO
	ll x, k, d;
	cin >> x >> k >> d;
	if (x < 0) x = -x;
	ll st = x / d;
	ll v1 = x - (st) * d; //
	ll v2 = x - (st + 1) * d;
	v2 = abs(v2);
	if (k <= st) {
		// cout << "hh ";
		cout << x - (k) * d; return 0;
	}
	ll rem = k - st;
	if (rem % 2 == 0) {
		cout << v1 << endl;
	}
	else cout << v2 << endl;
	return 0;
}


Measured memory_bytes: 3636
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
k = gets.chomp.to_i
a,b = gets.chomp.split.map(&:to_i)

a.upto(b) do |i|
  if i % k == 0
    puts 'OK'
    exit
  end
end

puts 'NG'



Measured memory_bytes: 14688
package main
 
import "fmt"
 
func main() {
	var n int
    fmt.Scan(&n)
   	s := make([]string, n+1)
    for i := 0; i < n; i++ {
        fmt.Scan(&s[i])
    }
  var output_map map[string]int =  map[string]int{"AC":0, "WA":0, "TLE":0, "RE":0}
  
  for _, v := range s {
    switch v {
    case "AC":
      output_map["AC"] = output_map["AC"] + 1
    case "WA":
      output_map["WA"] = output_map["WA"] + 1
    case "TLE":
      output_map["TLE"] = output_map["TLE"] + 1
    case "RE":
      output_map["RE"] = output_map["RE"] + 1
    }
  }
  fmt.Printf("AC x %#v\n", output_map["AC"])
  fmt.Printf("WA x %#v\n", output_map["WA"])
  fmt.Printf("TLE x %#v\n", output_map["TLE"])
  fmt.Printf("RE x %#v\n", output_map["RE"])
}


Measured memory_bytes: 6864
# -*- coding: utf-8 -*-
h,w = list(map(int,input().split()))
ss = ["#"*(w+2)]
for i in range(h):
    ss.append("#" + input()+"#")
ss.append("#"*(w+2))

yoko_list = []
tate_list = []
for s in ss:
    w_l_len_list = []
    w_l_len = 0
    for i,v in enumerate(s):
        if v == "#":
            w_l_len_list+=[w_l_len] * w_l_len
            w_l_len_list+=[0]
            w_l_len = 0
        else:
            w_l_len+=1
    yoko_list.append(w_l_len_list)
for s in zip(*ss):
    w_l_len_list = []
    w_l_len = 0
    for i,v in enumerate(s):
        if v == "#":
            w_l_len_list+=[w_l_len] * w_l_len
            w_l_len_list+=[0]
            w_l_len = 0
        else:
            w_l_len+=1
    tate_list.append(w_l_len_list)
ret = 0
for i in range(h+1):
    for j in range(w+1):
        ret = max(ret,tate_list[j][i]+yoko_list[i][j]-1)
print(ret)

Measured memory_bytes: 129540
x, y = map(int, input().split())
ans = float("inf")
if x <= y:
    ans = min(ans, y - x)
if -x <= y:
    ans = min(ans, y + x + 1)
if x <= -y:
    ans = min(ans, -y - x + 1)
if -x <= -y:
    ans = min(ans, -y + x + 2)
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int[] s=new int[3];
		for(int i=0;i<3;i++)
			s[i] = sc.nextInt();
		Arrays.sort(s);
		int sum = s[0] + s[1];
		
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 22740
def main(argv)
  n = gets.chomp.to_i
  s = [''] * n
  n.times {|i| s[i] = gets.chomp.split('').sort.join('') }
  
  h = {}
  n.times do |i|
    if h.has_key?(s[i]) then
      h[ s[i] ] += 1
    else
      h[ s[i] ] = 1
    end
  end
  
  c = 0
  h.each do |k, v|
    c += (v * (v - 1)) / 2
  end
  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

uint64_t modpow(uint64_t a, uint64_t p, const uint64_t& mod)
{
  if (p == 0) return 1;
  if (p % 2 == 0) {
    uint64_t h = modpow(a, p / 2, mod);
    return h * h % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

uint64_t combination(uint64_t a, uint64_t b, const uint64_t& mod)
{
  if (a - b < b) return combination(a, a - b, mod);
  uint64_t ansmul = 1;
  uint64_t ansdiv = 1;
  for (uint64_t i = 0; i < b; i++) {
    ansmul *= a - i;
    ansdiv *= i + 1;
    ansmul %= mod;
    ansdiv %= mod;
  }
  uint64_t ans = ansmul * modpow(ansdiv, mod - 2, mod) % mod;
  return ans;
}

int main()
{
  const uint64_t mod = 1'000'000'007;
  uint64_t n, m;
  cin >> n >> m;
  uint64_t mm = m;
  uint64_t ans = 1;
  for (auto i = 2; i <= mm; i++) {
    if (mm % i == 0) {
      uint64_t count = 0;
      while (mm % i == 0) {
	count++;
	mm /= i;
      }
      ans *= combination(n + count - 1, count, mod);
      ans %= mod;
    }
  }
  if (mm != 1) {
    ans *= n;
    ans %= mod;
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	string ans = S;

	for (int i = 0; (size_t)i < S.size(); i++) {
		ans[i] += N;
		if (ans[i] > 'Z') {
			ans[i] -= ('Z' - 'A' + 1);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int A[10],B[10],D[10],E[10];
void Sort(int C[10]);
int Search(int num,int ans);
int Answer_1(void);
int Answer_2(void);
int main(void){
	int tmp,i,n,cnt;
	char str[100],*line;

	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%d",&n); A[1]=n; B[1]=n;
	for(i=2;i<=6;i++){
		line = strtok(NULL," ");
		sscanf(line,"%d",&n); A[i]=n; B[i]=n;
	}
	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%d",&n); D[1]=n; E[1]=n;
	for(i=2;i<=6;i++){
		line = strtok(NULL," ");
		sscanf(line,"%d",&n); D[i]=n; E[i]=n;
	}
	Sort(A); Sort(D);
	if(Answer_1()) return 0;
	Search(1,2);
	Search(1,3);
	Search(2,3);
	Answer_2();	
	return 0;
}		

void Sort(int C[10]){
	int tmp,i;
	for(i=1;i<6;i++){
		if(C[i]>C[i+1]){
			tmp = C[i+1];
			C[i+1] = C[i];
			C[i] = tmp;	
		}
	}
}
int Search(int num,int ans){
	int tmp,i;
	for(i=0;i<10;i++){
		if(B[num]==E[num])
			return 0;
		tmp = B[num];
		B[num] = B[ans];
		B[ans] = B[7-num];
		B[7-num] = B[7-ans];
		B[7-ans] = tmp;
	}
	return 0;
}
int Answer_1(void){
	int i,cnt=0;
	for(i=1;i<=6;i++){
		if(A[i] == D[i])
			cnt++;
	}
	if((cnt==6) && (A[1]==A[2]) && (A[2]==A[3]) && (A[3]==A[4]) && (A[4]==A[5])){
		printf("Yes\n");
		return 1;
	}
	return 0;
}
int Answer_2(void){
	int i;
	for(i=2;i<=6;i++){
		if(B[i] != E[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
bool bemid(int a,int b,int c){
	return b<a&&a<c || b>a&&a>c;
}
int main(){
	int n;cin>>n;
	int p[29];
	for(int i=1;i<=n;++i)cin>>p[i];
	int c=0;
	for(int i=2;i<n;++i){
		if(bemid(p[i],p[i-1],p[i+1]))c++;
	}
	cout<<c;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int oturi, number;
  
  for(int i = 0; i * 1000 < N; i++) {
    number = i;
  }
  
  oturi = (number + 1) * 1000 - N;
  cout << oturi << endl;
  
}

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

main()
{
    long long n,s;
    scanf("%lld %lld",&n,&s);
    if(n==s)
    {
        printf("%lld",n+1);
        return 0;
    }
    long long ans=1e18;
    for(long long b=2;b*b<=n;b++)
    {
        long long cnt=0;
        long long sn=n;
        while(sn>0)
        {
            cnt+=sn%b;
            sn/=b;
        }
        if(cnt==s)
        {
            ans=min(ans,b);
        }
    }
    for(long long p=1;p*p<=n&&p<=s;p++)
    {
        long long q=s-p,b=(n-q)/p;
        if((n-q)%p!=0)continue;
        if(p<b&&q<b)ans=min(ans,b);
    }
    if(ans==1e18)printf("-1\n");
    else printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

int main(int argc, char* argv[])
{
  int a, b, c;
  std::cin >> a >> b >> c;

  int max_num = std::max(std::max(a, b), c);
  int x = max_num * 3 - a - b - c;
  int ans = 0;
  if (x % 2 == 0) {
    ans = x / 2;
  } else {
    ans = x / 2 + 2;
  }

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


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

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000] {0};

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;
		
		//まず0番目の単語を入れておく
		for (int i = 0; i < N; i++) word[i] = i + 1;

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
				--it;
			}
			else {
				it--;
				bubblenum = it->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			map<int, int>::iterator it2 = bubblehist.insert(it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (++it2; it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i+1)] * facttime;
			ans %= divisor;
		}
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++) cout << *it << "\n";

	delete[] word;
	delete[] factmodary;
	return 0;
}

Measured memory_bytes: 6816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp_a;

    rep(i,n){
        ll ai; cin >> ai;
        a[i] = ai;
        mp_a[ai]++;
    }
    ll total_cnt = 0;
    for (auto &u : mp_a){
        ll cnt = u.second;
        if (cnt > 1) total_cnt += cnt * (cnt-1) / 2;
    }
    rep(i,n){
        ll diff = 0;
        ll ex = a[i];
        ll cnt = mp_a[ex];
        if (cnt > 1){
            diff = ((cnt) * (cnt-1) / 2) - ( (cnt-1) * (cnt-2) / 2 );
        }
        cout << total_cnt - diff << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

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

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

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

  ll n,m;
  cin>>n>>m;
  vll a(m);
  REP(i,m)cin>>a[i];

  ll sum=0;
  REP(i,m)sum+=a[i];
  ll ans=n-sum;
  if(ans<0)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
}



Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int m,n;
  cin>>m>>n;
  string a="",b="";
  for(int i=1;i<=n;++i)
    a+=to_string(m);
  for(int i=1;i<=m;++i)
    b+=to_string(n);

    if(a<b)cout<<a;
    else cout<<b;
  
  return 0;
}

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

struct Team{
  int team_num,correct,time;

};

int main(){
  Team data[51];
  int T,P,R,i,j,team_wrong[51][11],t,p,jikan;
  string message;
  while(1){
  cin >> T >> P >> R;
  if( T == 0 && P == 0 && R == 0 ) break;
  for( i = 1; i <= T; i++ ) data[i].team_num = i;
  for( i = 1; i <= T; i++ ) data[i].time = 0;
  for( i = 1; i <= T; i++ ) data[i].correct = 0;
  for( i = 1; i <= 50; i++ ){
    for( j = 1; j <= 10; j++ ){
      team_wrong[i][j] = 0;
    }
  }
  for( i = 0; i < R; i++ ){
    cin >> t >> p >> jikan >> message;
    if( message == "CORRECT" ){
      data[t].correct++;
      data[t].time += jikan + team_wrong[t][p] * 1200;
    }else if( message == "WRONG" ){
      team_wrong[t][p]++;
    }
  }

  for( i = 1; i <=T; i++ ){
    for( j = 1; j < T; j++ ){
      if( data[j].time > data[j+1].time ) swap( data[j],data[j+1] );
    }
  }

  for( i = 1; i <=T; i++ ){
    for( j = 1; j < T; j++ ){
      if( data[j].correct < data[j+1].correct ) swap( data[j],data[j+1] );
    }
  }

  for( i = 1; i <= T; i++ )
    cout << data[i].team_num << " " 
	 << data[i].correct << " " << data[i].time << endl;
  }

  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N, M, K;
    cin >> N >> M >> K;

    REP0 (n, N + 1)
    {
        REP0 (m, M + 1)
        {
            if (K == m * (N - n) + n * (M - m))
            {
                std::cout << "Yes" << endl;
                return;
            }
        }
    }

    std::cout << "No" << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#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 <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e5 + 1;
const ll inf = 1e9;
const int sz = 20;

void input(){
    IOS;
    int n;
    cin >> n;
    vector<ll>a(n);
    int x = 0;
    f(i, n)cin >> a[i], x ^= a[i];
    f(i, n)cout << (x ^ a[i]) << " ";cout << endl;
}
int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

Measured memory_bytes: 4684
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld %lld", &N, &A);
	cout << N * N - A;
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split();
            var n = Int32.Parse(str[0]);
            var k = Int32.Parse(str[1]);
            var d = new int[k];
            str = Console.ReadLine().Split();
            for (int i = 0; i < k; i++)
            {
                d[i] = Int32.Parse(str[i]);
            }

            var cannot_use = new HashSet<int>(d);

            for (int i = n; i < Int32.MaxValue; i++)
            {
                if (!i.ToString().Select(c => Int32.Parse(c.ToString())).ToList().Any(c => cannot_use.Contains(c)))
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 7252
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vii vector<ll>
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define pb push_back
#define ii pair<int,int>
#define iii pair<ll,ll>
#define MAX 10000000000000
#define pi 3.1415926535
typedef long long ll;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vii h(n), dp(n,INT_MAX);
    f(i,0,n) cin>>h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++) {
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

vector<char> ans;

inline void rec(ll n) {
    if (n / 26 == 0) {
        char c = 'a' + (n % 26);
        ans.push_back(c);
        return ;
    }
    rec(n % 26);
    rec(n / 26 - 1);
}

int main() {
    ll n; cin >> n;
    n--;

    rec(n);
    reverse(ans.begin(), ans.end());
    for (auto x : ans) cout << x;
    cout << '\n';
    return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll a, b;
  string a_s, b_s;
  cin >> a >> b;
  a_s = to_string(a);
  b_s = to_string(b);
	
  ll count = b/100 - a/100 + 1;
  if (b/100 == a/100){
	ll m = stoll(string {a_s[0], a_s[1], a_s[2], a_s[1], a_s[0]});
	if (a <= m && m <=b)
	  count = 1;
	else
	  count = 0;
  }
  else{
	if (stoll(string {a_s[0], a_s[1], a_s[2], a_s[1], a_s[0]}) < a)
	  count -= 1;
	if (stoll(string {b_s[0], b_s[1], b_s[2], b_s[1], b_s[0]}) > b)
	  count -= 1;
  }
  cout << count << endl;
}

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

int main() {
long long int A[101][101],B[101][101];
int n,m,l;
scanf("%d %d %d",&n,&m,&l);
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		scanf("%lld",&A[i][j]);
	}
}
for(int i=0;i<m;i++){
	for(int j=0;j<l;j++){
		scanf("%lld",&B[i][j]);
	}
}
long long int c;
for(int i=0;i<n;i++){
	for(int j=0;j<l;j++){
		c=0;
		for(int k=0;k<m;k++){
			c+=A[i][k]*B[k][j];
		}
		if(j>0)printf(" ");
		printf("%lld",c);
	}
	printf("\n");
}

return 0;
}


Measured memory_bytes: 3324
#include <iostream>
using namespace std;
using ll = long long;

int main(){
    int n, m; cin >> n >> m;
    ll a[n + 1], b[n + 1];
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    ll c[m + 1], d[m + 1];
    for (int j = 0; j < m; j++) cin >> c[j] >> d[j];
    
    for (int i = 0; i < n; i++) {
        ll mn = 400000001;
        int ans;
        for (int j = 0; j < m; j++) {
            ll md = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (md < mn) { 
                mn = md;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
ab = []
for i in range(n):
    ab.append([int(i) for i in input().split()])

ab.sort()
tmp = 0
for i in range(n):
    tmp += ab[i][1]
    if tmp >= k:
        print(ab[i][0])
        exit()


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

int gcd(int m,int n){
    if(n==0)
    return m;

    return gcd(n,m%n);
}

int main(){
    int k;
    cin>>k;
    int ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                int a=gcd(i,j);
                ans+=gcd(a,l);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
	char inp;
	for(;;){
		scanf("%c",&inp);
		if(islower(inp))
				printf("%c",toupper(inp));
		else if(isupper(inp))
				printf("%c",tolower(inp));
		else 
				printf("%c",inp);
		if(inp=='\n')		break;
	}
	return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,k;cin >> n >> k;
  int res = k;
  rep(i,n-1) res *= (k-1);
  cout << res << "\n";
  return 0;
}


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

#define int long long

template <class Monoid> struct SegmentTree{
    using Func = function<Monoid(Monoid, Monoid)>;

    int size;
    vector<Monoid> seg;
    const Func merge;
    const Monoid def;

    SegmentTree(int n, Monoid d, const Func f): merge(f), def(d){
        for(size = 1; size <= n; size <<= 1);
        seg.assign(size*2, def);
    }

    Monoid& operator[] (int i) { return seg[i+size]; };
    void build(){ for(int i = size-1;i >= 0;i--) seg[i] = merge(seg[i*2], seg[i*2+1]); }

    void update(int i, Monoid val){
        seg[i += size] = val;
        while(i >>= 1) seg[i] = merge(seg[i*2], seg[i*2+1]);
    }

    void add(int i, Monoid val){ update(i, val+seg[i+size]); }

    Monoid get(int a, int b){
        Monoid l = def, r = def;
        for(a += size, b += size; a < b; a >>= 1, b >>= 1){
            if(a & 1) l = merge(l, seg[a++]);
            if(b & 1) r = merge(r, seg[--b]);
        }
        return merge(l, r);
    }
};

typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;

    SegmentTree<P> segl(n, {-1, -1}, [](P a, P b){
            int x[4];
            x[0] = a.first;
            x[1] = a.second;
            x[2] = b.first;
            x[3] = b.second;
            sort(x, x+4, greater<int>());
            return make_pair(x[0], x[1]);
        });


    SegmentTree<P> segr(n, {n, n}, [](P a, P b){
            int x[4];
            x[0] = a.first;
            x[1] = a.second;
            x[2] = b.first;
            x[3] = b.second;
            sort(x, x+4);
            return make_pair(x[0], x[1]);
        });


    int a[100010];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        segr.update(a[i],{i, n});
    }

    int ans = 0;

    P ll[100010];
    P rr[100010];

    for(int i = 0;i < n;i++){
        segr.update(a[i], {n, n});
        ll[i] = segl.get(a[i], n+1);
        rr[i] = segr.get(a[i], n+1);

        int l = ll[i].first;
        int r = rr[i].first;

        rr[i] = segr.get(a[i], n+1);
        if(l != -1){
            int lenl = l-ll[i].second;
            int lenr = r-i;
            ans += (lenl * lenr) * a[i];
        }

        if(r != n){
            int lenl = i-l;
            int lenr = rr[i].second-r;
            ans += (lenl * lenr) * a[i];
        }

        segl.update(a[i],{i, -1});
    }

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


Measured memory_bytes: 11264
#include <bits/stdc++.h>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define gcd(x,y) __builtin_gcd(x,y)
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 
 
 
using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek=998244353;
 
int main() {
mipletsplay;
double n,k;
cin>>n>>k;
double ans=(n-1)/(k-1);
cout<<ceil(ans);
return 0;}

Measured memory_bytes: 256
/**************************
  * Writer : Leo101
  * Problem : 
  * Tags : 
**************************/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define File(s) freopen(#s".in", "r", stdin); freopen(#s".out", "w", stdout)
#define gi get_int()
int get_int()
{
	int x = 0, y = 1; char ch = getchar();
	while ((ch < '0' || ch > '9') && ch != '-')
		ch = getchar();
	if (ch == '-') y = -1,ch = getchar();
	while (ch <= '9' && ch >= '0') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * y;
}

int main()
{
	int a = gi, b = gi, k = gi;

	printf("%d", std :: min(b / a, k));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
  
vector<int> G[9];
vector<bool> used(9);

int dfs(int v,int n,vector<bool> used){
  //int n=used.size();
  bool flag = true;
  REP(i,n){
    if(!used[i]){
      flag = false;
    }
  }
  if(flag){
    return 1;
  }
  
  int res=0;
  for(int i=0;i<G[v].size();i++){
    if(used[G[v][i]]){
      continue;
    }else{
      used[G[v][i]]=true;
      res += dfs(G[v][i],n,used);
      used[G[v][i]]=false;
    }
  }
  return res;
}
  
int main(){
  int n,m;
  cin>>n>>m;
  int a,b;
  REP(i,m){
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans;
  used[0]=true;
  ans = dfs(0,n,used);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    map<ll, ll> mp;
    rep(i, n) {
        ll m; cin >> m;
        mp[m]++;
    }
    ll count = 0;
    for (auto elem : mp) {
        if (elem.second % 2) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6528
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 100000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FDR(i,a,n) for(int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
const int N=100005;
//Code begin...
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}


int main()
{
    char s[20];
    scanf("%s", s);
    bool flag = true;
    for (int i = 1; i < strlen(s); ++i) {
        if (s[i] != '9') {
            flag = false;
            break;
        }
    }
    if (flag) printf("%d\n", s[0] - '0' + (strlen(s) - 1) * 9);
    else printf("%d\n", s[0] - '1' + (strlen(s) - 1) * 9);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#define int long long
#define WHITE 0
#define GRAY 1
#define BLACK 2
typedef long long ll;
using namespace std;

int H[100001]={0}, color[100001]={0};
vector<int> G[100001];

void bfs(int s){
    queue<int> Q;
    color[s]=GRAY;
    Q.push(s);
    while(!Q.empty()){
        int u=Q.front();
        Q.pop();
        for(int i=0;i<G[u].size();i++){
            if(color[G[u][i]]==WHITE){
                color[G[u][i]]=GRAY;
                Q.push(G[u][i]);
            }
        }
        color[s]=BLACK;
    }
}

signed main(){
    ll n, m;

    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> H[i];
    }
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int id=0;
    for(int u=0;u<n;u++){
        int ii = 1;
        for(int i=0;i<G[u].size();i++){
            if(H[u]<=H[G[u][i]]) ii = 0;
        }
        id += ii;
    }
    cout << id << endl;
    return 0;
}

Measured memory_bytes: 10260
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-9;
const double PI = acos(-1);
const LL INFF = 1e18;
const int INF = 1e9+1;
const int mod = 1e9+7;
const int MAX = 1e5+7;
int main(void){
  DRI(n);
  int pre = -1, ans = 0;
  rep1(i, 1, n+1){
    DRI(v);
    if(v == pre) ans++, pre = -1;
    else pre = v;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
//F5で実行 Shift+F5で停止
//F9でブレークポイント
#include<cmath>
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
//Shift+PageUpで上部の大半を選択できる
// 1e18 = 10の18乗

int N;
int A[201];
bool isOdd = false;

void _main() {
	int ans = 0;
	cin >> N;
	
	while(1) {
		rep(i, 0, N) {
			cin >> A[i];
			//奇数があれば両方のループを抜ける　２で割らないし、もう操作終わりだから
			if (A[i] % 2 != 0) {
				isOdd = true;
				break;
			}
			//A[i]が偶数なら2で割る
			A[i] /= 2;
		}

		if (isOdd) {
			break;
		}
		//2で割った回数
		ans++;
	}

	cout  << ans <<   endl;
}

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

const long long INF = 1LL << 30;

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> h(N);
  for(int n=0; n<N; n++) cin >> h[n];
  
  vector<int> dp(N, INF);
  dp[0] = 0;

  for(int n=1; n<N; n++){
  	for(int k=1; k<=K; k++){
      if(n-k >= 0) dp[n] = min(dp[n], dp[n-k] + abs(h[n] - h[n-k]));
    }
  }
  
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[10],b=0,c=0;
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
		if(a[i]==5) b++;
		if(a[i]==7) c++;
	}
	if(b==2&&c==1)
	{
		cout<<"YES"<<"\n";
	}
	else
	{
		cout<<"NO"<<"\n";
	}
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli n, m, k, i, a[200005], b[200005], pa[200005], pb[200005], nb, tm;
    cin >> n >> m >> k;
    for (i = 1; i <= n; i++)
        cin >> a[i];
    for (i = 1; i <= m; i++)
        cin >> b[i];
    for (i = 2; i <= n; i++)
        a[i] += a[i - 1];
    for (i = 2; i <= m; i++)
        b[i] += b[i - 1];
    nb = 0;
    for (i = 0; i <= n; i++)
    {
        if (a[i] > k)
            break;
        lli l = 0, r = m + 1, mid;
        // if (a[i] + b[r] <= k)
        // {
        //     l = r;
        //     nb = max(nb, i + l);
        //     continue;
        // }
        // else if (a[i] + b[l] > k)
        // {
        //     l = 0;
        //     nb = max(nb, i + l);
        //     continue;
        // }
        while (l + 1 < r)
        {
            mid = (l + r) / 2;
            if (a[i] + b[mid] > k)
                r = mid;
            else
                l = mid;
        }
        // if(a[i]+b[r]<=k)
        //     l=r;
        // if(nb<0)    nb=0;
        nb = max(nb, i + l);
    }
    cout << nb << "\n";
    return 0;
}

Measured memory_bytes: 6764
#include <iostream>
using namespace std;
int main()
{
	int n, m, i, j, d1[36] = {}, d2[36] = {};
	char t1[36] = {}, t2[36] = {};
	cin >> n;
	for(i = 0; i < n; ++i){
		cin >> t1[i] >> d1[i];
		t2[i] = t1[i];
		d2[i] = d1[i];
	}

	for(i = 0; i < n; ++i){
		for(j = n - 1; j > i; --j){
			if( d1[j] < d1[j-1] ){
				swap(d1[j], d1[j-1]);
				swap(t1[j], t1[j-1]);
			}
		}
	}

	for(i = 0; i < n; ++i){
		cout << t1[i] << d1[i];
		if( i != n -1 )
			cout << " ";
	}
	cout << "\nStable\n";

	for(i = 0; i < n; ++i){
		m = i;
		for(j = i; j < n; ++j){
			if( d2[j] < d2[m] )
				m = j;
		}
		if( i != m){
			swap(d2[i], d2[m]);
			swap(t2[i], t2[m]);
		}
	}

	for(i = 0; i < n; ++i){
		cout << t2[i] << d2[i];
		if( i != n -1 )
			cout << " ";
	}
	cout << "\n";

	bool stable = true;
	for(i = 0; i < n; ++i){
		if( t1[i] != t2[i] ){
			stable = false;
			break;
		}
	}

	if(stable) cout << "Stable\n";
	else cout << "Not stable\n";

	return 0;
}

Measured memory_bytes: 1164
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/big"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func gcd(m, n int) uint64 {
    x := new(big.Int)
    y := new(big.Int)
    z := new(big.Int)
    a := new(big.Int).SetUint64(uint64(m))
    b := new(big.Int).SetUint64(uint64(n))
    return z.GCD(x, y, a, b).Uint64()
}

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()

	ans := 0
	m := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		m[i] = make([]int, n+1)
		for j := 1; j <=n; j++ {
			m[i][j] = int(gcd(i,j))
		}
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			for k := 1; k <= n;k++{
				ans += m[m[i][j]][k]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6360
from math import ceil, floor, log, sqrt


def solve(string):
    x = int(string)
    ans = [1]
    for i in range(2, floor(sqrt(x)) + 1):
        ans.append(i**floor(log(x, i)))
        if i**ceil(log(x, i)) <= x:
            ans.append(i**ceil(log(x, i)))
    return str(max(ans))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 38256
use std::collections::HashMap;
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let n = stdin.lock().gets().parse::<u32>().unwrap();

    let mut talist = Vec::new();
    let mut x = 1;
    while x <= n {
        talist.push(x);
        x *= 6;
    }
    let mut x = 1;
    while x <= n {
        talist.push(x);
        x *= 9;
    }
    talist.sort();

    // remaining amount --> min txn count
    let mut count = HashMap::new();
    count.insert(n, 0);
    for txn in talist.into_iter().rev() {
        let series = if txn % 2 == 0 { 6 } else { 9 };
        let prev = count;
        count = HashMap::new();
        for (r, c) in prev {
            for i in 0..std::cmp::min(r / txn + 1, series) {
                let p = count.entry(r - i * txn).or_insert(c + i);
                if c + i < *p {
                    *p = c + i;
                }
            }
        }
    }
    println!("{}", count.into_iter().map(|(r, c)| r + c).min().unwrap());
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 9296
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	char b[11];
	cin>>a;
	int n=0;
	for(int i=0;i<a.size();i++){
		if(a[i]=='0'){
//			cout<<n<<"(0)";
			b[n]='0';
			n++;
//			cout<<b<<endl;
		}else if(a[i]=='1'){
//			cout<<n<<"(1)";
			b[n]='1';
			n++;
//			cout<<b<<endl;
		}else if(n!=0){
//			cout<<n<<"(B)";
			b[n]='\0';
			n--;
//			cout<<b<<endl;
		}else{
			n=0;
//			cout<<b<<endl;
			continue;
		}
	}
	for(int i=0;i<n;i++){
		cout<<b[i];
	}
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
if K<=N:
    next_city=0
    for i in range(K):
        next_city=A[next_city]-1
else:
    next_city=0
    visited=[-1]*N
    visited[0]=0
    for num in range(1,N):
        next_city=A[next_city]-1
        if visited[next_city]!=-1:
            break
        visited[next_city]=num
    K=(K-num)%(num-visited[next_city])
    for i in range(K):
        next_city=A[next_city]-1
print(next_city+1)

Measured memory_bytes: 32356