akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << CEIL(n, x)*t << endl;
}

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

    int tc = 1;
    //cin >> tc;
    FOR(i, 1, tc + 1) {
        //cout << "Case #" << i << ": ";
        solve();
    }
}



Measured memory_bytes: 3632
#include<stdio.h>{
   int main(){
      int d;
      scanf("%d",&d);
      if(d==25){
         printf("Christmas");
      }
      if(d==24){
         printf("Christmas Eve");
      }
      if(d==23){
         printf("Christmas Eve Eve");
      }
      if(d==22){
         printf("Christmas Eve Eve Eve");
      }
   return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 300
unsigned an1[MAX+5];
unsigned an2[MAX+5];
unsigned a[2*MAX+10];
char aa[MAX+10];
char b[MAX+10];
int main(){
	scanf("%s %s",&aa,&b);
	int i,j;
	int len_a=strlen(aa);
	memset(an1,0,sizeof(an1));
	memset(an2,0,sizeof(an2));
	memset(a,0,sizeof(a));
	j=0;
	for(i=len_a-1;i>=0;i--)
	an1[j++]=aa[i]-'0';//转换为10进制数字
	int len_b=strlen(b);
	j=0;
	for(i=len_b-1;i>=0;i--)
	an2[j++]=b[i]-'0';
	for(i=0;i<len_b;i++){//这一步可以进行优化 但是很复杂 O（logn（1.59））
		for(j=0;j<len_a;j++)
			a[i+j]+=an2[i]*an1[j];//每一位都进行相加 m*n的复杂度
	}
	for(i=0;i<2*MAX;i++){
		if(a[i]>=10){
			a[i+1]+=a[i]/10;//由于进位还没有考虑进去 这样就有些数字大于10的
			a[i]%=10;//我们要进位
		}
	}
	bool b=false;
	for(i=MAX*2;i>=0;i--)//下面就是输出了 一定要注意个位数字的下表更大 所以是从第一个非0数字开始的
	if(b)
	printf("%d",a[i]);
	else if(a[i]){
	printf("%d",a[i]);
		b=true;
	}
	if(!b)//这一步太重要了 一定不要忘记 如果有一个数字是0的话 这个我就忘记了 一直wrong answer 几乎快崩溃了
	cout<<0<<endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    string c;
    cin >> c;

    int rnum = 0;
    for (int i = 0; i < n; ++i) {
        if (c[i] == 'R') rnum++;
    }

    int res = 0;
    for (int i = 0; i < rnum; ++i) {
        if (c[i] == 'W') res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3764
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())

    ans = 0
    for i in range(1, N + 1, 2):
        c = 0
        for j in range(1, i + 1):
            if i % j == 0:
                c += 1
        if c == 8:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63248
//007naruto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define forn(i,n) for(int i=0;i<n;i++)
 
 int main()
 {
 	int a[100],c[100],v[100];
 	
   ll n,s=0,i;
   cin>>n;
   for( i=0;i<n;i++)
  cin>>v[i];
   for( i=0;i<n;i++)
  cin>>c[i];
  
   for( i=0;i<n;i++)
  a[i]=v[i]-c[i];
  
  sort(a,a+n);
  
   for( i=0;i<n;i++)
  if(a[i]>0)
  s+=a[i];
  
  
  
  cout<<s;
  
 }


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

int main() {
    int H, W;
    string s;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}

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

using namespace std;

const int N = 5e5 + 5;

struct FenwickTree {
    long long bit[N];
    void update (int x, int val) {
        for (int i = x; i < N; i += i & -i) bit[i] += val;
    }

    long long query (int x) {
        long long ans = 0;
        for (int i = x; i > 0; i -= i & -i) ans += bit[i];
        return ans;
    }
} fw;

int n, q, a[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i], fw.update(i, a[i]);
    while (q--) {
        int t, l, r;
        cin >> t >> l >> r; l++;
        if (t == 0) fw.update(l, r);
        else cout << fw.query(r) - fw.query(l - 1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 10212
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>
#include <iterator>

#define yes       cout<<"Yes" nl;
#define no        cout<<"No" nl;
#define na        cout<<-1 nl;
#define bye       return;
#define vll       vector<ll>
#define in        insert
#define ff        first
#define ss        second
#define sz        size()
#define bg        begin()
#define ed        end()
#define mp        make_pair
#define bs        binary_search
#define IOF       freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);  
#define pb        push_back
#define pob       pop_back
#define ll        long long
#define nl        <<endl
#define sp        <<" "<<
#define f(i,a,b)  for(int i=a;i<b;i++)
#define boost     ios::sync_with_stdio(false);cin.tie(0);    
using namespace std;

void acca()
{   
    int n;
    cin>>n;
    if(n>=30)
    yes
    else
    no

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

Measured memory_bytes: 3580
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	x := nextInt()
	y := nextInt()
	z := nextInt()

	fmt.Printf("%d %d %d\n", z, x, y)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a==b&&b==c) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) cout << "Left" << endl;
  else if ( A + B < C + D) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD =  998244353;
int main(){
	int n,k;
	cin >> n >> k;

	vector<pair<int,int>> lr;
	for(int i = 0;i < k;i++){
		int l,r;
		cin >> l >> r;
		lr.push_back(make_pair(l,r));
	}

	ll eff_seg = 0;
	priority_queue<pair<int,ll>,vector<pair<int,ll>>,greater<pair<int,ll>>> st;
	priority_queue<pair<int,ll>,vector<pair<int,ll>>,greater<pair<int,ll>>> en;

	st.push(make_pair(0,1));
	en.push(make_pair(0,1));
	vector<ll> ans(n);
	for(int i = 0;i < n;i++){
		while(st.size() && st.top().first == i){
			eff_seg += st.top().second;
			eff_seg %= MOD;
			st.pop();
		}
		ans[i] = eff_seg; 
		for(int j = 0;j < k;j++){
			st.push(make_pair(i + lr[j].first,ans[i]));
			en.push(make_pair(i + lr[j].second,ans[i]));
		}
		while(en.size() && en.top().first == i){
			eff_seg = (eff_seg - en.top().second + MOD) % MOD;
			en.pop();
		}
	}

	cout << ans[n-1] << endl;
}


Measured memory_bytes: 63188
import sys


def read():
    return sys.stdin.readline().rstrip()


def main():
    d = int(read())
    c = [int(i) for i in read().split()]
    s = [[int(i) for i in read().split()] for _ in range(d)]
    t = [int(read()) - 1 for _ in range(d)]
    m = int(read())
    query = [[int(i) - 1 for i in read().split()] for _ in range(m)]
    score = 0
    last = [[0] * 26 for _ in range(d)]
    for i in range(d):
        score += s[i][t[i]]
        if i > 0:
            last[i] = last[i - 1].copy()
        last[i][t[i]] = i + 1
        for j in range(26):
            score -= c[j] * (i + 1 - last[i][j])
    for di, qi in query:
        hi = t[di]
        t[di] = qi
        score -= s[di][hi]
        score += s[di][qi]
        if di == 0:
            last[di][hi] = 0
        else:
            last[di][hi] = last[di - 1][hi]
        score -= c[hi] * (di + 1 - last[di][hi])
        score += c[qi] * (di + 1 - last[di][qi])
        last[di][qi] = di + 1
        for i in range(di + 1, d):
            score += c[hi] * (i + 1 - last[i][hi])
            if t[i] != hi:
                last[i][hi] = last[i - 1][hi]
                score -= c[hi] * (i + 1 - last[i][hi])
            else:
                break
        for i in range(di + 1, d):
            score += c[qi] * (i + 1 - last[i][qi])
            if t[i] != qi:
                last[i][qi] = last[i - 1][qi]
                score -= c[qi] * (i + 1 - last[i][qi])
            else:
                break
        print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20884
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(all(v));
    v.push_back(-1);

    ll ans = 0;
    ll cnt = 1;
    rep(i, n){
        if(v[i] == v[i+1])cnt++;
        else{
            if(cnt<v[i]) ans += cnt;
            else ans += (cnt - v[i]);
            cnt = 1;
        }
    }

    cout << ans;

}

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

int day, month, year, next_day, next_month, next_year, calculation;
 
int main() {
  int a,b,ans=0; 
  cin >> a >> b;
  day = 1; month=1;   year =2018;
  while(month!=a||day!=b){
    if(day == month) ans++;
    next_day = day +1;
    next_month = month;
    next_year = year;
    calculation = 31;
    if (month == 2) {
        calculation = 28;
        if (year % 100 == 0) {
            if (year % 400 == 0) {
                calculation = 29;
            } 
        }else if (year % 4 == 0) {
                    calculation = 29;
        }
    }else if(month == 4||month==6||month==9||month==11){
            calculation=30;
    }


    if (next_day > calculation) {
                next_day = 1;
                next_month++;
    }
    if (next_month > 12) {
                next_month = 1;
                next_year++;
    }
    year = next_year;
    day = next_day;
    month = next_month;
  }
  if(a==b) ans++;
  cout << ans << endl;
    
}

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int A, B, C, kol = 0;
   cin >> A >> B >> C;
   for (int i = 0; i < 150; i++) {
      if (A % 2 || B % 2 || C % 2) {
         cout << i;
         return 0;
      }
      int o = A / 2, o1 = B / 2, o2 = C / 2;
      A = o, B = o1, C = o2;
      A = o1 + o2, B = o + o2, C = o1 + o;
     //cout << A << ' ' << B << ' ' << C << endl;
   }
   cout << -1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const long long mod = 1000000007;
long long mp(long long b, long long e) {
	if (e == 0) return 1;
	long long a = mp(b, e / 2);
	a = a * a % mod;
	if (e % 2) a = a * b % mod;
	return a;
}
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	long long A[N];
	for (int i = 0; i < N; ++i) scanf("%lld", &A[i]);
	sort(A, A + N);
	long long ans = 0, fac[N + 1], inv[N + 1];
	fac[0] = inv[0] = 1;
	for (int i = 1; i <= N; ++i) {
		fac[i] = i * fac[i - 1] % mod;
		inv[i] = mp(fac[i], mod - 2);
	}
	for (int i = 0; i <= N - K; ++i) ans = (ans - fac[N - 1 - i] * inv[K - 1] % mod * inv[N - i - K] % mod * A[i] % mod) % mod;
	for (int i = K - 1; i < N; ++i) ans = (ans + fac[i] * inv[K - 1] % mod * inv[i - K + 1] % mod * A[i] % mod) % mod;
	printf("%lld", (ans + mod) % mod);
	return 0;
}

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

int main() {
    string s, a;
    cin >> s;
    for (int i = 0; i < 3; ++i) {
    	if (s[i] == '1') a[i] = '9';
    	else if (s[i] == '9') a[i] = '1';
		else a[i] = s[i];
    }
  
    cout << a.c_str() << endl;
}

Measured memory_bytes: 256
L, R = gets.strip.split.map(&:to_i)

res = 2019
 
for i in L..R-1
  for j in i+1..R
    if res > i*j % 2019
      res = i*j % 2019
    end
    if res == 0
      puts 0
      exit
    end
  end
end

puts res


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();
        int[] answers = new int[n];
        for(int i = 1; i< n; i++)
        {
            answers[a[i - 1] - 1]++;
        }

        foreach(var answer in answers)
        {
            Console.WriteLine(answer);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,X;
  cin >> N >> X;
  int D=0,ans=1;
  rep(i,N){
    int L;
    cin >> L;
    D+=L;
    if(D<=X){
      ans++;
    }else break;
  }
    
    cout << ans <<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _Sync ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
#define _End return cout << '\n' , 0 ;
#define fo(i,x,y) for (int i = x; i < y; i++)
#define fd(i,x,y) for(int i = x; i>= y; i--)
#define ll long long
#define clr(A,x) memset(A, x, sizeof A)
#define pb push_back
#define mod 1000000007
#define debug(x) cout <<#x << " = " << x << endl
#define PI 3.14159265
#define MAXN 100001

using namespace std;


int f(string x,string y){
    int cnt =0;
    fo(i,0,x.size()){
        if(x[i]!=y[i]){
            cnt++;
        }
    }
    return cnt;
}
int main ()
{
    _Sync
    //freopen("D:/input.txt","r",stdin);
    string s;
    cin>>s;
    string nuevo1="",nuevo2 = "";
    fo(i,0,s.size()){
        if(i%2==0){
            nuevo1+="0";
            nuevo2+="1";
        }else{
            nuevo1+="1";
            nuevo2+="0";
        }
    }

    int ans = min(f(s,nuevo1),f(s,nuevo2));
    cout<<ans<<endl;
}


Measured memory_bytes: 1104
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args)throws IOException{
    	int a, b, c;
    	InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
        String buf = br.readLine();
        StringTokenizer st = new StringTokenizer(buf," ");
    	a = Integer.parseInt(st.nextToken());
        b = Integer.parseInt(st.nextToken());
        c = Integer.parseInt(st.nextToken());
        if (c < b) {
            int z;
            z = c;
            c = b;
            b = z;
        }
        if (b < a) {
            int z;
            z = b;
            b = a;
            a = z;
        }
        if (c < b) {
            int z;
            z = c;
            c = b;
            b = z;
        }
        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 24324
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int N;
    while(scanf("%d",&N)==1)
    {   int a[N][3],n;
        for(n=0;n<N;n++)
    scanf("%d%d%d",&a[n][0],&a[n][1],&a[n][2]);
        int x=a[0][1],y=a[0][2],flag=1,t=a[0][0];
        for(n=0;n<N;)
        {
            if(t>=x+y)
            {
                if((t-x-y)%2)
                    {flag=0;break;}
            }
            else {flag=0;break;}
            if(++n<N)
            {x=abs(a[n][1]-a[n-1][1]);
            y=abs(a[n][2]-a[n-1][2]);
            t=abs(a[n][0]-a[n-1][0]);}
        }
        printf(flag?"Yes\n":"No\n");
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
int main(){
	sonic;
	ll n , j = 1;
	cin >> n;
	while(j != 0){
		j = 1;
		for(ll i = 2 ; i < sqrt(n) ; i ++){
			if(n % i == 0){
				j ++;
				break;
			}
		}
		if(j == 1){
			cout << n;
			j = 0;
		}
		n ++;
	}
}


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

int EA[53][53] , EB[53][53] , faA[53] , faB[53] , T , N; bool same[53];

void find_same(int x , int p){
	same[x] = 1;
	for(int i = 1 ; i <= N ; ++i)
		if(EA[x][i] && EB[x][i] && i != p) find_same(i , x);
}

void getfa(int x , int p , int *fa , int E[][53]){
	fa[x] = p;
	for(int i = 1 ; i <= N ; ++i)
		if(E[x][i] && i != p) getfa(i , x , fa , E);
}

vector < int > nxt[53]; int du[53];

int main(){
	for(cin >> T ; T ; --T){
		cin >> N; int ans = 200;
		memset(EA , 0 , sizeof(EA));
		for(int i = 1 ; i < N ; ++i){int x , y; cin >> x >> y; EA[x][y] = EA[y][x] = 1;}
		memset(EB , 0 , sizeof(EB));
		for(int i = 1 ; i < N ; ++i){int x , y; cin >> x >> y; EB[x][y] = EB[y][x] = 1;}
		for(int i = 1 ; i <= N ; ++i){
			int cnt = 0;
			for(int j = 1 ; j <= N ; ++j) cnt += EA[i][j];
			if(cnt != 1) continue;
			int tar; for(int j = 1 ; j <= N ; ++j) if(EA[i][j]) tar = j;
			EA[i][tar] = EA[tar][i] = 0;
			for(int j = 1 ; j <= N ; ++j)
				if(j != i){
					EA[i][j] = EA[j][i] = 1; memset(same , 0 , sizeof(same));
					find_same(i , 0); memset(du , 0 , sizeof(du));
					getfa(i , 0 , faA , EA); getfa(i , 0 , faB , EB);
					int num = 0; for(int i = 1 ; i <= N ; ++i) nxt[i].clear();
					for(int i = 1 ; i <= N ; ++i)
						if(!same[i]){
							++num;
							if(!same[faA[i]]){nxt[i].push_back(faA[i]); ++du[faA[i]];}
							if(!same[faB[i]]){nxt[faB[i]].push_back(i); ++du[i];}
						}
					queue < int > q; int num1 = 0;
					for(int i = 1 ; i <= N ; ++i) if(!same[i] && !du[i]) q.push(i);
					while(!q.empty()){
						int t = q.front(); q.pop(); ++num1;
						for(auto p : nxt[t]) if(!--du[p]) q.push(p);
					}
					if(num1 == num) ans = min(ans , num + (j != tar));
					EA[i][j] = EA[j][i] = 0;
				}
			EA[i][tar] = EA[tar][i] = 1;
		}
		cout << (ans == 200 ? -1 : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b] <- map fromIntegral . unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  let x = gcd a b :: Int64
  print $ 1 + length (factor x)

--
-- Prime numbers
--

infixr 5 !:
(!:) :: a -> [a] -> [a]
(!x) !: xs = x : xs

-- | エラトステネスの篩により、 max 以下の素数の一覧を構築して返す
-- >>> sieve 100
-- [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
sieve :: Int -> [Int64]
sieve !max = 2 : U.ifoldr (\i isPrime xs -> if isPrime then fromIntegral (2 * i + 1) !: xs else xs) [] vec
  where
    vec = U.create $ do
      vec <- UM.replicate ((max - 1) `quot` 2 + 1) True
      UM.write vec 0 False -- 1 is not a prime
      -- vec ! i : is (2 * i + 1) prime?
      let clear !p = forM_ [3*p,5*p..max] $ \n -> UM.write vec (n `quot` 2) False
          factorBound = floor (sqrt (fromIntegral max) :: Double)
          loop !i | 2 * i + 1 > factorBound = return ()
                  | otherwise = do b <- UM.read vec i
                                   when b $ clear (2 * i + 1)
                                   loop (i + 1)
      loop 1
      return vec

-- |
-- >>> takeWhile (< 100) primes
-- [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
primes :: [Int64]
primes = sieve (10^6)

factor :: Int64 -> [(Int64, Int)]
factor 0 = error "factor 0"
factor x | x > 10^12 = error "factor: too large"
factor x = loop x primes
  where
    loop 1 _ = []
    loop x (p:ps) = case factorOut 0 x p of
                      (0,y) -> loop x ps
                      (n,y) -> (p,n) : loop y ps
    loop x [] = [(x,1)]
    factorOut !n !x !p | (q,0) <- x `quotRem` p = factorOut (n+1) q p
                       | otherwise = (n, x)


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

namespace VProblemSlovingClub
{
    class Program
    {
        static void Main(string[] args)
        {
            string arg = Console.In.ReadLine();
            float H = int.Parse(arg.Split(' ')[0]);
            float A = int.Parse(arg.Split(' ')[1]);

            int R = (int)Math.Ceiling(H / A);

            Console.Out.WriteLine(R);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>

using namespace std;

int V, E, S, T;
long long D;
long long int M[100][100];
static const int INF = 2000000000;


int main(void){
    // Your code here!
    cin >> V >> E;
    for(int i = 0; i < V; i++) {
        for(int j = 0; j < V; j++){
            if(i == j) M[i][j] = 0;
            else M[i][j] = INF;
        }
    }
    
    for(int i = 0; i < E; i++){
        cin >> S >> T >> D;
        M[S][T] = D;
    }

    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            if(M[i][k] == INF) continue;
            for(int j = 0; j < V; j++){
                if(M[k][j] == INF) continue;
                M[i][j] = min(M[i][j], M[i][k] + M[k][j]);
            }
        }
    }
    
    bool flag = true;
    for(int i = 0; i < V; i++){
        if(M[i][i] < 0){
            flag = false;
            break;
        }
    }
    
    if(!flag) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    
    for(int i = 0; i < V; i++){
        if(M[i][0] == INF) cout << "INF";
        else cout << M[i][0];
        
        for(int j = 1; j < V; j++){
            if(M[i][j] == INF) cout << " INF";
            else cout << " " << M[i][j];
        }
        
        cout << endl;
    }
    
  
    return 0;
    
}



Measured memory_bytes: 3192
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>

int main()
{
    int n,r;
    cin>>n>>r;
    
    int ans=r;

    if(n<10){
        ans=r+(100*(10-n));
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h.sort(reverse=True)
ans=h[0]-h[n-1]
for i in range(n-k+1):
    ans =min(ans,h[i]-h[i+k-1])
print(ans)

Measured memory_bytes: 7384
n,m = map(int, input().split())
s = []
for i in range(m):
    k = list(map(int, input().split()))
    K = []
    for i in k:
        K.append(i-1)
    s.append(K[1:])
p = list(map(int, input().split()))

# print("n,m:",n,m)
# print("s:",s)
# print("p:",p)

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

# print("---start---")
ans = 0
for i in range(2**n):
    bitnow = bitlist(i,n)
    # print("bitnow:",bitnow)
    flag = 0
    for j in range(m):
        checker = 0
        for l in s[j]:
            if bitnow[l]==1:
                # print("l:",l)
                checker += 1
        # print("checker:",checker)
        # print("p[j]:",p[j])
        if checker%2 != p[j]:
            flag = 1
    if flag == 0:
        ans += 1
    # print("ans:",ans)
    # print("--------------")

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
double mutu(double z){
	double l=0,r=90;
	double x=(l+r)/2;
	int cnt=0;
	while(cos(x*pie/180)!=z&&cnt<=30){
		if(cos(x*pie/180)>z)l=x;
		else r=x;
		x=(l+r)/2;
		cnt++;
	}
	return x;
}
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	double d=min(a*a*b-c,c);
	d/=a;
	if(a*a*b/2.0>=c){
		double x=d*2/b;
		double y=sqrt(x*x+b*b);
		printf("%.100lf",mutu(x/y));
	}
	if(a*a*b/2.0<c){
		double x=d*2/a;
		double y=sqrt(x*x+a*a);
		printf("%.100lf",mutu(a/y));
		
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	char str[n + 1];
	scanf("%s", str);
	if (n % 2 == 1) {
		puts("No");
	}
	else {
		int flag = 1;
		for (int i = 0; i < n / 2; i++) {
			if (str[i] != str[i + n / 2]) {
				flag = 0;
			}
		}
		if (flag) {
			puts("Yes");
		}
		else {
			puts("No");
		}
	}
	return 0;
}

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

int main(){
  int w,h;
  cin >> h >> w;
  int a=0;
  char c;
  for(int i=0;i<h*w;i++){
    cin >> c;
    if(c=='#')
      a++;
  }
  cout << (a==h+w-1?"Possible":"Impossible") << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%m;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j]+C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
int sum(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum(n / 10));  
}  
ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 

int main() {
  ios;
  int n;
  cin>>n;
  ll int a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  int l=0;
  for(int i=0;i<n-2;i++)
  {
      for(int j=i+1;j<n-1;j++)
      {
          for(int k=j+1;k<n;k++)
          {
              if(a[i]+a[j]>a[k] && a[k]+a[j]>a[i] && a[i]+a[k]>a[j] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])
              {
              l++;
              }
          }
      }
  }
  cout<<l<<endl;
}


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

int main() {
    int n, T;
    cin >> n >> T;
    vector<int> c(n);
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i] >> t[i];
    }

    int ans = 999999999;
    for (int i = 0; i < n; i++) {
        if (c[i] < ans && t[i] <= T)
            ans = c[i];
    }

    if (ans != 999999999)
        cout << ans << endl;
    else
        cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();

    if (S.equals("AAA") || S.equals("BBB")) {
      System.out.println("No");
      return;
    }
    
    System.out.println("Yes");
    
  }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int h,w,n;
char board[33][33];
char tmp[33][33];
bool check[33][33];

int dd[]={-1,0,1,0,-1};

bool is_ok(){
	rep(j,w){
		for(int i=h-1;i>0;i--)rep(ii,i){
			if(tmp[ii][j]!='.'&&tmp[ii+1][j]=='.')swap(tmp[ii][j],tmp[ii+1][j]);
		}
	}
	while(1){
		memset(check,0,sizeof(check));
		bool update=false;
		rep(i,h)rep(j,w){
			if(tmp[i][j]=='.')continue;
			rep(d,4){
				int ni=i+dd[d],nj=j+dd[d+1];
				int cnt=1;
				while(ni>=0&&ni<h&&nj>=0&&nj<w&&tmp[i][j]==tmp[ni][nj]){
					ni+=dd[d],nj+=dd[d+1];
					cnt++;
				}
				if(cnt>=n){
					update=true;
					int nni=i,nnj=j;
					while(nni>=0&&nni<h&&nnj>=0&&nnj<w&&tmp[i][j]==tmp[nni][nnj]){
						check[nni][nnj]=true;
						nni+=dd[d],nnj+=dd[d+1];
					}
				}
			}
		}
		if(!update)break;
		rep(i,h)rep(j,w){
			if(check[i][j])tmp[i][j]='.';
		}
		rep(j,w){
			for(int i=h-1;i>0;i--)rep(ii,i){
				if(tmp[ii][j]!='.'&&tmp[ii+1][j]=='.')swap(tmp[ii][j],tmp[ii+1][j]);
			}
		}
	}
	rep(i,h)rep(j,w){
		if(tmp[i][j]!='.')return false;
	}
	return true;
}

int main(){
	cin.sync_with_stdio(false);
	cin>>h>>w>>n;
	rep(i,h)cin>>board[i];
	bool ok=false;
	rep(i,h)rep(j,w-1){
		memcpy(tmp,board,sizeof(board));
		swap(tmp[i][j],tmp[i][j+1]);
		if(is_ok()){
			ok=true;
		}
	}
	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3212
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!(
    n: usize,
    a: [i32; n],
    );
    let mut A = 0;
    let mut B = 0;
    let mut m = 0;
    let mut max = 0;
    let mut v = a;
    loop {
        max = *v.iter().max().unwrap();
        A += max;
        for i in 0..n {
            if v[i] == max {
                v.swap_remove(i);
                break;
            }
        }
        m += 1;
        if m == n { break; }
        max = *v.iter().max().unwrap();
        for i in 0..n {
            if v[i] == max {
                v.swap_remove(i);
                break;
            }
        }
        B += max;
        m += 1;
        if m == n { break; }
    }
    println!("{}", A - B);
}


Measured memory_bytes: 4352
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::i64;
use std::io::{stdin, Read};
use std::usize;

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn merge(mut a: HashMap<usize, usize>, b: HashMap<usize, usize>) -> HashMap<usize, usize> {
    for (k, v) in b {
        *a.entry(k).or_default() += v;
    }
    a
}

pub fn factor<'a>(
    mut n: usize,
    mut memo: HashMap<usize, HashMap<usize, usize>>,
) -> HashMap<usize, HashMap<usize, usize>> {
    if memo.contains_key(&n) {
        return memo;
    }
    let mut ret = std::collections::HashMap::new();
    let n0 = n;
    let mut cur = 2;
    while cur * cur <= n0 {
        if let Some(a) = memo.get(&n) {
            ret = merge(ret, a.clone());
            n = 0;
            break;
        }
        if n % cur != 0 {
            cur += 1;
            continue;
        }
        let mut count = 0;
        while n % cur == 0 {
            n /= cur;
            count += 1;
        }
        ret.insert(cur, count);
        cur += 1;
    }
    if n > 1 {
        ret.insert(n, 1);
    }
    memo.insert(n0, ret);
    memo
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut count = 0;
    for a in 1..n {
        count += n / a;
        if n % a == 0 {
            count -= 1;
        }
    }
    println!("{}", count);
}
pub fn num_divs(facts: &HashMap<usize, usize>) -> usize {
    facts.iter().map(|(_, v)| v + 1).product()
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2084
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string SS;
  ll NN, KK;

  std::cin >> NN;
  std::cin >> KK;

  std::cin >> SS;

  // std::cout << SS << '\n';

  for (ll i = 0; i < NN; i++) {
    if (i == KK-1) {
      char s_tem = tolower(SS[i]);
      std::cout << s_tem ;
    }else{
      std::cout << SS[i];
    }
  }

  return 0;
}


Measured memory_bytes: 768
# 8 queens
import itertools


# x座標が全部異なる
# y座標が全部異なる
# 8C2でx座標の差分とy座標の差分が異なる
# 列挙して含まれるものを挙げる

def check(queens):
    for r1, c1 in queens:
        for r2, c2 in queens:
            # 同じ座標の時は気にしない
            if r1 == r2 and c1 == c2:
                continue
            if (r1 == r2) or (c1 == c2):
                return False
            if abs(r1 - r2) == abs(c1 - c2):
                return False
    return True


k = int(input())
queens = []
row, col = list(range(8)), list(range(8))
for _ in range(k):
    r, c = map(int, input().split())
    queens.append((r, c))
    row.remove(r)
    col.remove(c)

# colを順列化する
for l in itertools.permutations(col):
    tmp_queens = queens.copy()
    # rowは固定 どうせ全てにおかれる。
    for r, c in zip(row, l):
        tmp_queens.append((r, c))
    if check(tmp_queens):
        board = [''.join('Q' if (r, c) in tmp_queens else '.' for c in range(8)) for r in range(8)]
        print(*board, sep='\n')
        break


Measured memory_bytes: 5660
import sys

input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 7)


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    good = [True] * N

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if H[a] < H[b]:
            good[a] = False
        elif H[a] > H[b]:
            good[b] = False
        else:
            good[a] = False
            good[b] = False

    print(good.count(True))


if __name__ == "__main__":
    main()


Measured memory_bytes: 20304
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int H = sc.nextInt(), W = sc.nextInt() , D = sc.nextInt();
			if(H == 0 && W == 0 && D == 0){
				break;
			}
			
			int n = sc.nextInt();
			
			for(int i = 0; i < n; i++){
				int r = sc.nextInt();
				
				boolean OK = false;
				for(int[] dim : new int[][] {{H,W},{H,D},{W,D}}){
					if((r*r*4) > (dim[0]*dim[0] + dim[1]*dim[1])){
						OK = true;
						break;
					}
				}
				
				if(OK){
					System.out.println("OK");
				}else{
					System.out.println("NA");
				}
			}
		}
		
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int i;
	int arr[m];
	for(i=0;i<m;i++)
	cin>>arr[i];
	int sum=0;
	for(i=0;i<m;i++)
	sum+=arr[i];
	if(sum>n)
	cout<<"-1"<<endl;
	else
	cout<<(n-sum)<<endl;
	return 0;
}

Measured memory_bytes: 3644
<?php
fscanf(STDIN, "%d", $n);
for ($i = 1; $i <= $n; $i++) {
  fscanf(STDIN, "%s%d", $s, $p);
  $k = sprintf("%s%03d", $s, 100 - $p);
  $a[$k] = $i;
}
ksort($a);
echo implode("\n", $a);
?>

Measured memory_bytes: 4728
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
template<typename T>inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
inline void File(){
    freopen("fuck.in","r",stdin);
    freopen("fuck.out","w",stdout);
}


const LL inf=0x7f7f7f7f7f7f7f7f;
LL n;
LL ans,my=inf;
bool flag;
int main(){
	//File();
	read(n);
	for(Rint i=1;i<=n;i++){
		LL x,y;
		read(x);read(y);
		if(x!=y)flag=1;
		ans+=x;
		if(x>y)my=min(my,y);
	}
	if(flag==0)printf("0\n");
	else printf("%lld\n",ans-my);
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
import numpy as np


def solve(A: int, B: float):
    B100 = int(B*1000)
    ans = (A*B100)-((A*B100) % 1000)
    print(ans//1000)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = float(next(tokens))  # type: float
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27156
import java.util.*;

class Main{
	Scanner scan=new Scanner(System.in);
	int [][] a;
	int r;
	int c;
	int i;
	int j;
	public Main(){
		r=scan.nextInt();
		c=scan.nextInt();
		a=new int[r+1][c+1];
		for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				a[i][j]=scan.nextInt();
				a[i][c]=a[i][c]+a[i][j];
			}
		}
		for(j=0;j<=c;j++){
			for(i=0;i<r;i++){
				a[r][j]=a[r][j]+a[i][j];
			}
	//		System.out.print(a[r][j]+" ");
		}
		for(i=0;i<=r;i++){
			for(j=0;j<=c;j++){
				if(j==c){
					System.out.println(a[i][c]);
				}else{
					System.out.print(a[i][j]+" ");
				}
					
			}
		}
	}
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 42048
loop do
  h, w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  for j in 0..(h - 1) do
    s = ""
    for i in 0..(w - 1) do
      s += i.odd? && j.odd?  || i.even? && j.even? ? "#" : "."
    end
    puts s
  end
  puts "\n"
end


Measured memory_bytes: 7256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 3e18;
constexpr double eps = 1e-9;

int N, T, Q;
int A[100010];
int D[100010];

signed main()
{
    cin >> N >> T >> Q;

    rep(i, N) {
        cin >> A[i] >> D[i];
    }

    vi kabe;

    kabe.PB(-inf);

    rep(i, N - 1) {
        if (D[i] == 1 && D[i + 1] == 2) {
            kabe.PB((A[i] + A[i + 1]) / 2);
        }
    }

    kabe.PB(inf);

    rep(i, Q) {
        int x; cin >> x;
        --x;

        if (D[x] == 1) {
            // ??±???????????????
            int val = *lower_bound(all(kabe), A[x]);
            if (val == inf) {
                cout << A[x] + T << endl;
            } else {
                cout << min(A[x] + T, val) << endl;
            }
        } else {
            int val = *(upper_bound(all(kabe), A[x]) - 1);

            if (val == -inf) {
                cout << A[x] - T << endl;
            } else {
                cout << max(A[x] - T, val) << endl;
            }
        }
    }
}

Measured memory_bytes: 4660