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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll> 

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int n,w,h;

void solve(){
  vector<pi> c(n);
  rep(i, n)cin>>c[i].first>>c[i].second;
  vector<pi> cakes;
  cakes.push_back({w, h});
  rep(i, n){
    int p = c[i].first-1;
    int s = c[i].second;
    int cw = cakes[p].first;
    int ch = cakes[p].second;

    // rep(i, cakes.size()) cout<<cakes[i].first<<','<<cakes[i].second<<' ';

    cakes.erase(cakes.begin()+p);

    // cout<<endl;
    // cout<<i<<'|'<<cw<<','<<ch<<':'<<p<<' '<<s<<endl;
    // cout<<endl;

    s %= (cw + ch)*2;
    pi c1,c2;
    if(s<cw){
      c1 = {s, ch};
      c2 = {cw-s, ch};
    }else if((cw+ch < s && s < cw+ch+cw)){
      c1 = {s-cw-ch, ch};
      c2 = {cw+cw+ch-s, ch};
    }else if(cw<s && s< cw+ch){
      c1 = {cw, s-cw};
      c2 = {cw, cw+ch-s};
    }else{
      c1 = {cw, s-cw-cw-ch};
      c2 = {cw, cw+ch+cw+ch-s};
    }

    if(c1.first*c1.second > c2.first*c2.second)swap(c1,c2);

    cakes.push_back(c1);
    cakes.push_back(c2);

    // cakes.insert(cakes.begin()+p, c1);
    // cakes.insert(cakes.begin()+p+1, c2);
  }

  vector<int>s;
  rep(i, cakes.size())s.push_back(cakes[i].first*cakes[i].second);
  sort(s.begin(), s.end());

  rep(i, s.size()){
    cout<<s[i];
    if(i<s.size()-1)cout<<' ';
  }

  cout<<endl;
}

int main(){
  while(cin>>n>>w>>h){
    if(w==0)break;

    solve();
  }

  return 0;
}



Measured memory_bytes: 3068
#include <iostream>
using namespace std;
int a, b, c, x, y, mn;
int main() {
	cin>>a>>b>>c>>x>>y;
	mn = min(a*x+b*y, max(x,y)*2*c);
	cout<<(min(mn, (x>y ? (x-y)*a : (y-x)*b) + min(x,y)*2*c));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {
    static int n;
    static int m;
    static long[][] distances;
    static boolean[][] connected;
    static boolean[][] used;

    static void start(int node) {
        Set<Integer> visiting = new HashSet<>();
        boolean[] visited = new boolean[n];
        long[] distance = new long[n];
        for(int i = 0; i < n; i++) distance[i] = Long.MAX_VALUE;
        Map<Integer, List<Integer>> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            map.put(i, new ArrayList<>());
        }
        distance[node] = 0;
        visiting.add(node);

        while(visiting.size() > 0) {
            int id = -1;
            long minDistance = Long.MAX_VALUE;
            for(int i: visiting) {
                if(distance[i] < minDistance) {
                    id = i;
                    minDistance = distance[id];
                }
            }

            if(id == -1) break;
            visiting.remove(id);
            visited[id] = true;

            for(int i = 0 ; i < n; i++) {
                if(connected[id][i] && !visited[i]) {
                    long newDistance = distance[id] + distances[id][i];
                    if(newDistance < distance[i]) {
                        List<Integer> list = new ArrayList<>();
                        list.add(id);
                        map.put(i, list);
                    } else if(newDistance == distance[i]) {
                        map.get(i).add(id);
                    }

                    visiting.add(i);
                    distance[i] = Math.min(newDistance, distance[i]);
                }
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j: map.get(i)) {
                used[i][j] = true;
                used[j][i] = true;
            }
        }

    }

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

        distances = new long[n][n];
        connected = new boolean[n][n];
        used = new boolean[n][n];

        for(int i = 0 ; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            long c = sc.nextLong();
            distances[a][b] = c;
            distances[b][a] = c;
            connected[a][b] = true;
            connected[b][a] = true;
        }

        for(int i = 0 ; i < n; i++) {
            start(i);
        }

        int count = 0;
        for(int i = 0 ; i < n; i++) {
            for(int j = 0; j < i; j++) {
                if(connected[i][j] && !used[i][j])count++;
            }
        }

        System.out.println(count);
    }
}

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


using namespace std;

int main()
{
	int A,B;
	cin >> A >> B ; 
	string result;

	if (A==1) {
		A = 100;
	}

	if (B == 1) {
		B = 100;
	}

	if (A - B == 0) {
		result = "Draw";
	}
	else {
		if (A > B) {
			result = "Alice";
		}
		else {
			result = "Bob";
		}
	}

	cout << result << endl;
    
	return 0;
}

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

const int N = 6e4L + 11;
int p[N];

int main() {
	iota(p, p + N, 0);
	for(int i = 2; i < N; i ++) if(p[i] == i)
		for(int j = i; j < N; j += i) p[j] = i;
	ios :: sync_with_stdio(0);

	for(int x; cin >> x; ) {
		for(int i = x - 1; ; i --)
			if(p[i] == i) {
				cout << i << ' ';
				break;
			}
		for(int i = x + 1; ; i ++)
			if(p[i] == i) {
				cout << i << '\n';
				break;
			}
	}

	return 0;
}

Measured memory_bytes: 3404
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> Mat;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1000003;

ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}

vector<ll> fact;
vector<ll> inv_fact;

void comb_init(int n) {
	fact.resize(n + 1);
	inv_fact.resize(n + 1);
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
}

int main() {
	int Q;
	cin >> Q;
	comb_init(2 * MOD);
	for (int i = 0; i < Q; i++) {
		ll x, d, n;
		cin >> x >> d >> n;
		if (d == 0) {
			cout << mod_pow(x, n) << endl;
			continue;
		}
		if (n >= MOD) {
			cout << 0 << endl;
			continue;
		}
		(x *= mod_pow(d, MOD - 2)) %= MOD;
		ll ans = fact[x + (n - 1)];
		if (x > 0) (ans *= inv_fact[x - 1]) %= MOD;
		(ans *= mod_pow(d, n)) %= MOD;
		cout << ans << endl;
	}
}

Measured memory_bytes: 32128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

struct node{
	int x,y;
}que[100001],t;

int dx[5]={-1,0,0,1,-1},dy[5]={-1,1,-1,0,0},vis[51][51],n,m,dis[51][51],a[51][51],s;
char x;

int bfs(){
	int l=1,r=1;
	que[1].x=1;
	que[1].y=1;
	dis[1][1]=1;
	vis[1][1]=true;
	while(l<=r){
		t=que[l];
		l++;
		for(int i=1;i<=4;i++){
			int x=t.x+dx[i],y=t.y+dy[i];
			if(x<1 || x>n || y<1 || y>m)continue;
			if(x==n && y==m)return dis[t.x][t.y]+1;
			if(!vis[x][y] && a[x][y]){
				que[++r].x=x;
				que[r].y=y;
				dis[x][y]=dis[t.x][t.y]+1;
				vis[x][y]=true;
			}
		}
	}
	return -1;
}

int main(){
	cin >> n >> m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			cin >> x;
			if(x=='.')
				a[i][j]=1;
			else
				s++;
		}
	int x=bfs();
	if(x==-1)
		cout << -1;
	else
		cout << n*m-s-x;
	return 0;
}

Measured memory_bytes: 256
// failed to generate code

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


int h[100010];
int dp[100010];

int main(){
    int N, K;
    cin >> N;
    K = 2;

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

    for(int i = 0 ; i < 100010 ; i++) dp[i] = 1e9;

    dp[0] = 0;
    for(int i = 0 ; i < N ; i++){
        for(int j = 1 ; j <= K && i + j < N ; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int N_MAX = 2000;
int main()
{
  int n,t,a;
  int h[N_MAX];
  double min,tmp;
  int num;
  cin >> n;
  cin >> t >> a;
  min = 100000;
  for(int i=0;i<n;i++){
    cin >> h[i];
    tmp = fabs(a-(t-(double)h[i]*0.006));
    if(tmp<min){
      min = tmp;
      num = i+1;
    }
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#define MP make_pair
#define fi first
#define se second 
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const ll INF=100000000000000000ll;
const int N=200010;
int a[N];
ll s[N];
int n;ll ans;

int find(int L,int R){
	int ret=L-1;
	int l,r,mid;
	l=L;r=R-1;
	while(l<r){
		mid=l+r>>1;
		if(s[mid]-s[L-1]>s[R]-s[mid])	r=mid;
		else{l=mid+1;ret=mid;}
	}
	return ret;
}

void check(ll k1,ll k2,ll k3,ll k4){
	int i;
	static ll c[10];
	ll mn=INF;ll mx=0;
	c[1]=k1;c[2]=k2;c[3]=k3;c[4]=k4;
	rep(i,1,4)	mx=max(mx,c[i]);
	rep(i,1,4)	mn=min(mn,c[i]);
	ans=min(mx-mn,ans);
}	

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	ans=INF;
	int p1,p2,o1,o2,k1,k2;
	register int i;
	scanf("%d",&n);
	rep(i,1,n)	scanf("%d",&a[i]);
	rep(i,1,n)	s[i]=s[i-1]+a[i];
	rep(i,2,n-2){
		p1=find(1,i);
		p2=find(i+1,n);
		rep(o1,0,1)	rep(o2,0,1){
			k1=p1+o1;k2=p2+o2;
			if(1<=k1&&k1<i&&i+1<=k2&&k2<n)	check(s[i]-s[k1],s[k1],s[n]-s[k2],s[k2]-s[i]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}























Measured memory_bytes: 2560
import math
from fractions import gcd
from decimal import *
getcontext().prec = 56

def lcm(x, y):
  a = Decimal(max(x,y)) / Decimal(gcd(x, y))
  b = Decimal(min(x,y)) * Decimal(a)
#    return (x * y) // gcd(x, y)
  return b // 1
  
a,b,c,d = map(Decimal, input().split())

div_c_min = math.ceil(a/c) * c
div_c_max = math.floor(b/c) * c
if div_c_max >= div_c_min:
  div_c_cnt = (div_c_max - div_c_min) / c + 1
else:
  div_c_cnt = 0
  
div_d_min = math.ceil(a/d) * d
div_d_max = math.floor(b/d) * d
if div_d_max >= div_d_min:
  div_d_cnt = (div_d_max - div_d_min) / d + 1
else:
  div_d_cnt = 0

lcm_cd = lcm(c,d)
div_cd_min = math.ceil(a/lcm_cd) * lcm_cd
div_cd_max = math.floor(b/lcm_cd) * lcm_cd
if div_cd_max >= div_cd_min:
  div_cd_cnt = (div_cd_max - div_cd_min) / lcm_cd + 1
else:
  div_cd_cnt = 0

#print(d,c,div_c_cnt,div_d_cnt,div_cd_cnt)
  
print(int(b - a + 1 - (div_c_cnt + div_d_cnt - div_cd_cnt)))

Measured memory_bytes: 5048
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
S = list(input())
from collections import Counter
c = Counter(S)
ans = c['R']*c['B']*c['G']
for i in range(N-1):
    for j in range(i+1,N):
        if 2*j - i >= N:
            continue
        se = [S[i],S[j],S[2*j-i]]
        se = set(se)
        if len(se) == 3:
            ans -=1

print(ans)

Measured memory_bytes: 69052
fun main() {
    val n = nextInt()
    val l = nextIntList()
    var count = 0
    (0 until l.size - 2).forEach { i ->
        val I = l[i]
        (i + 1 until l.size - 1).forEach j@{ j ->
            val J = l[j]
            if (I == J) return@j
            (j + 1 until l.size).forEach k@{ k ->
                val K = l[k]
                if (I == K || J == K) return@k
                // println("${i + 1}, ${j + 1}, ${k + 1} = $I $J $K (${I + J > K && J + K > I && K + I > J})")
                if (I + J > K && J + K > I && K + I > J) {
                    count++
                }
            }
        }
    }
    println(count)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 39420
#include<stdio.h>
#define MAX 500000
#define INFTY 2000000000

int L[MAX / 2 + 1], R[MAX / 2 + 1];
int A[MAX];
int cnt = 0;

void merge(int A[], int left, int mid, int right){
	int i,j;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++){
		L[i] = A[left+i];
	}
	for (i = 0; i < n2; i++){
		R[i] = A[mid+i];
	}
	L[n1] = R[n2] = INFTY;
        i=0;
        j=0;
	for (int k = left; k < right; k++){
		cnt++;
		if (L[i] <= R[j]){
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int left, int right){
	if (left + 1 < right){
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	mergeSort(A, 0, n);
	for (int i = 0; i < n; i++){
		if (i)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
        printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 6596
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
  int n, k, a[55],h;
  bool cmp(int a ,int b){
  	return a > b;
  }
  
int main(){	
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++){
		h +=a[i];
		
	}
	cout<<h<<endl;
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
        x: u32,
    }
    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if i * 500 + j * 100 + k * 50 == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
a=[]
b=[]
for i in range(3):
	a+=list(map(int,input().split()))
n=int(input())
for i in range(n):
	num=int(input())
	for j in range(9):
		if num==a[j]:
			b.append(j)
if 0 in b and 1 in b and 2 in b:
	print("Yes")
elif 3 in b and 4 in b and 5 in b:
	print("Yes")
elif 6 in b and 7 in b and 8 in b:
	print("Yes")
elif 0 in b and 3 in b and 6 in b:
	print("Yes")
elif 1 in b and 4 in b and 7 in b:
	print("Yes")
elif 2 in b and 5 in b and 8 in b:
	print("Yes")
elif 0 in b and 4 in b and 8 in b:
	print("Yes")
elif 2 in b and 4 in b and 6 in b:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 3064
import java.util.*;

public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        int N = in.nextInt();
        int M = in.nextInt();
        PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
        for (int i = 0; i < N; i++) pq.add(in.nextLong());
        for (int i = 0; i < M; i++) {
            long v = pq.poll();
            pq.add(v >> 1);
        }
        long ans = 0L;
        for (long v : pq.toArray(new Long[0])) {
            ans += v;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60684
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for q in range(Q):
  b,c  = map(int, input().split())
  B.append(b)
  C.append(c)

NumCnt = {}
for a in A:
  if a in NumCnt:
    NumCnt[a]+=1
  else:
    NumCnt[a]=1
    
S = sum(A)
for b,c in zip(B,C):
  if b in NumCnt:
    cnt_c = NumCnt.pop(b)
    S += (c-b)*cnt_c
    if c in NumCnt:
      NumCnt[c] +=cnt_c
    else:
      NumCnt[c] = cnt_c
  else:
    pass
  print(S)

Measured memory_bytes: 27328
N = int(input())
s = [int(input()) for i in range(N)]
s_shadow = [i for i in s if i % 10 != 0]
ans = sum(s)
 
if ans % 10 == 0:
    if len(s_shadow) == 0:
        ans = 0
    
    else:
        ans = sum(s)-s_shadow[0]
        anss = sum(s)
        for i in s_shadow:
            ans = max(ans, anss-i)
            
print(ans)

Measured memory_bytes: 3064
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll K;
    cin >> K;

    if (K % 2 == 0 || K % 5 == 0)
    {
        cout << "-1" << endl;
        return 0;
    }

    ll L = K % 7 == 0 ? (9 * K / 7) : (9 * K);

    ll M = 10 % L;
    FOR(i, 1, L)
    {
        if (i >= 2)
            M = (M * 10) % L;

        if (M == 1)
        {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

const int MN = 105;
int N, M, i, j, a[MN];

int main(){
    scanf("%d",&N);
    if(N%2==0){
        M = N*(N-1)/2-(N/2);
        printf("%d\n",M);
        for(i=1;i<=N;i++){
            for(j=i+1;j<=N;j++){
                if(i+j!=N+1) printf("%d %d\n",i,j);
            }
        }
    }
    else{
        M = N*(N-1)/2-(N/2);
        printf("%d\n",M);
        for(i=1;i<=N;i++){
            for(j=i+1;j<=N;j++){
                if(i+j!=N) printf("%d %d\n",i,j);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
/*
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
 */
#define i_7 2019

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}

int main(){fastio
    
    string s;cin>>s;
    ll n=s.size();
    ll dp[n+1];
    dp[n]=0;
    for(ll i=n-1;i>=0;i--){
        dp[i]=mod(dp[i+1]+(s[i]-'0')*po(10,n-1-i));
    }
    //rep(i,0,n)cout<<dp[i]<<" ";cout<<endl;
    sort(dp,dp+n+1);
    ll ans=0;
    rep(i,0,n){
        ll c=1;
        while(i<=n-1&&dp[i]==dp[i+1]){
            c++;
            i++;
        }
        ans+=c*(c-1)/2;
    }
    cout<<ans<<endl;
    
    return 0;
}


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



int main(){
  int N;
  cin >> N;
  int ans;
  ans = 1000- N%1000;
  if(ans == 1000){
    cout << 0 << endl;
  }
  else{
    
  cout << ans << endl;
  }
}
  



Measured memory_bytes: 3636
# coding: utf-8

CAKE_DOLLAR = 4
DONUT_DOLLAR = 7

n = int(input())

cake_max = n // CAKE_DOLLAR
donut_max = n // DONUT_DOLLAR

for cake_amount in range(cake_max+1):
    for donut_amount in range(donut_max+1):
        if CAKE_DOLLAR * cake_amount + DONUT_DOLLAR * donut_amount == n:
            print("Yes")
            exit()

print("No")


Measured memory_bytes: 2940
#include <iostream>
int main(){
  int n, c[501], s[501], f[501], a[501]={}, i=0,j, t;
  std::cin>>n;
  while(std::cin>>c[i]>>s[i]>>f[i])i++;
  for(i=0;i<n-1;++i){
    t=0;
    j=i;
    while(j<n-1){
      if(t>=s[j]&&t%f[j]==0){t+=c[j];++j;}
      else ++t;
    }
    a[i] = t;
  }
  for(i=0;i<n;++i)std::cout<<a[i]<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int min(int a, int b){return (a>b)? b:a;}
int main(void){
    // Your code here!
    int N1, N2;
    scanf("%d %d",&N1,&N2);
    
    int ret = min(N1,N2);
    scanf("%d %d",&N1,&N2);
    ret += min(N1,N2);
    printf("%d\n", ret);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size()-1; i++){
    char s1 = s.at(i), s2 = s.at(i+1);
    if(s1 == s2){
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }

    if(i+2 < s.size()){
      char s3 = s.at(i+2);
      if(s1 == s3){
        cout << i+1 << ' ' <<  i+3 << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#define ms(A, B) memset(A, B, sizeof(A))
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x7fffffff;
const int N = 1e5 + 10;

char s[N];

int main() {
#ifdef local
    freopen("case.in", "r", stdin);
#endif
    scanf("%s", s);
    int len = strlen(s);
    bool flag = true;
    for (int i = 0; i < len - 2; i++) {
        if (s[i] != s[i + 2]) {
            flag = false;
            break;
        }
    }
    if (flag) {
        puts("Second");
        return 0;
    }
    if (len & 1) {
        if (s[0] == s[len-1])
            puts("Second");
        else
            puts("First");
    }
    else {
        if (s[0] == s[len-1])
            puts("First");
        else
            puts("Second");
    }
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int stack[1000],top=-1;

int main()
{
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=0;i<1000;i++)
    stack[i]=0;
  int min=(a<b)?a:b;
  for(int i=1;i<=min;i++)
    if(a%i==0 and b%i==0)
      stack[++top]=i;
  cout<<stack[top-k+1];
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  if(k>(n-1)*(n-2)/2){
    cout << -1 << endl;
    return 0;
  }

  int m = n-1;
  vector<int> ans[n];
  rep(i,n-1) ans[0].emplace_back(i+1);

  int cnt = (n-1)*(n-2)/2 - k;
  for(int i=1; i<n-1; ++i) for(int j = i+1; j<n; ++j){
    if(cnt<=0) break;
    ++m;
    ans[i].emplace_back(j);
    --cnt;
  }
  cout << m << endl;
  rep(i,n)rep(j,ans[i].size()) cout << i+1 << " " << ans[i][j]+1 << endl;
}


Measured memory_bytes: 256
n = int(input())
adj = [[] for _ in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  adj[a-1].append((b-1, i))
  adj[b-1].append((a-1, i))
max_degree = 0
for i in range(n):
  degree = len(adj[i])
  if degree > max_degree:
    root = i
    max_degree = degree
color = [[] for _ in range(n)]
edge = [0] * (n - 1)
queue = [root]
parent = [root] * n
while queue:
  vertex = queue.pop()
  c = 1
  for v, i in adj[vertex]:
    if parent[vertex] == v:
      continue
    while c in color[v] or c in color[vertex]:
      c += 1
    color[v].append(c)
    color[vertex].append(c)
    edge[i] = c
    queue.append(v)
    parent[v] = vertex
    c += 1
print(max_degree)
for c in edge:
  print(c)

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

#define rep(i, a, n) for(int i=(a);i<(n);++i)
#define per(i, a, n) for(int i=(a);i>(n);--i)
#define pb emplace_back
#define mp make_pair
#define lowbit(x) (x & -x)

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

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);

int m;
const int N = 1e6 + 10;
bool vis[N];

int main(){
	scanf("%d", &m);
	int cur = 0;
	memset(vis, 0, sizeof(vis));
	rep(i, 0, m+10){
		cur = (cur * 10 + 7) % m;
		if(cur == 0){
			printf("%d\n", i + 1);
			return 0;
		}
		if(vis[cur])	break;
		vis[cur] = 1;
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 4796
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main()
{
    set<string> ids;
    bool is_closed = true;

    int n;
    cin >> n;

    for( int i=0; i<n; ++i ) {
        string s;
        cin >> s;

        ids.insert( s );
    }

    int m;
    cin >> m;

    for( int i=0; i<m; ++i ) {
        string s;
        cin >> s;

        if ( ids.find( s ) != ids.end() ) {
            cout << ( is_closed ? "Opened" : "Closed" ) << " by " << s << endl;
            is_closed = !is_closed;
        } else {
            cout << "Unknown " << s << endl;
        }
    }
}

Measured memory_bytes: 1232
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int k = 0;
    int ans = 0;
    cin >> k;

    for (int i=1; i<=k; i++) {
    	rep (j, 1, k) {
    		rep (l, 1, k) {
    			ans += __gcd(__gcd(i, j), l);
    		}
    	}
    }

    cout << ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll n;
ll tg[3];
ll d[10];
ll gogo(ll mask){
  ll ret = INF;
  vector<ll> tmp;
  REP (i,n) if ((1<<i)&mask) tmp.eb(d[i]);
  do{
    ll com = SZ(tmp)-3;
    ll cur = tmp[0], idx = 0;
    ll sum = 0;
    REP1 (i,SZ(tmp)-1) {
      if (idx == 3) break;
      if (com > 0 && abs(cur + tmp[i]-tg[idx]) < abs(cur-tg[idx])) {
        sum += 10;
        cur += tmp[i];
        com--;
      }
      else {
        sum += abs(tg[idx]-cur);
        idx++;
        cur = tmp[i];
      }
    }
    if (idx < 3) sum += abs(tg[idx]-cur),idx++;
    if (idx != 3) ret = min(ret,INF);
    else ret = min(ret,sum);
  } while (next_permutation(ALL(tmp)));
  return ret;
}
int main(){
  IOS();
  cin >> n;
  REP (i,3) cin >> tg[i];
  REP (i,n) cin >> d[i];
  sort(d,d+n);
  ll ans = INF;
  REP (I,(1<<n)) {
    ll cnt = 0;
    REP (j,n) if ((1<<j)&I) cnt++;
    if (cnt < 3) continue;
    ans = min(ans,gogo(I));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class B_KagamiMochi085
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var map = new Map<int>(N);
            for (var i = 0; i < N; ++i)
            {
                map.Add(int.Parse(Console.ReadLine()));
            }
            Console.WriteLine(map.Length);
        }

        private class Map<T> where T : IComparable
        {
            public int Length { get; private set; }
            private T[] array = null;

            public Map(int _size)
            {
                this.Length = 0;
                this.array = new T[_size];
            }

            public void Add(T _value)
            {
                if (this.Find(_value)) { return; }

                this.array[this.Length] = _value;
                ++this.Length;
            }

            private bool Find(T _value)
            {
                for (var i = 0; i < this.Length; ++i)
                {
                    if (_value.Equals(this.array[i])) { return true; }
                }
                return false;
            }
        }
    }
}


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

int main(){
    int n, x;
    std::cin >> n >> x;

    int buf, l = 0, count = 1;
    for(int i = 0; i < n; ++i){
        std::cin >> buf;
        l += buf;
        if(l <= x){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
n = gets.chomp!.to_i

jpy = 0
btc = 0

n.times do
  x, n = gets.chomp!.split(" ")
  if n == 'JPY'
    jpy += x.to_i
  else
    btc += x.to_f
  end
end
puts jpy + btc * 380_000


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

int main(){
	int numOfElement;
	int elem[100] = {};

	cin >> numOfElement;

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

	for(int i = 0; i < numOfElement; i++){
		for(int j = i; j > 0 && elem[j] < elem[j -1]; j--){
			int buf = elem[j -1];
			elem[j - 1] = elem[j];
			elem[j] = buf;
		}
		for(int j = 0; j < numOfElement; j++){
			if(j + 1 >= numOfElement){
				cout << elem[j];
				break;
			}
			cout << elem[j] << " ";
		}
		cout << endl;

	}


	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#include <bitset>
#define FI first
#define SE second
#define EB emplace_back
#define MP make_pair
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N;
vector<vector<pair<int, bool>>> evis;

bool one(int b, int i) {
  return (b >> i) & 1;
}

bool right(int b, int i) {
  for (auto evi : evis[i]) {
    int x = evi.first;
    bool y = evi.second;
    if (y != one(b, x)) return false;
  }
  return true;
}


bool check(int b) {
  REP(i, N) {
    if (one(b, i) && !right(b, i)) return false;
  }
  return true;
}

int bit_cnt(int b) {
  int ret = 0;
  REP(i, N) {
    ret += one(b, i);
  }
  return ret;
}

int main()
{
  cin >> N;
  evis.resize(N);
  REP(i, N) {
    int A;
    cin >> A;
    REP(j, A) {
      int x;
      bool y;
      cin >> x >> y;
      x--;
      evis[i].push_back(MP(x, y));
    }
  }

  int ans = 0;
  REP(b, 1 << N) {
    if (check(b)) {
      ans = max(ans, bit_cnt(b));
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string yes = "Yes";
const string no = "No";

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

  string s1 = S.substr(0, (N+1)/2);
  string s2 = S.substr((N+1)/2, N-(N+1)/2);
  if (s1 == s2) {
    cout << yes << endl;
  } else {
    cout << no << endl;
  }

  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $a);

if($a % 2 === 0) {
    $num = $a / 2;
    $ans = $num * $num;
    echo $ans;
} else {
    $num = floor($a / 2);
    $num2 = $num++;
    $ans = $num * $num2;
    echo $ans;
}

?>

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    ll n, k; cin >> n >> k;

    ll a = n / k;
    ll b = (n + (k / 2)) / k;

    if(k % 2 == 0) cout << a * a * a + b * b * b << endl;
    else cout << a * a * a << endl;
}


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

signed main(){
int a;
int b=0;
while(cin>>a){
	int k=0;
   bool s[5][7]{};
   if(b)cout<<endl;
   for(int c=10000;c!=0;c/=10,k++){
   	int d=a/c;
   	if(d>4)s[k][1]=true;
   	else s[k][0]=true;
   	for(int h=0;h<5;h++){
   		if(d%5!=h)s[k][h+2]=true;
   	}
   	a-=d*c;
   }
   for(int x=0;x<2;x++){
   	for(int y=0;y<5;y++){if(s[y][x])printf("*");else printf(" ");}
   	printf("\n");
   }
   puts("=====");
   for(int x=2;x<7;x++){
   	for(int y=0;y<5;y++){if(s[y][x])printf("*");else printf(" ");}
   	printf("\n");
   }
   b++;
}
}

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

int dis(int h1, int h2){
  int distance = h1 - h2;
  if(distance >= 0 ) return distance;
  else return -distance;
}

int main() {
  //https://qiita.com/drken/items/dc53c683d6de8aeacf5a
  //↑↑これを参考にやったよ
  int N;
  cin >> N;
  vector<int> h(N);
  vector<int> cost(N,0);
  cin >> h.at(0);
  for(int i=1; i<N; i++) cin >> h.at(i);
  cost.at(1) = dis(h.at(0), h.at(1));
  
  for(int i=2; i<h.size(); i++){//dp
    int dis1 = cost.at(i-1) + dis(h.at(i-1), h.at(i));
    int dis2 = cost.at(i-2) + dis(h.at(i-2), h.at(i));
    cost.at(i) = min(dis1, dis2);
  }
  
  cout << cost.at(cost.size()-1) << endl;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) if(s[i] >= 'A' && s[i] <= 'Z'){
        if(s[i] != 'C' && s[i] != 'A') {
            cout << "WA";
        	return 0;
        }
    }
    if(s[0] == 'A'){
        int cnt = 0;
        for(int i = 2; i < s.size()-1; i++) {
            if(s[i] == 'C') cnt++;
        }
        if(cnt == 1) cout << "AC";
        else cout << "WA";
    }
    else cout << "WA";
}

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

const int N = 50 + 10 ;

int dx[]= {1,1,0,-1,-1,-1,0,1};//8 side move
int dy[]= {0,1,1,1,0,-1,-1,-1};//8 side move

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

char str[N][N] ;

int r , c ;

bool valid( int x,  int y ) {
    return ( x < r && y < c && x >= 0 && y >= 0 ) ;
}

int cnt( int x , int y ) {
    if( !valid( x , y ) ) return 0 ;
    return str[x][y] == '#' ? 1 : 0 ;
}

int main() {
    scanf("%d %d" , &r , &c ) ;
    for( int i = 0 ; i < r ; i++ ) {
        scanf("%s" , str[i] ) ;
    }
    for( int i = 0 ; i < r; i++ ) {
        for( int j = 0 ; j < c ; j++ ) {
            int x = i , y = j , tot = 0 ;
            for( int k = 0 ; k < 8 ; k++ ) {
                int xx = x + dx[k] ;
                int yy = y + dy[k] ;
                tot += cnt( xx , yy ) ;
            }
            if( str[i][j] =='.' ) printf("%d" , tot ) ;
            else printf("#") ;
        }
        printf("\n");
    }
}


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

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int bot=1,count=0;
    while(bot!=2){
        bot=a[bot-1];
        count++;
        if(count>N){
            count=-1;
            break;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void)

{

int a,b,c,i,s;

s=0;

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

for(i=a;i<=b;i++)

{

if(c%i==0)

{

s=s+1;

}

}

printf("%d\n",s);

return 0;

}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static  void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if(a<b && b<c){
			System.out.println("Yes");
		}else{
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 25996
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let x: usize = scn.read();
        let y = x / 200;
        println!("{}", 10 - y);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2236
#include <iostream>
using namespace std;
int main() {
    int A, B; cin >> A >> B; 
    int Bob = 0, Alice = 0;
    for (int i = 1; i <= 13; i++) {
        if (A == i) Alice = i;
        if (B == i) Bob = i;
        if (i == 1 && A == 1) Alice += 100;
        if (i == 1 && B == 1) Bob += 100;
    }
    if (Alice > Bob) printf("%s\n", "Alice");
    else if (Alice == Bob) printf("%s\n", "Draw");
    else printf("%s\n", "Bob");
}

Measured memory_bytes: 3640
def mapt(fn, *args):
    return tuple(map(fn, *args))


def main():
    n, m = mapt(int, input().split(" "))
    h = mapt(int, input().split(" "))
    ok = [True for i in range(n)]
    for i in range(m):
        a, b = mapt(int, input().split(" "))
        a = a-1
        b = b-1
        if h[a] <= h[b]: ok[a] = False
        if h[b] <= h[a]: ok[b] = False

    print(sum(ok))

main()

Measured memory_bytes: 19980
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;

//bool verified[200000];
//map <char, int> last_index;
//int next_same_char[200000];
int h[100000];
int main(){
    int K;
    int N;

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

    sort(h, h + N);
    int ans = INT_MAX;
    for(int i = 0; i <= N - K; i++){
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll h,w;cin>>h>>w;
    ll n;cin>>n;
    ll ans[h][w];
    ll id1 =0, id2=0;
    REP(i,n){
        ll cnt;cin>>cnt;
        REP(j,cnt){
            ans[id1][id2] = i+1;
            if(id1 % 2==0 && id2<w-1) id2++;
            else if (id1 % 2==0 && id2==w-1) id1++;
            else if(id1%2==1 && id2>0) id2--;
            else if(id1%2==1 && id2==0) id1++;
        }
    }
    REP(i,h){
        REP(j,w) cout<<ans[i][j]<<' ';
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3696