akhauriyash/Code-Regression huggingface dataset:
/*
“Being happy doesn't mean that everything is perfect.
It means that you decided to look beyond the imperfections.”
*/

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


#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define ii pair<int,int>
#define fr(i,x,n) for(i = x ; i< n ; i++)
#define f(i,n) for(i = 0 ; i< n ; i++) 
#define ff first
#define ss second
#define pb push_back
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
void solve();



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
//	freopen("input.txt", "r",stdin);
//	freopen("output.txt", "w", stdout);
    solve();
    return 0;
}



int i, j, k, l, n, a, c, nn, t, dot=0, toko=0, x, y, z;


void solve()
{
    // cin>>t;f(nn,t)
    {
        cin >> x ;
        bool b=false;
        fr(i,1,10)
        {
            if(x%i==0 and x/i<=9) b =true;
        }

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string> 
using namespace std;
int main()
{
    int i,j,k,n,s,sum;
	cin>>n>>s;
	sum=0;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(s-(i+j)>=0&&s-(i+j)<=n)
				sum++;
		}
	} 
	cout<<sum<<endl;
    return 0;
}

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

typedef struct{
    int a;
    int b;
}TEST;

int comp( const void *c1, const void *c2 )
{
  TEST test1 = *(TEST *)c1;
  TEST test2 = *(TEST *)c2;

  int tmp1 = test1.a;   /* b を基準とする */
  int tmp2 = test2.a;

  return tmp1 - tmp2;
}

int main(){
    int N, M;
    int i, j;
    double ans=0;
    TEST inp[110000];

    scanf("%d %d", &N, &M);

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

    qsort(inp, N, sizeof(TEST), comp);

    for(i=0; i<N; i++){
        if(M<inp[i].b){
            ans = ans + (double)M* inp[i].a;
            break;
        }else{
            ans = ans + (double)inp[i].b * inp[i].a;
            M = M-inp[i].b;
        }
    }

    printf("%.0lf", ans);

    return 0;
}


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

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	int A[N];
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}

	int count = 0;
	while (N >= K){
		if (count == 0){
			N -= K;
		}
		else {
			N -= (K - 1);
		}
		count++;
	}
	if (N != 0){
		count++;
	}
	
	cout << count << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,x[100000],y[100000],xcmp=0,ycmp=0,sum=0,t[100000];

string s,w;

vector<int> z;

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
		cin >> n;
  rep(i,n){
    cin >> t[i] >> x[i] >> y[i];
  }
  	if(n==1){
      if((t[0]-x[0]-y[0])%2!=0 || t[0]<x[0]+y[0]){
        Cout("No");
        return 0;
      }
    }
           else{  rep(i,n){
               xcmp=Abs(x[i],x[i+1]);
               ycmp=Abs(y[i],y[i+1]);
               cmp=xcmp+ycmp;
               //Cout(cmp);
               if((t[i+1]-t[i]-cmp)%2!=0 || t[i]<x[i]+y[i]){
                 Cout("No");
                 return 0;
               }
             if(i==n-2){
               break;
             }
               
             }
               }
  Cout("Yes");
  
  
          
       
       
return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int k; cin >> k;
    for(int i = 0; i < S.length(); i += k) cout << S[i];
    cout << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

template<typename T>
struct BinaryIndexedTree {
    vector<T> data;

    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for (++k; k < data.size(); k += k & -k) data[k] += x;
    }
};

ll solve(vector<int> v, int x) {
    ll ret = 0;

    int now = 150000;
    BinaryIndexedTree<int> BIT(300000);
    BIT.add(now, 1);
    for (auto a:v) {
        now += a >= x ? 1 : -1;
        ret += BIT.sum(now);
        BIT.add(now, 1);
    }

    return ret;
}

int main() {
    ll n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];

    int ng = 1145141919, ok = 0;
    while (ng - ok > 1) {
        int mid = ok + (ng - ok) / 2;
        if (solve(a, mid) * 2 >= n * (n + 1) / 2)ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int h, w;
    sc(h) sc(w)
    char ans[h + 2][w + 2];
    for (int i = 0; i < h + 2; i++){
        for (int j = 0; j < w + 2; j++){
            if (i == 0 || i == h + 1 || j == 0 || j == w + 1){
                ans[i][j] = '#';
            }else cin >> ans[i][j];
        }
    }
    for (int i = 0; i < h + 2; i++){
        for (int j = 0; j < w + 2; j++){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vll x2(n), y2(n);
    ll minx2 = INFL, maxx2 = -INFL, miny2 = INFL, maxy2 = -INFL;
    rep(i, n) {
        x2[i] = x[i] + y[i];
        chmin(minx2, x2[i]);
        chmax(maxx2, x2[i]);
        y2[i] = x[i] - y[i];
        chmin(miny2, y2[i]);
        chmax(maxy2, y2[i]);
    }
    cout << max(maxx2-minx2, maxy2-miny2) << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 9468
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	int a, b, c;
	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (a + c > i || b - c < i)cout << i << endl;
	}
	//for (int i = max(a,b-c); i <= b; i++)cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N,M,max,tmp;
    string str;
    max = 0;
    tmp = 0;
  
    map<string,int> B;
    map<string,int> R;
 
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> str;
        B[str]++;
    }
  
 	cin >> M;
    for(int i = 0; i < M; i++){
        cin >> str;
        R[str]++;
    }
 
    for(auto iter = B.begin(); iter != B.end(); iter++){
        if(R.count(iter->first)){
             tmp = B[iter->first] - R[iter->first];
        }else{
            tmp = B[iter->first];
        }
       
        if(tmp > max) max = tmp;
        tmp = 0;
    }
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3552
# Author: cr4zjh0bp
# Created: Sun Mar 22 22:02:37 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()

if s[0] == s[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sat May 19 14:55:45 2018
AOJ ITP2_1_A  
@author: maezawa
"""

q = int(input())
a = []

for i in range(q):
    ops= list(map(int,input().split()))
    if ops[0] == 0:
        a.append(ops[1])
    elif ops[0] == 1:
        print(a[ops[1]])
    else:
        a.pop(-1)

        




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

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

int main(){
    ll N, K;
    cin >> N >> K;

    ll per;

    per = N / K;

    ll n, p;
    n = N - ((per + 1) * K);
    p = N -  (per      * K);

    if(abs(n) > abs(p)){cout << p << endl;}
    else{cout << n * (-1) << endl;}


    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)!=t.substr(i,1))cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3780
N = int(input())
S = input()
ans = S.count("R") * S.count("B") * S.count("G")
for i in range(len(S)):
    for j in range(i + 1, len(S)):
        k = j * 2 - i
        if k >= len(S):
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)

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

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

  for(int i=0;i<k;i++){
  if(i%2==1){
    a+=(b/2);
    b=b/2;
  }else{
    b+=(a/2);
    a=a/2;
  }
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
<?php
$arg = fgets(STDIN);
list($x, $y) = explode(" ", $arg);

if($y%2 == 1){echo 'No'; exit();}

for($i = $x; $i >= 0; $i--){
    $crane = $i;
    $turtle = $x-$i;

    if(($crane * 2) + ($turtle * 4) == $y){
        echo 'Yes';
        exit();
    }
}
echo 'No';

Measured memory_bytes: 16128
#include "bits/stdc++.h"
using namespace std;

#define int long long


/*https://github.com/kurokoji/.cpp-Template/wiki#struct-fast*/
//理解できていないものはコメントアウト
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* short */
//#define pb push_back
//#define eb emplace_back
//#define mp make_pair
//#define Fi first
//#define Se second
#define ALL(v) begin(v), end(v) // sort(ALL(v));みたいに使う
//#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
//#define EACH(i, n) for (auto&& i : n)

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
//using pii = pair<int, int>;
using D = double;
//using P = complex<D>;
using vs = vector<string>;
//template <typename T> using PQ = priority_queue<T>;
//template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
//const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 }, dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };

/* func */
inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; cin >> x; return x; }
//inline vs split(const string& t, char c) { vs v; stringstream s(t); string b; while (getline(s, b, c)) v.eb(b); return v; }
//template <typename T> inline bool chmin(T& a, const T& b) { if (a > b) a = b; return a > b; }
//template <typename T> inline bool chmax(T& a, const T& b) { if (a < b) a = b; return a < b; }
//template <typename T, typename S> inline void print(const pair<T, S>& p) { cout << p.first << " " << p.second << endl; }
template <typename T> inline void print(const T& x) { cout << x << '\n'; }
//template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) { for (auto&& p : v) print(p); }
//template <typename T> inline void print(const vector<T>& v, string s = " ") { REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n"); }



signed main() {
	ll N, M;

	cin >> N >> M;

	vector<pair<int, int> > pairs(N);

	for (int i = 0; i < N; ++i) { int A, B; cin >> A >> B; pairs[i] = make_pair(A, B); }

	int buy = 0;
	int ans = 0;



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

	REP(i, N) {
		int tmp = min(M - buy, pairs[i].second);
		buy += tmp;
		ans += pairs[i].first * tmp;

		if (buy >= M) break;
	}

	cout << ans << endl;

	#ifdef _DEBUG
		system("pause");
	#endif
	return 0;
}



Measured memory_bytes: 1792
n = int(input())
s = input()
dp = [[0]*5005 for _ in range(5005)]
for i in range(n)[::-1]:
    for j in range(n)[::-1]:
        if s[i]!=s[j]:
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)

Measured memory_bytes: 231944
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  char c;
  while(cin >> c){
    cout << (char)(c+1) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
S = input()
lenS = len(S)

if lenS % 2 == 0:
    target1 = [str(0), str(1)] * int(lenS / 2)
    target2 = [str(1), str(0)] * int(lenS / 2)
else:
    target1 = [str(0), str(1)] * int(lenS / 2) + ['0']
    target2 = [str(1), str(0)] * int(lenS / 2) + ['1']


diff1 = 0
diff2 = 0

for i in range(len(S)):
    if target1[i] != S[i]:
        diff1 += 1
    if target2[i] != S[i]:
        diff2 += 1
        
print(min(diff1, diff2))

Measured memory_bytes: 5476
void main(){
	int ans = 6;
	int[] ab;
	ab ~= _scan();
	ab ~= _scan();
	foreach(elm; ab)ans -= elm;
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2608
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio> 
#include <cstring>

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
struct Student {
	int t, n, m, s;
};

constexpr int timeOffset = 540;
//[PC][time] = Student
int use[1000][1260 - timeOffset];


class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		std::vector<std::vector<int>> results;
		while (1) {
			int n, m, r, q;
			std::cin >> n >> m;
			if (!n) break;

			std::memset(use, 0, sizeof(use));
			results.push_back(std::vector<int>());
			//login info
			std::cin >> r;
			Student s;
			rep(i, r) {
				//time, PC, student, isLogin
				std::cin >> s.t >> s.n >> s.m >> s.s;
				//login
				if (s.s) {
					//set login start time
					use[s.n - 1][s.t - timeOffset] = s.m;
				}//logout
				else {
					//Fill until login start time
					int time = s.t - timeOffset - 1;
					while (use[s.n - 1][time] == 0) {
						use[s.n - 1][time--] = s.m;
					} 
				}
			}

			//question [ts, te]
			std::cin >> q;
			rep(i, q) {
				int num = 0;
				int ts, te, m;
				std::cin >> ts >> te >> m;
				ts -= timeOffset; te -= timeOffset;
				//Check if logged in on any PC.
				rangeRep(j, ts, te) {
					rep(k, n) {
						if (use[k][j] == m) {
							num++;
							break;
						}
					}
				}
				results.back().push_back(num);
			}
		}

		for (auto& x : results) {
			for (auto& y : x) {
				std::cout << y << std::endl;
			}
		}
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

Measured memory_bytes: 5848
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a, b, k;
    cin >>a >>b >>k;
    if(k <= a){
        cout <<a - k <<" " <<b;
    }
    else if(k <= (a + b)){
        cout <<"0 " <<b - (k - a);
    }
    else{
        cout <<"0 0";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	ll n,f=1; cin>>n;
	vector<vector<int>> p(n,vector<int>(2));
	vector<int> v;
	for(int i=0;i<n;i++) cin>>p[i][0]>>p[i][1],v.push_back(i),f*=(i+1);
	double ans=0;
	do{
		for(int i=1;i<n;i++){
			double dx=abs(p[v[i]][0]-p[v[i-1]][0]);
			double dy=abs(p[v[i]][1]-p[v[i-1]][1]);
			ans+=sqrt(dx*dx+dy*dy);
		}
	}while(next_permutation(v.begin(),v.end()));
	ans/=(double)f;
	cout<<fixed<<setprecision(12)<<ans;
}


Measured memory_bytes: 3868
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin  >> s;
    int n = s.length();
    if(n%2) {
        cout << "No" << endl;
        return 0; 
    }
    for(int i=0;i<n;++i) {
        if(i%2 == 0) {
            if(s[i] != 'h') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(s[i] != 'i') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<tuple>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;

#define INF ((int)(1e9))
#define MAX 110000

int n, k, a, q;
set<int> se;
bool flag = true;

int main(){
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>a;
		se.insert(a);
	}
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>k;
		if(!se.count(k))flag = false;
	}
	
	cout<<flag<<endl;
	return 0;
}


Measured memory_bytes: 12444
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
typedef long long ll;

vector<int> edge[100005];
int disu[100005],disv[100005];
int q[100005];

void bfs(int u,int dis[]){
  int l=1,r=0;
  dis[u]=0;
  q[++r]=u;
  while(l<=r){
    int now=q[l];l++;
    int siz=edge[now].size();
    for(int i=0;i<siz;i++){
        int nxt=edge[now][i];
        if(dis[now]+1<dis[nxt]){
            dis[nxt]=dis[now]+1;
            q[++r]=nxt;
        }
    }
  }
}

int main()
{
    int n,u,v;scanf("%d%d%d",&n,&u,&v);
    for(int i=1;i<=n-1;i++){
        int a,b;scanf("%d%d",&a,&b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    memset(disu,0x3f,sizeof(disu));
    bfs(u,disu);
    memset(disv,0x3f,sizeof(disv));
    bfs(v,disv);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(disu[i]<disv[i]) ans=max(ans,disv[i]-1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
  
double eps = 1e-8;
bool eq(double a,double b){
  return (-eps < a-b && a-b < eps);
}
  
struct S{
  P p,q;
  S(double a=0,double b=0,double c=0,double d=0){
    p=P(a,b);
    q=P(c,d);
  }
  S(P a,P b){
    p=a;
    q=b;
  }
};
  
P crosspoint(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
P crosspoint(S a,S b){
  return crosspoint( a.p, a.q, b.p, b.q);
}
  
int ccw(P a,P b,P c){
  b-=a;
  c-=a;
  P k=c*conj(b);
  if(k.imag() > 0)return 1;
  if(k.imag() < 0)return -1;
  return 0;
}
  
int W,H,N;
S lw,rw;
vector< P > v;
vector<double> t;
  
typedef pair< double , P > Pair;
 
double calcAB(double height){
  double left=0,right=H,mid;
  double left2=0,right2=H,mid2;
 
  for(int i=0;i<30;i++){
    mid=(left+right)*0.5;
    mid2=(left2+right2)*0.5;
    S base=S(0,height,W,mid);
    S base2=S(0,height,W,mid2);
 
    int lc=0,rc=0;
    int lc2=0,rc2=0;
 
    for(int j=0;j<N+N;j++){
      int k=ccw(base.p,base.q,v[j]);
      if(k==1)lc++;
      if(k==-1)rc++;
      
      int k2=ccw(base2.p,base2.q,v[j]);
      if(k2==1)lc2++;
      if(k2==-1)rc2++;
    }
    if(lc>N)left=mid;
    else right=mid;
 
    if(rc2>N)right2=mid2;
    else left2=mid2;
 
  }
  return mid2 - mid;
} 
 
double f(double height,int flg){
  return calcAB(height);
}
  
int main(){
  while(1){
  
    scanf("%d %d %d",&W,&H,&N);
    if(W==0&&H==0&&N==0)break;
      
    v.clear();
    t.clear();
  
    lw=S(0,0,0,H);
    rw=S(W,0,W,H);
  
    v.resize(N+N+2);
    for(int i=0;i<N+N;i++){
      int x,y;
      scanf("%d %d",&x,&y);
      v[i]=P(x,y);
    }
    v[N+N]=P(W,H);
    v[N+N+1]=P(W,0);
  
    for(int i=0;i<(int)v.size();i++){
      for(int j=0;j<i;j++){
        P a=v[i],b=v[j];
        if(a==b)continue;
        if(a.real() == b.real())continue;
        S c=S(a,b);
        int lc=0,rc=0;
        for(int k=0;k<N+N;k++){
          if( ccw( c.p , c.q , v[k] ) == 1 )lc++;
          if( ccw( c.p , c.q , v[k] ) == -1)rc++;
        }
        if(lc>N||rc>N)continue;
        
        P target=crosspoint(lw,c);
        if(target.imag()<0)continue;
        if(target.imag()>H)continue;
        t.push_back( target.imag() );      
      }
    }
  
    double last=0;
    double ans=0;
    t.push_back(H);
    sort(t.begin(),t.end());
  
 
    double ep=1e-6;
    for(int i=0;i<(int)t.size();i++){
      double py=t[i];
      if(py<0 ||  py>H || abs(py-last) < eps )continue;
      ans+= ( f(last+ep,1) + f(py-ep,-1) ) * (py-last) * 0.5;
      last=py;
    }
    printf("%.10f\n",ans/(double)(H*H));
  
  }
  return 0;
}

Measured memory_bytes: 3264
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	
	string s; cin >> s;
	if (s[s.size() - 1] == '3') {
		cout << "bon" << '\n';
	}
	else if (s[s.size() - 1] == '0' || s[s.size() - 1] == '1' || s[s.size() - 1] == '6' || s[s.size() - 1] == '8') {
		cout << "pon" << '\n';
	}
	else cout << "hon" << '\n';







} 

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
ll n;cin>>n;
ll m;cin>>m;
For(i,0,m){
    ll a;cin>>a;
    n-=a;
}
cout<<max(-1ll,n)<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3632
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


N, X = map(int, input().split())
xs = map(int, input().split())
diffs = [abs(X-x) for x in xs]

ans = diffs[0]
if N > 1:
    for i in range(1, N):
        ans = gcd(ans, diffs[i])
print(ans)


Measured memory_bytes: 14252
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<iostream>
using namespace std;
typedef long long LL;
const int MaxN = 3e5 + 5;
 
LL n, a[MaxN];
LL pre[MaxN], tail[MaxN];
 
int main()
{
	while(~scanf("%lld", &n))
	{
		for(int i = 1; i <= 3 * n; i++) scanf("%lld", &a[i]);
		priority_queue<LL, vector<LL>, greater<LL> > pq1;
		priority_queue<LL, vector<LL>, less<LL> > pq2;
		LL pp = 0, tt = 0;
		for(int i = 1; i <= n; i++) 
		{
			pq1.push(a[i]);
			pp += a[i];
		}
		pre[n] = pp;
		for(int i = 2 * n + 1; i <= 3 * n; i++) 
		{
			pq2.push(a[i]);
			tt += a[i];
		}
		tail[2 * n + 1] = tt;
		for(int i = n + 1; i <= 2 * n; i++)
		{
			pq1.push(a[i]);
			LL x = pq1.top();
			pq1.pop();
			pp -= (x - a[i]);
			pre[i] = pp;
			//printf("%d : %lld\n", i, pre[i]);
		}
		for(int i = 2 * n; i >= n + 1; i--)
		{
			pq2.push(a[i]);
			LL x = pq2.top();
			pq2.pop();
			tt -= (x - a[i]);
			tail[i] = tt;
			//printf("%d: %lld\n", i, tail[i]);
		}
		LL ma = -1e16;
		for(int i = n; i <= 2 * n; i++)
		{
			ma = max(ma, pre[i] - tail[i + 1]);
		}
		printf("%lld\n", ma);
	}	
	return 0;
}

Measured memory_bytes: 8180
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N; cin >> N; 
	long long A[310] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	long long xsum = 0; // これが xor になる
	for(int i = 2; i < N; i++){
		xsum ^= A[i]; 
	}
	long long total = A[0] + A[1]; 
	if(total % 2 != xsum % 2){
		cout << -1 << endl; return 0; 
	}
	long long an = (total - xsum) / 2; // これが and になる
	if(A[0] < an){
		cout << -1 << endl; return 0; 
	}
	long long tmp = an; 
	if(an & xsum){
		cout << -1 << endl; return 0; 
	}
	for(int i = 60; i >= 0; i--){
		if(!((xsum >> i) & 1)) continue; 
		if(tmp + (1LL << i) > A[0]) continue; 
		tmp += (1LL << i); 
	}
	if(tmp == 0) cout << -1 << endl; 
	else{
		cout << A[0] - tmp << endl; 
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int a[N];

int main(){
	fast;
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	int sum = 0;
	for(int i = 0; i < k; i++) sum += a[i];
	cout << sum;
	
	
	return 0;
}


Measured memory_bytes: 3468
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
main(){
    int tcase, m; cin >> tcase;
    string s1, s2, s3;
    for ( int i = 0; i < tcase; i++ ){
    cin >> s1 >> s2; s3 = "";
    m = max(s1.size(), s2.size());
    while( s1.size() < m ) s1 = '0' + s1;
    while( s2.size() < m ) s2 = '0' + s2;
    int c = 0;
    for ( int i = m-1; i >= 0; i-- ){
        char ch = ((s1[i]-'0')+(s2[i]-'0')+c)%10 + '0';
        c = ((s1[i]-'0')+(s2[i]-'0')+c)/10;
        s3 += ch;
    }
    if ( c ) s3 += c+'0';
    reverse(s3.begin(), s3.end());
    while( s3.size() > 1 && s3[0] == '0' ) s3.erase(s3.begin());
    if ( s3.size() > 80 ) cout << "overflow" << endl;
    else cout << s3 << endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  string S;
  cin>>S;
  for(int i=0;i<S.size();i+=2){
    if(S[i]=='h'&&S[i+1]=='i') continue;
    else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A, B;
  cin>>A>>B;

  int ans = max({A + B, A - B, A * B});
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def intlist():
    k = [int(i) for i in input().split()]
    return k
def intmat(x):
    k = [[int(i) for i in input().split()] for i in range(x)]
    return k
#ここから下に書く
s = input()
ans=10**9+7
for i in range(len(s)-2):
    a=int(s[i:i+3])
    if ans>abs(a-753):
        ans=abs(a-753)
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(N, A):
    v = []
    for i in range(N):
        v.append((A[i], i + 1))

    ans = []
    for p in sorted(v):
        ans.append(p[1])

    print(*ans)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    solve(N, A)


if __name__ == '__main__':
    main()


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll c;
	cin >>n >>c;
	VL x(n), v(n);
	rep(i, n) cin >>x[i] >>v[i];
	VL smc(n+1), smu(n+1);
	rep(i, n) smc[i+1] = smc[i] + v[i] - (x[i] - (i? x[i-1]:0));
	
	VL rx(n);
	rep(i, n) rx[i] = c - x[i];
	reverse(all(rx));
	rep(i, n) smu[i+1] = smu[i] + v[n-1-i] - (rx[i] -(i? rx[i-1]: 0));
	rep(i, n){
		smu[i+1] = max(smu[i+1], smu[i]);
		smc[i+1] = max(smc[i+1], smc[i]);
	}
	ll ans = max(smc.back(), smu.back());
	rep(i,  n){
		ll w = smc[i+1] + smu[n-i-1] - x[i];
		ans = max(ans , w);

		w = smu[i+1] + smc[n-i-1] -rx[i];
		ans = max(ans , w);
	}
	cout << ans <<"\n";
return 0;
}


Measured memory_bytes: 4224
main :: IO()
main = do
  getLine
  as <- map read . words <$> getLine
  print $ solve 1 (as::[Int])

solve :: Int -> [Int] -> Int
solve _ [] = 0
solve n [a]
  | n == a = 1
  | otherwise = 0
solve n (a1:a2:as)
  | a1 == n = 1 + solve (n+2) as
  | otherwise = solve (n+1) (a2:as)

Measured memory_bytes: 20860
#include<iostream>
#define abs(a) (a<0?-(a):a)
using namespace std;
main()
{
	int n,m,a[50],b[50],c[50],d[50];
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	for(int i=0;i<m;i++)cin>>c[i]>>d[i];
	for(int i=0;i<n;i++)
	{
		int v=1e9,p=0;
		for(int j=0;j<m;j++)
		{
			if(v>abs(a[i]-c[j])+abs(b[i]-d[j]))p=j,v=abs(a[i]-c[j])+abs(b[i]-d[j]);
		}
		cout<<p+1<<endl;
	}
}


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


int mc[100];
int p[100][100];
int dp[100][100];
int pr[100][100];

int N,D;
int dfs(int day,int pos){
	if( day == D ) return 0;
	if( dp[day][pos] != -1 ) return dp[day][pos];
	
	int ans = 1e9;
	int po = -1;
	for(int i = 0 ; i < N ; i++){
		if( p[i][day] != mc[day] ) continue;
		
		int g = dfs(day+1,i)+(i!=pos);
		if( g < ans ){
			ans = g;
			po = i;
		}
	}
	pr[day][pos] = po;
	return dp[day][pos] = ans;
}
int rdfs(int day,int pos){
	if( day == D ) return 0;
	cout << pr[day][pos]+1 << endl;
	rdfs(day+1,pr[day][pos]);
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin >> N >> D;
	for(int i = 0 ; i < N ; i++){
		for(int j = 0 ; j < D ; j++){
			cin >> p[i][j];
		}
	}
	int sum = 0;
	for(int j = 0 ; j < D ; j++){
		int cc = 1e9;
		for(int i = 0 ; i < N ; i++)
			cc = min(cc,p[i][j]);
		mc[j]=cc;
		sum += cc;
	}
	cout << sum << " " << dfs(0,60)-1 << endl;
	rdfs(0,60);
	
	
}
	

Measured memory_bytes: 1260
N = int(input())
abclist = [[0,0,0]]
for _ in range(N):
    a,b,c = map(int,input().split())
    abclist.append([a,b,c])
dp = [[-1,-1,-1] for _ in range(N+1)]
dp[0] = [0,0,0]
for i in range(1,N+1):
    for abc in [0,1,2]:
        if abc == 0: #a
            dp[i][abc] = max(dp[i-1][1]+abclist[i][0],dp[i-1][2]+abclist[i][0])
        elif abc == 1: #b
            dp[i][abc] = max(dp[i-1][0]+abclist[i][1],dp[i-1][2]+abclist[i][1])
        else:
            dp[i][abc] = max(dp[i-1][0]+abclist[i][2],dp[i-1][1]+abclist[i][2])
print(max(dp[N]))

Measured memory_bytes: 75524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int H,W; cin>>H>>W;
    vector<vector<char>> S(H,vector<char>(W));
    vector<pair<int,int>> pos;
    rep(h,0,H)rep(w,0,W){
        cin>>S.at(h).at(w);
        if(S.at(h).at(w)=='.') pos.emplace_back(h,w);
    }

    int ans=0;
    vector<pair<int,int>> d;
    d.emplace_back(0,-1);
    d.emplace_back(-1,0);
    d.emplace_back(0,1);
    d.emplace_back(1,0);

    rep(i,0,pos.size()-1){
        vector<vector<int>> Cost(H,vector<int>(W,INT_MAX));
        pair<int,int> sp=pos.at(i);
        Cost.at(sp.first).at(sp.second)=0;

        queue<pair<int,int>> q;
        q.push(sp);
        
        int _ans=0;
        while(!q.empty()){
            pair<int,int> p=q.front();
            q.pop();

            for(auto _d:d){
                int newX=p.first+_d.first,newY=p.second+_d.second;
                if(newX>=0 && newX<H && newY>=0 && newY<W){
                    if(S.at(newX).at(newY)=='.' && Cost.at(p.first).at(p.second)+1<Cost.at(newX).at(newY)){
                        Cost.at(newX).at(newY)=Cost.at(p.first).at(p.second)+1;
                        q.emplace(newX,newY);
                        _ans=max(_ans,Cost.at(p.first).at(p.second)+1);
                    }
                }
            }
        }
        //cout<<sp.first<<" "<<sp.second<<" "<<_ans<<endl;
        ans=max(ans,_ans);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef bitset<4000005> bs;

bs dp;
void solve() {
  int n;
  cin >> n;
  int tot = 0;
  dp.set(0);
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    tot += x;
    dp |= (dp << x);
  }
  int ret = (tot+1)/2;
  while(!dp[ret]) ret++;
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
struct dice{
    int x[6];
    
    void roll(char c){
        int tmp;
        if(c == 'E'){
            tmp = x[0];
            x[0] = x[3];
            x[3] = x[5];
            x[5] = x[2];
            x[2] = tmp;
        }
        if(c == 'N'){
            tmp = x[0];
            x[0] = x[1];
            x[1] = x[5];
            x[5] = x[4];
            x[4] = tmp;
        }
        if(c == 'S'){
            tmp = x[0];
            x[0] = x[4];
            x[4] = x[5];
            x[5] = x[1];
            x[1] = tmp;
        }
        if(c == 'W'){
            tmp = x[0];
            x[0] = x[2];
            x[2] = x[5];
            x[5] = x[3];
            x[3] = tmp;
        }
    }
    int top(void){
        return x[0];
    }
};

int main(void){
    dice d;
    for(int i = 0; i < 6; i++){
        cin >> d.x[i];
    }
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        d.roll(s[i]);    
    }
    cout << d.top() << endl;

    return 0;
}



Measured memory_bytes: 3216
from collections import deque

     
def dfs(N, AB):
    status = [-1] * N
    for i in range(N):
        if status[i] == 1:
            continue
        stack = [i]
        status[i] = 0
        while stack:
            v = stack[-1]
            if AB[v]:
                n = AB[v].popleft()
                if status[n] == -1:
                    stack.append(n)
                    status[n] = 0
                else:
                    if n in stack:
                        idx = stack.index(n)
                        cycle = stack[idx:]
                        return cycle
            else:                  
                status[v] = 1
                stack.pop()
    return False


def find_smaller_cycle(cycle, AB):
    i = 0
    while i < len(cycle):
        v = cycle[i]
        if AB[v]:
            n = AB[v].popleft()
            if n in cycle:
                r = cycle.index(n)
                if i < r:
                    cycle = cycle[:i+1] + cycle[r:]
                else:
                    cycle = cycle[r:i+1]
                i = cycle.index(v)
        else:
            i += 1
            
    return cycle


N, M = [int(i) for i in input().split()]
AB = [deque() for _ in range(N)]
for _ in range(M):
    A, B = [int(i) - 1 for i in input().split()]
    AB[A].append(B)
                      
cycle = dfs(N, AB)
if not cycle:
    print(-1)
else:
    cycle = find_smaller_cycle(cycle, AB)
            
    print(len(cycle))
    for v in cycle:
        print(v + 1)

Measured memory_bytes: 4212
#include<stdio.h>
int main()
{
    long long int a, b, remainder, num1, num2;
    while (scanf("%lld %lld", &num1, &num2) != EOF)
    {
        if(num1 > num2)
        {
            a = num1;
            b = num2;
        }
        else
        {
            a = num2;
            b = num1;
        }
        remainder = a % b;
    while(remainder != 0)
    {
        a = b;
        b = remainder;
        remainder = a % b;
    }
    printf("%lld %lld\n", b, (num1 * num2)/b);
    }
    return 0;
}


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

int main(){
int r; cin >> r;
int ans=0;
ans=r*r;
cout << ans << endl; 
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		double ans = 0;

		for (int i = 0; i < N; i++) {
			ans += 1 / sc.nextDouble();

		}
		System.out.println(1/ans);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
long long a[305][305];
long long f[305][305];
int liangle[305][305];
int main() {
	int n;
	long long ans = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			cin >> a[i][j], f[i][j] = a[i][j];
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(i != j)
				for(int k = 1; k <= n; k++) 
					if(k != i && k != j) {
						if(f[i][k] + f[k][j] < f[i][j]) {
							cout << "-1" << endl;
							return 0;
						}
						if(f[i][j] == f[i][k] + f[k][j])
							liangle[i][j] = liangle[j][i] = 1;
						f[i][j] = f[j][i] = min(f[i][k] + f[k][j], f[i][j]);
					}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j < i; j++)
			if(liangle[i][j] == 0)
				ans += a[i][j];
	cout << ans << endl;
	return 0;
}


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

int main(){
    long N, K, ans = 0;
    cin >> N >> K;
    for(long i = K; i < N + 2; i++){
        ans = (ans + N * (N + 1) / 2 - (N - i) * (N - i + 1) / 2 - (i - 1) * i / 2 + 1) % 1000000007;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, x, y;
    cin >> n >> x >> y;

    vector<int> ans(n, 0);
    for(int i=1;i<=n;++i) {
        for(int j=i+1;j<=n;++j) {
            if(j <= x) {
                ++ans[j-i];
            } else if(j <= y) {
                if(i <= x) {
                    ++ans[min(j-i, x-i+1+(y-j))];
                } else {
                    ++ans[min(j-i, i-x+1+y-j)];
                }
            } else {
                if(i <= x) {
                    ++ans[x-i+1+j-y];
                } else if(i <= y) {
                    ++ans[min(j-i, i-x+1+j-y)];
                } else{
                    ++ans[j-i];
                }
            }
        }
    }

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


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		sc.close();

		R = Math.min(L + 2019, R);

//		if(R-L > 3000) {
//			out.println(0);
//			return;
//		}
		
		int ans = Integer.MAX_VALUE;
		for(int x=L;x<R;x++) {
			for(int y=x+1;y<=R;y++) {
				if(x==y)continue;
				
				int m = (int)(((long)x * y) % 2019);
				ans = Math.min(ans, m);
			}
		}
		out.println(ans);

	}

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


Measured memory_bytes: 21844