akhauriyash/Code-Regression huggingface dataset:
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var h, w int

	fmt.Sscan(getNextLine(scanner), &h, &w)

	aaa := make([][]int, h)
	for i := 0; i < h; i++ {
		aaa[i] = getIntList(scanner)
	}

	commands := make([]string, 0)

	for i := 0; i < h-1; i++ {
		for ii := 0; ii < w; ii++ {
			if aaa[i][ii]%2 == 0 {
				continue
			}
			aaa[i][ii]--
			aaa[i+1][ii]++
			commands = append(commands, fmt.Sprintf("%d %d %d %d", i+1, ii+1, i+2, ii+1))
		}
	}

	for i := 0; i < w-1; i++ {
		if aaa[h-1][i]%2 == 0 {
			continue
		}
		aaa[h-1][i]--
		aaa[h-1][i+1]++
		commands = append(commands, fmt.Sprintf("%d %d %d %d", h, i+1, h, i+2))
	}

	fmt.Println(len(commands))
	for i := 0; i < len(commands); i++ {
		fmt.Println(commands[i])
	}
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (a > b) swap(a, b);
  cout << max(0, b - a - w) << endl;


  
  return 0;
}

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

using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
 string s;
  
   char res1;
   int res2;
  
  for(int i=1;i<=h;i++){
   for(int j=0;j<w;j++){
     cin >> s;
     if(s=="snuke"){
       res1=j+'A';
       res2=i;
      break;
     }
   }
  }

  cout << char(res1) << res2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int a[400000],b[400000];
int length;
vector<int>ans;
bool ball[400000];
signed main(){
    int n;
    cin>>n;
    rep(i,n)cin>>a[i];
    reverse(a,a+n);
    rep(i,n){
        int cnt=0;
        for(int j=(n-i)*2;j<=n;j+=(n-i)){
            if(ball[j])cnt++;
        }
        if(cnt%2!=a[i]){
            ans.push_back(n-i);
            ball[n-i]=true;
        }
    }
    int l=ans.size();
    cout<<l<<endl;
    reverse(ans.begin(),ans.end());
    rep(i,l){
        cout<<ans[i];
        if(i==l-1)cout<<endl;
        else cout<<" ";
    }
    return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int main() {
    int N; cin >> N;
    vi p(N); rep(i,N) cin >> p[i];
    int ans = accumulate(ALL(p), 0) - (*max_element(ALL(p)))/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max =2999+20;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

double dp[Max][Max];

ll n;


double ara[Max+10];
bool vis[Max+10][Max+10];

double call(int i,int head)
{
    double &ret=dp[i][head];

    if(head<0)return 0.0;


 //     vis[i][head]=true;

      if(i<0)
       return (head==0);

        if(vis[i][head])return ret;


        vis[i][head]=true;

       ret=(ara[i]*call(i-1,head-1))+((1.0-ara[i])*call(i-1,head));

       return ret;


}


int main()
{

   fastread();

   ll i,j,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      memset(dp,0,sizeof(dp));
      memset(vis,false,sizeof(vis));

      cin>>n;

      for(i=0; i<n; i++)
        cin>>ara[i];


        double ans=0;
    for(ll head=0; head<=n; head++)
    {
        ll tail=n-head;

       // cout<<head<<" "<<tail<<endl;
        if(head>tail)
            {
                ans+=call(n-1,head);

                //cout<<head<<endl;
            }
    }

    cout<<setprecision(9)<<fixed<<ans<<endl;




}



Measured memory_bytes: 84184
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int k;
  scanf("%d", &k);

  char s[101];
  scanf("%s", s);

  string str = s;

  if (str.length() <= k) {
    printf("%s\n", str.c_str());
  } else {
    string str2 = str.substr(0, k) + "...";
    printf("%s\n", str2.c_str());
  }

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


Measured memory_bytes: 3696
import java.util.*;

class Main{

    public Main(){
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();


        for(int i=A;i<=B;i++){
            if(i%K == 0){
                System.out.println("OK");
                return;
            }
        }

        System.out.println("NG");
    }

    public static void main(String[] args){
        new Main();
    }

}


Measured memory_bytes: 35636
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int n = sc.nextInt();
		int sum = 0;
		for(int i = 0; i < n; i++){
		    sum += sc.nextInt();
		}
		
		// 計算
		String result = "Yes";
		if(sum < h) result = "No";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 47764
#include <stdio.h>

int main(void)
{
    int ans = 0;
    int n, h, w;
    scanf("%d %d %d", &n, &h, &w);

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

//    printf("%d %d %d\n", n, h, w);
//    for (int i = 0; i < n; i++) {
//        printf("%d %d\n", a[i], b[i]);
//    }

    for (int i = 0; i < n; i++) {
        if (a[i] >= h && b[i] >= w) {
            ans++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
list1 = list(map(int,input().split()))
list2 = list(map(int,input().split()))
list3 = list(map(int,input().split()))
n=int(input())
b_list=list(map(int,[input() for i in range(4,n+4)]))


list_all=[list1,list2,list3]

for i in b_list:
    sub={i:'t'}
    list_all = [[sub.get(x,x) for x in inner] for inner in list_all]

if list_all[1][1]=='t':
    if list_all[0][0]=='t' and list_all[2][2]=='t':
        print('Yes')
    elif list_all[0][2]=='t' and list_all[2][0]=='t':
        print('Yes')
    elif list_all[0][1]=='t' and list_all[2][1]=='t':
        print('Yes')
    elif list_all[1][0]=='t' and list_all[1][2]=='t':
        print('Yes')

else:
    if list_all[0][0]=='t' and list_all[1][0]=='t' and list_all[2][0]=='t':
        print('Yes')
    elif list_all[0][0]=='t' and list_all[0][1]=='t' and list_all[0][2]=='t':
        print('Yes')
    elif list_all[0][2]=='t' and list_all[1][2]=='t' and list_all[2][2]=='t':
        print('Yes')
    elif list_all[2][0]=='t' and list_all[2][1]=='t' and list_all[2][2]=='t':
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 3064
fun main(args: Array<String>) {
    // 全体一括ソートは遅いはずだが，StringBuilder を使っている部分で実行速度が上がっている？？

    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    // 各県の初期ランクを定義
    var rank = IntArray(n + 1) { 1 }


    // 全ての市を year で一括並び替え
    val cities=(1..m).map {
        // map の中で複数の式を定義している
        val (p, y) = readLine()!!.split(" ").map { it.toInt() }

        // map の lambda式でのローカルリターンを定義（@map が付いていないと main でのリターンになってしまう)
        // Kotlinのラムダでreturnする : https://qiita.com/MasanoriMT/items/f5e814737479ff8d6fec
        // return が明示的に書かれているとわかりやすいが， return を書かなくても最後の式の評価結果が戻り値となる
        return@map Triple(it, p, y)
    }.sortedBy { it.third }

    val sb=StringBuilder()

    // 各市に県内で何番目かの情報を付与した後に，入力順にソート
    cities.map {
        // 同じ県内で何番目かの情報付与
        Pair(it,rank[it.second]++)
    }.sortedBy {
        // データの入力順にソート
        it.first.first
    }.forEach {
//        // 出力文字列を StringBuilder に格納
//        sb.append(it.first.second.toString().padStart(6,'0'))
//        sb.append(it.second.toString().padStart(6,'0'))
//        sb.append("\n")
        println(it.first.second.toString().padStart(6,'0') + it.second.toString().padStart(6,'0') )
    }

    // まとめて出力
//    println(sb)
    
    // 仮にStringBuilder を使わなかった場合
}


Measured memory_bytes: 130444
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main() {
	int N, K;
	cin >> N >> K;
	if (N % K == 0)cout << 0;
	else cout << 1;
}

Measured memory_bytes: 256
#include <iostream>                                                                                                               
using namespace std;                                                                                                              
                                                                                                                                  
int main(void) {                                                                                                                  
  int x, y;                                                                                                                       
  while (true) {                                                                                                                  
    cin >> x >> y;                                                                                                                
    if (x==0 && y==0) {                                                                                                           
      break;                                                                                                                      
    }                                                                                                                             
    if (x>=y) {                                                                                                                   
      swap(x,y);                                                                                                                  
    }                                                                                                                             
    cout << x << " " << y << endl;                                                                                                
  }                                                                                                                               
  return 0;                                                                                                                       
}                                                                                                                                 
                                                                                                                                  
                                     

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int q;
  cin >> q;
  vector<int> a(100010,0);
  for(int i=1;i<100010;i++){
    int y=0,j=2;
    bool u=true;
    while (true){
      if (j*j>i) break;
      if (i%j==0) y++;
      if (y==2) {u=false;break;}
      j++;
    }
    if (u) a.at(i)=a.at(i-1);
    else a.at(i)=a.at(i-1)+1;
  }
  rep(i,q){
    int t;
    cin >> t;
    cout << a.at(t) << endl;
  }
}



Measured memory_bytes: 3136
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int h[n]; for (int i = 0; i < n; i++) cin >> h[i];
    int dp[n];
    fill(dp, dp+n, 1<<30);
    dp[0] = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j <= i+k && j < n; j++)
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
import sys
stdin = sys.stdin
from itertools import accumulate, groupby
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

n = ni()
a = na()
b = list(accumulate(a))
b.sort()
ans = 0
for key, gr in groupby(b):
    m = len(list(gr))
    if int(key) == 0:
        ans += m
    ans += m * (m-1)//2
print(ans)

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

int main(){
    int antenas[5], k;
    for(int i = 0; i < 5; i ++){
        cin >> antenas[i]; 
    }
    cin >> k;
    for(int i =1;i < 5; i++){
        for(int j =0 ;j < 5; j++){
            if(antenas[i] - antenas[j] > k){
                cout << ":("<<endl;
                return 0;
            }

        }

    }
    cout << "Yay!" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 3600
// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        
        System.out.println(z+" "+x+" "+y);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define ui unsigned int
#define ull unsigned ll
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define fok(n) for(ll k=0;k<n;k++)
#pragma GCC optimize("O3", "unroll-loops")
#define fixed(); cout << fixed << setprecision(20);
#define fast(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

/*****************************************************************************/


#define graph          vector<vector<int>>
#define V              vector
typedef pair<int, int> pii;
typedef pair<ll, ll>   pll;
typedef V<int>         vi;
typedef V<ll>          vll;
typedef V<string>      vs;
typedef V<double>      vd;
typedef V<pii>         vpii;             
typedef V<pll>         vpll;             
typedef pair<int,pii>  piii;             
typedef priority_queue<pii, vector<pii>, greater<pii> > pqq;   

/*****************************************************************************/

#define mp                   make_pair
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define popb                 pop_back
#define popf                 pop_front
#define hashmap              unordered_map
#define hashset              unordered_set
#define lb                   lower_bound
#define ub                   upper_bound
#define all(a)               (a).begin(), (a).end()
#define rall(a)              (a).rbegin(), (a).rend()
#define ff                   first
#define ss                   second
#define lbpos(v,x)           (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(v,x)           (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB

/*****************************************************************************/

int32_t main(){
    bool is=false;
   ll x,y;
   cin>>x>>y;
   for(ll i=0;i<=y/2;i++)
   for(ll j=0;j<=y/4;j++)
   if((i*2+j*4)==y&&i+j==x)
   is=true;
   if(is) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
from math import sqrt
def main():
    n,d=map(int,input().split())
    xy=[]
    c=0
    for i in range(n):
        xy.append(list(map(int,input().split())))
    for i in range(n):
        if sqrt(xy[i][0]**2+xy[i][1]**2)<=d:
            c+=1
    print(c)
if __name__ == "__main__":
    main()

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	lf ans=0.0;
	rep(i, n){
		lf x; string u;
		cin >> x >> u;
		if (u=="JPY")
			ans += x;
		else
			ans += 380000.0*x;
	}
	cout << setp(8) << ans << "\n";
	return 0;
}

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

signed main() {
  int N;
  string S, T;
  cin >> N;
  cin >> S >> T;
  
  string ans = "";
  for( int i = 0; i < N; i++ ){
    ans += S.at(i);
    ans += T.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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 gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    graph G(N);
    vector<ll> city(M),ban(M);
    rep(i,M){
        cin >> city[i] >> ban[i];city[i]--;
        G[city[i]].push_back(ban[i]);
    }
    rep(i,N){
        sort(all(G[i]));
    }
    rep(i,M){
        ll ans = lower_bound(all(G[city[i]]),ban[i]) - G[city[i]].begin() + 1;
        printf("%06lld%06lld\n",city[i] + 1,ans);
    }
}

Measured memory_bytes: 10304
#include <iostream>
using namespace std;
int main(){
    int N,T;
    int m=1001;
    int c,t;
    cin>>N>>T;
    for(int i=1;i<=N;i++){
        cin>>c>>t;
        if(t<=T){m=min(m,c);}
    }
    if(m==1001){cout<<"TLE"<<endl;}
    else{cout<<m<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 1 << 12;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    while (1) {
        int h, w, e[11][11];
        cin >> h >> w;
        if (h == 0) break;
        REP(i, h) {
            REP(j, w) { cin >> e[i][j]; }
        }
        int ans = 0;
        REP(it, h) {
            FOR(ib, it + 2, h) {
                REP(jl, w) {
                    FOR(jr, jl + 2, w) {
                        int hmin = 10;
                        FOR(i, it, ib+1) hmin = min(hmin, min(e[i][jl], e[i][jr]));
                        FOR(j, jl, jr+1) hmin = min(hmin, min(e[it][j], e[ib][j]));
                        bool flag = true;
                        int p = 0;
                        FOR(i, it + 1, ib && flag) {
                            FOR(j, jl + 1, jr && flag) {
                                if (e[i][j] >= hmin) {
                                    flag = false;
                                    break;
                                }
                                p += hmin - e[i][j];
                            }
                        }
                        if (flag) ans = max(ans, p);
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
MOD=10**9+7

N,M=map(int,input().split())
slist=list(map(int,input().split()))
tlist=list(map(int,input().split()))

dp,dp_sum=[],[]
for i in range(N+1):
  dp.append([0]*(M+1))
  dp_sum.append([1]*(M+1))
dp[0][0]=1
#print(dp)

for i in range(1,N+1):
  for j in range(1,M+1):
    if slist[i-1]==tlist[j-1]:
      dp[i][j]=dp_sum[i-1][j-1]      
    dp_sum[i][j]=(dp[i][j]+dp_sum[i-1][j]+dp_sum[i][j-1]-dp_sum[i-1][j-1])%MOD
#print(dp)
#print(dp_sum)

print(dp_sum[-1][-1])

Measured memory_bytes: 103900
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  int n;
  int L[201];
  int tmp, ans = 0;

  scanf("%d", &n);

  for(int i = 0; i < (n*2); i++){
    scanf("%d", &L[i]);
  }

   /* 数値を降順にソート */
  for (int i=0; i< n*2; i++) {
    for (int j=i; j<n*2; j++) {
      if (L[i] > L[j]) {
        tmp =  L[i];
        L[i] = L[j];
        L[j] = tmp;
      }
    }
  }

  for(int i = 0; i < n; i++){
    ans += L[i*2];
  }

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

  return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	fmt.Println(logic(a))
}

func logic(nums []int) float64 {
	a := 0.0
	for _, num := range nums {
		a += 1.0 / float64(num)
	}

	return 1.0 / a
}

Measured memory_bytes: 512
def diff_a(c)
  "z".ord + 1 - c.ord
end

s = gets.chomp
k = gets.to_i
n = s.size
res = ""
s.each_char.with_index do |c, i|
  if c == "a" && i != n - 1
    res << "a"
    next
  end
  d = diff_a(c)
  if i == n - 1
    res << (97 + ((c.ord - 97) + k) % 26).chr
  elsif k >= d
    k -= d
    res << "a"
  else
    res << c
    next
  end
end
puts res


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

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

    ll n, m;
    cin >> n >> m;
    if (2 * n >= m){
        ll res = m / 2;
        cout << res << endl;
    } else {
        ll res = n;
        m -= 2 * n;
        res += m / 4;
        cout << res << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 2005;

struct ball{
    string color;
    int number;
};

signed main(){
    int n;
    cin >> n;
    ball B[2 * n];
    int black_iti[n_max];
    int white_iti[n_max];
    REP(i,2 * n){
        cin >>B[i].color  >> B[i].number;
        if(B[i].color == "B") black_iti[B[i].number] = i;
        else white_iti[B[i].number] = i;
    }
    int black[n_max][n_max];
    FOR(i,1,n+1){
        int tmp_iti = black_iti[i];
        int black_num = 0;
        FOR(j,i+1,n+1) if(black_iti[j] < tmp_iti) black_num ++;
        black[i][n+1] = black_num;
        REPR(j,n){
            if(j == 0) break;
            if(white_iti[j] < tmp_iti){
                black[i][j] = black[i][j+1] + 1;
            }
            else{
                black[i][j] = black[i][j + 1];
            }
        }
    }

    int white[n_max][n_max];
    FOR(i,1,n+1){
        int tmp_iti = white_iti[i];
        int white_num = 0;
        FOR(j,i+1,n+1) if(white_iti[j] < tmp_iti) white_num ++;
        white[i][n+1] = white_num;
        REPR(j,n){
            if(j == 0) break;
            if(black_iti[j] < tmp_iti){
                white[i][j] = white[i][j+1] + 1;
            }
            else{
                white[i][j] = white[i][j + 1];
            }
        }
    }

    int dp[2 * n_max][n_max];
    dp[0][0] = 0;
    FOR(i,1,2*n+1) dp[0][i] = 0;
    REP(i,2 * n){
        REP(k,i+2){
            if(k>n) break;
            if(k <= i) dp[i+1][k] = dp[i][k] + white[i-k + 1][k+1];
            else dp[i+1][k] = INF;
            if(k >= 1){
                chmin(dp[i+1][k],dp[i][k-1] + black[k][i-k+2]);
            }
        }
    }
    cout << dp[2 * n][n] << endl;





}

Measured memory_bytes: 126080
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define eps 0.000000001
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	int x;cin>>x;
	if(x==1) puts("0");
	else puts("1");
}


Measured memory_bytes: 3636
// Example program

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

int main() {
   int n;
   cin >> n;
   vector<int> arr(n);
   for(int i = 0; i < n; i++) cin >> arr[i];
   int cnt = 0;
   while(true) {
       bool quit = false;
        for(int i = 0; i < n; i++) if(arr[i]%2 != 0) {
            quit = true;    
        }   
        if(quit) break;
        cnt++;
        for(int i = 0; i < n; i++) arr[i] /= 2;
   }
   cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 10000

int distinguish( int );

int main(){
    int array[N], num , cnt = 0, i;

    //input number of data and data
    scanf("%d", &num);
    for (i = 0; i<num; i++)
	scanf("%d", &array[i]);
    
    //distinguish whether array[i] is prime number
    for (i = 0; i<num; i++)
	if (distinguish(array[i]) == 1)
	    cnt++;
	
    
    //display the result
    printf("%d\n", cnt);

    return 0;
}

int distinguish( int x ){
    int i;

    //check whether x is odd
    if ( x == 2 ) return 1;
    else if ( x <= 1 )	return 0; 
    else if ((x % 2) == 0) return 0;
    
    
    for (i = 3; i <= (int)sqrt(x); i+=2)
	if ((x % i) == 0)
	    return 0;
    
    return 1;
}


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

int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> data(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int count = 0, sum;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      sum = 0;
      for (int k = 0; k < d; k++) {
        sum += (data.at(i).at(k) - data.at(j).at(k))*(data.at(i).at(k) - data.at(j).at(k));
      }
      for (int k = 0; k <= sum; k++) {
        if( k*k == sum ) count++;
      }
    }
  }
  cout << count;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n;
	cin>>n;
	ll res=2LL*(n/11LL);
	n%=11LL;
	if(n){
		if(n<=6) res++;
		else res+=2;
	}
	cout<<res<<'\n';
}



Measured memory_bytes: 3600
year = int(input())
i = year
lst = []
j=0
while j < 4:
    if(i%10==0):
        lst.append(0)
    else:
        lst.append(i%10)
    i //= 10 # 必須
    j+=1

a=lst[3]*10
b=lst[1]*10
c=a+lst[2]
d=b+lst[0]
if(c==0 and d==0):
    print("NA")
elif(c>0 and c<13 and d==0):
    print("MMYY")
elif(c==0 and d>0 and d<13):
    print("YYMM")
elif(c>0 and c<13 and d>0 and d<13):
    print("AMBIGUOUS")
elif(c>0 and c<13 and d>12):
    print("MMYY")
elif(c>12 and d>0 and d<13):
    print("YYMM")
elif(c>12 and d>12):
    print("NA")
elif(c>12 and d==0):
    print("NA")
elif(c==0 and d>12):
    print("NA")
else:
    print("NA")

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kMax9 = 1000000010;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, int n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

double dist(double lhs, double rhs) {
  return sqrt(lhs * lhs + rhs * rhs);
}

int main() {
  long n, m, k, t;
  string s;
  ll ans = 0;
  vector<long> a, b;

  cin >> s;
  rep(i, 0, (s.size() + 1) / 2 - 1) {
    if (s[i] != s[s.size() - 1 - i]) { ++ans; }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//In the name of God

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 1e5 + 5;

void solve() {
	int k;
	cin >> k;
	int i = 0;
	int r = 0;
	int c = 0;
	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1;
		return;
	}
	while (true) {
		r = (10*r + 7)%k;
		if (r == 0) {
			cout << i + 1;
			return;
		}
		i++;
	}
}

int main() {
	ios_base::sync_with_stdio(false);	
    cin.tie(NULL);
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case " <<;
		solve();
		// cout << chk(2);
	}
}

Measured memory_bytes: 3648
K = int(input())

from collections import deque
d = deque()
for i in range(1,10):
  d.append(str(i))

for _ in range(K):
  a = d.popleft()
  #print(a)
  if a[-1] != '0':
    d.append(a+str(int(a[-1])-1))
  d.append(a+a[-1])
  if a[-1] != '9':
    d.append(a+str(int(a[-1])+1))

ans = a
print(ans)
#print(*ans,sep=' ')


Measured memory_bytes: 88004
#include<bits/stdc++.h>
using namespace std;
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define ll long long
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.length();i++){
        int an=1;
        for(int j=0;j<a.length();j++){
            if(a[(i+j)%a.length()]!=b[j]){
                an=0;
                break;
            }
        }
        if(an){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define rep(n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define max(a,b) (a>b)? a:b
#define min(a,b) (a<b)? a:b

#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(0)
const int mod=1e9+7;
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}

int main()
{
   int n;cin>>n;int a[n],sum=0;rep(n){cin>>a[i];sum+=a[i];}
   int aa=sum/n;
   if(sum%n)
   {
       sum=sum/n+1;
   }
   else
   sum/=n;
   int ans=0,ans1=0;
   rep(n)
   {
       ans+=pow(a[i]-sum,2);
       ans1+=pow(a[i]-aa,2);
   }
   cout<<(min(ans,ans1))<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    int N;
    cin>>N;
    set<string> ans;
    string tmp;
    for(int i=0;i<N;++i){
        cin>>tmp;
        ans.insert(tmp);
    }
    cout<<ans.size()<<endl;
}



Measured memory_bytes: 19216
b = [0.5,0.25,0.125,0.0625]
list = []
(1..4).each do |i|
  b.combination(i) do |arr|
    list << arr.inject{|sum,x| sum+x}
  end
end
num = ["1000","0100","0010","0001","1100","1010","1001","0110","0101","0011","1110","1101","1011","0111","1111"]

hash=Hash.new
list.each_index do |i|
  hash[list[i]]=num[i]
end
hash[0]="0000"
loop do
  n=gets.chomp
  next if n==""
  n = n.to_f
  break if n <0
  a = n.floor
  b = n-a
  a=a.to_i.to_s(2)
  if a.size >8
    puts "NA"
    next
  end
  a = "%08d" % a.to_i

  b=0if b>-0.0000000000001 && b<0.0000000000001
  unless hash[b]
    puts "NA"
    next
  end
  puts a+"."+hash[b]
end

Measured memory_bytes: 2560
n=int(input())
m=int(n**(1/2))

F=[]
n1=n
k=2

while k<=m:
    if n%k==0:
        F.append([k,1])
        n//=k
        #print(n)
        while n%k==0:
            F[-1][1]+=1
            n//=k
    k+=1

if n>m:
    F.append([n,1])
product=1
l=len(F)
for i in range(l):
    product=product*((F[i][0]**(F[i][1]-1))*(F[i][0]-1))
print(product)



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
typedef long long lint;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;

class SegmentTree {
private:
	int size__;
	Vec< pii > data;
	
	inline int left_t(int k) { return (k << 1) + 1; }
	inline int right_t(int k) { return (k << 1) + 2; }
	inline int center(int l, int r) { return (l + r) >> 1; }
	
	pii calc(pii d1, pii d2) { return min(d1, d2); }
	
	pii query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return pii(1e9, 1e9);
		if (a <= l && r <= b) return data[k];
		return calc(query(a, b, left_t(k), l, center(l, r)),
					query(a, b, right_t(k), center(l, r), r));
	}
	
public:
	SegmentTree() {}
	
	SegmentTree(int n) {
		for (size__ = 1; size__ < n; size__ <<= 1);
		data.assign(2 * size__ - 1, pii(1e9, 1e9));
	}
	
	void update(int k, pii a) {
		k += size__ - 1;
		data[k] = a;
		
		while (k > 0) {
			k = (k - 1) >> 1;
			data[k] = calc(data[left_t(k)], data[right_t(k)]);
		}
	}
	
	pii query(int a, int b) { return query(a, b, 0, 0, size__); }
};

int N;
SegmentTree seg[2];

Vec< pii > piece;
Vec< int > nxt[100010];
map< pii, int > piece_to_id;

void divide(int l, int r, int par) {
	if (l >= r) return;
	
	pii a = seg[l % 2].query(l, r-1);
	pii b = seg[(l + 1) % 2].query(a.second+1, r);
	
	if (par != -1) nxt[par].push_back(piece.size());
	piece_to_id[pii(a.first, b.first)] = piece.size();
	piece.push_back(pii(a.first, b.first));
	
	int cur = piece.size() - 1;
	if (l < a.second) divide(l, a.second, cur);
	divide(a.second + 1, b.second, cur);
	if (b.second + 1 < r) divide(b.second + 1, r, cur);
}

int main() {
	cin >> N;
	
	for_(i,0,2) seg[i] = SegmentTree(N);
	
	for_(i,0,N) {
		int p; cin >> p;
		seg[i % 2].update(i, pii(p, i));
	}
	
	divide(0, N, -1);
	
	Vec< int > ans;
	priority_queue< pii, Vec< pii >, greater< pii > > que;
	que.push(piece[0]);
	
	while (!que.empty()) {
		pii p = que.top(); que.pop();
		ans.push_back(p.first);
		ans.push_back(p.second);
		
		int id = piece_to_id[p];
		for (int i : nxt[id]) que.push(piece[i]);
	}
	
	for_(i,0,N) cout << ans[i] << (i < N - 1 ? " " : "\n");
}

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

int main() {
  	char c;
  cin >> c;
  if ('A' == c) cout << 'T';
  else if ('C' == c) cout << 'G';
  else if ('G' == c) cout << 'C';
  else cout << 'A';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Y cout << "Yes\n"
#define N cout << "No\n"
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define R(i, n) for (int i = 0; i < n; i++)
#define RE(i, a, b) for (int i = a; i >= b; i--)

int main()
{
		int a , b ;
		cin >> a >> b ;
		if(b%2 == 0 && ( b >= 2*a && b <= 4*a) )
		{
			Y;
		}
		else
		{
			N ;
		}
}


Measured memory_bytes: 3632
N = int(input())
X = [int(x) for x in input().split()]

l = min(X)
r = max(X)
ans = 100000000000
for i in range(l, r+1):
    now = 0
    for j in range(N):
        now += (X[j]-i)*(X[j]-i)
    ans = min(now, ans)
print(ans)

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

#define MAXN 3010
#define ll long long
#define mod 998244353

using namespace std;

ll n, tot, ans, s;

ll a[MAXN], f[MAXN]; 

int main() {
	int t;
	scanf("%lld%lld", &n, &s);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = s; j > a[i]; j--) {
			f[j] = (f[j] + f[j - a[i]]) % mod;
		}
		f[a[i]] = (f[a[i]] + i) % mod;
		ans = (ans + (n - i + 1) * f[s] % mod) % mod;
		f[s] = 0;
	}
	cout << (ll)ans << endl;
	return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(void){
    int n,p,sum1=0;
    cin>>n>>p;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]%=2;
        if(a[i]==1)sum1++;
    }
    int sum0=n-sum1;
    long long ans;
    if(p==1&&sum1==0)ans=0;
    else if(sum1==0)ans=pow(2,sum0);
    else ans=pow(2,sum0)*pow(2,sum1-1);
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
const int N = 2000006;

int par[N];
int sz[N];

int n;

int root(int x){
	while(par[x] != x){
		par[x] = par[par[x]];
		x = par[x];
	}
	return x;
}

void onion(int x, int y){
	//cout<<x<<" "<<y<<" with roots ";
	x = root(x);
	y = root(y);
	//cout<<x<<" "<<y<<endl;
	if(x == y)return ;
	if(sz[x] < sz[y]){
		par[x] = y;
		sz[y] += sz[x];
	}
	else{
		par[y] = x;
		sz[x] += sz[y];
	}
}

vector<int> v[N];
int vstd[N];

bool vstdroots[N];

vector<int> roots;
ll cntrts[N];
set<int> rts[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=100000;i++){
		par[i] = i;
		sz[i] = 1;
	}
	
	int mn = 1000000;
	int mx = 0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		mn = min(mn,x);
		mx = max(mx,x);
	}
	
	for(int i=mn;i<=mx;i++){
		for(int x:v[i]){
			if(vstd[x]){
				onion(i,vstd[x]);
				//cout<<"unioning "<<i<<" with "<<vstd[x]<<endl;
			}else{
				vstd[x] = i;
			}
		}
	}
	/*
	for(int i=1;i<=5;i++){
		cout<<i<<" : "<<root(i)<<endl;
	}
	*/
	for(int i=mn;i<=mx;i++){
		int r = root(i);
		//cout<<i<<" "<<r<<endl;
		if(!vstdroots[r]){
			vstdroots[r] = true;
			roots.push_back(r);
		}
		cntrts[r]++;
		for(int x:v[i]){
			rts[r].insert(x);
		}
	}
	ll ans = 0;
	for(int r:roots){
		//cout<<r<<" "<<cntrts[r]<<" "<<rts[r].size()<<endl;
		ans += cntrts[r] * 1ll * rts[r].size();
	}
	
	cout<<ans-n;
	
	return 0;
}


Measured memory_bytes: 150180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
    int n,m;
    cin>>n>>m;
    vector<bool> issafe;
    issafe.assign(n+1,true);
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        issafe[a]=false;
    }
    vector<int> dp(n+1,0);
    dp[0]=1;
    if(issafe[1]) dp[1]=1;
    
    for(int i=2;i<=n;i++){
        if(issafe[i-1]) dp[i]+=dp[i-1];
        if(issafe[i-2]) dp[i]+=dp[i-2];
        dp[i]%=MOD;
    }
    cout<<dp[n]<<endl;
}

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

int main() {
 int n,k ; 
 cin>>n>>k; int a ;
 vector<int> inp ; 
 for(int i = 0 ; i<n ; i++){
    cin>>a ;
    inp.push_back(a);
 }
 vector<int> ans(n,-1) ; int m1,m2 ;
 ans[0] = 0 ; ans[1] = abs(inp[1] - inp[0]) ;
 for(int i = 2 ; i<n;i++){
    //  m1 = ans[i-2] + abs(inp[i] - inp[i-2]) ;
    //  m2 = ans[i-1] + abs(inp[i] - inp[i-1]) ;
    vector<int> m ;
    for(int j = 1 ; j<=k ; j++){
        if(i-j>=0){
        m1 = ans[i-j] + abs(inp[i] - inp[i-j]) ;
        m.push_back(m1); 
        }
    }
     ans[i] = *min_element(m.begin(),m.end()) ;
 }
 cout<<ans[n-1] ;   
    
}

Measured memory_bytes: 4028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		try {
			while (input.ready()) {
				int num = Integer.valueOf(input.readLine());
				int ans = 0;
				for (int i = 0; i < 10; i++) {
					if(i > num) break;
					for (int j = 0; j < 10; j++) {
						if(j > num) break;
						for (int k = 0; k < 10; k++) {
							if(k > num) break;
							for (int l = 0; l < 10; l++) {
								if(l > num) break;
								if (i + j + k + l == num) {
									ans += 1;
								}
							}
						}
					}
				}
				System.out.println(ans);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 24896
from collections import defaultdict

N = int(input())
X, Y = [], []
for i in range(N):
    x, y = list(map(int, input().split()))
    X.append(x)
    Y.append(y)

diffs = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        diffs[(X[i]-X[j], Y[i]-Y[j])] += 1

maxans = -1
maxkey = 0
for k, v in diffs.items():
    if v > maxans:
        maxans = v
        maxkey = k

if N == 1:
    print(1)
else:
    print(N-maxans)



Measured memory_bytes: 3828