akhauriyash/Code-Regression huggingface dataset:
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(int i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	string x;
	cin>>x;
	int e=0;
	forin(i,0,x.length()-1)
	{
		if(!(i%2))
		{
			if(x[i]=='R' || x[i]=='U' || x[i]=='D')
			{
				
			}
			else
			{
				e++;
				break;
			}
		}
		else
		{
			if(x[i]=='L' || x[i]=='U' || x[i]=='D')
			{
				
			}
			else
			{
				e++;
				break;
			}
		}
	}
	if(e)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n,x, t;
    cin >> n >> x >> t;
    if(n % x == 0) {
        cout << (n / x) * t << endl;
    } else {
        cout << (n/x + 1) * t << endl;
    }
    return 0;
}

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

int S[10000];
int n, q;
int C;

int main() {
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    cin >> q;
    for(int i=0; i<q; i++){
        int t;
        cin >> t;
        for(int j=0; j<n; j++){
            if(S[j] == t){
                C++;
                break;
            }
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    ll h;
    cin>>h;
    ll pos=1;
    ll ind=0;
    while(h>=pos){
        pos*=2;
        ind++;
    }
    cout<<pos-1<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int X  = keyboard.nextInt();
		int T  = keyboard.nextInt();
		
		int ans = 0;
		if(N%X == 0) {
			ans = N/X*T;
		}else {
			ans = (N/X+1)*T;
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}

Measured memory_bytes: 35608
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MAXN 300005
	int ee[MAXN]={0},ww[MAXN]={0},ans[MAXN]={0};
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s[0]=='E') ee[0]++;
	else ww[0]++;
	for(int i=1;i<n;i++){
		ee[i]=ee[i-1]; ww[i]=ww[i-1];
		if(s[i]=='E') ee[i]++;
		else ww[i]++;
	}
	for(int i=0;i<n;i++){
		ans[i]=ee[i]+ww[n-1]-ww[i-1]-1;
	}
	sort(ans,ans+n);
	cout<<n-ans[n-1]-1;
	return 0;
} 

Measured memory_bytes: 4228
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
	int n, x[100], y[100];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i];
	for (int i = 0; i < n; i++)cin >> y[i];
	double d[4];
	for (int i = 0; i < 4; i++)d[i] = 0.0;
	for (int p = 1; p <= 3; p++) {
		for (int i = 0; i < n; i++) {
			d[p] += pow(fabs(x[i] - y[i]), p);
		}
		d[p] = pow(d[p], 1.0 / p);
	}
	for (int i = 0; i < n; i++) {
		d[0] = (d[0] < fabs(x[i] - y[i]) ? fabs(x[i] - y[i]) : d[0]);
	}

	printf("%lf\n", d[1]);
	printf("%lf\n", d[2]);
	printf("%lf\n", d[3]);
	printf("%lf\n", d[0]);

    return 0;
}


Measured memory_bytes: 3340
import java.util.Scanner;
 
public class Main {
  public static void main ( String[] args ) {
 
    Scanner sc = new Scanner ( System.in );

    String S = sc.next();
    
    if( S.equals("Sunny")){
      System.out.println("Cloudy");
    }else if ( S.equals("Cloudy")){
      System.out.println("Rainy");
    }else if ( S.equals("Rainy")){
      System.out.println("Sunny");
    }
  }
}

Measured memory_bytes: 26800
import numpy as np
n = int(input())
weights = np.array(list(map(lambda x: int(x),input().split())))
min = 99999
for t in range(1, n-1):
    w1 = weights[:t+1]
    w2 = weights[t+1:]
    s1 = np.sum(w1)
    s2 = np.sum(w2)
    sa = np.abs(s1-s2)
    if sa < min:
        min = sa
print(min)

Measured memory_bytes: 12500
import sys
def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6)
from functools import reduce
from collections import defaultdict
from math import gcd

n = int(input())
A = list(int(x) for x in input().split())

if reduce(gcd, A) != 1:
    print("not coprime")
    exit()

def is_prime_miller_rabin(n):  # ミラー-ラビン素数判定法
    if n < 2:
        return False
    elif n in {2, 3, 5, 7, 11}:
        return True
    elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0 or n % 7 == 0 or n % 11 == 0:
        return False

    if n < 4_759_123_141:
        witnesses = [2, 7, 61]
    elif n < 341_550_071_728_321:
        witnesses = [2, 3, 5, 7, 11, 13, 17]
    else:
        witnesses = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]

    d = n - 1
    d = d // (d & -d)

    for a in witnesses:
        y = pow(a, d, n)
        if y == 1:
            continue
        t = d
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1:
                return False
            t <<= 1
    return True

def find_factor_rho(n):  # ポラード・ロー素因数分解法
    if n < 2:
        return None
    m = 1<<n.bit_length() // 8 + 1
    for c in range(1, 99):
        def f(x):
            return (x * x + c) % n

        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if is_prime_miller_rabin(g):
                return g
            elif is_prime_miller_rabin(n // g):
                return n // g
    return None

def prime_factorize_dict(n):
    prime_dict = defaultdict(int)
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            prime_dict[i] += 1
        i += 1 + i % 2
        if i != 101 or n < 1<<20:
            continue
        while n > 1:
            if is_prime_miller_rabin(n):
                prime_dict[n] = n = 1
                break
            j = find_factor_rho(n)
            while n % j == 0:
                n //= j
                prime_dict[j] += 1
    if n > 1:
        prime_dict[n] += 1
    return prime_dict

# ---------------------- #

pset = set()
for a in A:
    for k in prime_factorize_dict(a).keys():
        if k in pset:
            print("setwise coprime")
            exit()
        pset.add(k)

print("pairwise coprime")


Measured memory_bytes: 191848
n = int(input())
a = list(map(int, input().split()))
a.sort()
bai = [0 for _ in range(max(a)+1)]
i = 2
for i in a:
    j = i
    while j < len(bai):
        bai[j] += 1
        j += i

res = 0
if n <= 1:
    print(n)
    exit()

for i in range(n):
    if bai[a[i]] == 1:
        res += 1

print(res)

Measured memory_bytes: 157224
#include <stdio.h>
#define SENTINEL 1000000000
int N[5000000], L[2500000], R[2500000], count=0;

void Merge(left, mid, right){
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++)
    L[i] = N[left + i];
  for(i = 0; i < n2; i++)
    R[i] = N[mid + i];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      N[k] = L[i];
      i = i + 1;
      count++;
    }
    else{
      N[k] = R[j];
      j = j + 1;
      count++;
    }   
  }
}

void Merge_Sort(left, right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    Merge_Sort(left, mid);
    Merge_Sort(mid, right);
    Merge(left, mid, right);
  }
}

int main(){
  int i, n;
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&N[i]);

  Merge_Sort(0,n);

  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d",N[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    int n = S.length();
    int64_t ans = 0;
    for (int bits = 0; bits < 1 << (n - 1); bits++){
        int64_t res = S[0] - '0';
        for (int i = 0; i < n - 1; i++){
            if (bits & (1 << i)){
                ans += res;
                res = 0;
            }
            res = res * 10 + S[i + 1] - '0';
        }
        ans += res;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left
n = int(input())
a = [int(input()) for _ in range(n)]
ans = deque([a[0]])
for a_i in a[1:]:
    if ans[0] < a_i:
        i = bisect_left(ans, a_i)
        ans[i-1] = a_i
    else:
        ans.appendleft(a_i)

print(len(ans))




Measured memory_bytes: 8828
#include <iostream>
using namespace std;
int main(){
  int h, n;
  cin >> h >> n;
  int a;
  for(int i=0; i<n; i++){
    cin >> a;
    h-=a;
  }
  if(h<=0) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	// 文字列の入力
	string S;
	cin >> S;
	
	string first = S.substr(0, 2);
	string second = S.substr(2, 2);
	// 数値変換
	int first_value = atoi(first.c_str());
	int second_value = atoi(second.c_str());
	
	int yymm = 0;
	int mmyy = 0;
	// YYMMのチェック
	if (second_value > 0 && second_value <= 12)
	{
		yymm++;
	}
	// MMYYのチェック
	if (first_value > 0 && first_value <= 12)
	{
		mmyy++;
	}
	
	if (yymm == 1 && mmyy == 1)
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if (yymm == 1)
	{
		cout << "YYMM" << endl;
	}
	else if (mmyy == 1)
	{
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, char *> P;

P fact(char *p);
P term(char *p);
P expr(char *p);

P fact(char *p){
  if(isdigit(*p)){
    int t = *(p++) - '0';
    while(isdigit(*p)) t = t * 10 + *(p++) - '0';
    return P(t, p);
  } else if(*p == '('){
    P r = expr(p + 1);
    if(*r.second != ')') exit(0); //閉じ括弧が無いエラー
    return P(r.first, r.second + 1);
  } else{
    exit(0); //括弧でも数字でもないエラー
  }
}

P term(char *p){
  P r = fact(p);
  while(*r.second == '*' || *r.second == '/'){
    char op = *r.second;
    int tmp = r.first;
    r = fact(r.second + 1);
    if(op == '*') r.first *= tmp;
    else r.first /= tmp;
  }
  return r;
}

P expr(char *p){
  P r = term(p);
  while(*r.second == '+' || *r.second == '-'){
    char op = *r.second;
    int tmp = r.first;
    r = term(r.second + 1);
    if(op == '+') r.first = tmp + r.first;
    else r.first = tmp - r.first;
  }
  return r;
}

int num(string s, int &p){
  int res = 0;
  while(p < (int)(s.length()) && isdigit(s[p])){
    res *= 10;
    res += s[p++] - '0';
  }
  return res;
}

int calc(string s){
  int p = 0, res = num(s, p);
  while(p < s.length()){
    char c = s[p++];
    int n = num(s, p);
    if(c == '+') res += n;
    else res *= n;
  }
  return res;
}

int main() {
  string s; cin >>s;
  int res; cin >>res;
  char *cs = new char[(int)(s.length()) + 1];
  strcpy(cs, s.c_str());
  P tmp = expr(cs);
  int n = calc(s);
  if(tmp.first == res && n != res) cout <<"M" <<endl;
  else if(tmp.first != res && n == res) cout <<"L" <<endl;
  else if(tmp.first == res && n == res) cout <<"U" <<endl;
  else cout <<"I" <<endl;
  return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ; 
  int ans = 0 ;
  
  rep(i,n) {
    int c ; 
    cin >> c ; 
    if( i%2 == 0 && c%2 == 1) ans ++ ;
  }
  
  cout << ans ;


}


Measured memory_bytes: 3572
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

checked = [False]*n
q = deque([])
cnt = 0

#連結成分のカウント

for i in range(n):
    if checked[i]:
        continue
    checked[i] = True
    q.append(i)
    while q:
        v = q.pop()
        s = g[v]
        for j in s:
            if checked[j]:
                continue
            checked[j] = True
            q.append(j)
    cnt += 1

print(cnt - 1)

Measured memory_bytes: 26452
from math import factorial
from sys import exit, stdin
N = int(stdin.readline().rstrip())
H = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(1,N):
    if H[i-1] > H[i]:
        ans += H[i-1]-H[i]
ans += H[-1]
print(ans)

Measured memory_bytes: 3188
let ss = Array.init 3 @@ fun _ -> read_line ()
let i_s = Array.make 3 0
let j = ref 0
let _ =
  while i_s.(!j) < String.length ss.(!j) do
    let j1 = Char.code ss.(!j).[i_s.(!j)] - Char.code 'a' in
    i_s.(!j) <- i_s.(!j) + 1;
    j := j1
  done;
  Char.chr @@ Char.code 'A' + !j |> Printf.printf "%c\n"

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S;
  cin >> S;
  ll ans = kMod;
  REP(i, 0, S.size() - 2) {
    string ss = S.substr(i, 3);
    ll aa = abs(753 - atoi(ss.c_str()));
    if (aa < ans) {
      ans = aa;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;
 
int main() {
        string l;
        l = readln().split[0];
        int c = to!int(l); // iteration
        int d = 100000; // debt
        for(int i=0; i<c; i++){
                d *= 1.05;
                if(d > d / 1000 * 1000) d += 1000;
                d = d / 1000 * 1000;
                }
        printf("%d\n", d);
        return 0;
}

Measured memory_bytes: 1088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node {
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}Node;
#define NIL NULL

void inorder(Node *);
void preorder(Node *);
void insert(int );

Node *root;
int main(){
  int n, i, x;
  char com[7];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}
void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->left;
	} else
	{
	  x = x->right;
	}
    }
  z->parent = y;
  if(y == NIL)
    {
      root = z;
    } else if(z->key < y->key)
    {
      y->left = z;
    } else
    {
      y->right = z;
    }
}
void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 25128
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
const int NR = 1005;
//ifstream in ("date.in");

set < pair < int , int > > s ;
int n , k , x ;
int main(){
    int i ;
    cin >> k >> n ;
    for ( i = 1 ; i <= n ; ++ i )   {
        cin >> x ;
        s.insert( mp ( x , i ) );
    }

    //for ( set < pair < int , int > > :: iterator it = s.begin() ; it != s.end() ; ++ it )
      //  cout << (*it).first << ' ' << (*it).second << '\n';

    set < pair < int , int > > :: iterator it2 ;

    it2 = s.end() ;
    it2 -- ;
    int last = -1, pos , el, pozitie;
    while ( s.size() != 1 )  {

        it2 = s.end() ;
        it2 -- ;
        pos = (*it2).second;
        if ( pos == last )  {
            it2 -- ;
            el = (*it2).first - 1 ;
            pos =  (*it2).second;
            s.erase(it2);
            if ( el )
            s.insert( {el,pos} );
     //       cout << el << '\n';
        }   else    {
            el = (*it2).first - 1 ;
            pozitie =  (*it2).second;
            s.erase(it2);
            if ( el )
            s.insert( {el,pos} );
       //     cout << el << '\n';
        }
                    last = pos ;

    }
    it2 = s.end() ;
    it2 -- ;
    cout << (*it2).first - 1 << '\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        var S = cin.next;
        N = S.Length;
        for (int i = 0; i < N - 8; i++)
        {
            Write(S[i]);
        }
        WriteLine();
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

int main()
{
    Fast
    string s;
    cin >> s;
    if(s[2]==s[3] and s[4]==s[5]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100];

int main(){
  int n,mini=101,maxi=-101;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mini=min(a[i],mini);
    maxi=max(a[i],maxi);
  }
  int ans=1000000,cost;
  for(int i=mini;i<=maxi;i++)
  {	cost=0;
    for(int j=0;j<n;j++){
      cost+=(a[j]-i)*(a[j]-i);
    }
   ans=min(ans,cost);
  }
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int dp[114][11400];
int s[114];
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> s[i];

	int sum = 0;
	for (int i = 0; i < n; i++)sum += s[i];

	if (sum % 10 != 0)cout << sum << endl;
	else {
		sort(s, s + n);
		int mn = sum;
		for (int i = 0; i < n; i++) {
			if (s[i] % 10 != 0) {
				mn = s[i];
				break;
			}
		}
		cout << sum - mn << endl;
	}
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long kouyaku = __gcd(c, d);
  long long koubai = (c * d) / kouyaku;
  long long l_c = (a - 1) / c;
  long long l_d = (a - 1) / d;
  long long r_c = b / c;
  long long r_d = b / d;
  long long koubai_a = (a - 1) / (koubai);
  long long koubai_b = b / koubai;
  long long ans =
      (b - a + 1) - (r_c - l_c) - (r_d - l_d) + (koubai_b - koubai_a);
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int l,ans=0;
  string s;
  cin>>s;
  l=s.size();
  for(int i=0;i<l/2;i++)
    if(s[i]!=s[l-i-1]){
      s[i]=s[l-i-1];
      ans++;
    }
  cout<<ans<<endl;
  return 0;
}
  

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,X[101010],Y[101010];
vector<pll> xyv;
ll num[101010],mk[101010];
ll i,j,k,ans;

struct UnionFind{
    vector<int> nxt;
    UnionFind(int x){
        nxt.resize(x);
        for (int i = 0; i < x;i++){
            nxt[i] = i;
        }
    }
    int find(int x){
        if(nxt[x]==x)
            return x;
        return nxt[x] =find(nxt[x]);
    }
    inline void unite(int x,int y){
        nxt[find(y)] = find(x);
    }
};


int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld%lld", &X[i], &Y[i]);
        xyv.push_back({X[i], Y[i]});
    }
    sort(xyv.begin(), xyv.end());
    UnionFind uf(100500);
    map<ll, ll> ufm;

    j = 0;
    fornum(i,0,N){
        auto xy = xyv[i];
        if(j!=xy.first){
            j = xy.first;
            k = 0;
        }
        if(k!=0){
            if(ufm.find(xy.second)==ufm.end()){
                ufm[xy.second] = ufm.size();
            }
            uf.unite(ufm[k], ufm[xy.second]);
        }else{
            k = xy.second;
            if(ufm.find(k)==ufm.end()){
                ufm[k] = ufm.size();
            }
        }
        k = xy.second;
    }
    fornum(i,0,ufm.size()){
        num[uf.find(i+1)]++;
    }

    j = 0;
    fornum(i,0,N){
        auto xy=xyv[i];
        if(j!=xy.first){
            j = xy.first;
        }
        ll g = uf.find(ufm[xy.second]);
        if(mk[g]!=j){
            mk[g] = j;
            ans += num[g];
        }
        ans--;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 7152
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678], cost[1234][1234];
signed main() {
	vector<int> v; map<string, int> mn;
	int n, m, q, a = 0, b, c, cnt = 0, ans = 0; string s, t;
	cin >> s;
	if (s == "ABC") { cout << "ARC" << endl; }
	else { cout << "ABC" << endl; }
	return 0;
}

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

int main(){
  int X, ans;
  cin >> X;
  ans = 0;

  if (X >= 400 && X <= 599){
    ans = 8;
  }
  if (X >= 600 && X <= 799){
    ans = 7;
  }
  if (X >= 800 && X <= 999){
    ans = 6;
  }
  if (X >= 1000 && X <= 1199){
    ans = 5;
  }
  if (X >= 1200 && X <= 1399){
    ans = 4;
  }
  if (X >= 1400 && X <= 1599){
    ans = 3;
  }
  if (X >= 1600 && X <= 1799){
    ans = 2;
  }
  if (X >= 1800 && X <= 1999){
    ans = 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3192
#include <cstdio>  
#include <iostream>  
#include <algorithm>  
#include <string>  
#include <vector>  
using namespace std;  
int n;  
  
int solve(string s){  
  if('0' <= s[0] && s[0] <= '9'){  
    int ret = 0;  
    for(int i = 0; i < (int)s.size(); i++){  
      ret *= 10;  
      ret += s[i] - '0';   
    }  
    return ret/2 +1;  
  }  
  
  vector<int> v;  
  for(int i = 0; i < (int)s.size(); i++){  
    if(s[i] == '['){  
      int c = 1;  
      int j;  
      for(j = i+1; c; j++){  
    if(s[j] == '[') c++;  
    if(s[j] == ']') c--;  
      }  
      v.push_back( solve(s.substr(i+1,j-i-2) ) );  
      i = j-1;  
    }  
  }  
  sort(v.begin(),v.end());  
  int ret = 0;  
  for(int i = 0; i < (int)(v.size())/2 + 1; i++){  
    ret += v[i];  
  }  
  return ret;  
}  
  
int main(void){  
  cin >> n;  
  for(int t = 0; t < n; t++){  
    string str;  
    cin >> str;  
    cout << solve(str.substr(1,(int)str.size()-2)) << endl;  
  }  
}  

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

int main(){
    ll N; cin>>N;
	vector<ll>h(N);
	rep(i,N) cin>>h[i];
	vector<ll> dp(N,0);//dp[i]:iにつくまでの最小コスト
	dp[1]=abs(h[1]-h[0]);
	rep1(i,N-1){
		dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout<<dp[N-1];
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	double a, b;
	cin >> a >> b;
	printf("%.12lf\n", a / b);
	endre;
}

Measured memory_bytes: 764
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	var ans string
	if s == "Sunny" {
		ans = "Cloudy"
	} else if s == "Cloudy" {
		ans = "Rainy"
	} else if s == "Rainy" {
		ans = "Sunny"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
int N;
vector<string> s;






//サブ関数
//入力
void input()
{
	cin >> N;
	s.resize(N);
	REP(i, N)cin >> s[i];
}

bool isSame(int h, int w, int offset)
{
	return s[(h + offset) % N][w] == s[h][(w + offset) % N];
}

bool isSym(int h, int w) 
{
	REP(offset, N) {
		if (!isSame(h, w, offset))return false;
	}
	return true;
}

bool allSym(const vector<vector<bool>> sym , int slide)
{
	REP(h, N) {
		if (!sym[h][(h + slide) % N])return false;
	}
	return true;
}


//計算
void calc()
{
	//is symmetry
	vector<vector<bool>> sym(N, vector<bool>(N));
	REP(h, N)REP(w, N) {
		sym[h][w] = isSym(h, w);
	}

	int ans = 0;
	REP(slide, N) 
		if (allSym(sym, slide))
			ans++;
	ans *= N;
	cout << ans << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<double> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  double ans=a[0];
  rep(i,n-1){
    ans=(ans+a[i+1])/2;
  }
  cout<<fixed<<ans;
  return 0;
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return "<too deep!>" end if o == _G then return "<_G>" end local indent0 = (" "):rep((depth) * 2) local indent1 = (" "):rep((depth+1) * 2) local indent2= (" "):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\n' .. table.concat(inside, ',\n') .. '\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end
local function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. ":" .. info.linedefined .. ">" if info.name then fname = info.name end print(info.short_src .. ":" .. info.currentline .. ": in " .. ("%q"):format(fname)) print(" LOCALS:") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) p = p + 1 end print(" UPVALUES:") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) end x = x + 1 end end
local function myassert(b) if not b then richtraceback() error("assertion failed") end end 
--
local N = read.nl()
local f = {'AC', 'WA', 'TLE', 'RE'}
local t = {}
for i=1,N do
    local s = read.l():gsub('%s', '')
    t[s] = (t[s] or 0) + 1
end
for i=1,4 do
    print(f[i] .. ' x ' .. (t[f[i]] or 0))
end

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int ans = 1000000000;
    for(int i = 0; i < n - k + 1; ++i){
        if(h[i + k - 1] - h[i] < ans){
            ans = h[i + k - 1] - h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long LL;

const int N=5000;

int n,m;
char s[N+9];

void into(){
  scanf("%d%d%s",&n,&m,s+1);
  m=min(m,15);
}

char ans[N+9],tmp[N+9];

bool Check_cmp(){
  if (!ans[1]) return 1;
  for (int i=1;i<=n;++i)
	if (tmp[i]^ans[i]) return tmp[i]<ans[i];
  return 0;
}

void Get_ans(){
  char mn='z';
  for (int i=1;i<=n;++i) mn=min(mn,s[i]);
  int mx=0;
  for (int i=1,c=0;i<=n;++i){
	s[i]==mn?++c:c=0;
	mx=max(mx,c<<(i==n));
  }
  if (mx*(1<<m-1)>=n){
	for (int i=1;i<=n;++i) ans[i]=mn;
	return;
  }
  for (int i=1,c=0;i<=n;++i){
	s[i]==mn?++c:c=0;
	if (c<<(i==n)<mx) continue;
	int ct=0;
	for (int j=1;j<=mx*(1<<m-1);++j) tmp[++ct]=mn;
	for (int j=i+1;j<=n&&ct<n;++j) tmp[++ct]=s[j];
	for (int j=i==n?n-c:n;j>=1&&ct<n;--j) tmp[++ct]=s[j];
    if (Check_cmp())
	  for (int j=1;j<=n;++j) ans[j]=tmp[j];
  }
}

void work(){
  Get_ans();
}

void outo(){
  for (int i=1;i<=n;++i)
	putchar(ans[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3740
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def dev(a):
    d = {}
    for i in (2, 5):
        r = 0
        while a % i == 0:
            r += 1
            a //= i
        d[i] = min(18, r)
    return d


def main():
    N = int(input())
    A = []
    for _ in range(N):
        s = input().strip().split(".")
        a = int(s[0]) * (10 ** 9)
        if len(s) > 1:
            t = s[1] + "0" * (9 - len(s[1]))
            a += int(t)
            # a += int(float("0." + s[1]) * (10 ** 9))
        # a = int(float(input()) * (10 ** 9))
        # print(a)
        A.append(dev(a))
    # print(A)
    S = [[0] * 19 for _ in range(19)]
    dp = [[0] * 20 for _ in range(20)]
    for a in A:
        S[a[2]][a[5]] += 1

    # print(S)
    for i in range(19):
        for j in range(19):
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + S[i][j]
    
    # print(dp[-1])
    res = 0
    for a in A:
        s = 18 - a[2]
        t = 18 - a[5]
        
        r = N - dp[-1][t] - dp[s][-1] + dp[s][t]
        if a[2] >= 9 and a[5] >= 9:
            r -= 1
        # print(a, r)
        res += r
    print(res // 2)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 145432
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b;
    c = (3 * a + b) / 2;
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;

	LL ans = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;

		while (x % 2 == 0) {
			x /= 2;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main()
    {
      int f;
      cin>>f;
      int n;
      n=f%10;
      if(n==2 || n==4 || n==5 || n==7 || n==9)
      {
        cout<<"hon";
      }
        if(n==0 || n==1 || n==6 || n==8)
      {
        cout<<"pon";
      }
      if(n==3 )
      {
        cout<<"bon";
      }
     
    }

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int h, w, d;
    cin >> h >> w >> d;

    int n = h * w;
    vector<int> y(n), x(n);
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            int a;
            cin >> a;
            -- a;
            y[a] = i;
            x[a] = j;
        }
    }

    vector<int> cost(n, 0);
    for(int i=n-d-1; i>=0; --i){
        int diff = abs(y[i] - y[i+d]) + abs(x[i] - x[i+d]);
        cost[i] = diff + cost[i+d];
    }

    int q;
    cin >> q;
    while(--q >= 0){
        int l, r;
        cin >> l >> r;
        -- l;
        -- r;
        int ans = cost[l] - cost[r];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>

using namespace std;


int main() {
    int N;
    cin >> N;
    vector<vector<int>> perm;
    vector<int> P(N, 0);
    vector<int> Q(N, 0);

    vector<int> tmp;

    for(int i=1; i<=N; i++){
        tmp.push_back(i);
    }

    for(int i=0; i<N; i++){
        cin>>P[i];
    }

    for(int i=0; i<N; i++){
        cin>>Q[i];
    }

    int p=0;
    int q=0;
    int idx=0;

    do {
        if(tmp==P)
            p=idx;
        if(tmp==Q)
            q=idx;
        idx++;
    } while (next_permutation(tmp.begin(), tmp.end()));

    cout<<abs(p-q)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
 int a,b,c,w;
 scanf("%d %d %d",&a,&b,&c);
 if(a>b)
  {
   w=a;
   a=b;
   b=w;
  }
  if(b>c)
  {
   w=b;
   b=c;
   c=w;
  }
  if(a>b)
  {
   w=a;
   a=b;
   b=w;
  }
 printf("%d %d %d\n",a,b,c);
 return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;
class Main{
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
 for(int i=1;i<=3000; i++){
  int a = scan.nextInt();
  int b = scan.nextInt();
    if(0!=a+b){
     if(a>=b){
      System.out.println(b+" "+a);
      }else{
      System.out.println(a+" "+b);
      }
                   }else{break;      
                   }
                   }
                                        } 
           }


Measured memory_bytes: 35488
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

ll n, ans, k;

signed main()
{
    srand(time(NULL));
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n;
    k = 100;
    while (k < n)
    {
        k = k + k / 100;
        ans++;
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
No def int long long for now.
*/


Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;


public class Main{
    public static int[] dp=new int[77777777];
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
       int[][] a = new int[2][4];
       int i,j,m;
       long k=1,n=0;
       m = solve(76543210);
       while(s.hasNext()){
       for(i=0;i<2;i++){
           for(j=0;j<4;j++){
        m=s.nextInt();
        n+=k*(long)m;
        k*=10;
       }
    }


           
       // m = solve(n);
        System.out.println(Main.dp[(int)n]);
        n=0;
        k=1;
}
    }
    public static int solve(long n){
        Queue<Long> qu=new LinkedList<Long>();
        int[] x = {1,-1,0,0},y= {0,0,1,-1};
        long[] zc =new long[50000];
        int[][] arr = new int[2][4];
        int i,j,zh=-5,zw=-5,e,ppp=0,col=0,kri=0;
        long k=n,temp,no;
        boolean ch=false,chk=false;
        qu.add(n);
        while(true){
            if(qu.size()==0)return 0;
        k = qu.remove();
  //      if(k%100000000==76543210)return (int)k/100000000+kri;
        for(i=0;i<2;i++){
            for(j=0;j<4;j++){
                arr[i][j]=(int)k%10;
                k/=10;
                if(arr[i][j]==0){
                    zh=i;
                    zw=j;
                }
            }
        }
   //     System.out.println(k+" " +col);
        if(k==19){
            kri=20;
            k=0;
        }
        else k++;

        k*=100000000;
        no = k;
        for(e=0;e<4;e++){
            if(zh+x[e]>=0&&zh+x[e]<2&&zw+y[e]>=0&&zw+y[e]<4){
            arr[zh][zw] = arr[zh+x[e]][zw+y[e]];
            arr[zh+x[e]][zw+y[e]]=0;
        temp =1;
        for(i=0;i<2;i++){
            for(j=0;j<4;j++){
                k+=temp*(long)arr[i][j];
                temp*=10;
            }
        }
       /* for(ppp=0;ppp<col;ppp++)if(zc[ppp]==k%100000000)ch=true;
        if(ch==false){
            zc[col]=k%100000000;
            qu.add(k);
            col++;
        }*/
        if(Main.dp[(int)k%100000000]==0){
            Main.dp[(int)k%100000000]=(int)k/100000000+kri;
            //System.out.println(sep3.dp[(int)k%100000000]+" "+k%100000000);
            qu.add(k);
        }
        else ch = false;
        k = no;
        arr[zh+x[e]][zw+y[e]] = arr[zh][zw];
        arr[zh][zw]=0;
    }
}
    }
}

    }




Measured memory_bytes: 345032
#include <stdio.h>

int main(void)
{
  int aih,aim,ais,aoh,aom,aos,bih,bim,bis,boh,bom,bos,cih,cim,cis,coh,com,cos;
  int dif[3],j = 0,i = 0, value[] = {3600, 60, 1};
  int new[3];

  new[0] = new[1] = new[2] = 0;

  scanf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", &aih,&aim,&ais,&aoh,&aom,&aos,&bih,&bim,&bis,&boh,&bom,&bos,&cih,&cim,&cis,&coh,&com,&cos);

  dif[0] = (aoh*3600 + aom * 60 + aos) - (aih*3600 + aim * 60 + ais);
  dif[1] = (boh*3600 + bom * 60 + bos) - (bih*3600 + bim * 60 + bis);
  dif[2] = (coh*3600 + com * 60 + cos) - (cih*3600 + cim * 60 + cis);

  while(i != 3){
    j = 0;
  while(dif[i] != 0){
    if(dif[i] - value[j] >= 0){
      dif[i] -= value[j];
      new[j]++;
    }
    else
      j++;
  }
  printf("%d %d %d\n", new[0], new[1], new[2]);
  new[0] = new[1] = new[2] = 0;
  i++;
  }
  return 0;
}

Measured memory_bytes: 600