akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef complex<double> Point;
struct Line : public vector<Point> {
    Line () {}
    Line(Point a, Point b){
        push_back(a);
        push_back(b);
    }
    Point vector() const {
        return back() - front();
    }
};
double dot(Point a, Point b){
    return real(conj(a) * b);
}
double cross(Point a, Point b){
    return imag(conj(a) * b);
}
// (left, right)
pair<Point, Point> lr_align(Point a, Point b){
    if(cross(a, b) > 0) swap(a, b);
    return make_pair(a, b);
}
// 点pから直線lに対する射影
Point projection(Line l, Point p){
    double t = dot(p - l[0], l.vector()) / norm(l.vector());
    return l[0] + t * l.vector();
}

// 点pの直線lに関する反射
Point reflection(Line l, Point p){
    return 2.0 * projection(l, p) - p;
}

const double EPS = 1e-6;

int main(){
    int N;
    while(cin >> N && N){
        double sx, sy;
        cin >> sx >> sy;
        vector<Point> ps(N);
        REP(i, N){
            double x, y;
            cin >> x >> y;
            ps[i] = Point(x - sx, y - sy);
        }
        vector<Line> lv(N);
        REP(i, N){
            lv[i] = Line(ps[i], ps[(i + 1) % N]);
        }
        vector<int> perm(N);
        REP(i, N) perm[i] = i;
        int ans = 0;
        do{
            vector<Line> l(N);
            REP(i, N){
                l[i] = lv[ perm[i] ];
            }

            Point left;
            Point right;

            for(int i = 0; i < N; i++){
                // cout << "i = " << i << endl;
                for(int j = 0; j < i; j++){
                    l[i][0] = reflection(l[j], l[i][0]);
                    l[i][1] = reflection(l[j], l[i][1]);
                }
                Point vec = l[i].vector() / abs(l[i].vector());
                // l[i][0] += EPS * vec;
                // l[i][1] -= EPS * vec;
                // cout << l[i][0] << " " << l[i][1] << endl;
                pair<Point, Point> pp = lr_align(l[i][0], l[i][1]);
                // cout << pp.first << " " << pp.second << endl;
                if(i == 0) {
                    left = pp.first, right = pp.second;
                }else{
                    left = lr_align(left, pp.first).second;
                    right = lr_align(right, pp.second).first;
                }
                if(cross(right, left) < EPS){
                    break;
                }
                if(i == N - 1) {
                    ans++;
                }
                // cout << "left : " << left << " right : " << right << endl;
            }
        }while(next_permutation(perm.begin(), perm.end()));

        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1264
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

void solve(int tt){
	long long req; cin>>req;
	long long c = 100.00;
	if(req == 100){
		cout<<0<<endl;
		return;
	}
	int i;
	for(i=1;;i++){
		long double x = c * 1.01;
		long long y = x;
		if(y >= req) break;
		c = y;
	}
	cout<<i<<endl;
}
/*
void solve(int tt){
	ll a, b, x;
	cin>>a>>b>>x;
	ll tmp = min(b,x);
	ll ans = 0;
	if(tmp != 1){
		if(tmp == b) tmp--;
		ans = ((a*tmp)/b) + (a*(tmp/b));
	}
	else{
		ans = ((a*tmp)/b) + (a*(tmp/b));
	}
	cout<<ans<<endl;
}
*/


int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve(i);
	return 0;
}

Measured memory_bytes: 3656
import sys
n,y=map(int,input().split())
for i in range(n,-1,-1):
    for j in range(n-i,-1,-1):
        if (n-(i+j))*1000+j*5000+i*10000 == y:
            print(i,j,n-i-j)
            sys.exit()
print(-1,-1,-1)

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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if (a >=b){
    cout << "delicious" << endl;
  } else if(b - a <= x){
    cout << "safe" << endl;
  } else{
    cout << "dangerous" << endl;
  }
  return 0;
}


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

public class Main {
	int N,M;
	ArrayList<Integer>[] graph;
	boolean[] used;

	public int dfs(int v,int c){
		if(c == N-1)return 1;

		used[v] = true;

		int ret = 0;

		for(int u : graph[v]){
			if(used[u])continue;
			ret += dfs(u,c+1);
		}
		used[v] = false;
		return ret;
	}


	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextInt();
		M = nextInt();

		graph = new ArrayList[N];
		for(int i = 0;i < N;i++){
			graph[i] = new ArrayList<Integer>();
		}
		used = new boolean[N];

		for(int i = 0;i < M;i++){

			int a = nextInt()-1;
			int b = nextInt()-1;

			graph[a].add(b);
			graph[b].add(a);
		}

		out.println(dfs(0,0));
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

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

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

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

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

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s1,s2;
  int cnt=0;
  cin>>s1>>s2;
  for(int i=0;i<3;i++)
  	if(s1.at(i)==s2.at(2-i)) cnt++;
  if(cnt==3) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

from itertools import accumulate

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n, w = li()
value = {i: [] for i in range(4)}

for i in range(n):
    wei, val = li()

    if i == 0:
        w0 = wei

    value[wei - w0].append(val)

for i in range(4):
    value[i].sort(reverse=True)

    value[i] = [0] + list(accumulate(value[i]))


ans = 0

for i in range(len(value[0])):
    for j in range(len(value[1])):
        for k in range(len(value[2])):
            rest = w - i*w0 - j*(w0+1) - k*(w0+2)
            x = rest // (w0+3)

            if x < 0:
                continue
            else:
                ans = max(ans, value[0][i] + value[1][j] + value[2][k] + value[3][min(len(value[3])-1, x)])

print(ans)


Measured memory_bytes: 40688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		partC100();
	}


	public static void partC100() {
		Scanner scC = new Scanner(System.in);
		boolean bool = false;
		int count = 0;
		int N = scC.nextInt();
		int[] a = new int[N];

		for(int i = 0 ; i < N ; i++) {
			a[i] = scC.nextInt();
		}


		for(int j = 0 ; j < N ; j++) {
			if(a[j] % 2 == 0) {
				while(a[j] % 2 == 0) {
					a[j] /= 2;
					count++;
				}
				bool = true;
			}
		}


		if(bool) {
			System.out.println(count);
		}else {
			System.out.println(0);
		}

	}
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << "\n"
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << "\n"
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

/***** MAIN *****/
signed main() {
  int n; cin >> n;
  int nums[n];
  vector<int> cum_sum(n+1);
  
  for(int i = 0; i < n; ++i) {
    cin >> nums[i];
    cum_sum[i+1] = cum_sum[i] + nums[i];
  }
  mint ans = nums[0];
  ans *= cum_sum[n] - cum_sum[1];
  for(int i = 1; i < n-1; ++i) {
    ans += (nums[i] % MOD) * ((cum_sum[n] - cum_sum[i+1]) % MOD);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 6416
def cin; gets.split.map(&:to_i) end

# exit if $0 != __FILE__

# n, *x = cin
# s = gets.chomp

# puts n
MOD = 1000000007
n,m = cin
as = Array.new(n+1, -1)
as[0] = 1
m.times do
  as[gets.to_i] = 0
end

(n+1).times do |x|
  next if as[x] >= 0

  a = x >= 1 ? as[x-1] : 0
  b = x >= 2 ? as[x-2] : 0
  as[x] = (a + b) % MOD
end

p as[n]




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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	long long n,a,b;
	cin>>n>>a>>b;
	long long p=n/(a+b);
	long long ans=p*a;
	long long temp = n%(a+b);
	if(temp<=a)
	{
	    ans+=temp;
	}
	else
	{
	    ans+=a;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(x,y);
  while(x <= y) {
    x *= 2;
    z++;
  }
  OUT(z);
}

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

#include <cstdio>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;
  ll cnt = 0;

  dsu d(n);

  for (int i =0; i<m; i++){
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    d.merge(a, b);
  }

  rep(i, n){
    if (d.leader(i) == i){
      cnt++;
    }
  }
  int ans = cnt -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3820
from sys import stdin,stdout                           #
import math                                            #
import heapq                                           #
                                                       #
t = 1                                                  #
def aint():                                            #
	return int(input().strip())                        #
def lint():                                            #
	return list(map(int,input().split()))              #
def fint():                                            #
	return list(map(int,stdin.readline().split()))     #
                                                       #	
########################################################

def main():
	n=aint()
	l=lint()
	ans=0
	for i in range(0,n,2):
		if l[i]%2:
			ans+=1
	print(ans)
	return

#t=int(input())

########################################################
for i in range(t):                                     #
	#print("Case #"+str(i+1)+":",end=" ")		       #
	main()                                             #

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

int N, M;
P p[100000];
int box[100001], red[100001];

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

    cin >> N >> M;
    red[1] = 1;
    for(int i = 1; i <= N; ++i) box[i] = 1;
    for(int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        --box[x]; ++box[y];
        if(red[x]) red[y] = 1;
        if(box[x] == 0) red[x] = 0;
    }
    int res = 0;
    for(int i = 1; i <= N; ++i) {
        if(red[i]) ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    ll n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>a>>b;

    if((a+b)&1)cout<<"IMPOSSIBLE\n";
    else cout<<(a+b)/2<<"\n";


    return 0;
}


Measured memory_bytes: 256
from heapq import heappush,heappop
N,M=map(int,input().split())
LRC=[list(map(int,input().split())) for i in range(M)]
data=[[],[]]+[[[i-1,0]] for i in range(2,N+1)]
for L,R,C in LRC:
    data[L].append([R,C])
dist=[[0,1]]
inf=float("inf")
flag=[inf]*(N+1)
while dist:
    y,x=heappop(dist)
    if flag[x]!=inf:
        continue
    flag[x]=y
    for u in data[x]:
        if flag[u[0]]==inf:
            heappush(dist,[y+u[1],u[0]])
    if flag[N]!=inf:
        break
if flag[N]==inf:
    print(-1)
else:
    print(flag[N])

Measured memory_bytes: 111320
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X = MAP()
m = [INT() for _ in range(N)]

X -= sum(m)
print(len(m)+X//min(m))


Measured memory_bytes: 5144
n, m = map(int, input().split())
d = [tuple(map(int, input().split())) for i in range(n)]
d.sort()
x = 0
for i in range(len(d)):
    x += d[i][0] * min(d[i][1], m)
    m -= min(d[i][1], m)
    if m == 0:
        break
print(x)

Measured memory_bytes: 17000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

#define rep(i, b, e) for(int (i) = (b); (i) < (e); (i)++)
#define repm(i, b, e) for(int (i) = (b); (i) < (e); (i)--)

int main() {
  int N, K;
  string S;
  
  cin >> N >> K;
  cin >> S;
  K--;
  char c = S[K];
  c = c + 0x20;
  S[K] = c;

  cout << S << endl;
  

  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cksharma
 */

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

class ARightTriangle {
public:
    void solve(istream& cin, ostream& cout) {
        ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
        cout.setf(ios::fixed); cout.precision(20);
        int a, b, c; cin >> a >> b >> c;
        cout << (a * b) / 2 << endl;
    }
};


int main() {
    ARightTriangle solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c){
    long long x[3] = {a, b, c};
    sort(x, x + 3);
    if (x[0] + x[1] == x[2])
        cout << YES << endl;
    else
        cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 3740
import scala.io.Source.stdin
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  def to(a:Array[Int],y:Int,m:Int,d:Int) =
    (a(0)<y) || (a(0)==y && a(1)<m) || (a(0)==y && a(1)==m && a(2)<=d)

  val b = new ArrayBuffer[String]

  stdin.getLines.foreach { s=>
    val n = s.split(" ").map(_.toInt)
    if(to(n,1868,9,7)) b+="pre-meiji"
    else if(to(n,1912,7,29)) b+="meiji " + (n(0)-1867) + " " + n(1) + " " + n(2)
    else if(to(n,1926,12,24)) b+="taisho " + (n(0)-1911) + " " + n(1) + " " + n(2)
    else if(to(n,1989,1,7)) b+="showa " + (n(0)-1925) + " " + n(1) + " " + n(2)
    else b+="heisei " + (n(0)-1988) + " " + n(1) + " " + n(2)
  }
  println(b.mkString("\n"))
}

Measured memory_bytes: 43552
def a():
    N, K = [int(n) for n in input().split()]
    h = [int(n) for n in input().split()]
    # dp[i]はi番目までたどり着くのに必要な最小コスト
    # dp[0] = 0
    # dp[1] = |h[1] - h[0]|
    # dp[i] = min(dp[0]+h[i]-h[0], dp[1]+h[i]-h[1], ...)
    dp = [0] * N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min([dp[k] + abs(h[k] - h[i]) for k in range(max(i - K, 0), i)])
    print(dp[N-1])

if __name__ == "__main__":
    a()

Measured memory_bytes: 52448
#include<stdio.h>
int main()
{
    int min,max,n;
    scanf("%d",&n);
    int a[n];
    int i;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    min=a[1],max=a[1];
    for(i=2;i<=n;i++)
    {
        if(min>a[i])
        {
            min=a[i];
        }
        if(max<a[i])
        {
            max=a[i];
        }
    }
    printf("%d\n",max-min);
    return 0;
}


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

typedef  long long ll;
typedef long double ld;
using namespace std;
const int N=1e5+5;

#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define point complex<double>
ll mod=1e9+7;
ll inf=2e18;
double eps=1e-10;
double pi=acos(-1);
double dot(point a, point b)
{
    return (conj(a)*b).real();
}
double cross(point a, point b)
{
    return (conj(a)*b).imag();
}

ll a[N],b[N],bb[N],c[N];
int main()
{
 int n;
 cin>>n;
 for(int i=0;i<n;i++)
    cin>>a[i];
 for(int i=0;i<n;i++)
    cin>>b[i];
 for(int i=0;i<n;i++)
    cin>>c[i];
 sort(a,a+n);
 sort(b,b+n);
 sort(c,c+n);
ll ind=0;
 for(int i=0;i<n;i++)
 {
     while(ind<n&&a[ind]<b[i])
        ind++;
     bb[i]=ind;
     if(i)
        bb[i]+=bb[i-1];
 }

 ll ans=0;
ind=0;
 for(int i=0;i<n;i++)
 {
     while(ind<n&&b[ind]<c[i])
        ind++;
   if(ind)
     ans+=bb[ind-1];

 }

 cout<<ans;

    return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n, i;
    cin >> n >> i;
    cout << (n - i) + 1 << endl;
    return 0;
}

Measured memory_bytes: 3544
def main():
    X = int(input())


    def isOK(A, B):
        eq = A**5 - B**5
        if eq <= X:
            return True
        else:
            False
    
    def bin_search(B):
        # search A
        # A**5 - B **5 <= X となる最大のAを求める
        left = B
        right = 10 ** 4 * 2

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

        return left
    

    for B in range(-10**4, 10**4 + 1):
        A = bin_search(B)
        if A**5 - B**5 == X:
            print(A, B)
            exit()
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 9160
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    ld a,b;
    cin >> a>>b;
    int res=round(a*b*100);
    cout << res/100 << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main() {
    //
    int num;
    string str;

    cin >> str;

    num = str.size();
    vector<int> vec(num, 0);

    for (int x = 0; x < 2; x++) {
        int cnt = 0;
        for (int i = 0; i < num; i++) {
            if (str.at(i) == 'R')
                cnt++;
            else {
                vec.at(i) += cnt / 2;
                vec.at(i - 1) += (cnt + 1) / 2;
                cnt = 0;
            }
        }

        reverse(vec.begin(), vec.end());
        reverse(str.begin(), str.end());
        for (int i = 0; i < num; i++) {
            if (str.at(i) == 'L')
                str.at(i) = 'R';
            else
                str.at(i) = 'L';
        }
    }

    for (int i = 0; i < num; i++) { cout << vec.at(i) << " "; }
}


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


int main(void){
  ll a,b,c;
  
  cin >> a >> b >> c;
  
  if (a+b < c && a*b*4 < (c-a-b)*(c-a-b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

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

#define P pair<int,int>
using namespace std;

// マスの縦横
int H,W;
// #,.を格納するマス
char A[1000][1000];
// 幅優先探索の深さを格納するマス
int am[1000][1000];
// 隣り合う辺への移動量
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
// 答え
int ans=0;
 
void BFS(){
  // 入力を受取り、キューに位置x,yを格納
  cin >> H >> W;
  queue<P> que;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >> A[i][j];
      am[i][j] = -1;
      if (A[i][j]=='#'){
        am[i][j] = 0;
        que.push(P(i,j));
      }
    }
  }
  // キューを前から取り出し、隣り合う辺が.か#か調べ.なら#に更新し、深さを1足す
  while (!que.empty()){
    P p = que.front();
    que.pop();
    for (int i=0;i<4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx>=0 && nx<H && ny>=0 && ny<W && A[nx][ny]!='#'){
        A[nx][ny] = '#';
        am[nx][ny] = am[p.first][p.second]+1;
        que.push(P(nx,ny));
      }
    }
  }
}
 
int main(){
  BFS();
  // 答えとなる最も深いものを取り出す
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      ans = max(ans, am[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13328
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    string res = "";
    ll min = 26;
    while(N > 0) {
        N -= 1;
        res += (char)('a' + (N % 26));
        N /= 26;
    }
    reverse(All(res));
    cout << res << endl;
    return 0;
}

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

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


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

int main(){
    int N,K,a,b,c;
    cin >> N >> K;

    vector<ll> v(N,0),res(N,1e9);

    cin >> v[0];
    res[0]=0;
    for (int i=1;i<K;++i){
        cin >> v[i];
        for (int j=0;j<i;++j){
            res[i] = min(res[j] + abs(v[i] - v[j]) , res[i]);
        }
    }
    
    for (int i=K;i<N;++i){
        cin >> v[i];
        for (int j=i-K;j<i;++j){
            res[i] = min(res[j] + abs(v[i] - v[j]) , res[i]);
        }
        
    }
    cout << res[N-1] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int h,w,a=0,t,r,i,j,k;
  int Y[]={1,0,-1,0};
  int X[]={0,1,0,-1};
  int y[10000],x[10000];
  while(scanf("%d %d",&h,&w),h||w){
  char c,m[103][103]={0};
  a=0;
    for(i=0;i<h;i++)scanf("%s",m[i+1]+1);
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(m[i+1][j+1]==0)continue;
	y[t=0]=i+1;
	x[t  ]=j+1;
	c=m[i+1][j+1];
	m[i+1][j+1]=0;
	a++;
	for(r=1;r-t;t++){
	  for(k=0;k<4;k++){
	    if(m[y[t]+Y[k]][x[t]+X[k]]==c){
	      y[r]=y[t]+Y[k];
	      x[r]=x[t]+X[k];
	      m[y[r]][x[r]]=0;
	      r++;
	    }
	  }
	}
      }
    }
    printf("%d\n",a);
  }
  return 0;
}
  
      

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

int main() {
	string s1,s2;
	long long count=0;
	cin>>s1>>s2;
	for(long int i=0;i<s1.size();i++){
		
			if(s1[i]!=s2[i]) count++;
		
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3916
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら4321)
    return *((int*)b)- *((int*)a);
}

#define MIN(a,b)  ( ((a)>(b))?(b):(a) )

int main(){
    int A[3];

    InputIntAry(A,10,3);
    if(
        (A[0]==A[1] && A[0]!=A[2]) ||
        (A[1]==A[2] && A[0]!=A[1]) ||
        (A[0]==A[2] && A[0]!=A[1])
    ){
        puts("Yes");
    }
    else{
        puts("No");
    }

    return 0;
} 

Measured memory_bytes: 128
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint64_t Q, H, S, D, N;

    scanf("%"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64"\n%"PRIu64, &Q, &H, &S, &D, &N);

    uint64_t min = 4 * Q * N;

    if (2 * H * N < min) {
        min = 2 * H * N;
    }
    if (S * N < min) {
        min = S * N;
    }
    if (N / 2 * D + (N % 2) * 4 * Q < min) {
        min = N / 2 * D + (N % 2) * 4 * Q;
    }
    if (N / 2 * D + (N % 2) * 2 * H < min) {
        min = N / 2 * D + (N % 2) * 2 * H;
    }
    if (N / 2 * D + (N % 2) * S < min) {
        min = N / 2 * D + (N % 2) * S;
    }

    printf("%"PRIu64, min);

    return 0;
}


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

int main(){
    long long n, e; cin >> n >> e;
    vector<vector<long long> > g(n + 1, vector<long long> (n + 1, 1000000000000));
    for(long long i = 0; i < n; i++) g[i][i] = 0;
    for(long long i = 0; i < e; i++){
        long long a, b, d; cin >> a >> b >> d;
        g[a][b] = min(g[a][b], d);
    }

    //ワーシャルフロイド
    for(long long k = 0; k < n; k++){
        for(long long i = 0; i < n; i++){
            for(long long j = 0; j < n; j++){
                if(g[i][k] != 1000000000000 && g[k][j] != 1000000000000) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
                if(i == j && g[i][j] < 0) return !printf("NEGATIVE CYCLE\n");
            }
        }
    }

    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < n; j++){
            if(g[i][j] == 1000000000000) cout << "INF";
            else cout << g[i][j];

            if(j != n - 1) cout << " ";
            else cout << endl;
        }
    }
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200;
const int L=62;
const LL X=1LL<<L;
LL a[N];
char s[N];
LL x[L];
bool ins(LL v){
	for(int i=L-1;i>=0;i--){
		if((v>>i)&1){
			if(x[i]){
				v^=x[i];
			}
			else{
				x[i]=v;
				return true;
			}
		}
	}
	return false;
}
bool work(){
	memset(x,0,sizeof(x));
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cin>>s;
	for(int i=n-1;i>=0;i--){
		if(ins(a[i])&&s[i]=='1'){
			return true;
		}
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	int t;
	cin>>t;
	while(t--){
		puts(work()?"1":"0");
	}
	return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

class E
{
	static int F()
	{
		return int.Parse(Console.ReadLine());
	}
	static int[] G()
	{
		return Console.ReadLine().Split().Select(int.Parse).ToArray();
	}
	static int D(int[] a, int[] b)
	{
		return Math.Abs(a[0] - b[0]) + Math.Abs(a[1] - b[1]);
	}
	public static void Main()
	{
		var I = G();
		int N = I[0], M = I[1];
		var p = new int[N][];
		for (var i = 0; i < N; i++) p[i] = G();
		var c = new int[M][];
		for (var i = 0; i < M; i++) c[i] = G();
		for (var i = 0; i < N; i++)
		{
			var m = D(p[i], c[0]);
			var k = 0;
			for (var j = 1; j < M; j++)
			{
				var d = D(p[i], c[j]);
				if (d < m)
				{
					m = d;
					k = j;
				}
			}
			Console.WriteLine(k + 1);
		}
	}
}


Measured memory_bytes: 11476
s = input()
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
aa = [0]*26
ans = "yes"
for i in range(len(s)):
    for j in range(26):
        if s[i] == alphabet[j]:
            aa[j] += 1
            if aa[j] >= 2:
                ans = "no"
                break
print(ans)


Measured memory_bytes: 61936
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat May  5 21:05:21 2018
//
package main

import (
	"fmt"
)

type pair struct {
	x, y int
}

var H, W int

func main() {
	fmt.Scan(&H, &W)

	graph := make([]string, H)
	for i := range graph {
		fmt.Scan(&graph[i])
	}

	for i := range graph {
		for j := range graph[i] {
			if graph[i][j] == '#' {
				invalid := true
				for _, p := range []pair{{-1, 0}, {1, 0}, {0, 1}, {0, -1}} {
					x := i + p.x
					y := j + p.y
					if 0 <= x && x < H && 0 <= y && y < W && graph[x][y] == '#' {
						invalid = false
					}
				}
				if invalid {
					fmt.Println("No")
					return
				}
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
int a[200000];
int main() {
	int N;
	cin >> N;
	LL sum = 0;
	rep(i, N) cin >> a[i], sum += a[i];
	LL snuke = 0;
	LL ans = 1LL << 60;
	REP(i, 0, N - 1) {
		snuke += a[i];
		ans = min(ans, abs(sum - 2 * snuke));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	// AOJ 0056 , 0185 とソースコードは同じ

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

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

		while(true){
			int max = 0;
			int n = stdIn.nextInt();

			if(max<n){
				primeSet(n);
				max=n;
			}

			if(n==0){
				break;
			}

			// if(奇数) then "0" な訳ではない。n=7 ... [2,5]

			int cnt = 0;
			for(int i=2;i<=n/2;i++){
				if(primes[i]&&primes[n-i]){
					// System.out.println("["+i+","+(n-i)+"]");
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

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

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    if(k==0) ans=n*n;
    else{
        for(ll b=k+1;b<=n;b++) ans+=(b-k)*(n/b)+max((ll)0,n%b-k+1);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  reverse(mochi.begin(), mochi.end());
  int ans = 0;
  int prev = 101;
  for (int i = 0; i < N; i++) {
    int cur = mochi.at(i);
    if (cur < prev) ans++;
    prev = cur;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
h,w = map(int,input().split())
a = []
a.append("@"*(w+2))
for i in range(h):
    a.append("@"+str(input())+"@")
a.append("@"*(w+2))
for i in range(1,h+1):
    for j in range(1,w+1):
        if a[i][j]==".":
            l=[a[i-1][j-1],a[i-1][j],a[i-1][j+1],a[i][j-1],a[i][j+1],a[i+1][j-1],a[i+1][j],a[i+1][j+1]]
            tmp = l.count("#")
            a[i]=a[i][:j]+str(tmp)+a[i][j+1:]
for i in a:
    print(i.replace("@",""))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int main()
{

    #ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int sum = 0;
	sum += min(k, a);
	k -= min(k, a);
	k -= min(k, b);
	sum -= min(k, c);
	cout << sum;
    return 0;
}


Measured memory_bytes: 3596
from collections import defaultdict
from math import gcd
N = int(input())
MOD = 10**9 + 7
L = defaultdict(lambda: [0,0])
zero = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A==0: d=B
    elif B==0: d=A
    else: d=gcd(A,B)
    if d != 0:
        A, B = A//d, B//d
        if A<0: A, B = -A, -B
        if B>0: L[(A,B)][0] += 1
        else: L[(-B,A)][1] += 1
    else: zero += 1
res = 1
for x,y in L.values():
    res *= pow(2,x,MOD) + pow(2,y,MOD) -1
    res %= MOD
print((res+zero-1)%MOD)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using PL = pair<ll,ll>;

int n, cur = 0;
vector<vector<int>> hen;
vector<vector<int>> id(1005, vector<int>(1005, -1));
vector<int> dp;
bool is_dag = true;

void init() {
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            id[i][j] = cur++;
        }
    }   
    dp.resize(cur);
    hen.resize(cur);
}

int value(int i, int j) {
    if(i > j)swap(i, j);
    return id[i][j];
}

int dfs(int v) {
    if(dp[v] != 0) {
        if(dp[v] > 0) {
            return dp[v];
        }else {
            is_dag = false;
            dp[v] = -2;
            return -1;
        }
    }

    int now = dp[v];
    dp[v] = -1;
    for(auto i : hen[v]) {
        now = max(now, dfs(i) + 1);
    }
    dp[v] = now;
    return dp[v];
}


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

    for(int i = 0; i < n; i++) {
        int s; cin >> s; s--;
        s = value(i, s);
        for(int j = 0; j < n - 2; j++) {
            int a; cin >> a; a--;
            hen[s].push_back(value(i, a));
            s = value(i, a);
        }
    }

    for(int i = 0; i < cur; i++) {
        dfs(i);
    }
    
    cout << (is_dag ? *max_element(dp.begin(), dp.end()) + 1 : -1) << endl;

}

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

int main(){
    int n,max = 0;
    string s;
    cin >> n;
    cin >> s;
    for(int i = 1; i < n; i++){
        string a = s.substr(0,i);
        string b = s.substr(i);
        int count = 0;
        for(char j = 'a'; j <= 'z'; j++){
            if(a.find(j) != string::npos&& b.find(j) != string::npos)
                count++;
        }
        if(count > max)
            max = count;
    }
    cout << max;
}

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

int main() {
    int N;
    cin >> N;
    int M;
    cin >> M;
    int X;
    cin >> X;
    vector<int> checkpoint(M);
    for(int i = 0; i < M; i++) cin >> checkpoint.at(i);

    int right = 0;
    int left = 0;

    for(int i = 0; i < M; i++){
        if(checkpoint.at(i) < X) left++;
        else right++;
    }

    int ans = min(right, left);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int par[110001];

int rt(int u)
{
	if(par[u]<0) return u;
	return (par[u]=rt(par[u]));
}

void merge(int u,int v)
{
	u=rt(u); v=rt(v);
	if(u==v) return ;
	if(par[u]>par[v]) swap(u,v);
	par[u]+=par[v]; par[v]=u;
}

ii a[111111];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	memset(par,-1,sizeof(par));
	vector<pair<ll,ii> > vec;
	vector<ii> X,Y;
	for(int i = 0; i < n; i++)
	{
		int x,y; cin>>x>>y;
		a[i]=mp(x,y);
		X.pb(mp(x,i)); Y.pb(mp(y,i));
	}
	sort(X.begin(),X.end()); sort(Y.begin(),Y.end());
	for(int i=0;i+1<n;i++)
	{
		vec.pb(mp(min(abs(a[X[i].se].fi-a[X[i+1].se].fi),abs(a[X[i].se].se-a[X[i+1].se].se)),mp(X[i].se,X[i+1].se)));
		vec.pb(mp(min(abs(a[Y[i].se].fi-a[Y[i+1].se].fi),abs(a[Y[i].se].se-a[Y[i+1].se].se)),mp(Y[i].se,Y[i+1].se)));
	}
	sort(vec.begin(),vec.end());
	ll ans=0;
	for(int i=0;i<vec.size();i++)
	{
		if(rt(vec[i].se.fi)!=rt(vec[i].se.se))
		{
			ans+=vec[i].fi;
			merge(vec[i].se.fi,vec[i].se.se);
		}
	}
	cout<<ans<<'\n';
}


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

using namespace std;

int H,W,K;
int X1,Y1,X2,Y2;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<vector<bool>> grid;
vector<vector<int>> dist;

bool inside(int i,int j){
	return (i>=0)&&(i<H)&&(j>=0)&&(j<W)&&(grid[i][j]);
}
 
int main(){
    cin>>H>>W>>K;
    cin>>X1>>Y1>>X2>>Y2;
    X1--;X2--;Y1--;Y2--;
    grid.resize(H);
    dist.resize(H);
    for(int i=0;i<H;i++){
        string s;
        cin>>s;
        grid[i].resize(W);
        dist[i].resize(W,INT_MAX);
        for(int j=0;j<W;j++) 
        	grid[i][j]=(s[j]=='.');
    }
    queue<pair<int,int>> q;
    q.push({X1,Y1});
    dist[X1][Y1]=0;
    while(!q.empty()){
        int i=q.front().first,j=q.front().second;
        	q.pop();
        for(int k=0;k<4;k++){
        	for(int d=1;d<=K;d++){
            	int x=i+d*dx[k],y=j+d*dy[k];
            	if(!inside(x,y)||dist[x][y]<=dist[i][j]) 
            		break;
            	if(dist[x][y]==INT_MAX){
                	dist[x][y]=dist[i][j]+1;
                	q.push({x,y});
            	}
        	}
        }
    }
    int ans=dist[X2][Y2];
    if(ans==INT_MAX) 
    	ans=-1;
    cout << ans << endl;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (X > Y) {
        swap(X, Y);
        swap(A, B);
    }
    if (A + B <= 2 * C) cout << (A + B) * X + min(B, 2 * C) * (Y - X) << endl;
    else cout << X * 2 * C + min(B, 2 * C) * (Y - X) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    vector<vector<int>> a(3,vector<int>(3)); 

    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int d1 = a[0][0]-a[0][1],d2 = a[0][1] - a[0][2];
    rep(i,3){
        if(a[i][0]-a[i][1]==d1&&a[i][1]-a[i][2]==d2){
            continue;
        }
        else{
            cout << "No";
            return 0;
        }
    }

    int g1 = a[0][0] - a[1][0], g2 = a[1][0] - a[2][0];
    rep(i,3){
        if(a[0][i]-a[1][i]==g1&&a[1][i]-a[2][i]==g2){
            continue;
        }
        else{
            cout << "No";
            return 0;
        }
    } 
    cout << "Yes";

    return 0;
}

Measured memory_bytes: 256