akhauriyash/Code-Regression huggingface dataset:
import java.math.*

val INF = 1000000000
val d = Array(200) { IntArray(200) { INF } }

fun main(args: Array<String>) {
    val (N, M, R) = readInputLine().split(" ").map { it.toInt() }
    
    val rs = readInputLine().split(" ").map { it.toInt() - 1 }.toIntArray()

    for (i in 0 until N) {
        d[i][i] = 0
    }
    
    for (i in 1..M) {
        val (A, B, C) = readInputLine().split(" ").map { it.toInt() }
        d[A - 1][B - 1] = C
        d[B - 1][A - 1] = C
    }

    for (k in 0 until N) {
        for (i in 0 until N) {
            for (j in 0 until N) {
                d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j])
            }
        }
    }
    
    var RBin = 1
    for (i in 1 until R) {
        RBin = RBin shl 1
        RBin++
    }
    
    var ans = Int.MAX_VALUE
    
    for ((i, r) in rs.withIndex()) {
        ans = Math.min(ans, dfs(rs, RBin, r, 1 shl i, 0))
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(rs:IntArray, RBin: Int, now: Int, visited: Int, cost: Int): Int {
    if (RBin == visited) {
        return cost
    }
    
    var ret = Int.MAX_VALUE
    
    for ((i, r) in rs.withIndex()) {
        if ((1 shl i) and visited != 0) {
            continue
        }
        
        ret = Math.min(ret, dfs(rs, RBin, r, visited + (1 shl i), cost + d[now][r]))
    }
    
    return ret
}


Measured memory_bytes: 41696
#include <iostream>
using namespace std;
int main() {
  int m, f, b;
  cin>>m>>f>>b;
  if(b<=m){
    cout << 0 << endl;
  }else if(b<=m+f){
    cout << b-m << endl;
  }else{
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 3088
from math import gcd
n = int(input())
XY = [tuple(map(int, input().split())) for i in range(n)]
C = {}
z = 0
for x, y in XY:
    if x == 0 and y == 0:
        z += 1
        continue
    g = gcd(x, y)
    x, y = x // g, y // g
    if y < 0:
        x, y = -x, -y
    try:
        C[(x, y)] += 1
    except KeyError:
        C[(x, y)] = 1
ans = 1
p = 10**9 + 7
for x, y in C:
    if C[(x, y)] == 0:
        continue
    a = C[(x, y)]
    if x > 0:
        x0, y0 = -y, x
    else:
        x0, y0 = y, -x
    try:
        b = C[(x0, y0)]
        C[(x0, y0)] = 0
    except KeyError:
        b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    C[(x, y)] = 0
print((ans + z - 1) % p)


Measured memory_bytes: 73192
import java.util.*;

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

        long N = sc.nextLong();
        long M = sc.nextLong();
        long ans = 0;
        if(N == 1) {
            if(M == 1) {
                ans = 1;
            } else if(M == 2) {
                ans = 0;
            } else {
                ans = M - 2;
            }
        } else if(N == 2) {
            if(M == 1) {
                ans = 0;
            } else if(M == 2) {
                ans = 0;
            } else {
                ans = 0;
            }
        } else {
            if(M == 1) {
                ans = N - 2;
            } else if(M == 2) {
                ans = 0;
            } else {
                ans = (N - 2) * (M - 2);
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
// #include<bits/stdc++.h>
// #define lli long long int
// #define MOD 1000000007
// #define KING 1000000002
// #define queen 1000002
// #define fi first
// #define se second
// #define se second
// #define lsb(i) (i & -i)
// #define nl cout<<'\n'
// #define TEST cout<<"TEST",nl
// #define pr pair<lli,lli>
// #define pb push_back
// #define eb emplace_back
// #define mp make_pair
// #define vi vector<lli>
// #define vpi vector<pr> 
// #define P pair<lli,pr>
// #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
// #define NA(i,s,n) for(lli i=s;i<n;i++)
// using namespace std;

// void solve(){
//     lli n; cin>>n;
//     vi a(n+1), b(n+1, 0), c(n+1, 0);
//     set<lli> s1, s2;
//     NA(i,1,n+1) {
//         cin>>a[i];
//         s1.insert(a[i]);
//         if(*(s1.rbegin()) == i && s1.size()==i) b[i] = 1;
//     }
//     for(lli i=n; i>0; --i){
//         s2.insert(a[i]); 
//         if(*(s2.rbegin()) == (n-i+1) && s2.size()==(n-i+1)) c[i]=1;
//     }
//     lli res = 0; vi ans;
//     NA(i,1,n) if(b[i] && b[i]==c[i+1]) ++res, ans.pb(i);
//     cout<<res; nl;
//     for(lli i:ans) cout<<i<<' '<<n-i<<'\n';
//     return; 
// }
// int main(){
//     fastIO;
//     lli t = 1; cin>>t; 
//     NA(i,0,t) {
//         // cout<<"Case #"<<(i+1)<<": ";
//         solve();
//     }
//     return 0;
// }


#include<bits/stdc++.h>
#define nl cout<<'\n'
#define lli long long int
#define NA(i,s,n) for(lli i=s; i<n; ++i)
using namespace std;

lli n, k, c;
string s;
vector<lli> res;

int main(){

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    cin>>n>>k>>c>>s;
    lli f[n], l[n], i = 0, pos = 0;
    while(i<n && pos<k){
        if(s[i]=='o') {
            f[pos] = i;
            i+=(c+1), ++pos;}
        else ++i;
    }
    i = n-1; pos = k-1;
    while(i>=0 && pos>=0){
        if(s[i]=='o') {
            l[pos] = i;
            i -= (c+1);
            --pos;
        } else --i;
    }
    NA(i,0,k) if(f[i]==l[i]) cout<< f[i]+1 << '\n';
    // nl;
    return 0;
}

Measured memory_bytes: 5012
fun main(args: Array<String>) {
    val mod = 1000000007L
    val S = readLine()!!
    var dp = LongArray(13){0L}
    dp[0]++
    
    for (c in S) {
        val tmp = LongArray(13){0L}
        val list = if(c == '?') IntArray(10){it} else intArrayOf(c-'0')

        for (n in list) {
            for ((i,d) in dp.withIndex()) {
                val pos = (10*i + n)%13
                tmp[pos] = (tmp[pos] + d)%mod
            }
        }

        dp = tmp
    }

    println(dp[5])
}

Measured memory_bytes: 115388
#include<iostream>
#include<vector>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int days[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},
		   {0,31,29,31,30,31,30,31,31,30,31,30,31}};//leap year
bool isLeap(int year)
{
  return ((year%4) == 0 && (year%100) != 0 || ( year % 400 ) == 0);
}

int main()
{
  while(true)
    {
      int y1,m1,d1,y2,m2,d2;
      cin >> y1 >> m1 >> d1 >> y2 >> m2 >>d2;
      if(y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 ||  m2 < 0 || d2 < 0)break;

      int dayc = 0;
      bool f = true;
      for(int y=y1;y<=y2;y++)
	{
	  for(int m=(f?m1:1);m<=12;m++)
	    {
	      for(int d=(f?d1:1);d<=days[isLeap(y)][m];d++)
		{
		  f = false;
		  dayc++;
		  if(y == y2 && m == m2 && d == d2)goto Fin;
		}
	    }
	}
    Fin:;
      cout << dayc-1 << endl;
    }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
 
using namespace std;
 
int main() {
	FAST;

	int n;
	cin >> n;

	string p;
	if (n <= 999) p = "ABC";
	else p = "ABD";

	cout << p << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Move[4][2]={-1,0,1,0,0,1,0,-1};
char mp[1010][1010];
int step[1010][1010];
bool vis[1010][1010];
int n,m;

bool check(int x,int y)
{
    if(x<0 || y<0|| x>=n || y>=m || vis[x][y] || mp[x][y]=='#') return false;
    return true;
}

int BFS()
{
    queue<pair<int,int> > q;
    q.push(make_pair(0,0));
    step[0][0]=1;
    vis[0][0]=true;
    while(!q.empty())
	{
        pair<int,int> t=q.front();
        q.pop();
        for(int i=0;i<4;i++)
		{
            int tox=t.first+Move[i][0];
            int toy=t.second+Move[i][1];
            if(tox==n-1 && toy==m-1) return step[t.first][t.second]+1;
            if(check(tox,toy))
			{
                vis[tox][toy]=true;
                step[tox][toy]=step[t.first][t.second]+1;
                q.push(make_pair(tox,toy));
            }
        }
    }
    return -1;
}


int main()
{
    cin>>n>>m;
    int cnt=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
		{
            cin>>mp[i][j];
            if(mp[i][j]=='#') cnt++;
        }
    int res=BFS();
    if(res==-1) cout<<"-1"<<endl;
    else cout<<n*m - res - cnt<<endl;
    return 0;
}

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

int main() {
    char c; cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }

    else cout << "consonant" << endl;

    return 0;
}


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

typedef long long           ll;
typedef unsigned long long  ull;


#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) 		cout << fixed << setprecision(a)
#define FasterIO()     		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

int main()
{
    string s;
    cin >> s;
    if(s=="ABC")
    cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);

}

class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, M;
        cin >> N >> M;
        if (!(M % N)) cout << N + M;
        else cout << -N + M;
        cout << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a[105], b[105], n, m, i;
  scanf("%d%d%d%d", &n, &m, &a[0], &b[0]);
  for(i = 1; i <= n; i++) scanf("%d", &a[i]);
  for(i = 1; i <= m; i++) scanf("%d", &b[i]);
  sort(a, a+n+1);
  sort(b, b+m+1);
  puts(b[0] > a[n] ? "No War" : "War");
}

Measured memory_bytes: 256
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dp = [-1] * 2001

def main():
    n = int(input())
    a = dfs(n) % mod
    print(a)

def dfs(s):
    if s == 0:
        return 1
    if s < 3:
        return 0
    if dp[s] >= 0:
        return dp[s]
    a = 0
    for i in range(3, s+1):
        a += dfs(s-i)
    dp[s] = a
    return a % mod
main()


Measured memory_bytes: 9652
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(void){
    int N, tmp;
    cin >> N;
    priority_queue<double, vector<double>, greater<int> > q;

    for(int i = 0; i < N; i++){
        cin >> tmp;
        q.push(tmp);
    }

    while(q.size() > 1){
        double first = q.top();
        q.pop();
        double second = q.top();
        q.pop();
        double avg = (first + second) / 2;
        q.push(avg);
    }

    cout << q.top() << endl;

    return 0;
}

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

using namespace std;

int main() {
	double n, k;
	
	scanf("%lf %lf", &n, &k);
	
	double ans = 0, i = 1;
	for(i = 1; i <= n; i++){
	    if(i >= k){
	        ans += 1;
	        continue;
	    }
	    int len = log2((k-1)/i)+1;
	    
	    ans += 1 / pow(2,len);
	    
	}
	ans /= n;
	printf("%1.12lf", ans);
}


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

int main()
{
    string s;
    cin >> s;

    int n = s.size();
    int cnt = count(s.begin(), s.end(), 'o');
    cnt += 15 - s.size();
    if(cnt < 8)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256
// finish date: 2018/08/19
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


bool ex(int n) {
    int cnt =0;
    FOR(i, 1, n + 1) if (n % i == 0) cnt++;
    if(cnt==8) return true;
    else return false;

}

int main() {
    int N;
    cin >> N;

    int cnt = 0;
    for (int i = 1; i <= N; i += 2) {
        if (ex(i)) cnt++;
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	unsigned long long sum = 0;

	for (int i = 1; i <= n; i++)
		if (i % 15 != 0 && i % 3 != 0 && i % 5 != 0)
			sum += i;

	cout << sum;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    intl ans = INF;
    intl len = s.length();
    rep(i,len-2){
        string n = s.substr(i,3);
        ans = min(ans,abs(753-stoi(n)));
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define gcd(a, b) __gcd(a, b)
#define min3(a, b, c) min(c, min(a, b))
#define max3(a, b, c) max(c, max(a, b))

#define        MX        3005
#define        MOD       1000000007

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

int H, W;
bool visited[MX][MX];

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

ll dp[MX][MX];
string str[MX];

bool valid(int x, int y)
{
    return x < H && x >= 0 && y < W && y >= 0 && str[x][y] != '#';
}
int main()
{
    optimize
    cin>>H>>W;

    for(int i = 0; i < H; i++) cin>>str[i];

    dp[0][0] = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            for(int k = 0; k < 2; k++){
                int x = i+dx[k], y = j+dy[k];
                if(valid(x, y)){
                    dp[x][y] = modAdd(dp[x][y], dp[i][j]);
                }
            }
        }
    }
    cout<<dp[H-1][W-1]<<endl;
}


Measured memory_bytes: 16552
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0539
AC
"""
import sys
from sys import stdin
from bisect import bisect_right
input = stdin.readline


def main(args):
    while True:
        d = int(input())        #  ??°??¶????????????
        if d == 0:
            break
        n = int(input())        #  ??¬????????????????????°
        m = int(input())        #  ??¨????????°
        cw_pos = [int(input()) for _ in range(n-1)]
        dests = [int(input()) for _ in range(m)]

        cw_pos.append(0)        #  ??¬????????????
        cw_pos.append(d)        #  ??°??¶??????1??¨??????????????¬????????????(??????)
        cw_pos.sort()

#        ccw_pos = [d-x for x in cw_pos] #  ??°??¶?????????????????£????????????????????????
#        ccw_pos.sort()


        total_distance = 0
        for t in dests:
            if t == 0:          #  ?????????????????????0?????\??£????????????bisect_right?????¨????????????????????§??????
                continue
            i = bisect_right(cw_pos, t)          #  ????¨?????????§??????????????????
            a1 = min(t-cw_pos[i-1], cw_pos[i]-t) #  ?????????????????????????????¢

#            j = bisect_right(ccw_pos, d-t)       #  ???????¨?????????§???????????¨?????????
#            a2 = min(d-t-ccw_pos[j-1], ccw_pos[j]-(d-t))

#            ans = min(a1, a2)
            total_distance += a1 #  ?????????????????????????????°OK

        print(total_distance)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 12824
S=input()
s1=S[0]
s2=0

if S[0]!=S[1]:
  s2=S[1]
elif S[0]!=S[2]:
  s2=S[2]
else:
  s2=S[3]

if S.count(s1)==2 and S.count(s2)==2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <map>

using namespace std;
char* alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
map<char,char> caesar;
int main() {
	// your code goes here
	for(int i=0;i<26;i++){//table initialization
		char from=alphabet[(i+3)%26],to=alphabet[i%26];
		caesar[from]=to;
	}
	char in;
	while(cin >> in){
		cout << caesar[in];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int main(){
	int N;
	int t,x,y;
	cin>>N;
	int f=1;//能 
	while(N--){
		cin>>t>>x>>y;
		//下面开始判断
		if(x+y>t){
			f=0;
		}
		if((t-(x+y))%2!=0){
			f=0;
		}
		
	}
	if(f==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
	
}

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

int main(){
  int n, x; cin>> n>> x;
  vector<int> l(n);
  for(int i=0; i<n;i++) cin>> l[i];
  int ans=1;
  int sum=0;
  for(int i=0; i<n;i++){
    sum +=l[i];
    if(sum<= x)++ans;
  }
  cout<< ans<< endl;
  return 0;
}

Measured memory_bytes: 256
<?php
define("MOD", 10**9+7);
$str = str_split(str());
$n = count($str);
for($j = 0; $j < 13; $j++){
  $dp[$n-1][$j] = 0;
}
if($str[$n-1] == "?"){
  for($i = 0; $i < 10; $i++){
    $dp[$n-1][$i] = 1;
  }
}else{
  $dp[$n-1][$str[$n-1]] = 1;
}
$c = 0;
$m = 1;
for($i = $n-2; $i>=0; --$i){
  $m*=10;
  $m%=13;
  for($j = 0; $j < 13; ++$j){
    $dp[$i][$j] = 0;
  }
  $dpi = &$dp[$i];
  $dpip = $dp[$i+1];
  if($str[$i] != "?"){
    $diff = $m*intval($str[$i])%13;
    for($j = 0; $j < 13; ++$j){
      $dpi[($j+$diff)%13] = $dpip[$j];
    }
  }else{
    for($k = 0; $k < 10; ++$k){
      $diff = $m*$k%13;
      for($j = 0; $j < 13; ++$j){
        $dpi[($j+$diff)%13] += $dpip[$j];
        $c+=$dpip[$j];
      }
    }
  }
  for($j = 0; $j < 13; ++$j){
    $dpi[$j] %= MOD;
  }
}
echo $dp[0][5];


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}


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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, T; cin >> N >> T;
  int cmin = 10000;
  for (int i = 0; i < N; i++) {
    int c, t; cin >> c >> t;
    if (t <= T) cmin = min(cmin, c);
  }
  if (cmin == 10000) {
    cout << "TLE\n";
  }else {
    cout << cmin << endl;
  }


  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int a,b,c,d,ct;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    ct=1;
    while(a>0 && c>0)
    {
        if(ct==1)
            c-=b;
        else
            a-=d;
        ct=1-ct;
    }
    if(a>0)
        printf("Yes");
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 3824
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{

    static long M=(long)1e9+7;
    
    public static void main(String[] args) {
        FastReader fs=new FastReader();
        int n=fs.nextInt();
        int k=fs.nextInt();
        long[] h=new long[n];
        for(int i=0;i<n;i++){
            h[i]=fs.nextLong();
        }
        long ans=0;
        if(k>=n){
            ans=0;
        }
        else{
            long whilk=0;
            Arrays.sort(h);
            for(int i=h.length-k-1;i>=0;i--){
                whilk+=h[i];
            }
            ans=whilk;
        }
        System.out.println(ans);
    }
    
    public static long min(long a, long mod){
        return pow(a, mod-2,mod);
    }
    public static long mul(long a,long b,long mod){
        long res=0;
        while(b!=0){
            if ((b & 1) == 1){ res = (res + a) % mod;}
            a = (a + a) % mod;
            b >>= 1;
        }
        return res;
    }
    
    public static long pow(long a, long n, long mod){
        long res=1;
        while(n != 0){
            if ((n & 1) == 1) res = mul(res, a, mod)%mod;
            a = mul(a , a, mod)%mod;
            n >>= 1;
        }
        return res;
    }
    
    public static long gcd(long a, long b){
        if(a == 0) return b;
        return b == 0 ? a: gcd(b, a % b);
    }

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


Measured memory_bytes: 58588
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int A, int B, int C) {
  int ans = max<int>({A * 10 + B + C, A + B * 10 + C, A + B + C * 10});
  printf("%d\n", ans);
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  solve(A, B, C);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    int a,b;
    double t;
    int sum=0;
    cin>>a>>b>>t;
    for(int i = a; i<t+0.5;i+=a){
      sum+=b;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
	int N, R;
	cin >> N >> R;

	if (N >= 10)
	{
		cout << R << endl;
	}
	else
	{
		cout << R + 100 * (10 - N);
	}

	return 0;
}

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

typedef struct{
    long x;
    long y;
    long z;
} cake_t;



int main(void){
    long n, m;
    cin >> n >> m;
    vector<cake_t> v(n);
    array<vector<long>,8> value;
    for(long i=0; i<8; i++){
        value[i].resize(n);
    }
    for(long i=0; i<n; i++){
        cin >> v[i].x >> v[i].y >> v[i].z;
        value[0][i] = + v[i].x + v[i].y + v[i].z;
        value[1][i] = + v[i].x + v[i].y - v[i].z;
        value[2][i] = + v[i].x - v[i].y + v[i].z;
        value[3][i] = + v[i].x - v[i].y - v[i].z;
        value[4][i] = - v[i].x + v[i].y + v[i].z;
        value[5][i] = - v[i].x + v[i].y - v[i].z;
        value[6][i] = - v[i].x - v[i].y + v[i].z;
        value[7][i] = - v[i].x - v[i].y - v[i].z;
    }
    for(long i=0; i<8; i++){
        sort(value[i].begin(), value[i].end());
        reverse(value[i].begin(), value[i].end());
    }
    long v_max=0;
    array<long,8> sum;
    for(long i=0; i<8; i++){
        sum[i] = 0;
        for(long j=0; j<m; j++){
            sum[i] += value[i][j];
        }
        //printf("%ld %ld\n", i, sum[i]);
        v_max = max(sum[i], v_max);
    }
    cout << v_max << endl;
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
 
 
def solve(A: int, B: int, N: int):
    x = min(B - 1, N)
    print(A * x // B)
 
 
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 61944
#include <stdio.h>

int main()
{
	int N;
	int l[1000],r[1000];
	int i=0;
	int temp=0;
	int total=0;

	scanf("%d",&N);

	while(i<N){
		scanf("%d %d",&l[i],&r[i]);
		i++;
	}

	i=0;
	while(i<N){
		temp=r[i]-l[i]+1;
		total=total+temp;
		i++;
	}

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

	return 0;
}



Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,a,n) for(int = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	
	
	ll x,y,cnt = 0;
	cin >> x >> y;
	
	if(x > y){
		if(x >= 0 && y < 0){
			cnt += 1;
			cnt += abs(y + x);
		}
		else if(x < 0 && y < 0){
			cnt += 2;
			cnt += abs(x-y);
		}
		else{
			cnt += min(abs(x-y)+2,abs(x+y)+1);
		}
	}
	else{
		if(x < 0 && y > 0){
			cnt += 1;
			cnt += abs(y + x);
		}
		else if(x <= 0 && y <= 0){
			cnt += abs(y-x);
		}
		else{
			cnt += min(abs(y-x),abs(y+x)+1);
		}
		
	}
	
	cout << cnt << endl;
	
	return 0;
}

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


int main() {
  int a,b ;
  cin >>a >>b;
  
  int c=0;
  vector<int>vec(a);
  for(int i=0;i<a;i++){
    cin >> vec.at(i);
      if(vec.at(i)>=b){
        c++;
      }
  }
  
  
  cout << c << endl;
}
 
  

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int N;
    cin >> N;
    long long X[N];
    long long Y[N];
    for(int i = 0; i < N; i++){
        cin >> X[i];
        Y[i] = X[i];
    }

    sort(Y,Y+N);

    long long Y_R = Y[N/2];
    long long Y_L = Y[N/2 -1];

    for(int i = 0; i < N; i++){
        if(X[i] <= Y_L){
            cout << Y_R << endl;
        }else{
            cout << Y_L << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5248
import sys
input = sys.stdin.readline

A = input()
N = list(map(int, input().split()))

ans = 1
max = 10**18
if 0 in N:
  print(0)
else:
  for i in range(len(N)):
    ans = ans * N[i]
    if ans > max:
      ans = -1
      break
  print(ans)

Measured memory_bytes: 21880
def main():
    N, K, *xn = map(int, open(0).read().split())
    ans = int(1e9+7)
    for xl, xr in zip(xn[:], xn[K - 1:]):
        ans = min(ans, xr - xl + min(abs(xr), abs(xl)))
    print(ans)
    return


main()


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

bool solve() {
    string S;
    int x, y;
    cin >> S >> x >> y;
    vector<vector<int>> C(2);
    int cnt = 0;
    rep(l, 0, S.size()) {
        int r = l;
        while(r < S.size() && S[r] == 'F') r++;
        C[(cnt++) % 2].push_back(r - l);
        l = r;
    }
    int N = C[0].size();
    int M = C[1].size();
    vector<vector<bool>> dp(N + 1, vector<bool>(16001));
    vector<vector<bool>> ep(M + 1, vector<bool>(16001));
    int g = 8000;
    dp[1][C[0][0] + g] = 1;
    rep(i, 1, N) rep(j, -8000, 8001) {
        if(dp[i][j + g] == 0) continue;
        dp[i + 1][j + C[0][i] + g] = 1;
        dp[i + 1][j - C[0][i] + g] = 1;
    }
    ep[0][g] = 1;
    rep(i, 0, M) rep(j, -8000, 8001) {
        if(ep[i][j + g] == 0) continue;
        ep[i + 1][j + C[1][i] + g] = 1;
        ep[i + 1][j - C[1][i] + g] = 1;
    }
    return dp[N][x + g] && ep[M][y + g];
}

int main() {
    cout << (solve() ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 16256
import re
text = input()
alphabet = list('abcdefghijklmnopqrstuvwxyz')
output = ['-1', '-1']
for i in range(len(alphabet)):
    pattern = alphabet[i] + '.?' + alphabet[i]
    match_object = re.search(r'%s.?%s' % (alphabet[i], alphabet[i]), text)
    if match_object:
        output[0] = str(match_object.start() + 1)
        output[1] = str(match_object.end())
        break

print(' '.join(output))

Measured memory_bytes: 10084
using System;

class Program
{
    static void Main()
    {
        string st = "";
        bool flg = false;
        string n = "";
        int sum = 0;

        while(true)
        {
            st = Console.ReadLine();
            if (st == null) break;

            for (int i = 0; i < st.Length; i++)
            {
                if (st[i] >= '0' && st[i] <= '9')
                {
                    flg = true;
                    n = n + st[i];
                }
                else
                {
                    if (flg)
                    {
                        sum += int.Parse(n);
                        flg = false;
                        n = "";
                    }
                }
            }
        }

        Console.WriteLine(sum);
    }
}



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

int main(){
  vector<int> x(5);
  rep(i,5) {
    cin >>x[i];
    if(x[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0; 
}

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

//整数の桁数を数える関数
int64_t getDigit(int64_t num){
    return to_string(num).length();
}

int main(){
    int64_t n;
    cin >> n;
    int64_t ans = 10000000;
    for(int64_t i=1; i<=ceil(sqrt(n)); i++){
        if(n%i==0){
            ans = min(ans, getDigit(n/i));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int x,y;
  for(int i=0; i<3000; i++) {
      cin >> x >> y;
      if(x==0&&y==0) {
          return 0;
      }
      cout << min(x,y) << " " << max(x,y) << endl;
  }
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			double
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	double	ans = 0.0;
	int n;
	cin >> n;
	vdef x(n);
	vdef y(n);
	for (int i = 0; i < n; ++i)	cin >> x[i] >> y[i];

	for (int i = 0; i < n; ++i)
	{
		for (int j = i; j < n; ++j)
		{
			if (i == j) continue;
			ans += sqrt(pow((double)x[i] - (double)x[j], 2) + pow((double)y[i] - (double)y[j], 2));
		}
	}

	printf("%f\n", ans *2.0 / (double)n);
	//cout << ans << endl;
	return 0;
}

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


#define N 100005
class uf{
  private:
    int par[N]={},r[N]={},size[N]={};
  
  public:
    uf(int n){
      int i;
      for (i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
      }
    }
    
    int root(int a){
      if (par[a]==a) return a;
      return par[a]=root(par[a]);
    }
    
    void unite(int a,int b){
      a=root(a);
      b=root(b);
      if (a==b) return;
      if (r[a]>r[b]){
        par[b]=a;
        r[a]++;
        size[a]+=size[b];
      }else{
        par[a]=b;
        r[b]++;
        size[b]+=size[a];
      }
    }
    
    int show_size(int a){
      return size[root(a)];
    }
    
    int group(int n){
      int i,t,res=0;
      bool u[N]={false};
      for (i=0;i<n;i++){
        t=root(i);
        if (!u[t]){
          res++;
          u[t]=true;
        }
      }
      return res;
    }
    
};

int main(void){
  int n,m,k,i,j,a,b,c,d,f[100005]={};
  vector<int> bl[100005];
  
  cin >> n >> m >> k;
  uf fs(n);
  
  for (i=0;i<m;i++){
    cin >> a >> b;
    f[a-1]++;
    f[b-1]++;
    fs.unite(a-1,b-1);
  }
  
  for (i=0;i<k;i++){
    cin >> c >> d;
    bl[c-1].push_back(d-1);
    bl[d-1].push_back(c-1);
  }
  
  int y;
  for (i=0;i<n;i++){
    y=0;
    for (j=0;j<bl[i].size();j++){
      if (fs.root(i)==fs.root(bl[i][j])) y++;
    }
    cout << fs.show_size(i)-f[i]-y-1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 7552
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
boolean yes = false;
for(int i=1;i<=9;i++){
for(int j=i;j<=9;j++){
if(i*j == N) yes= true;
}
}
String ans = yes ? "Yes" : "No";

System.out.println(ans);

} 
}

Measured memory_bytes: 22996
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, m, v, p = MAP()
a = LIST()
a = sorted(a, reverse=True)

def hantei(i):
    if i < p: return True
    if a[p-1] > a[i] + m: return False
    if ((i-p+1)*(a[i]+m)-sum(a[p-1:i]))+m*(p-1+n-i) < m*v: return False
    return True

def check(x):
    if (n-x)<=p:
        return True
 
    x_score = a[x]+m
    total_v = (v-x-p)*m
 
    if(a[n-p]>x_score):
        return False
 
    for i in range(x+1,n-p+1):
        total_v -= min(m,(x_score -a[i]))
    if total_v <= 0:
        return True
    else:
        return False

if hantei(n-1):
    print(n)
    sys.exit()
right = n-1
left = 0

while right-left > 1:
    mid = (right+left)//2
    if hantei(mid):
        left = mid
    else:
        right = mid

print(right)

Measured memory_bytes: 91900
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))


def count_max(diff):
    # 左右対称に diff 間隔でとるときの最大
    b = 0
    a = N - 1
    ret = 0
    cumsum = 0
    while diff < a and a != b and b - a != diff:
        cumsum += S[b] + S[a]
        ret = max(ret, cumsum)
        b += diff
        a -= diff
    return ret


ans = 0
for diff in range(1, N // 2 + 1):
    ans = max(ans, count_max(diff))
print(ans)


Measured memory_bytes: 14860
#include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

int m; // number of stars in the constellation (1 <= m <= 200)
int n; // number of stars in the picture (1 <= n <= 1000)

#define MAX_M 201
#define MAX_N 1001

pair<int, int> seiza[MAX_M];
pair<int, int> pic[MAX_N];

// 0 <= x, y <= 1000000

// (bx, by)??¨(x, y)???????????????????????????????????§?????? O(mn)
bool eval(int bx, int by, int x, int y) {
  for (int i=0; i<m; i++) {
    // ???????????§
    pair<int, int> t = seiza[i];
    int vx = t.first  - bx;
    int vy = t.second - by;

    bool flag = false;
    // exists?
    for (int i=0; i<n; i++) {
      if (vx == pic[i].first - x && vy == pic[i].second - y) {
        flag = true;
        break;
      }
    }
    if (!flag) return false;
  }
  return true;
}

int main() {
  while (true) {
    cin >> m;
    if (m == 0) break;
    rep(i, m) {
      int x, y;
      cin >> x >> y;
      seiza[i] = pair<int, int>(x, y);
    }
    cin >> n;
    rep(i, n) {
      int x, y;
      cin >> x >> y;
      pic[i] = pair<int, int>(x, y);
    }
    pair<int, int> base = seiza[0];
    // search O(n * eval) : O(m n^2)
    rep(i, n) {
      int x = pic[i].first;
      int y = pic[i].second;
      // cout << "eval("<<base.first<<", "<<base.second<<", "<<x<<", "<<y<<")"<<endl;
      if (eval(base.first, base.second, x, y)) {
        cout << x-base.first << " " << y-base.second << endl;
        break;
      }
    }
  }

  return 0;
}

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

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

	string a, b;
	cin >> a >> b;

	if (b.size() < a.size()) {
		cout << "No";
		return 0;
	}

	bool flag = true;
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] != b[i]) {
			flag = false;
			break;
		}
	}
	if (flag)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3652
N,K=map(int,input().split())
p=10**9 + 7
L_min,L_max=0,0
for i in range(K-1,N+1):
  L_min+=i*(i+1)//2 - 1
  L_max+=(N*(N+1)//2)-((N-i-1)*(N-i)//2)
ans = (L_max-L_min)%p
print(ans)


Measured memory_bytes: 9124
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader rd = new Reader();    
        int N, M;
        {int[] a = rd.ii(); N = a[0]; M = a[1];}
        int l = 1;
        int r = N;
        for(int i = 0; i < M; i++){
            int[] a = rd.ii();
            if(l < a[0])
                l = a[0];
            if(a[1] < r)
                r = a[1];                
        }
        println(Math.max(r-l+1, 0));
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 45588
import sys
from collections import Counter

h, w = map(int, input().split())
s_list = [list('.' * (w + 2))]
s_list.extend([list('.' + input() + '.') for i in range(h)])
s_list.append(list('.' * (w + 2)))

for i in range(1, h+1):
    for j in range(1, w+1):
        if s_list[i][j] == '.':
            cnt = 0
            cnt += s_list[i-1][j-1:j+2].count('#')
            cnt += s_list[i][j-1:j+2].count('#')
            cnt += s_list[i+1][j-1:j+2].count('#')
            s_list[i][j] = str(cnt)

for i in s_list[1:-1]:
    print(''.join(i[1:-1]))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w,a,b;
  cin>>w>>a>>b;
  if(a+w<b){
    cout<<abs(b-a-w)<<endl;
  }
  else if(a>b+w){
    cout<<abs(a-b-w)<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;

}

Measured memory_bytes: 256
import sys

N=input()
D=map(int, sys.stdin.readline().split())
D.sort()

if N%2==1:
	print 0
else:
	p1=N/2-1
	p2=N/2
	if D[p1]==D[p2]:
		print 0
	else:
		print D[p2]-D[p1]


Measured memory_bytes: 41964
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;


int main() {
 string b ;
 cin >> b;
  if (b == "A"){
cout << "T" << endl;
  }
  else if (b == "T"){
cout << "A" << endl;
  }
  else if (b == "C"){
cout << "G" << endl;
  }
  else if (b == "G"){
cout << "C" << endl;
  }
}

Measured memory_bytes: 256