akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input())
ab = [[int(x) for x in input().split()] for _ in range(n)]
from collections import defaultdict, Counter
import math

double_zero_cnt = 0 # [0, 0]の個数
a_b = [] # a/bを、約分した形で保持(a/gcd(a, b), b/gcd(a, b), 符号)
for a, b in ab:
    if a == 0 and b == 0: 
        double_zero_cnt += 1
        continue
    g = math.gcd(a, b)
    a //= g
    b //= g
    sign = 1 if a*b > 0 else -1 if a*b < 0 else 0
    a_b.append((abs(a), abs(b), sign))

c = Counter(a_b) # ベクトルごとにグループ分け
key_list = list(c.keys())

d = defaultdict(list) # [a, b] あるngなペアのそれぞれの要素の個数
for key in key_list:
    a, b, sign = key
    if d[(b, a, -sign)]: # ダブルカウントしないように
        continue 
    if c[(b, a, -sign)] != 0:
        d[(a, b, sign)] = [c[(a, b, sign)], c[(b, a, -sign)]]

ans = 1 # 積算の単位元
used_cnt = double_zero_cnt # 組めないものがあるイワシの個数(計算で使用したらカウント)
for key in d.keys():
    if d[key] == []: # 前のループで調べると[]が生まれてしまう
        continue
    x, y = d[key]
    used_cnt += (x + y)
    mul = (pow(2, x, mod) + pow(2, y, mod) - 1) % mod # このグループからは、片方ずつからしか出せない。何も選ばないがダブルカウントになる。
    ans *= mul
    ans %= mod

ans *= pow(2, n - (used_cnt), mod) # まだ使われていないイワシは好きな組み合わせ可能
ans += double_zero_cnt # 両方0のものは1つにつき自分のみの1通り
ans -= 1 # 0匹は選べない
ans %= mod
print(ans)

Measured memory_bytes: 184016
from itertools import product
S = input()
l = ["+", "-"]
for k in list(product(l, repeat=3)):
  ans = S[0] + k[0] + S[1] + k[1] + S[2] + k[2] + S[3]
  if eval(ans) == 7:
    print(ans+"=7")
    exit()

Measured memory_bytes: 3060
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
      
      if(n.charAt(0)==n.charAt(2)){
        System.out.print("Yes");
      }else{
         System.out.print("No");
      }

    }
}

Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d%d", &a,&b);

	if (a > b)
		printf("a > b\n");
	else
		if (a < b)
			printf("a < b\n");
		else
			printf("a == b\n");

	return 0;
}

Measured memory_bytes: 1008
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Apr 25 08:26:35 2018
//
package main

import (
	"fmt"
)

var S string

func main() {
	fmt.Scan(&S)
	ans := 700
	for i := range S {
		if S[i] == 'o' {
			ans += 100
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
	int  n, a, b, c, d, a1, a2;
	cin >> n >> a >> b >> c >> d;
	a1 = b * ((n / a) + 1);
	if (n%a == 0)
	{
		a1 -= b;
	}
	a2 = d * ((n / c) + 1);
	if (n%c == 0)
	{
		a2 -= d;
	}
	if (a1 < a2)
	{
		cout << a1 << endl;
	}
	else
		cout << a2 << endl;
		
	return 0;
}


Measured memory_bytes: 3136
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int W, D;
  while(cin>>W>>D,W){
	VI hw(W), hd(D);
	VI hw_cnt(21, 0), hd_cnt(21,0);
	int sumW = 0, sumD = 0;
	REP(i,W){
	  cin>>hw[i];
	  sumW += hw[i];
	  ++hw_cnt[hw[i]];
	}
	REP(i,D){
	  cin>>hd[i];
	  sumD += hd[i];
	  ++hd_cnt[hd[i]];
	}

	REP(i,21)
	  if(hw_cnt[i] < hd_cnt[i])
		sumW += (hd_cnt[i] - hw_cnt[i]) * i;

	REP(i,21)
	  if(hw_cnt[i] > hd_cnt[i])
		sumD += (hw_cnt[i] - hd_cnt[i]) * i;
	
	cout << min(sumW, sumD) << endl;
  }
  
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

inline long double dist(long double x1,long double y1,long double x2,long double y2){return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));}

const ld INF = 1e18;
vector<ld> dijkstra(int N,int start,int dest,const vector<vector<pair<int,ld>>>& Hen){
    vector<ld> dist(N, INF), prever(N, -1), seen(N);
    dist[start] = 0.0;
    priority_queue<pair<ld,ll>, vector<pair<ld,ll>>, greater<pair<ld,ll>>> que;
    que.emplace(0.0, start);

    while(que.size()) {
        ll ver = que.top().second;
        ld cost = que.top().first; que.pop();
        if(seen[ver])continue;
        seen[ver] = true;
        for(auto i : Hen[ver]) {
            if(dist[i.first] > cost + i.second) {
                dist[i.first] = cost + i.second;
                prever[i.first] = ver;
                que.emplace(dist[i.first], i.first);
            }
        }
    }
    return dist;
}

int main()
{
    ld sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int n; cin >> n;
    n = n + 2;
    vector<tuple<ld,ld,ld>> cir(n);
    for(int i = 2; i < n; i++) {
        ld x, y, r; cin >> x >> y >> r;
        cir[i] = make_tuple(x, y, r);
    }
    cir[0] = make_tuple(sx, sy, 0);
    cir[1] = make_tuple(tx, ty, 0);
    vector<vector<pair<int,ld>>> hen(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j)continue;
            ld x1, y1, r1, x2, y2, r2;
            tie(x1, y1, r1) = cir[i];
            tie(x2, y2, r2) = cir[j];
            hen[i].emplace_back(j,max((ld)0, dist(x1, y1, x2, y2) - (r1 + r2)));
        }
    }

    cout << fixed <<setprecision(12) <<  dijkstra(n,0,1,hen)[1]  << endl; 
}

Measured memory_bytes: 42092
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  u64 n, c, k;
  cin >> n >> c >> k;
  priority_queue< u64, vector< u64 >, greater< u64 > > q;
  for (u64 i = 0; i < n; ++i) {
    u64 t;
    cin >> t;
    q.push(t);
  }
  u64 wait = q.top();
  u64 w_n = 1;
  u64 b_cnt = 0;
  q.pop();
  while (!q.empty()) {
    while (w_n < c && !q.empty()) {
      u64 next = q.top();
      if (next > wait+k) {
        break;
      }
      w_n++;
      q.pop();
    }
    if (q.empty()) break;
    b_cnt++;
    wait = q.top();
    q.pop();
    w_n = 1;
  }
  if (w_n>0) b_cnt++;
  cout << b_cnt << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=3e3+10;
int n,t;
pii v[mxN];
int dp[mxN][mxN];
int solve(int obj,int aguenta){
    if(obj<0)return 0;
    if(!aguenta)return dp[obj][aguenta]=0;
    if(dp[obj][aguenta]>=0)return dp[obj][aguenta];

    int naoc=solve(obj-1,aguenta);
    if(v[obj].first<=aguenta){
        int col=solve(obj-1,aguenta-v[obj].first)+v[obj].second;

        return dp[obj][aguenta]=max(naoc,col);
    }
    return dp[obj][aguenta]=naoc;
}
int main(){
    memset(dp,-1,sizeof(dp));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>t;
    t--;
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    sort(v,v+n);
    solve(n-1,t);
    ll ans = (ll)(dp[0][t]);
    for(int i=1;i<n;i++){
        ans=max(ans,(ll)dp[i-1][t]+v[i].second);
    }
    cout<<ans;
}

Measured memory_bytes: 35840
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
#define N 52
#define M 2520
using namespace std;

int a[N], b[N];
vector<tuple<int, int, int> > e[N];
long long d[N][M];
pair<long long, int> f[N * M * 2];

bool Checkmin(long long &a, long long b)
{
    if(a > b)
    {
        a = b;

        return true;
    }

    return false;
}

inline pair<long long, int> Compare(pair<long long, int> a, pair<long long, int> b)
{
    return make_pair(min(a.first, b.first), a.first < b.first ? a.second : b.second);
}

void InitSegwin(int n)
{
    int i;

    for(i = 0; i < n; i ++)
        f[i + n] = make_pair(LLONG_MAX >> 2, i);
    for(i = n - 1; i > -1; i --)
        f[i] = Compare(f[i << 1], f[i << 1 | 1]);

    return;
}

void SetSegwin(int p, int n, long long v)
{
    for(f[p += n].first = v; p >>= 1; )
        f[p] = Compare(f[p << 1], f[p << 1 | 1]);

    return;
}

void Dijkstra(int n, int s, int v)
{
    int i, x, y;
    long long k;

    for(i = 0; i < N; i ++)
        fill(d[i], d[i] + M, LLONG_MAX >> 2);
    d[s][v] = 0;

    InitSegwin(n * 2501);
    SetSegwin(s * 2501 + v, n * 2501, 0);

    while(f[1].first != LLONG_MAX >> 2)
    {
        x = f[1].second / 2501;
        y = f[1].second % 2501;
        k = d[x][y];
        SetSegwin(x * 2501 + y, n * 2501, LLONG_MAX >> 2);

        // printf("%d %d %lld %d\n", x, y, k, (int)q.size());
        for(i = 0; i < (signed)e[x].size(); i ++)
            if(y >= get<1>(e[x][i]) && Checkmin(d[get<0>(e[x][i])][y - get<1>(e[x][i])], k + get<2>(e[x][i])))
                SetSegwin(get<0>(e[x][i]) * 2501 + (y - get<1>(e[x][i])), n * 2501, k + get<2>(e[x][i]));

        for(k += b[x], y += a[x]; y <= 2500; k += b[x], y += a[x])
            if(Checkmin(d[x][y], k))
                SetSegwin(x * 2501 + y, n * 2501, k);
    }

    return;
}

int main(void)
{
    int n, m, s;
    int u, v, a, b;
    int i;

    scanf("%d %d %d", &n, &m, &s);
    while(m --)
    {
        scanf("%d %d %d %d", &u, &v, &a, &b);
        e[-- u].push_back(make_tuple(-- v, a, b));
        e[   v].push_back(make_tuple(   u, a, b));
    }
    for(i = 0; i < n; i ++)
        scanf("%d %d", &::a[i], &::b[i]);

    Dijkstra(n, 0, min(s, 2500));
    for(i = 1; i < n; i ++)
        printf("%lld\n", *min_element(d[i], d[i] + M));

    return 0;
}


Measured memory_bytes: 8772
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<bitset>
#include<queue>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
const int N = 5 * 100*1000 + 7;

int test;

int n;

int a[N],b[N];

int s1 = 0, s2 = 0;

void solve()
{
    cin >> n;

    FOR(i,1,n){
        cin >> a[i];
    }

    FOR(i,1,n){
        cin >> b[i];

        int x = b[i] - a[i];

        if (x > 0){
            if (x % 2 == 0){
                s1 += x/2;
            }else{
                s1 += x/2+1;
                s2 ++;
            }
        }else{
            s2 += abs(x);
        }
    }

    debug(s1,s2);

    if (s1 >= s2){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return;
}

int32_t main()
{
    boost

    test=1;

    while(test--)
    {
        solve();
    }

  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
using namespace std;
int x=1;
char y='A';
int h,w;
string s;
int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s;
      if(s=="snuke"){x+=i;y+=j;}
    }
  }
  cout<<y<<x;
}

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

int main() {
	int a, b, c, n, m;
	scanf("%d %d %d", &a, &b, &c);/////////////////////////
	n = a;
	m = 0;
	while (n <= b) {
		if (c%n == 0) {
			m++;
		}
		n++;
	}
	printf("%d\n", m);
	return 0;
}

Measured memory_bytes: 2760
def main():
    import sys
    import math
    input = sys.stdin.buffer.readline
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    node = 1
    max_node = sum(A)
    for i in range(n+1):
        ans += node
        max_node -= A[i]
        node = min(max_node,(node-A[i])*2)
        if node < 0:
            print(-1)
            exit(0)
    print(ans)


if __name__ == '__main__':
    main()

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


int main ()
{
    long long int r, d, x;
    cin >> r >> d >> x;

    int i;
    for (i = 2001; i <= 2010; ++i)
    {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    rep(i,n){
        if(s.at(i) == 'R') r.push_back(i);
        else if(s.at(i) == 'G') g.push_back(i);
        else b.push_back(i);
    }
    ll sum =(ll) r.size() * g.size() * b.size();
    for(int i : r)
        for(int j : g){
            int k1 = 2*i-j;
            int k2 = (i+j)%2 == 0 ? (i+j)/2 : -1;
            int k3 = 2*j-i;
            if(0 <= k1 && k1 < n && s.at(k1) == 'B') sum--;
            if(0 <= k2 && k2 < n && s.at(k2) == 'B') sum--;
            if(0 <= k3 && k3 < n && s.at(k3) == 'B') sum--; 
        }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define N 200005
int n,A[N],AN[N],an;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&A[i]);
	for(int i=n; i; i--) {
		if(A[i]) {
			AN[++an]=i;
			for(int z=1; z*z<=i; z++) {
				if(i%z==0) {
					A[z]^=1;
					if(z*z!=i)A[i/z]^=1;
				}
			}
		}
	}
	printf("%d\n",an);
	for(int i=an; i; i--) printf("%d ",AN[i]);
	return 0;
}

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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N;
	bool d[101];

	cin >> N;
	rep(i, 0, 101) {
		d[i] = false;
	}

	int D;

	rep(i, 1, N + 1) {
		cin >> D;
		d[D] = true;
	}

	int count = 0;
	rep(i, 1, 101) {
		if (d[i]) count++;
	}
	cout << count << endl;

	return 0;
}

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

int main(){
    ll n,k,c;
    cin >> n >> k >> c;
    char s[n];
    cin >> s;

    vector<int> dpl,dpr;
    for (int i=0; i<n && dpl.size() < k; i++){
        if(s[i] == 'o'){
            dpl.push_back(i);
            i += c;
        }
    }
    for (int i=n; i>=0 && dpr.size() < k; i--){
        if(s[i] == 'o'){
            dpr.push_back(i);
            i -= c;
        }
    }
    reverse(dpr.begin(),dpr.end());
    for(int i=0;i<k;i++){
        if (dpl[i] == dpr[i]){
            cout << dpl[i]+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3444
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ribhav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Q1 solver = new Q1();
        solver.solve(1, in, out);
        out.close();
    }

    static class Q1 {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt();
            int b = s.nextInt();
            int c = s.nextInt();
            if (a == b && a == c) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int N;
	ll T;
	cin >> N >> T;
	ll t[N];
	REP(i,N) cin >> t[i];
	ll ans = 0;
	ans += T;
	for(int i = 1; i < N; i++){
		if(t[i] - t[i - 1] <= T) ans += t[i] - t[i - 1];
		else ans += T;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
def debug(k,v) puts "#{k}: #{v}" end
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end #Using .sort.reverse instead decreases Exec Time but increases Memory Usage
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end 

INF = 10**11
A,B,Q = gsmi
s = Array.new(A){gi}
t = Array.new(B){gi}
x = Array.new(Q){gi}
[s,t].each{|arr| arr.unshift(-INF);arr.push(INF)}

x.each do |q|
	ans = []
	[[s,t],[t,s]].each do |arr|
		a,b = arr
		2.times do |i|
			apos = a.bsearch_index{|x|x>=q} - i
			ax = a[apos]
			2.times do |j|
				bpos = b.bsearch_index{|x|x>=ax} - j
				bx = b[bpos]
				ans << ((q - ax).abs + (ax - bx).abs)
			end
		end
	end
	puts ans.min
end

Measured memory_bytes: 6140
/*
  author:   Ziel
  created:  05.07.2020 17:38:45
*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
  int n;
  cin >> n;
  for (int i = 1; i <= 10; i++) {
    if (i * 1000 >= n) {
      cout << i * 1000 - n;
      return 0;
    }
  }
  
  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

struct LowestCommonAncestor {
    size_t n;
    size_t size() const { return n; }
    enum { B = 1000 };
    vector<int> color, parent, depth, topDepth, goUp, visited;
    vector<vector<int>> g;
    LowestCommonAncestor(size_t n_) : n(n_), g(n) {}
    void addEdge(int u, int v){
        g[u].push_back(v); g[v].push_back(u);
    }
    void decomp(int root){
        color.assign(n, 0); parent.assign(n, -1); depth.assign(n, 0);
        topDepth.assign(n, 0); goUp.assign(n, -1); visited.assign(n, false);
        vector<int> tord;
        vector<int> q(n+1); int l = 0, r = 0;
        q[r++] = root;
        while(l != r){
            int v = q[l++]; visited[v] = true;
            tord.push_back(v);
            for(int c : g[v]){
                if(visited[c]) continue;
                parent[c] = v; depth[c] = depth[v] + 1; q[r++] = c;
            }
        }
        visited.assign(n, false);
        int c = 0;
        for(int u : tord){
            if(color[u]) continue;
            c++;
            l = 0, r = 0;
            q[r++] = u;
            for(int i = 0; i < B && l != r; i++){
                int v = q[l++];
                color[v] = c; goUp[v] = parent[u]; topDepth[v] = depth[u];
                for(int c : g[v]) if(!color[c]) q[r++] = c;
            }
        }
    }
    int solve(int u, int v){
        while(color[u] != color[v]){
            if(topDepth[u] > topDepth[v]) u = goUp[u];
            else v = goUp[v];
        }
        while(u != v){
            if(depth[u] > depth[v]) u = parent[u];
            else v = parent[v];
        }
        return u;
    }
};

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

int main(){
    int n;
    cin >> n;
    LowestCommonAncestor g(n);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g.addEdge(i,c);
        }
    }
    g.decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << g.solve(u,v) << endl;
    }
}

Measured memory_bytes: 10292
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n=0,s=0,w=0,e=0;
    string str ;
    cin >> str;
    
    for(int i=0;i<str.length();i++){
        switch(str[i]){
            case 'N':
                n++;
                break;
            case 'S':
                s++;
                break;
            case 'W':
                w++;
                break;
            case 'E':
                e++;
                break;
        }
    }
    
    if(n==0 && s==0){
        if(w>0 && e>0){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }else if(w==0&& e==0){
        if(s>0 && n>0){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }else{
        if(s>0 && n>0 && w>0 && e>0){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }
    
    
    
}


Measured memory_bytes: 256
def Lucas_Update(L0,L1):
    L2=L0+L1
    return L2
N=int(input())
L=[2,1]
if N==0:
    print(2)
elif N==1:
    print(1)
else:
    for i in range(2,N+1):
        L.append(Lucas_Update(L[i-1],L[i-2]))
    print(L[N])

Measured memory_bytes: 9108
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        int count = a.IndexOf("YAKI");
        if(count == 0){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}

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


using namespace std;

int gcd(int a, int b){
    if (a >= b) {
        swap(a, b);
    }
    while(a > 0){
        int c = b % a;
        b = a;
        a = c;
    }
    return b;
}


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

    vector <int> x(n + 1), y(n);
    for(int i = 0; i < n + 1; i++){
        cin >> x[i];
    }
    sort(x.begin(), x.end());

    for(int i = 0; i < n; i++){
        y[i] = x[i + 1] - x[i];
    }
    
    int ans = y[0];
    if (n >= 2){
        for(int i = 1; i < n; i++){
            ans = gcd(ans, y[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	string x;
	int d, theta;
	int direction=0;
	pair<double,double> p;
	while(cin >> x){
		sscanf(x.c_str(),"%d,%d",&d,&theta);
		p.first += d*cos(direction/360.0*2*M_PI);
		p.second += d*sin(direction/360.0*2*M_PI);
		direction += theta;
	}
	cout << (int)p.second << endl;
	cout << (int)p.first << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
  private static int height, width;
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    while (true) {
      height = stdIn.nextInt();
      width = stdIn.nextInt();
      if (height == 0 && width == 0) {
        break;
      }
      for (int i = 0;i < height; i++) {
        for (int j =0;j < width; j++) {
          if (i % 2 == 0) {
            if (j % 2 == 0) {
              System.out.print("#");
            } else {
              System.out.print(".");
            }
          } else {
            if (j % 2 == 0) {
              System.out.print(".");
            } else {
              System.out.print("#");
            }
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}

Measured memory_bytes: 33128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int TH = sc.nextInt();
		int TA = sc.nextInt();
		int AH = sc.nextInt();
		int AA = sc.nextInt();
		int turn = 1;

		while (TH > 0 && AH > 0) {
			if (turn % 2 == 1) {
				AH = AH - TA;
			} else {
				TH = TH - AA;
			}
			turn++;
		}

		if (TH <= 0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 35812
/* 
 * Author: sr1jan
 * I shall taste the blood...
 *
*/
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mp make_pair
#define pb push_back

typedef long long ll;
// global 

ll gcd(ll a, ll b) {if(a==0) return b; return gcd(b%a, a);}

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

    int num[3][3];
    int seen[3][3];
    memset(seen, 0, sizeof seen);
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> num[i][j];
        }
    }

    int n; 
    cin>>n;
    while(n--){
        int in;
        cin >> in;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(num[i][j]==in){
                    seen[i][j]=1;
                }
            }
        }
    }

    /* for(int i=0; i<3; i++){ */
    /*     for(int j=0; j<3; j++){ */
    /*         cout << num[i][j] << ' '; */
    /*     } */
    /*     cout << endl; */
    /* } */

    bool ans = false;
    for(int i=0; i<3; i++){
        if(seen[i][0] && seen[i][1] && seen[i][2]) ans = true;
    }
    for(int i=0; i<3; i++){
        if(seen[0][i] && seen[1][i] && seen[2][i]) ans = true;
    }

    if(seen[0][0] && seen[1][1] && seen[2][2]) ans = true;
    if(seen[0][2] && seen[1][1] && seen[2][0]) ans = true;

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
 
#define DEBUG 0
 
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define MAX 0
#define MIN 1

using namespace std;


int main(){
	lli n,k;
	cin>>n>>k;
	vector<lli> a(n);
	lli dp[2][100]={0};
	lli flag[2][100]={0};
	lli maxA = 0;
	REP(i,n){
		cin>>a[i];
		maxA = max(a[i],maxA);
	}

	lli maxb = 0;
	lli maxAB = 0;
	lli tmpN = k;
	while(tmpN){
		maxb++;
		tmpN/=2;
	}
	while(maxA){
		maxAB++;
		maxA/=2;
	}
	maxb = max(maxb,maxAB);

	if(DEBUG)cout<<"maxb="<<maxb<<endl;

	lli maxNum = 0;
	for(lli i=maxb;i>=0;i--){
		if(DEBUG)cout<<"i="<<i<<endl;
		lli nowOnB = ((lli)1<<i);
		lli nextMaxNum = maxNum | nowOnB;

		/*該当bitON時の増える量*/
		lli sumOn = 0;
		REP(j,n)sumOn += (a[j] & nowOnB)^nowOnB;

		/*該当bitOFFのときの増える量*/
		lli sumOff=0;
		REP(j,n)sumOff += a[j] & nowOnB;
		
		if(DEBUG)cout<<"sumON="<<sumOn<<endl;
		/*ONにしても問題がない時*/
		if(nextMaxNum <= k){
			dp[MAX][i] = max(dp[MAX][i],sumOn + dp[MAX][i+1]);
			dp[MIN][i] = max(dp[MIN][i],sumOff +dp[MAX][i+1]);
			flag[MIN][i]=1;
			maxNum = nextMaxNum;
		}
		else{
			dp[MAX][i] = max(dp[MAX][i],sumOff + dp[MAX][i+1]);
		}
		if(flag[MIN][i+1]){
			dp[MIN][i] = max(dp[MIN][i],sumOn + dp[MIN][i+1]);
			dp[MIN][i] = max(dp[MIN][i],sumOff+ dp[MIN][i+1]);
			flag[MIN][i]=1;
		}
	}
	cout<<max(dp[MAX][0],dp[MIN][0])<<endl;

	return 0;
}

Measured memory_bytes: 1024
def pp(x):
    if x==0:
        x=0
    return "{0:.3f}".format(round(x,3))


n=int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3=map(float, input().split())

    a=2*(x2-x1)
    b=2*(y2-y1)
    c=( x2**2 + y2**2 ) - ( x1**2 + y1**2 )
    d=2*(x3-x1)
    e=2*(y3-y1)
    f=( x3**2 + y3**2 ) - ( x1**2 + y1**2 )
    x=(c*e-b*f)/(a*e-b*d)
    y=(a*f-c*d)/(a*e-b*d)
    r=( (x-x1)**2 + (y-y1)**2 )**0.5
 
    print(pp(x), pp(y), pp(r))

Measured memory_bytes: 7724
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll ans = 0;
    int x,y;
    cin >> x >> y;
    if(x == 1 && y == 1) ans += 400000;
    if(x == 1) ans += 300000;
    if(y == 1) ans += 300000;
    if(x == 2) ans += 200000;
    if(y == 2) ans += 200000;
    if(x == 3) ans += 100000;
    if(y == 3) ans += 100000;
    print(ans);

}




Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    char aa;
    while(cin>>aa){
    char tmp[10][10]={};
    tmp[0][0]=aa;
    rep(i,8) rep(j,8) if(i!=0 || j!=0)cin>>tmp[i][j];
    int data[10][10]={};
    rep(i,8) rep(j,8) data[i][j]=tmp[i][j]-'0';
    
    rep(i,8){
        rep(j,8){
            if(data[i][j]){
                if( i+1<8           && j+1<8 && data[i+1][j] && data[i][j+1] && data[i+1][j+1] ){cout<<"A"<<endl;goto next;}
                if( i+3<8           && data[i+1][j] && data[i+2][j] && data[i+3][j] ){cout<<"B"<<endl;goto next;}
                if( j+3<8           && data[i][j+1] && data[i][j+2] && data[i][j+3] ){cout<<"C"<<endl;goto next;}
                if( i+2<8 && j-1>=0 && data[i+1][j] && data[i+1][j-1] && data[i+2][j-1] ){cout<<"D"<<endl;goto next;}
                if( i+1<8 && j+2<8  && data[i][j+1] && data[i+1][j+1] && data[i+1][j+2] ){cout<<"E"<<endl;goto next;}
                if( i+2<8 && j+1<8  && data[i+1][j] && data[i+1][j+1] && data[i+2][j+1] ){cout<<"F"<<endl;goto next;}
                if( i+1<8 && j-1>=0 && j+1<8 && data[i+1][j] && data[i][j+1] && data[i+1][j-1] ){cout<<"G"<<endl;goto next;}
            }
        }
    }
    next:;
    }
    
    return 0;
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int N, C, K;
    cin >> N >> C >> K;
    vint T(N);
    rep(i, N)
    {
        cin >> T[i];
    }
    sort(all(T));
    int ans = 0, time = 0, cnt = 0, idx = 0;
    while (idx < N)
    {
        time = 0;
        while (time <= K and cnt < C and idx < N)
        {
            if (idx == N - 1)
            {
                idx++;
                break;
            }
            time += T[idx + 1] - T[idx];
            cnt++;
            idx++;
        }
        ans++;
        cnt = 0;
    }
    cout << ans;
    return 0;
}

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

#define int long long

struct T {
    int x, y, id;
    T () {}
    T (int x, int y, int id) : x(x), y(y), id(id) {}
};

int n, m, x, y;
vector<T> u, v;
vector<int> ans;

signed main() {
    cin >> n >> m;
    u.resize(n);
    v.resize(m);

    for (int i = 0; i < n; ++i){ 
        cin >> x >> y;
        u[i] = T(x, y, i);
    }

    for (int i = 0; i < m; ++i) {
        cin >> x >> y;
        v[i] = T(x, y, i + 1);
    }

    for (int i = 0; i < n; ++i) {
        int ux = u[i].x, uy = u[i].y, minid = 999, mind = (long long)(1e9);
        //cout << "id = " << i << endl;
        for (int j = 0; j < m; ++j) {
            int tmp = abs(v[j].x - ux) + abs(v[j].y - uy), tid = v[j].id;

            //cout << "tmp, mind = " << tmp << " " << mind << endl;
            //cout << "tid, minid = " << tid << " " << minid << endl;

            if (mind > tmp) {
                mind = tmp;
                minid = tid;
            }
            else if (mind == tmp) {
                if (minid > tid) {
                    minid = tid;
                }
            }
        }

        ans.push_back(minid);
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}

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

int main(){
    int K,A,B;
    cin >> K >> A >> B;
    int flag = 0;
    for(int i=0;i<1001;i++){
        if (K * i < B+1 && K * i> A-1){
            cout << "OK";
            flag = 1;
            break;
        }
    }
    if(flag == 0) cout << "NG";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vii vector<vi>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,k; cin >> n >> k;
  vi h(n); rep(i, n) cin >> h[i];
  sort(h.begin(),h.end());

  int ans = 1000000007;
  for (int i = 0; i <= n-k; i++) {
    ans = min(ans,h[i+k-1]-h[i]);
  }
  std::cout << ans << '\n';
}


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

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i=0;i<n;++i) cin >> A.at(i);
  int ans=0,count=1;
  for(int i=0;i<n-1;++i){
    if(A.at(i)==A.at(i+1)){
      count++;
    }
    else{
        ans+=count/2;
        count=1;
    }
  }
  ans+=count/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
int main() {
	std::vector<std::vector<int>> state(3, std::vector<int>(3));
	for (auto& line : state) for (auto& cell : line) std::cin >> cell;
	int n; std::cin >> n;
	std::set<int> called;
	for (auto i = 0; i < n; ++i) {
		int b; std::cin >> b;
		called.insert(b);
	}
	bool bingo = false;
	for (auto i = 0; i < 3; ++i) {
		bool b = true;
		for (auto j = 0; j < 3; ++j) {
			if (called.find(state[i][j]) == called.end()) b = false;
		}
		if (b) bingo = true;
		b = true;
		for (auto j = 0; j < 3; ++j) {
			if (called.find(state[j][i]) == called.end()) b = false;
		}
		if (b) bingo = true;
	}
	bool b = true;
	for (auto i = 0; i < 3; ++i) {
		if (called.find(state[i][i]) == called.end()) b = false;
	}
	if (b) bingo = true;
	b = true;
	for (auto i = 0; i < 3; ++i) {
		if (called.find(state[i][2 - i]) == called.end()) b = false;
	}
	if (b) bingo = true;
	std::cout << (bingo ? "Yes\n" : "No\n");
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  int max=-100;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++){
    cin >> t.at(i);
  }
  vector<int> totalscore(N+M,0);
  for(int i=0;i<M+N;i++){
    for(int j=0;j<M+N;j++){
      if(i<N && j<N){
        if(s.at(i)==s.at(j))totalscore.at(i)++;
      }
      else if(i<N && j>=N){
        if(s.at(i)==t.at(j-N))totalscore.at(i)--;
      }
      else if(i>=N && j<N){
        if(t.at(i-N)==s.at(j))totalscore.at(i)++;
      }
      else{
        if(t.at(i-N)==t.at(j-N))totalscore.at(i)--;
      }
    }
  }
  for(int i=0;i<M+N;i++){
    if(totalscore.at(i)>=max)max=totalscore.at(i);
  }
  if(max<0)max=0;
  cout << max << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  set<int> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  cout << (st.size() == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

ll gcd2(ll p,ll q){
    if(p>q)swap(p,q);
    if(p==0)return q;
    return gcd2(q%p,p);
}

int main(){
    ll N;cin>>N;
    vll A(N);
    for(ll i=0;i<N;i++)cin>>A[i];
    sort(ALL(A));
    vector<ll> D(1000001);
    for(ll i=1;i<=1000000;i++)D[i]=i;
    for(ll i=2;i<=1000000;i++){
        for(ll j=i;j<=1000000;j+=i){
            D[j]=min(D[j],i);
        }
    }

    bool pc=true;
    vector<bool> used(1000001,false);
    for(int i=0;i<N;i++){
        ll v=A[i];
        ll chokuzen=-1;
        while(v>1){
            if(used[D[v]]==false){
                used[D[v]]=true;chokuzen=D[v];v/=D[v];
            }else if(chokuzen==D[v]){
                v/=D[v];
            }else{
                pc=false;break;
            }
        }
        if(pc==false)break;
    }

    
    if(pc){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    ll gcd=gcd2(A[0],A[1]);
    for(ll i=2;i<N;i++){
        gcd=gcd2(gcd,A[i]);
    }
    if(gcd==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}

Measured memory_bytes: 19092
import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))

a = np.array(a)
a.sort()

nega = a[a<0]
zero = a[a==0]
posi = a[a>0]

l = -10**18-1
r = 10**18+1
while r - l > 1:
   mid = (r+l)//2
   cnt = 0
   if mid >= 0:
      cnt += len(zero)*n
   cnt += a.searchsorted(mid//posi, side='right').sum()
   cnt += (n - a.searchsorted(-(-mid//nega), side='left')).sum()
   cnt -= np.count_nonzero(a*a <= mid)
   cnt //=2
   if cnt >= k:
      r = mid
   else:
      l= mid

print(r)


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

int main() {
    int n;
    cin >> n;
    vector<int> t(n + 1);
    vector<pair<int, int>> p(n + 1);
    t.at(0) = 0;
    p.at(0) = make_pair(0, 0);
    rep(i, n) cin >> t.at(i + 1) >> p.at(i + 1).first >> p.at(i + 1).second;
    bool flag = true;
    rep(i, n) {
        int dis = abs(p.at(i + 1).first - p.at(i).first) + abs(p.at(i + 1).second - p.at(i).second);
        int time = t.at(i + 1) - t.at(i);
        if(dis > time || (dis + time) % 2) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main(){
  long n;
  cin >> n;
  long ans = 0;
  long u,v;
  rep(i,n-1){
    cin >> u >> v;
    if(u>v)swap(u,v);
    ans += (i+1)*(n-i) - u*(n-v+1);
  }
  ans += n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
   int n;
   int ans=111;
   cin >> n;
   while(ans<n) ans+=111;
   cout << ans <<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007
typedef vector<vector<int>> Graph; 
int main(){
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i,H) cin >> S[i];
    Graph L(H,vector<int>(W)),R(H,vector<int>(W)),U(H,vector<int>(W)),D(H,vector<int>(W));
    rep(i,H){
        if(S[i][0]=='.'){
            L[i][0]=1;
        }
        for(int j=1;j<W;j++){
            if(S[i][j]=='.'){
                L[i][j] = L[i][j-1] + 1;
            }else{
                L[i][j] = 0;
            }
        }
        if(S[i][W-1]=='.'){
            R[i][W-1]=1;
        }
        for(int j=W-2;j>=0;j--){
            if(S[i][j]=='.'){
                R[i][j] = R[i][j+1] + 1;
            }else{
                R[i][j] = 0;
            }
        }
    }
    rep(i,W){
        if(S[0][i]=='.'){
            U[0][i]=1;
        }
        for(int j=1;j<H;j++){
            if(S[j][i]=='.'){
                U[j][i] = U[j-1][i] + 1;
            }else{
                U[j][i] = 0;
            }
        }
        if(S[H-1][i]=='.'){
            D[H-1][i]=1;
        }
        for(int j=H-2;j>=0;j--){
            if(S[j][i]=='.'){
                D[j][i] = D[j+1][i] + 1;
            }else{
                D[j][i] = 0;
            }
        }
    }

    int ans = 0;
    rep(i,H)rep(j,W){
        int tmp;
        //cout << L[i][j] << " " << R[i][j] << " " << U[i][j] << " " << D[i][j] << endl;
        tmp = L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67200