akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	string s;cin>>s;
	int n=s.size();
	int cnt1=0,cnt2=0;
	int c=0;

	rep(i,n){
		if(s[i]-'0'!=c) cnt1++;
		c=1-c;
	}
	c=1;
	rep(i,n){
		if(s[i]-'0'!=c) cnt2++;
		c=1-c;
	}
	cout<<min(cnt1,cnt2)<<endl;


	return 0;
}



Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<math.h>
#include<stdio.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > b * 2) {
		cout << a - b * 2 << endl;
	}
	else {
		cout << "0" << endl;
	}
}

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

using namespace std;

class team{
public:
	int time;
	int ac;
	vector<int> wa;
	int pe;
	int id;

	void print() const{
		cout<<id<<" "<<ac<<" "<<pe<<endl;
	}

};

bool operator<(const team& t1 , const team& t2){
	if(t1.ac != t2.ac) return t1.ac>t2.ac;
	if(t1.pe != t2.pe) return t1.pe<t2.pe;
	else		   return t1.id<t2.id;
};

int main()
{

	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<team> T(t);
		for(int i=0;i<t;i++){
			T[i].wa=vector<int>(p,0);
			T[i].id=i+1;
		}

		for(int i=0;i<r;i++){
			int tID,pID,time;
			string me;

			cin>>tID>>pID>>time>>me;
			tID--; pID--;

			if(me=="CORRECT"){
				T[tID].ac++;
				T[tID].pe+=(T[tID].wa[pID]*1200)+time;
			}else{
				T[tID].wa[pID]++;
			}

		}

		sort(T.begin(),T.end());
		for(int i=0;i<t;i++) T[i].print();

	}

	return 0;
}

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

int main() {

  int A;
  cin >> A;
  if ( A/1000 == (A % 1000)/100 && A/1000 == (A % 100)/10) {
    cout << "Yes" << endl;
  }
  else if ( (A % 1000)/100 == (A % 100)/10 && (A % 1000)/100 == A % 10) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
long long M = 1e9+7;
long long power(long long a, long long p)
{
    if(p==0) return 1;
    long long ans= power(a,p/2);
    ans =(ans * ans) % M;
    if(p%2) ans = (ans*a) % M;
    return ans;
}

bool isPrime(long long n)
{
    if (n <= 1)
        return false;
    for (long long i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
long long SieveOfEratosthenes(long long n, long long a)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (long long p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (long long i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (long long p=2; p<=n; p++)
       if (prime[p])
       {
           if(a%p==0)
           {
               return (a-p);
           }
       }
}
long long nCr(int n, int r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}
int vis[51][51];
int x[]={1,0,0,-1};
int y[]={0,1,-1,0};
void dfs_visit(long long n,long long a, long long b)
{
    vis[a][b]=1;
    for(int i=0; i<4; i++)
    {

        int p=a+x[i];
        int q=b+y[i];
        if(p>=0 && p<n && q>=0 && q<n && vis[p][q]==0)
        {
           // cout<<p<<" "<<q<<endl;
            vis[p][q]=1;
            dfs_visit(n,p,q);
        }
    }
}

int main()
{
    IOS;
    long long a,b,c,d,e,h,l,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
   // vector<string>vs;
   // vector<string>vs1;
    vector<char>vc;
    //map<long long,long long>mp;
    map<char,int>mp1;
    //set<long long>s;
    set<long long>s1;
    //list<char>li;
    queue<long long> q;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
   // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    //int x[]={1,1,1,0,0,-1,-1,-1};
    //int y[]={0,1,-1,1,-1,1,-1,0};
    //int x[]={1,0,0,-1};
    //int y[]={0,1,-1,0};
    cin>>a>>b;
    for(int i=0; i<b; i++)
    {
        cin>>c;
        sum+=c;
    }
    if(sum>a)
    {
        cout<<-1<<endl;
    }
    else cout<<a-sum<<endl;
    return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }






int main(int argc, char* argv[])
{
	for (;;) {
		int H, W;
		cin >> H >> W;
		if (cin.fail()) break;

		int C[10][10]{};
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				cin >> C[i][j];
			}
		}
		bool updated;
		do {
			updated = false;
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					for (int k = 0; k < 10; k++) {
						if (C[i][k] + C[k][j] < C[i][j]) {
							C[i][j] = C[i][k] + C[k][j];
							updated = true;
						}
					}
				}
			}
		} while (updated);
		int ans = 0;
		for (int i = 0; i < H * W; i++) {
			int A;
			cin >> A;
			if (abs(A) != 1) {
				ans += C[A][1];
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < e; i++)
#define rep(i, n) REP(i, 0, n)

static const int MAX_N = 1000000;
static const int MAX_P = 2000000000;

int N, M, Q, S[MAX_N];

map<int, int> PM; // point map
vector<int> ATI, ATV;
vector<int> MS;
set<int> R;
vector<pair<int, int> > seg;

void init(){
  MS.clear();
  for ( set<int>::iterator it = R.begin(); it != R.end(); it++ ){
    MS.push_back(S[*it]);
  }
  sort(MS.begin(), MS.end());
}

int getCount(int r){
  seg.clear();

  if ( MS.size() > 0 ) seg.push_back(make_pair(MS[0]-r, MS[0]));

  for ( int i = 1; i < MS.size(); i++ ){
    int b = MS[i]-r;
    int e = MS[i];
    if ( b <= seg[seg.size()-1].second){
      seg[seg.size()-1].second = max(seg[seg.size()-1].second, e);
    } else {
      seg.push_back(make_pair(b, e));
    }
  }

  int cnt = 0;

  for ( int i = 0; i < seg.size(); i++ ){
    int a = distance(ATI.begin(), lower_bound(ATI.begin(), ATI.end(), max(0, seg[i].first) )) - 1;
    int b = distance(ATI.begin(), lower_bound(ATI.begin(), ATI.end(), max(0, seg[i].second) ));
    cnt += ATV[b] - ATV[a];
  }

  return cnt;
}

void bsearch(int X){
  init();

  int l = 0;
  int r = MAX_P+2000000;
  int m;
  int diff = r - l;
  int cnt = getCount(r);
  if ( cnt < X ){
    cout << "NA" << endl;
    return;
  }
  bool ok = false;
  for (int i = 0; i < 200; i++ ){
    m = (l+r)/2;
    cnt = getCount(m);
    if ( cnt >= X ){
      r = m;
      ok = true;
    } else if ( cnt < X ){
      l = m;
    }
    if ( diff == l - r ) break;
    diff = l - r;
  }
  cout << r << endl;
}

main(){
  scanf("%d %d", &N, &Q);

  MS.clear();
  PM.clear();
  ATI.clear();
  ATV.clear();

  rep(i, N) {
    scanf("%d", &S[i]);
    PM[S[i]]++;
  }

  bool isR[MAX_N];
  rep(i, N) isR[i] = false;

  M = 0;

  ATI.push_back(-1);
  ATV.push_back(0);
  int pre = 0;
  for ( map<int, int>::iterator it = PM.begin(); it != PM.end(); it++ ){
    ATI.push_back((*it).first);
    ATV.push_back((*it).second + ATV[pre++]);
  }

  string com;
  int x;
  rep(i, Q){
    cin >> com >> x;
    if ( com[0] == 'C' ){
      bsearch(N - x);
    } else if ( com[0] == 'R' ){
      x--; // 0 base
      R.erase(R.find(x));
      M--;
    } else if ( com[0] == 'A' ){
      x--; // 0 base
      R.insert(x);
      M++;
    }
  }
}

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

int main() {
  string S;
  cin >> S;
  if (S=="RRS"||S=="SRR") {
    cout << 2 << endl;
  }
  if (S=="RSS"||S=="RSR"||S=="SRS"||S=="SSR") {
    cout << 1 << endl;
  }
  if (S=="RRR") {
    cout << 3 << endl;
  }
  if (S=="SSS") {
    cout << 0 << endl;
  }
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> q(N);
    vector<int> s(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        s[i] = p[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> q[i];
    }

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

    int cnt = 0;
    int pnum = -1;
    int qnum = -1;
    do
    {
        cnt++;
        if (p == s)
            pnum = cnt;
        if (q == s)
            qnum = cnt;

    } while (next_permutation(s.begin(), s.end()));

    cout << abs(pnum - qnum) << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
//mapを使う
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> p;
    rep(i,n){
        cin>>a[i];
        p[a[i]]++;
    }
    int64_t sum=0;
    for(auto c:p){
        int v = c.first;//値
        int s = c.second;//数
        if(s>=v){
            sum += s-v;
        }
        else{
            sum += s;
        }
    }
    cout<<sum<<endl;
}

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

int main(){
    string s; cin >> s;
    int n = s.size();
    if(s[0] == s[n-1]){
        if(n%2) cout << "Second" << endl;
        else cout << "First" << endl; 
    }else{
        if(n%2) cout << "First" << endl;
        else cout << "Second" << endl;
    }
}

Measured memory_bytes: 3756
import java.util.Scanner;
class Main{
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
 int a=scan.nextInt();
  int b=scan.nextInt();
  int c=scan.nextInt();
  int d[]=new int[a];
  for(int i=0;i<a;i++)d[i]-=c;
  for(int i=0;i<c;i++){
  int x=scan.nextInt();
  d[x-1]++;
  }
  for(int i=0;i<a;i++){
  if(d[i]>-1*b){System.out.println("Yes");}
  else{System.out.println("No");}
  }
}
}


Measured memory_bytes: 61300
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAXN = 3010; // Número máximo de ítens
const int MAXW = 3010; // Número máximo de peso carregado
int mt[MAXN+1][MAXW+1]; // Matríz global é iniciada com zeros

int knapSack(int w, int wt[], int val[], int n){
	for(int i=1; i<=n; i++){
		for(int j=1; j<=w; j++){
			if(j==w)
				mt[i][j] = max(val[i-1]+mt[i-1][j-1], mt[i-1][j]);
			else if(wt[i-1]<=j)
				mt[i][j] = max(val[i-1]+mt[i-1][j-wt[i-1]], mt[i-1][j]);
			else
				mt[i][j] = mt[i-1][j];
		}
	}
	return mt[n][w];
}
int32_t main(){
	ios::sync_with_stdio(0);
	int n, t;
	cin >> n >> t;
	int wt[n], val[n];
	vector<ii> vs(n);
	for(auto &x:vs)
		cin >> x.ff >> x.ss;
	sort(all(vs));
	for(int i=0; i<n; ++i)
		wt[i]=vs[i].ff, val[i] = vs[i].ss;

	int ans = knapSack(t, wt, val, n);
	cout << ans << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll x;
    cin >> x;

    if(x <= 599) cout << 8;
    if(600 <= x && x <= 799) cout << 7;
    if(800 <= x && x <= 999) cout << 6;
    if(1000 <= x && x <= 1199) cout << 5;
    if(1200 <= x && x <= 1399) cout << 4;
    if(1400 <= x && x <= 1599) cout << 3;
    if(1600 <= x && x <= 1799) cout << 2;
    if(1800 <= x) cout << 1;
}

Measured memory_bytes: 3648
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

import bisect

abc="abcdefghijklmnopqrstuvwxyz"

def main():

    n,m=mi()
    a=li()
    s=sum(a)
    if s>n:
        print(-1)
    else:
        print(n-sum(a))

        
# region fastio

 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main()

Measured memory_bytes: 70744
package main

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

// Circle
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	a, _ := strconv.ParseFloat(sc.Text(), 64)
	fmt.Printf("%f %f\n", a*a*math.Pi, 2*a*math.Pi)
}



Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lld;

#define forn(i,n) for(ll i = 0;i<n;i++)
#define forne(i,j,n) for(ll i = j;i<n;i++)
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ll INF = 1000000001;
const ll N = 100001;
const lld PI = 3.141593;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

lld powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}

// ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
// bool valid(ll i, ll j) {
// 	return i >= 1 && i <= n && j >= 1 && j <= m; 
// }
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll a[N],b[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];


int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n,k;
cin>>n>>k;
ll a[n];
forn(i,n) cin>>a[i];
sort(a,a+n);
ll s = 0;
forn(i,k){
	s+=a[i];
}
cout<<s<<endl;


}

Measured memory_bytes: 3664
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=1e7+69, INF=2e9+6969;

ll n,lp[R],dp[R],ans;
vector <ll> p;
ll wo(ll a, ll p)
{
	while(a%p==0) a/=p;
	return a;
}
int main()
{
	scanf("%lld", &n);
	for(int i=2;i<=n;++i)
	{
		if(lp[i]==0)
		{
			lp[i]=i;
			p.pb(i);
		}
		for(int j=0;j<p.size() && p[j]*i<=n && p[j]<=lp[i];++j)
		{
			lp[i*p[j]]=p[j];
		}
	}
	dp[1]=1;
	for(ll i=2;i<=n;++i)
	{
		dp[i]=dp[i/lp[i]]+dp[wo(i,lp[i])];
		ans+=dp[i]*i;
		//  printf("%lld ", dp[i]);
	}
	printf("%lld\n", ans+1);
	//  puts("");
	return 0;
}


Measured memory_bytes: 164948
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    ans = 0

    if n % 2 == 1:
        print(ans)
    else:
        division = 10

        while division <= n:
            ans += n // division

            division *= 5

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  
  
  int N, best = 0; cin >> N;
  vector<int> candy[2];

  for(int r = 0; r < 2; ++r){
    for(int c = 0; c < N; ++c){
      int x; cin >> x;
      candy[r].PB(x);
    }
  }

  for(int c = 1; c < N; ++c) candy[0][c] += candy[0][c - 1];
  for(int c = N - 2; c >= 0; --c) candy[1][c] += candy[1][c + 1];

  for(int c = 0; c < N; ++c){
    max_self(best, candy[0][c] + candy[1][c]);
  }

  cout << best << "\n";

  return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

int main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;

  ANS(a[k - 1]);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N=200005;

bool reach[MAX_N];
vector<int> graph[MAX_N];

int main(){
  int N,M;
  cin >> N >> M ;
  fill(reach,reach+N,false);
  rep(i,M){
    int a,b;
    scanf("%d%d",&a,&b);
    a--; b--;
    graph[a].pb(b); graph[b].pb(a);
    if(a==N-1) reach[b]=true;
    else if(b==N-1) reach[a]=true;
  }
  for(auto x:graph[0]){
    if(reach[x]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    vector<int> num(100);
    vector<int> ans(100);
    for (int i=0; i<100; i++) {
        num[i] = i+1;
        ans[i] = 0;
    }
    for (int i=0; i<100; i++) {
        if (a % num[i] == 0 && b % num[i] == 0) {
            ans[i] = num[i];
        }
    }

    sort(ans.begin(), ans.end());
    cout << ans[100-k] << endl;

    return 0;
}

Measured memory_bytes: 256
## キューとスタックhttp://ailaby.com/deque/
## https://qiita.com/drken/items/6a95b57d2e374a3d3292
from collections import deque
def main():
    K = int(input())
    cnt = 0
    mod = 10
    
    q = deque([])
    for i in range(1, 10):
        q.append(i)
    
    while cnt < K:
        x = q.popleft()
        cnt += 1
        if x%mod == 0:
            q.append(10*x + (x%mod))
            q.append(10*x + (x%mod)+1)
        elif x%mod == 9:
            q.append(10*x + (x%mod) -1)
            q.append(10*x + (x%mod))
        else:
            q.append(10*x + (x%mod)-1)
            q.append(10*x + (x%mod))
            q.append(10*x + (x%mod+1))
    print(x)
main()

Measured memory_bytes: 11920
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    long int n;
    cin >> n;
    string s[n];
    rep(i, n) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s, s + n);
    long int ans = 0;
    long int num = 1;
    rep(i, n-1) {
        if (s[i] == s[i+1]){
            num++;
        }else{
            ans += (num * (num - 1)) / 2;
            num = 1;
        }
    }
    ans += (num * (num - 1)) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 7296
#include<stdio.h>

int main()
{
	int a,b,p,c,d,q,i;
	float x,y;
	while(scanf("%d %d %d %d %d %d",&a,&b,&p,&c,&d,&q)!=EOF){
		x=(float)(p*d-b*q)/(a*d-b*c);
		y=(float)(a*q-p*c)/(a*d-b*c);
		if(-0.0005<x &&x<=0)
		    x=0;
		if(-0.0005<y &&y<=0)
		    y=0;
		printf("%.3f %.3f\n",x,y);
	}	
	return 0;
}

Measured memory_bytes: 632
/*
	构造
	n为2的幂时显然无解 
	发现n大于3并且为奇数时很容易可以构造出一组解 
	每次增加两个时，两两配对即可
	如果最后还剩一个数也可以很容易配出来 
*/
#include <bits/stdc++.h>

using namespace std;

int n;

inline void link(int u, int v) {
	printf("%d %d\n", u, v);
}

int main() {
	scanf("%d", &n);
	if(n < 3 || (n & -n) == n) {
		puts("No");
	} else {
		puts("Yes");
		link(1, 2);
		link(2, 3);
		link(3, 1 + n);
		link(1 + n, 2 + n);
		link(2 + n, 3 + n);
		for(int i = 4; i < n; i += 2) {
			link(1, i);
			link(i, i + 1);
			link(1, i + 1 + n);
			link(i + 1 + n, i + n);
		}
		if(~n & 1) {
			int x = n;
			x ^= 1;
			for(int i = 2; i <= n; ++i) {
				int r = x ^ i;			
				if(r != 1 && r < n) {
					link(n, (i & 1 ? i + n : i));
					link(n + n, (r & 1 ? r + n : r));
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2304
<?php
    fscanf(STDIN,'%d %d %d',$a,$b,$n);
    
    if($n >= $b){
        $ans = floor(($a * ($b-1)) / $b) - ($a * floor(($b-1) / $b));
    }else{
        $ans = floor(($a * $n) / $b) - ($a * floor($n / $b));
    }

    echo $ans . PHP_EOL;
?>

Measured memory_bytes: 16156
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



class weighted_unionfind
{
private:
    vector<long long> par;
    vector<long long> rank;
    vector<long long> diff_weight;
public:
    weighted_unionfind(long long n);
    long long find(long long x);
    void unite(long long x, long long y, long long w);
    bool same(long long x, long long y);
    void swap(long long *x, long long *y);
    long long weight(long long x);
    long long diff(long long x, long long y);
};

// 初期化
weighted_unionfind::weighted_unionfind(long long n){
    for (long long i = 0; i < n; i++) {
        par.push_back(i);
        rank.push_back(0);
    }
    diff_weight.resize(n, 0);
}

// 木の根を求める
long long weighted_unionfind::find(long long x) {
    if (par[x] == x) {
        return x;
    }
    else {
        long long t = find(par[x]);
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = t;
    }
}

void weighted_unionfind::swap(long long *x, long long *y){
    long long tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

// xとyの属する集合を併合
void weighted_unionfind::unite(long long x, long long y, long long w) {
    w += weight(x);
    w -= weight(y);
    x = find(x);
    y = find(y);
    if (x == y)return;
    
    if (rank[x] < rank[y]) {
        swap(&x, &y);
        w = -w;
    }
    if(rank[x] == rank[y]){
        rank[x]++;
    }
    
    par[y] = x;
    diff_weight[y] = w;
}

// xとyが同じ集合に属していたらtrue
bool weighted_unionfind::same(long long x, long long y) {
    return find(x) == find(y);
}

long long weighted_unionfind::weight(long long x){
    find(x);
    return diff_weight[x];
}

long long weighted_unionfind::diff(long long x, long long y){
    return weight(y) - weight(x);
}



int main() {
    ll n, m;
    cin >> n >> m;
    
    weighted_unionfind uni(n);
    
    REP(i, m){
        ll l, r, d;
        cin >> l >> r >> d;
        l--;r--;
        if(uni.same(l, r)){
            ll diff = uni.diff(l, r);
            if(diff != d){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            uni.unite(l, r, d);
        }
    }
    
    cout << "Yes" << endl;
}


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

int main() {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << a[n - 1];

}

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

int asc(const void *lhs, const void *rhs) {
  return *(int *)lhs - *(int *)rhs;
}

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

  int has_sweets_count[sweets_kind_count];
  int sweets_kind = 0;

  int sunuke_array[9999];

  int i = 0;
  while (sweets_kind < sweets_kind_count) {
    scanf("%d", has_sweets_count + sweets_kind);
    for (int j = 0; j < has_sweets_count[sweets_kind]; j += 1) {
      scanf("%d", sunuke_array + i);
      i += 1;
    }
    sweets_kind += 1;
  }
  qsort(sunuke_array, i, sizeof(*sunuke_array), asc);

  int sunuke_genuine_count = 0;
  for (short k = 0; k < i; k += 1) {
    if (sunuke_array[k] != sunuke_array[k + 1]) {
      sunuke_genuine_count += 1;
    }
  }
  int output = sunuke_count - sunuke_genuine_count;
  printf("%d", output);
  printf("%c", '\n');
  return 0;
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> p(n),q(n),r(n);
    for(auto&i:p) in>>i,--i;
    for(auto&i:q) in>>i,--i;
    fr(i,n) r[i]=i;
    int a{},b{},c{};
    do{
        bool f=true,g=true;
        fr(i,n){
            if(p[i]!=r[i]) f=false;
            if(q[i]!=r[i]) g=false;
        }
        if(f) a=c;
        if(g) b=c;
        ++c;
    }while(next_permutation(r.begin(),r.end()));
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 998244353;
 
int dx[]={-1, 0, 1, 0,1,-1,1,-1};
int dy[]={0, -1, 0, 1,1,-1,-1,1};




int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 




queue<int>q;
vector<int>v;
int k;
cin>>k;
for(int i=1;i<10;i++)
q.push(i);

while(1){
    int x=q.front();
    q.pop();
    if(x>0)v.push_back(x);
    if(v.size()>=100000)break;
    int last=x%10;
    
    for(int i=-1;i<=1;i++)
    {
        
        int j=last+i;
        if(j<=9&&j>=0)
        {
            q.push(10ll*x+j);
        }
    }
}

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

cout<<v[k-1]<<"\n";






}


Measured memory_bytes: 2676
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()
N = len(S)
K = INT()

min_s = min(S)
B = [s for s in S]
B.sort()
# print(B)

cursol = 0
min_s = 'ATCODER'
cand = []
while len(cand) < K:
	# print(cursol)
	if min_s == B[cursol]:
		cursol += 1
		continue
	else:
		min_s = B[cursol]
	for i,s in enumerate(S):
		if s == min_s:
			for j in range(i+1, i+1+K):
				if not cand.count(S[i:j]): cand.append(S[i:j])
	cursol += 1

cand.sort()
# print(cand)

s = min(S)
cnt = 0
for c in cand:
	cnt += 1
	if cnt == K:
		print(c)
		break

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;

  ll ans = INF;
  for(ll ab=0;ab<3e5;ab+=2){
    ll needx = x-ab/2;
    ll needy = y-ab/2;
    ll tmp = ab*c;
    if(needx>0)tmp+=needx*a;
    if(needy>0)tmp+=needy*b;
    if(chmin(ans,tmp)){
      //dump(ab,needx,needy);
    }
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> v;
  REP(i, n) {
    int a;
    cin >> a;
    int b = upper_bound(ALL(v), a, [](int l, int r) { return l > r; }) - v.begin();
    if (b == v.size()) v.push_back(a);
    else v[b] = a;
  }
  cout << v.size() << endl;
  return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll a,b,x;
	scanf("%lld %lld %lld",&a,&b,&x);

	ll ans = b/x-a/x;
	if(a%x == 0){

		ans++;
	}

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

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
typedef long long int ll;



int main()
{
	ll  i, j, k, l, m, sum, flag,ans,N;
	sum = 0;
	flag = 0;
	cin >> N;
	ans = 0;
	vector<ll>A(N);
	vector<ll>B;
	vector<ll>C;
	vector<pair<ll,ll>>D(N);
	REP(i, 0, N) {
		cin >> A[i];
		D[i].first = A[i];
		D[i].second = i;
	}
	sort(D.begin(), D.end());
	ans = 0;
	REP(i, 0, N) {
		if (i % 2 != D[i].second % 2) {
			ans++;
		}
	}

	output(ans/2);


	return 0;
}



Measured memory_bytes: 2560
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
#from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


h,w=mdata()
ch,cw=mdata()
dh,dw=mdata()
ch,cw,dh,dw=ch-1,cw-1,dh-1,dw-1
S=[data() for i in range(h)]
steps=[(0,1),(1,0),(-1,0),(0,-1)]
dist=[[INF]*w for i in range(h)]
dist[ch][cw]=0

queue = [(0, (ch, cw))]
while queue:
    path_len, (u, v) = heappop(queue)
    if path_len == dist[u][v]:
        for i in range(-2, 3):
            for j in range(-2, 3):
                if 0 <= u + i < h and 0 <= v + j < w and S[u + i][v + j] == '.':
                    if (i,j) in steps:
                        if path_len < dist[u+i][v+j]:
                            dist[u+i][v+j] = path_len
                            heappush(queue, (path_len, (u+i, v+j)))
                    else:
                        if 1 + path_len < dist[u + i][v + j]:
                            dist[u + i][v + j] = 1 + path_len
                            heappush(queue, (1 + path_len, (u + i, v + j)))


if dist[dh][dw]!=INF:
    out(dist[dh][dw])
else:
    out(-1)


Measured memory_bytes: 130748
/*
[abc139] D - ModSum
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int N;

ll solve() {
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ans += i;
    }

    return ans;
}

int main() {
    cin >> N;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5+7;
int arr[N];

int main(void)
{
    int n,m,i,j;
    int a,b;
    while (~scanf("%d%d",&n,&m))
    {
        CLR(arr,0);
        for (i=0; i<m; ++i)
        {
            scanf("%d%d",&a,&b);
            ++arr[a];
            ++arr[b];
        }
        int flag=1;
        for (i=1; i<=n; ++i)
        {
            if(arr[i]&1)
            {
                flag=0;
                break;
            }
        }
        puts(flag?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long 
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std ;

int32_t main ()
{

    FIO

    int n ;
    cin >> n ;
    vector < int > nums ;
    for ( int i = 0 ; i < n ; i++ )
    {
        int val ;
        cin >> val;
        nums.push_back(val) ;
    }
    if ( n == 1 )
    {
        cout<<"0\n";
        return 0 ;
    }
    int dd = abs ( nums[0] - nums[1] ) ;
    if ( n == 2 )
    {
        cout<<dd<<"\n";
        return 0 ;
    }
    vector < int > dp ( n ,  0 ) ;
    dp[1] = dd ; 
    for ( int i = 2 ; i < n ; i++ )
    {
        int val1 = abs(nums[i] - nums[i-1] ) ;
        int val2 = abs(nums[i] - nums[i-2] ) ;
        dp[i] = min( val1 + dp[i-1] , val2 + dp[i-2] ) ;
    }

    cout<<dp[n-1]<<"\n";

    return 0 ; 
}

Measured memory_bytes: 5032
#include <stdio.h>

int main(void){
	int a[10], b[10], c[10];
	int i, j, n, b_num, c_num, flag;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		b_num = c_num = flag = 0;
		scanf("%d %d %d %d %d %d %d %d %d %d", 
			&a[0], &a[1],
			&a[2], &a[3], 
			&a[4], &a[5], 
			&a[6], &a[7], 
			&a[8], &a[9]
		);
		for(j = 0; j < 10; j++){
			if(b_num == 0){
				b[b_num] = a[j];
				b_num++;
			}else if(a[j] > b[b_num-1]){
				b[b_num] = a[j];
				b_num++;
			}else if(c_num == 0){
				c[c_num] = a[j];
				c_num++;
			}else if(a[j] > c[c_num-1]){
				c[c_num] = a[j];
				c_num++;
			}else {
				flag = 1;
				break;
			}
		}
		if(flag){
			printf("NO\n");
		}else {
			printf("YES\n");
		}
	}
	return 0;
}

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

int c[3][3];
int a[3];
int b[3];

void solve() {
  int a_0, a_1, a_2;
  for(a_0 = 0; a_0 <= 100; a_0++) {
    for(a_1 = 0; a_1 <= 100; a_1++) {
      for(a_2 = 0; a_2 <= 100; a_2++) {
        b[0] = c[0][0] - a_0;
        b[1] = c[1][1] - a_1;
        b[2] = c[2][2] - a_2;
        if (a_0 + b[1] == c[0][1] && a_0 + b[2] == c[0][2] && a_1 + b[0] == c[1][0] && a_1 + b[2] == c[1][2] && a_2 + b[0] == c[2][0] && a_2 + b[1] == c[2][1]) {
          printf("Yes");
          return;
        }
      }
    }
  }
  printf("No");
  return;
}

int main() {
  int i;
  for(i = 0; i < 3; i++) {
    scanf("%d %d %d", &c[i][0], &c[i][1], &c[i][2]);
  }
  solve();
  return 0;
}

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

using namespace std;

int main(){
    
    long long int i,j,k,n,m;
    cin>>n;
    int a[n],b[n],c[n];
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n][3];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++){
            dp[i][j]=-100;
        }
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            if(j==0){
                dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+b[i+1]);
                dp[i+1][j+2]=max(dp[i+1][j+2],dp[i][j]+c[i+1]);
            }
            if(j==1){
                dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+a[i+1]);
                dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+c[i+1]);
            }
             if(j==2){
                dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+b[i+1]);
                dp[i+1][j-2]=max(dp[i+1][j-2],dp[i][j]+a[i+1]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
    return 0;
}

Measured memory_bytes: 2560
n,m = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(n)]
chkpoints = [list(map(int, input().split())) for _ in range(m)]
dist = 0
ans = 0
for student in students:
  min_dist = 1000000000
  for i in range(m):
    dist = abs(student[0]-chkpoints[i][0])+abs(student[1]-chkpoints[i][1])
    if dist < min_dist:
      min_dist = dist
      ans = i+1
  print(ans)

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

#define int long long
typedef long long ll;
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int l, r;
    cin >> l >> r;
    for (int i = l; i <= r; i++) {
        if (i % 2019 == 0)return cout << 0 << endl, 0;
    }
    int ans = 2020;
    for (int i = l; i <= r; i++) {
        for (int j = i + 1; j <= r; j++) {
            ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def fact(n):
    num = n
    cnt = [0]*(n+1)
    ans = 1
    for i in range(2, n+1):
        while num % i == 0:
            cnt[i] += 1
            num /= i
    for i in range(2, n+1):
        ans *= cnt[i] + 1
    return ans

n = int(input())

res = 0
for i in range(1, n+1):
    if i % 2 == 1 and fact(i) == 8:
        res += 1
print(res)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>

int main(int argc, char *argv[]){
    std::string string;
    std::cin >> string;
    unsigned int N = string.size();
    static unsigned long int mod13Count[100001][13];
    unsigned long int mod = 1000000007;
    int i;
    mod13Count[0][0] = 1;
    int digit;
    int oldNumberMod13, newNumberMod13;
    for(i=0; i<N; ++i){
        digit = string[i];
        if(digit != '?'){
            digit = digit - '0';
            for(oldNumberMod13=0; oldNumberMod13<13; ++oldNumberMod13){
                newNumberMod13 = (oldNumberMod13*10 + digit) % 13;
                mod13Count[i+1][newNumberMod13] += mod13Count[i][oldNumberMod13];
                mod13Count[i+1][newNumberMod13] %= mod;
            }
        }else{
            for(digit=0; digit<10; ++digit){
                for(oldNumberMod13=0; oldNumberMod13<13; ++oldNumberMod13){
                    newNumberMod13 = (oldNumberMod13*10 + digit) % 13;
                    mod13Count[i+1][newNumberMod13] += mod13Count[i][oldNumberMod13];
                    mod13Count[i+1][newNumberMod13] %= mod;
                }
            }
        }
    }
    std::cout << mod13Count[N][5] << std::endl;
    return 0;
}


Measured memory_bytes: 10624
n,k=map(int,input().split())
a = list(map(int,input().split()))
di=10**9+7
a.sort()

maxl = a[k-1:]
minl = a[:n-k+1]

kai = [i for i in range(n+1)]
gya = [i for i in range(n+1)]
kai[0]=1
gya[0]=1
for i in range(1,n+1):
    kai[i]=(kai[i-1]*kai[i])%di

for i in range(n+1):
    gya[i]=pow(gya[i],di-2,di)

for i in range(1,n+1):
    gya[i]=(gya[i]*gya[i-1])%di

for i in range(n-k+1):
    tmp=(((kai[k-1+i]*gya[k-1])%di)*gya[i])%di
    maxl[i]=(maxl[i]*tmp)%di

for i in range(n-k+1):
    tmp = (((kai[n-1-i]*gya[k-1])%di)*gya[n-i-k])%di
    minl[i] = (minl[i]*tmp)%di

su=0
for i in range(n-k+1):
    su = (su+maxl[i])%di
    su = (su-minl[i])%di
print(su)


Measured memory_bytes: 65704
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;
int uf[100000],rk[100000],w[100000];

void ini(){
    for(int i=0;i<100000;i++){
        uf[i]=i;
        rk[i]=0;
    }
}
int root(int x){
    return uf[x]==x ? x:(uf[x]=root(uf[x]));
}

void connect(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y) return;
    if(rk[x]<rk[y]) {
        uf[x]=y;
    }else{
        uf[y]=x;
        if(rk[x]==rk[y]) rk[x]++;
    }
}
int main() {
    // insert code here...
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    ini();
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        connect(x,y);
    }
    //cout<<uf[1]<<endl;
    vector<vector<int>> comp(n);
    int counter=0;
    for(int i=0;i<n;i++){
        //cout<<uf[i]<<endl;
        comp[root(i)].push_back(w[i]);
    }
    for(int i=0;i<n;i++){
        if(!comp[i].empty()) counter++;
        }
    
    if(counter==1){
        cout<<0<<endl;
        return 0;
    }
    //cout<<counter<<endl;
    //cout<<v[0]<<v[1]<<endl;
    //cout<<root(0)<<endl;
    int choose=2*(counter-1);
    long long sum=0;
    vector<int> other;
    for(int i=0;i<n;i++){
        if(!comp[i].empty()){
            sort(comp[i].begin(),comp[i].end());
            sum+=comp[i][0];
            choose--;
            for(int j=1;j<comp[i].size();j++){
                other.push_back(comp[i][j]);
        }
    }
    }
    if(choose>other.size()){
        cout<<"Impossible"<<endl;
        return 0;
    }
    sort(other.begin(),other.end());
    for(int i=0;i<choose;i++){
        sum+=other[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6912
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
  
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                if i > 0 and i < H - 1 and j > 0 and j < W - 1: bar += "."
                else: bar += "#"
            if i < H - 1: print(bar)
            else: print(bar + '\n')
  
if __name__ == "__main__":
    main()


Measured memory_bytes: 5620
import sys
import numpy as np
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n = Ii()
a = Li()
b = [0]*(n+1)
bm = [0]*(n+1)
b[0] = 1
if a[0] > 1:
  print(-1)
  exit(0)
bm[-1] = a[-1]
for i in range(1,n+1):
  bm[-1-i] = bm[-i]+a[-i-1]
  b[i] = (b[i-1]-a[i-1])*2
b = np.array(b)
bm = np.array(bm)
b = np.amin([[b],[bm]], axis=0)
if a[-1] != b[-1,-1]:
  print(-1)
  exit(0)
if np.any(b <= 0):
  print(-1)
  exit(0)
print(np.sum(b))

Measured memory_bytes: 698672
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [W, H, x, y] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2]), long(input_raw[3])]
    if (H /2 == y) and  (H % 2 == 0)  and (W/2 == x) and (W % 2 == 0):
        ans2 = 1
    else:
        ans2 = 0

    #if(W * y == H * x or y * W ==  (-H * x) + W * H):
    print "%20.15f %d" % (float(H)/2.0 * W , ans2)
    return

    if (H /2 == y) and  (H % 2 == 0)  and (W/2 == x) and (W % 2 == 0):
        ans2 = 1
    else:
        ans2 = 0

    ans = max(min(H - y, y) * W, min(W - x, x) * H)
    print "%20.15f %d" % (float(ans), ans2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2928