akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::vector<int> v(10);
while (std::cin >> x>>y,x) {
for(int i=0;i<x;i++){
  y+=num[i];
}
y%=7;
if(y==4)std::cout << "Sunday" << '\n';
else if(y==5)std::cout << "Monday" << '\n';
else if(y==6)std::cout << "Tuesday" << '\n';
else if(y==0)std::cout << "Wednesday" << '\n';
else if(y==1)std::cout << "Thursday" << '\n';
else if(y==2)std::cout << "Friday" << '\n';
else if (y==3) {std::cout << "Saturday" << '\n';
  /* code */
}
}
}



Measured memory_bytes: 3072
#include <stdio.h>
#include <vector>
#include <utility>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;

vector<pair<int, int> > v[8];

bool match(const vector<pair<int, int> >& v, const vector<pair<int, int> >& p) {
	if(v.size()!=p.size()-1) return false;
	rep(i, v.size()) {
		if(v[i].first!=p[i+1].first-p[i].first
				|| v[i].second!=p[i+1].second-p[i].second)
			return false;
	}
	return true;
}

int main() {
	for(;;) {
		int n;
		scanf("%d", &n);
		if(n==0) return 0;
		vector<pair<int, int> > o;
		rep(i, 8) v[i].clear();
		int m;
		scanf("%d", &m);
		rep(i, m) {
			int x, y;
			scanf("%d%d", &x, &y);
			o.push_back(make_pair(x, y));
		}
		rep(i, m) if(i!=0) {
			int x = o[i].first-o[i-1].first;
			int y = o[i].second-o[i-1].second;
			v[0].push_back(make_pair(x, y));
			v[1].push_back(make_pair(y, -x));
			v[2].push_back(make_pair(-x, -y));
			v[3].push_back(make_pair(-y, x));
			int rx = o[m-i-1].first-o[m-i].first;
			int ry = o[m-i-1].second-o[m-i].second;
			v[4].push_back(make_pair(rx, ry));
			v[5].push_back(make_pair(ry, -rx));
			v[6].push_back(make_pair(-rx, -ry));
			v[7].push_back(make_pair(-ry, rx));
		}
		rep(i, n) {
			vector<pair<int, int> > p;
			int m;
			scanf("%d", &m);
			rep(j, m) {
				int x, y;
				scanf("%d%d", &x, &y);
				p.push_back(make_pair(x, y));
			}
			rep(d, 8) {
				if(match(v[d], p)) {
					printf("%d\n", i+1);
					break;
				}
			}
		}
		printf("+++++\n");
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{string s;
 cin>>s;
 cout<<"2018"<<s.substr(4,s.size()-4);
 system("pause");
 return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main(){
    int h,w,i,j;
    char c[100][100];
    int flag[100],ic[100];

    for(i=0;i<100;i++){
        flag[i] = 1;
        ic[i] = 1;
    }

    scanf("%d",&h);
    scanf("%d",&w);

    for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
            scanf(" %c",&c[i][j]);
            if(c[i][j] == '#'){
                ic[i] = 0;
            }
        }
    }

    for(j = 0;j<w;j++){
        for(i=0;i<h;i++){
            if(c[i][j] == '#'){
                flag[j] = 0;
            }
        }
    }

    for(i=0;i<h;i++){
        if(ic[i] == 0){
            for(j=0;j<w;j++){
                if(flag[j] == 0)
                    printf("%c",c[i][j]);
            }
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MAX=550000;
ll fanc[MAX],inv[MAX],finv[MAX];
void COMinit(){
  fanc[0]=fanc[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fanc[i]=fanc[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
int COM(int a,int b){
  if(a<b)return 0;
  if(a<0||b<0)return 0;
  return (fanc[a]*finv[a-b]%MOD)*finv[b]%MOD;
}
ll Repeat(int N,int M,int P){
  if(M==0)return 1;
  if(M%2==0){
    ll t=Repeat(N,M/2,P);
    return t*t%MOD;
  }
  return Repeat(N,M-1,P)*N;
}

int main(){
 COMinit();
 ll N,a,b;
 cin>>N>>a>>b;
ll all=Repeat(2,N,MOD);
ll v1=1;
ll v2=1;
for(ll i=N;i>=N-a+1;i--){
  v1=v1*i;
  v1%=MOD;
}
for(ll i=N;i>=N-b+1;i--){
  v2=v2*i;
  v2%=MOD;
}
ll nCa=v1*finv[a]%MOD;
ll nCb=v2*finv[b]%MOD;
//cout<<<<endl;
//cout<<v2<<endl;
ll ans=all-1-nCa-nCb;
while(ans<0){
  ans+=MOD;
}
ans%=MOD;
cout<<ans<<endl;
}

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

int main(){
	double a,b,x; cin>>a>>b>>x;
	double s=x/a;
	cout<<setprecision(10)<<fixed<<atan(s<a*b/2?b/(s/b*2):(b-s/a)*2/a)*180/M_PI<<"\n";
	return 0;
}

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

int main(){ 
     int a,b,c;
     cin >>a>>b>>c;
     if(a>=b&&a>=c){
         cout << b+c <<endl;
     }else if(b>=a&&b>=c){
         cout<<a+c<<endl;
     }else{
         cout<<a+b<<endl;
     }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    int size = S.size();
    int count = 0;
    vector<int> A(size, 0);
    rep(i, 1, size)
    {
        if ((S.at(i - 1) == 'A') && (S.at(i) == 'C'))
        {
            count++;
            A.at(i) = count;
        }
        else
        {
            A.at(i) = count;
        }
    }
    vector<int> ans(Q);
    rep(i, 0, Q)
    {
        int l, r;
        cin >> l >> r;
        ans.at(i) = A.at(r - 1) - A.at(l - 1);
    }
    rep(i, 0, Q)
    {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 1792
import Control.Applicative
main = do
  v <- takeWhile (\x-> x/= [0,0]) . map (map (read::String->Int) . words) . lines <$> getContents
  mapM_ (putStrLn . show . solve) v

solve::[Int] -> Int 
solve (n:m:_) = joseph m 1 [1..n]

joseph:: Int -> Int -> [Int] -> Int
joseph m p xs
  | length xs==1 = head xs
  | otherwise = joseph m pNext xsNext
  where
     hit = last . take m . dropWhile (/= p)  $ cycle xs
     xsNext = filter (/= hit) xs
     pNext = head . tail . dropWhile (/= hit)  $ cycle xs

Measured memory_bytes: 3972
s = input()

y = int(s[:2])
m = int(s[2:])
if 1 <= y <= 12 and 1 <= m <= 12:
    print("AMBIGUOUS")
elif 1 <= y <= 12:
    print("MMYY")
elif 1 <= m <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile("\\s");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 180292
#include <algorithm>
#include <iostream>
#include <vector>

std::vector<int> to_vec(int n) {
  std::vector<int> v;
  for (int i = 0; i < 5; ++i) {
    v.push_back(n % 10);
    n /= 10;
  }
  std::reverse(v.begin(), v.end());
  return v;
}

int checkdigit(int table[10][10], const std::vector<int> &v) {
  int a = 0;
  for (int i = 0; i < 4; ++i) {
    a = table[a][v[i]];
  }
  return a;
}

bool is_valid(int table[10][10], const std::vector<int> &v) {
  int a = 0;
  for (int i = 0; i < 5; ++i) {
    a = table[a][v[i]];
  }
  return a == 0;
}

int main() {
  int table[10][10];
  int num = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      std::cin >> table[i][j];
    }
  }
  for (int n = 0; n < 10000; ++n) {
    std::vector<int> v = to_vec(10 * n);
    v.back() = checkdigit(table, v);
    for (int i = 0; i < 5; ++i) {
      int x = v[i];
      for (int d = 0; d < 10; ++d) {
        if (d == x) continue;
        v[i] = d;
        if (is_valid(table, v)) goto fail;
      }
      v[i] = x;
    }
    for (int i = 0; i < 4; ++i) {
      if (v[i] == v[i + 1]) continue;
      std::swap(v[i], v[i + 1]);
      if (is_valid(table, v)) goto  fail;
      std::swap(v[i], v[i + 1]);
    }
    continue;
fail:
    ++num;
  }
  std::cout << num << std::endl;
  return 0;
}

Measured memory_bytes: 3136
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


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

	long long n, k;
	cin >> n >> k;

	vector<int>a(n + 1);

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	vector<int>b(n + 2);

	vector<int>visited(n + 1);
	b[0] = 1;
	int next = a[1];

	visited[next] = 1;
	b[1] = next;
	next = a[next];

	for (int i = 2; i <= n + 1; i++) {

		if (!visited[next]) {
			visited[next] = i;
		}
		b[i] = next;

		next = a[next];

	}



	int pos = visited[b[n]];

	vector<int>c;

	for (int i = pos; i < n; i++) {
		c.push_back(b[i]);
	}



	int cycle = c.size();

	if (k <= n) {
		cout << b[k] << endl;
		return 0;
	}

	k -= n;

	int rem = (k) % cycle;

	cout << c[rem] << endl;


}


Measured memory_bytes: 6588
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
int judge(int i){
    for(int j = 2;j*j <= i;j++){
        if(i % j == 0){
            return 0;
        }
    }
    return 1;
}
main(){
    vector<int> isPrime(100001);
    vector<int> accu(100001);
    for(int i = 3;i <= 100000;i+=2){
        isPrime[i] = (judge(i) & judge((i+1)/2));
    }
    for(int i = 1;i <= 100000;i++){
        accu[i] = accu[i-1] + isPrime[i];
    }
    int Q;
    cin >> Q;
    for(int i = 0;i < Q;i++){
        int l,r;
        cin >> l >> r;
        cout << accu[r] - accu[l-1] << endl;
    }
}

Measured memory_bytes: 1408
#include <stdio.h>

int gcd(int a, int b) {
  while (b != 0) {
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int gcd3(int a, int b, int c) {
  return gcd(gcd(a, b), c);
}

int main(void) {
  int input;
  int sum = 0;
  scanf("%d", &input);
  for(int i = 1; i <= input; i++) {
    for(int j = 1; j <= input; j++) {
      for(int k = 1; k <= input; k++) {
        sum += gcd3(i, j, k);
      }
    }
  }
  printf("%d\n", sum);
  
  return 0;
}

Measured memory_bytes: 1704
#include<iostream>
#include<cstdio>
using namespace std;
int a[11][11],n,m,p[11];
bool check(int sta){
	for(int i=1;i<=m;i++){
		int cnt=0;
		for(int j=1;j<=a[i][0];j++){
			if(sta&(1<<(a[i][j]-1))){
				cnt++;
			}
		}
		if(cnt%2!=p[i])return 0;
	}
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&a[i][0]);
		for(int j=1;j<=a[i][0];j++)
			scanf("%d",&a[i][j]);
	}
	for(int i=1;i<=m;i++)
		scanf("%d",&p[i]);
	int sum=(1<<n)-1,ans=0;
	for(int sta=0;sta<=sum;sta++){
		if(check(sta))ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		int D = sc.nextInt();
		int amari = N % (1 + 2 * D);
		int syou = N / (1 + 2 * D);
		if (amari != 0) {
			syou++;
		}
		System.out.println(syou);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21204
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in [0]*10]
A = [list(map(int,input().split())) for _ in [0]*H]

def Warshall_Floyd(d,N=None):
    if N==None : N = len(d)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])

Warshall_Floyd(C,10)
ans = sum(C[b][1] for a in A for b in a if b!= -1)

print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}

int main(void) {
	int m, d, m2, d2;
	cin >> m >> d >> m2 >> d2;
	if (m == 1 && d==31)m2 = 13;
	if (m < m2)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

a, b = Is()
if str(a)*b > str(b)*a:
    print(str(b)*a)
else:
    print(str(a)*b)

Measured memory_bytes: 64748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

ll d[16][16],dp[(1<<16)][16];
ll n,e;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	FOR(i,0,(1<<16))FOR(j,0,16)dp[i][j]=INF;
	FOR(i,0,16)FOR(j,0,16)d[i][j]=INF;
	cin>>n>>e;
	dp[(1<<n)-1][0]=0;
	FOR(i,0,e){
		ll x,y,c;
		cin>>x>>y>>c;
		d[x][y] = c;
	}
	FORR(S,0,(1<<n)-1){
		FOR(v,0,n){
			FOR(u,0,n){
				if( !(S >> u & 1))
					dp[S][v] = min(dp[S][v],dp[S | 1<<u][u] + d[v][u]);
			}
		}
	}
	cout << (dp[0][0]==INF ? -1 : dp[0][0]) <<endl;
}


Measured memory_bytes: 11336
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
d=sorted(l)
x=d[-2]
m=max(l)
for i in range(n):
    if(l[i]==m):
        l[i]=x
    else:
        l[i]=m
for i in l:
    print(i)


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

using namespace std;

int main(void) {
    int N;
    string S;
    int K;
    cin >> N >> S >> K;
    char ref = S[K-1];
    for(int i = 0; i < N; i++) {
        if(S[i] != ref) {
            S[i] = '*';
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const double BTC = 380000;
    int N; cin >> N;
    double ans = 0;
    REP(i,N) {
        double x; cin >> x;
        string u; cin >> u;
        if (u == "JPY") ans += x;
        else ans += x * BTC;
    }

    cout << fixed << setprecision(10) << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
N = int(input())
LLL = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            a, b, c = LLL[i], LLL[j], LLL[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                ans += 1
print(ans)


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

int main()
{
	string X, Y;
	int x, y;
	cin >> X>>Y;

	if (X == "A")
		x = 10;
	else if (X == "B")
		x = 11;
	else if (X == "C")
		x = 12;
	else if (X == "D")
		x = 13;
	else if (X == "E")
		x = 14;
	else if (X == "F")
		x = 15;

	if (Y == "A")
		y = 10;
	else if (Y == "B")
		y = 11;
	else if (Y == "C")
		y = 12;
	else if (Y == "D")
		y = 13;
	else if (Y == "E")
		y = 14;
	else if (Y == "F")
		y = 15;

	if (x > y)cout << ">" << endl;
	else if (x < y)cout << "<" << endl;
	else cout << "=" << endl;

	return 0;

}

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

using namespace std;
typedef long long ll;

int main(void)
{
    int n, k;
    cin >> n >> k;
    if(n<=k){
        cout << 0 << endl;
        return 0;
    }
    ll sum = 0;
    vector<ll> h(n);
    for (int i = 0; i < n;i++){
        cin >> h.at(i);
        sum += h.at(i);
    }
    if(k==0){
        cout << sum << endl;
        return 0;
    }

    sort(h.begin(), h.end(), greater<int>());
    ll cnt = 0;
    for (int i = k; i < n;i++){
        cnt += h.at(i);
    }
    cout << cnt << endl;

    return 0;
}

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

int main() {
    while (true) {
        string number;
        cin >> number;

        if (number == "0") {
            break;
        }

        int sum = 0;
        for (int i = 0; i < number.size(); i++) {
            sum += number[i] - '0';
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string s,t;cin>>s>>t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){

   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   sort(a,a+n);
   int x=0;

   for(int j=0;j<n-1;j++){
       if(a[j]==a[j+1]) x=1;
   }
   if(x==1) cout<<"NO"<<endl;
   else cout<<"YES"<<endl;

return 0;
}

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


int main() {
  long long  N , A ,B ; 
  cin >> N >> A >> B ; 
  
  long long  i = N % (A+B);
  long long  j = N/(A+B) ; 
  
  
  if(i  <= A ){
    j = j*A  + i ; 
  }
  else {
    j = j*A + A ; 
  }
    
    cout << j << endl ; 
  
  
  
}


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

int main(){
    int a, b, r=0;
    string num;
    cin >> a >> b;
    for(int i=a;i<=b;i++){
        num = to_string(i);
        if(num[0] == num[4] && num[1] == num[3])
            r++;
    }
    cout << r << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>

#define MAX_N 100
#define MAX_K 100

using namespace std;

int main() {

    int N, K;
    int d[MAX_N];
    int A[MAX_N];

    set <int> a;

    int i, j;

    int answer;

    scanf("%d %d", &N, &K);
    //printf("N = %d, K = %d\n", N, K);

    for (i = 0; i < K; i++) {
        scanf("%d", &d[i]);
        //printf("d[%d] = %d\n", i, d[i]);
        for (j = 0; j < d[i]; j++) {
        scanf("%d", &A[j]);
        a.insert(A[j]);
        //printf("A[%d] = %d\n", j, A[j]);
        }
    }

    answer = N - a.size();

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

    return 0;

}

Measured memory_bytes: 3236
x, y = map(int, input().split())
grid = []
visit = []
mod = 1000000007
for _ in range(x):
    grid.append([i for i in input()])
    visit.append([0 for i in range(y)])
grid[x-1][y-1] = 'X'
visit[x-1][y-1] = 1
for i in range(x-1, -1, -1):
    for j in range(y-1, -1, -1):
        if grid[i][j] == '.':
            if i < x-1 and j < y-1:
                visit[i][j] = (visit[i][j+1] + visit[i+1][j])%mod
            elif i < x-1 and j == y-1:
                visit[i][j] = visit[i+1][j]
            else:
                visit[i][j] = visit[i][j+1]
print(visit[0][0])
        
            


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  double n, m, d;
  cin >> n >> m >> d;
  if (d == 0) {
    printf("%.10lf\n", (1 / n) * (m - 1));
  } else {
    printf("%.10lf\n", 2 * (n - d) * (m - 1) / (n * n));
  }
}


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

int main() {
    int n; cin >> n;
    int x; cin >> x;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    int sum = accumulate(begin(a), end(a), 0);
    int mi = *min_element(begin(a), end(a));
    cout << n + (x - sum) / mi << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

MOD = 10**9 + 7

def modFact(x):
  if x < 1:
    raise ValueError
  res = 1
  for i in range(x):
    res = res * (i+1) % MOD
  return res

# @njit
def solve(n,m):
  if abs(n-m) > 1:
    return 0
  elif abs(n-m) == 1:
    return modFact(n) * modFact(m) % MOD
  else:
    return modFact(n) * modFact(m) * 2 % MOD


def main():
  N,M = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(N,M))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n, t;
    scanf("%d%d", &n, &t);
    int sum[t+1];
    rep(i, t+1) sum[i] = 0;
    rep(i, n){
        int l, r;
        scanf("%d%d", &l, &r);
        ++sum[l];
        --sum[r];
    }
    int ans = 0;
    rep(i, t+1){
        sum[i+1] += sum[i];
        ans = max(ans, sum[i]);
    }
    printf("%d\n", ans);
}


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

int main() {
  int X; int A; int B;
  cin>>X>>A>>B;
  if(A>=B)
    cout<<"delicious"<<endl;
  else if(B-A<=X)
    cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 256
s=input().split()
n,m=int(s[0]),int(s[1])
l=[[] for i in range(100001)]
d=[{} for i in range(100001)]
inp=[]
for i in range(m):
    s=input().split()
    p,y=int(s[0]),int(s[1])
    inp.append((p,y))
    l[p].append(y)
for i in range(100001):
    l[i].sort()
for i in range(100001):
    cnt=1
    for j in l[i]:
        d[i][j]=cnt
        cnt+=1
for pa in inp:
    print(str(pa[0]).zfill(6)+str(d[pa[0]][pa[1]]).zfill(6))

Measured memory_bytes: 95408
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, ans=1, M=1e9+7, c[150];
string s;
int main() {
	ll i;
	cin >> n >> s;
	for(i=0; i<n; i++) c[s[i]]++;
	for(i='a'; i<='z'; i++) ans = ans * (c[i]+1) % M;
	cout << (ans - 1 + M) % M;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int A,B,C;
    A>=1 && A<=10;
    B>=1 && B<=10;
    C>=1 && C<=10;
    scanf("%d %d %d",&A,&B,&C);
    if (A+B+C==17) printf("YES");
    else  printf("NO");
	system("pause");
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
	int n, a,b;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> a >> b;
	for(int i = 1; ; ++i)
	{
		if(i > 1000000)
			return cout << "Draw", 0;
		if(i % 2 == 1)
		{
			if(a + 1 != b)
				a++;
			else
				a--;
			if(a < 1)
				return cout << "Borys", 0;
		}
		else
		{
			if(b - 1 != a)
				b--;
			else
				b++;
			if(b > n)
				return cout << "Alice", 0;
		}
	}
	return 0;            
}

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

using namespace std;
typedef long long ll;

vector <long long > chinh;
vector <pair <long long, long long> >phu;

bool choose ( pair <long long, long long > &a,
				pair <long long, long long > &b) {
	return (a.second > b.second );
}

int main()
{
	//freopen("t.txt","r",stdin);
	int n,m;
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		int t; cin>>t; chinh.push_back(t);
	}
	sort (chinh.begin(),chinh.end());
	
	for (int i=1;i<=m;i++){
		long long b,c; cin>>b>>c;
		phu.push_back(make_pair (b,c));
	}
	sort (phu.begin(),phu.end(),choose);
	
	
	int i=0,j=0;
	while ( chinh[i] < phu[j].second  && i<n && j<m ){
		chinh[i] = phu[j].second;
		phu[j].first --;
		if (phu[j].first == 0){
			j++;
		}
		i++;
		
	}
	// test
	long long sum =0;
	for (int i=0;i<n; i++){
		sum+=chinh[i];
	}
	cout<<sum;
}

Measured memory_bytes: 3188
//IN THE NAME OF GOD

#include <iostream>
using namespace std;
typedef long long int ll;
int n,a[110],ans;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                ans++;
            }
        }
    }
    for(int i=0;i<n-1;i++)
        cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1196
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static long P = 1000000007;
		static void Main(string[] args)
		{
			var xy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int x = xy[0];
			int y = xy[1];

			long max = Math.Max(x, y);
			long min = Math.Min(x, y);
			long dif = max - min;
			if ((min - dif) % 3 != 0) {
				Console.WriteLine(0);
				return;
			}

			long n = dif + (min - dif) / 3 * 2;
			long k = (min - dif) / 3;
			if (n < k || n < 0 || k < 0) {
				Console.WriteLine(0);
				return;
			}

			long[] fact = new long[n + 1];
			long[] invfact = new long[n + 1];
			long[] inv = new long[n + 1];
			fact[0] = fact[1] = 1;
			invfact[0] = invfact[1] = 1;
			inv[1] = 1;
			for (int i = 2; i < n + 1; i++) {
				fact[i] = fact[i - 1] * i % P;
				inv[i] = P - inv[P % i] * (P / i) % P;
				invfact[i] = invfact[i - 1] * inv[i] % P;
			}

			long ans = (((fact[n] * invfact[n - k]) % P) * invfact[k]) % P;
			Console.WriteLine(ans);
		}
	}
}

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

int main(){
    string s;
    cin >> s;
    string key = "keyence";
    for(int i=0; i<=7; i++){
        string head = key.substr(0, i);
        string tail = key.substr(i, key.size()-i);
        string sHead = s.substr(0, i);
        string sTail = s.substr(s.size()-tail.size(), tail.size());
        if(sHead == head && sTail == tail){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;

}

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0, a; i < N; ++i) {
        cin >> a;
        A.push_back(a);
    }

    ll dp[100000][2] = {};
    dp[0][0] = A[0] + A[1];
    dp[0][1] = -dp[0][0];

    for (int i = 1; i < N - 1; ++i) {
        dp[i][0] = max(dp[i-1][0] + A[i+1], dp[i-1][1] + A[i+1]);
        dp[i][1] = max(dp[i-1][0] + -2 * A[i] - A[i+1], dp[i-1][1] +2 * A[i] - A[i+1]);
    }

    cout << max(dp[N-2][0], dp[N-2][1]) << endl;

    return 0;
}


Measured memory_bytes: 2296
using System;

namespace abc103A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            Array.Sort(str);
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            int G = 0 + (A - B) + (B - C);
            if (G > 0)
                Console.WriteLine(G);
            else
                Console.WriteLine(-G);
        }
    }
}


Measured memory_bytes: 13408
import sys
input = sys.stdin.readline
N, M, Q = map(int, input().split())
a = []
b = []
c = []
d = []
for _ in range(Q):
    w,x,y,z = map(int, input().split())
    w -= 1
    x -= 1
    a.append(w)
    b.append(x)
    c.append(y)
    d.append(z)
def dfs(A_, k):
    if k == N-1:
        res = 0
        for i in range(Q):
            if A_[b[i]] - A_[a[i]] == c[i]:
                res += d[i]
        return res
    x = A_[k]
    res = 0
    for i in range(x, M+1):
        A_[k+1] = i
        res = max(res, dfs(A_, k+1))
    return res

ans = 0
A = [1]*N
for i in range(1, M+1):
    A[0] = i
    ans = max(ans, dfs(A, 0))
print(ans)


Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    rep(i, 10) rep(j, 10) {
        if (i * j == n) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int i, n, m, k, l, x, y, a[15][2];

int main() {
  for(scanf("%d", &n); i < n; i++) {
    for(scanf("%d", &m); m--;) {
      scanf("%d%d", &x, &y);
      a[i][y] |= 1 << x - 1;
    }
  }
  l = (1 << n) - 1;
  for(x = 1; x <= l; x++) {
    for(i = 0; i < n && !((x >> i) & 1 && (a[i][0] & x || a[i][1] & l - x)); i++);
    if(i == n) {
      y = __builtin_popcount(x);
      if(y > k)
        k = y;
    }
  }
  printf("%d\n", k);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<int> l(N);
    for(int i = 0; i < N; i++) cin >> l.at(i);
    
    int ans = 1000007;
    for(int bit = 0; bit < (1<<2*N); bit++) {
        int MP = 0;
        int X = 0, Y = 0, Z = 0;
        for(int i = 0; i < N; i++) {
            if((bit&(1<<2*i)) && (bit&(1<<(2*i+1)))) {
                X += l.at(i);
                MP += 10;
            }
            else if(bit&(1<<2*i)) {
                Y += l.at(i);
                MP += 10;
            }
            else if(bit&(1<<(2*i+1))) {
                Z += l.at(i);
                MP += 10;
            }
        }
        if(X==0 || Y==0 || Z==0) continue;
        MP -= 30;
        MP += abs(A-X) + abs(B-Y) + abs(C-Z);
        ans = min(ans, MP);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
//package abc127.B;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int y = Integer.parseInt("" + s.charAt(0) + s.charAt(1));
		int m = Integer.parseInt("" + s.charAt(2) + s.charAt(3));
		
		String ans;
		if (1 <= y && y <= 12 && 1 <= m && m <= 12) ans = "AMBIGUOUS";
		else if (1 <= m && m <= 12) ans = "YYMM";
		else if (1 <= y && y <= 12) ans = "MMYY";
		else ans = "NA";
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 21716
N = int(input())
total = []
a_list = []
b_list = []
for i in range(0,N):
  a,b = map(int,input().split())
  a_list += [a]
  b_list += [b]
  total += [a+b]

total.sort(reverse = True)

taka = 0

for j in range(0,N):
  if j % 2 == 0:
    taka += total[j]
  
print(-sum(b_list) + taka)

Measured memory_bytes: 15400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sz 200100

ll tr[4 * sz];
ll h[sz]; ll b[sz];

void upd(ll s, ll e, ll i, ll idx, ll v)
{
	if (s > i || e < i)
		return;
	if (s == e)
	{
		tr[idx] = v;
		return;
	}
	ll m = (s + e) / 2;
	upd(s, m, i, 2 * idx, v);
	upd(m + 1, e, i, 2 * idx + 1, v);
	tr[idx] = max(tr[2 * idx], tr[2 * idx + 1]);
}

ll que(ll s, ll e, ll qs, ll qe, ll idx)
{
	if (qs > e || qe < s || qs > qe)
		return 0;
	if (qs <= s && qe >= e)
		return tr[idx];
	ll m = (s + e) / 2;
	ll a = que(s, m, qs, qe, 2 * idx);
	ll b = que(m + 1, e, qs, qe, 2 * idx + 1);
	return max(a, b);
}

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

	ll n; cin >> n;

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

	for (ll i = 0; i < n; ++i)
	{
		ll x; cin >> x;
		ll ans = que(0, n, 0, h[i] - 1, 1);
		upd(0, n, h[i], 1, ans + x);
	}

	cout << tr[1];

	return 0;
}

Measured memory_bytes: 9292
using System;
using System.Collections.Generic;

namespace B_004_57
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            
            new Logic_B().Start();

        }

        public class Logic_B
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var studentNum = Convert.ToInt32(str[0]);
                var checkPNum = Convert.ToInt32(str[1]);

                var studentPos = new List<Student>();
                for (int i = 0; i < studentNum; i++)
                {
                    var studentPosInfo = Console.ReadLine().Split(' ');
                    var xPos = Convert.ToInt32(studentPosInfo[0]);
                    var yPos = Convert.ToInt32(studentPosInfo[1]);
                    studentPos.Add(new Student() { x = xPos, y = yPos });
                }
                var checkPos = new List<CheckPoint>();

                for (int i = 0; i < checkPNum; i++)
                {
                    var checkPosInfo = Console.ReadLine().Split(' ');
                    var xPos = Convert.ToInt32(checkPosInfo[0]);
                    var yPos = Convert.ToInt32(checkPosInfo[1]);
                    checkPos.Add(new CheckPoint() { x = xPos, y = yPos });
                }

                for (int i = 0; i < studentPos.Count; i++)
                {
                    var minimumdistance = int.MaxValue;
                    for (int j = 0; j < checkPos.Count; j++)
                    {
                        var distance = (Math.Abs(studentPos[i].x - checkPos[j].x) + Math.Abs(studentPos[i].y - checkPos[j].y));
                        if (minimumdistance > distance)
                        {
                            minimumdistance = distance;
                            studentPos[i].c = j + 1;
                        }
                    }
                }

                for (int i = 0; i < studentPos.Count; i++)
                {
                    Console.WriteLine(studentPos[i].c);
                }
            }
        }

        internal class Student
        {
            internal int x;
            internal int y;

            internal int c;
        }

        internal class CheckPoint
        {
            internal int x;
            internal int y;
        }

      
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp1, tmp2;
    string S;
    bool flag=true;
    
    cin >> A >> B >> C;
    
    // ans = A*A -B;
    // cout << ans << endl;

    if(A == B)
    	cout << C <<endl;
    else if (B==C)
    	cout << A <<endl;
    else
	cout << B <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


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

double memo[150][150];

int main(void){
  int i,j,h,w;
  int min,now,nh,nw,nnh,nnw;
  while(1){
    scanf("%d%d",&h,&w);
    if(h+w==0)break;
    //if(h<w-1)printf("%d %d\n",h+1,w);
    //else{
    now = h*h+w*w;
    min = now*1500;
    nh = 150;
    nw =150;
    nnh = 150;
    nnw = 150;
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
	//if(i*i+j*j==4069)printf("%d %d %d %d %d\n",now,min,i*i+j*j,i,j);
	if(now==i*i+j*j&&h<i&&nnh>i){
	  //printf("a%d %d\n",i,j);
	  nnw = j;
	  nnh = i;
	}
	if(now<i*i+j*j&&min>=i*i+j*j){
	  //printf("%d %d %d %d %d\n",now,min,i*i+j*j,i,j);
	  if(min==i*i+j*j&&nh>i){
	    nh = i;
	    nw = j;
	  }
	  else if(min>i*i+j*j){
	    nh = i;
	    nw = j;
	    min = i*i+j*j;
	  }
	}
      }
    }
    if(nnh != 150){
      nh = nnh;
      nw = nnw;
    }
    printf("%d %d\n",nh,nw);
  }
  return 0;
}


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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }

    sort(s.begin(), s.end());

    for (int i = 0; i < n; i++) {
        cout << s.at(i);
    }
    cout << endl;
}

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();
        int n = s.length();
        char c[] = s.toCharArray();
        int a[] = new int[n];
        for(int i=0;i<n;i++)a[i] = c[i] - '0';
        sc.close();

        if(a[0]==0||a[n-1]==1){
            System.out.println(-1);
            return;
        }

        for(int i=1;i<n-1;i++){
            if(a[i]!=a[n-2-i]){
                System.out.println(-1);
                return;
            }
        }

        int ans[][] = new int[n-1][2];
        ans[0][0] = 0; ans[0][1] = 1;
        for(int i=1;i<n-1;i++){
            if(a[i-1] == 0){
                ans[i][0] = ans[i-1][0];
            }
            else{
                ans[i][0] = ans[i-1][1];
            }
            ans[i][1] = i+1; 
        }
        for(int i=0;i<n-1;i++){
            int from = ans[i][0] + 1, to = ans[i][1] + 1;
            System.out.println(from + " " + to);
        }
        System.out.println();
    }
}


Measured memory_bytes: 54748
//~14:54
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    set<int> costs;
    int input, front_cost, back_cost = 0;
    for (int i = 0; i < m; i++){
        cin >> input;
        costs.insert(input);
    }
    
    for (int i = 0; i < x; i++){
        if(costs.count(i) != 1){//料金所でない

        }else{
            front_cost++;
        }
    }

    for (int i = x + 1; i < n; i++){
        if(costs.count(i) != 1){//料金所でない

        }else{
            back_cost++;
        }
    }
    
    if(front_cost > back_cost){
        cout << back_cost << endl;
    }else{
        cout << front_cost << endl;
    }
}

Measured memory_bytes: 256
s = input()[::-1]
MOD = 10**9 + 7

dp = [[0] * 13 for _ in range(len(s))]

for i, x in enumerate(s):
    # 1, 10, 100, 1000...の剰余を順に計算し、各桁までの剰余を計算
    if i == 0:
        tmp = 1
    else:
        tmp = tmp * 10 % 13
    if x != "?":
        move = int(x) * tmp
        if i == 0:
            dp[i][move] = 1
        else:
            for j in range(13):
                dp[i][j] += dp[i - 1][(j - move + 13) % 13]
                dp[i][j] %= MOD
    else:
        for coef in range(10):
            move = coef * tmp
            if i == 0:
                dp[i][move] = 1
            else:
                for j in range(13):
                    dp[i][j] += dp[i - 1][(j - move + 13) % 13]
                    dp[i][j] %= MOD

print(dp[-1][5])

Measured memory_bytes: 95892
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long s = long.Parse(Console.ReadLine());
    long mod = 1000000000;
		long t = (s+mod-1)/mod;
    long x = mod*t-s;

		Console.WriteLine(0+" "+0+" "+x+" "+t+" "+mod+" "+1);
	}
}

Measured memory_bytes: 11220
//usr/bin/env swift $0 $@;exit
let n=Int(readLine()!)!
var t=0
var x=0
var y=0
var r="Yes"
for i in 0..<n {
	let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
	let t0=arr[0]
	let x0=arr[1]
	let y0=arr[2]
	let dt=t0-t
	let dx=x0-x
	let dy=y0-y
	if dx+dy>dt || (dt-dx-dy)%2>0 {r="No"}
	t=t0
	x=x0
	y=y0
}
print(r)


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = N % 1000 / 100;
  c = N % 100 / 10;
  d = N % 10;

  if (a == b && b == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && c == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string s;
int n, a, b, c, d;

bool check1()
{
    FOR(i,min(a,b),max(c,d)) {
        if (s[i] == '#' && s[i+1] == '#')
            return false;
    }
    return true;
}

bool check2()
{
    if (c < d)
        return true;
    else if (c == d)
        return false;
    else {
        FOR(i,b-1,min(d,n-2)) {
            if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.')
                return true;
        }
    }
    return false;
}

int main()
{
    cin>>n>>a>>b>>c>>d;
    a--; b--; c--; d--;
    cin>>s;
    bool ans = true;

    ans &= check1();
    ans &= check2();
    Yes(ans);

    return 0;
}


Measured memory_bytes: 640