akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
ll a[1004];
ll b[1004];
ll dp[20004];
int main()
{
    
	
    	
        FastIO
        ll i,h,n,j,x=0;

        cin>>h>>n;

        for(i=0;i<n;i++) {cin>>a[i]>>b[i];x=max(x,a[i]);}

        	dp[0]=0;

        	for(i=1;i<=20003;i++)
        		dp[i]=999999999999;

        	for(i=1;i<=h+x-1;i++)
        	{

        		for(j=0;j<n;j++)
        		{
        			if(i-a[j]>=0)
        				dp[i]=min(dp[i-a[j]]+b[j],dp[i]);
        		}
        	}
        	for(i=h;i<=h+x-1;i++)
        		dp[h]=min(dp[h],dp[i]);
        	cout<<dp[h];
        	return 0;
        }


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

template<class T> 
struct BinaryIndexedTree {
    int N,power = 1;
    vector<T> bit;

    BinaryIndexedTree(int N = 0): N(N){
        bit.assign(N + 1,0);
        while (power <= N) power <<= 1; //power > N
    }
    void build(const vector<T> &A) {
        for (int i = 1;i <= N; ++i) add(i,A[i - 1]);
    }
    //add x to a[i]
    void add(int i,T x) {
        for (int idx = i; idx <= N; idx += (idx & -idx)) {
            bit[idx] += x;
        }
    }
    // return a[1] + a[2] + a[3] + .. + a[k]
    T sum(int k) {
        T ret = 0;
        for (int idx = k; idx > 0; idx -= (idx & -idx)) {
            ret += bit[idx];
        }
        return ret;
    }
    // return a[l] + a[l + 1] + a[l + 2] + .. + a[r - 1]
    T sum(int l,int r) {
        return sum(r - 1) - sum(l - 1);
    }
    // return min index s.t. a[1] + a[2] + a[3] + .. + a[x] >= w
    int lower_bound(T w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int r = power; r > 0; r >>= 1) {
            if (x + r <= N && bit[x + r] < w) {
                w -= bit[x + r];
                x += r;
            }
        } 
        return x + 1;
    }
};

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

    int N,Q; cin >> N >> Q;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    BinaryIndexedTree<ll> bit(N);
    bit.build(A);

    rep(i,Q) {
        int t; cin >> t;
        if (t == 0) {
            int p,x; cin >> p >> x;
            bit.add(p + 1,x);
        } else {
            int l,r; cin >> l >> r;
            cout << bit.sum(l + 1,r + 1) << '\n';
        }
    }
    return 0;
}

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

const ll siz = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll maxx = 1e9;
const ll MAXX = 1e17;
const ll base = 31;

string s;
char x;
int q, t, f;
bool rev = false;
deque <char> d;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_2.INP", "r", stdin);
//    freopen ("OUT_2.OUT", "w", stdout);
    cin >> s >> q;
    for (int i = 0; i < s.size(); i++)
        d.push_back(s[i]);
    while (q--)
    {
        cin >> t;
        if (t == 1)
        {
            if (rev == false) rev = true;
            else rev = false;
        }
        else
        {
            cin >> f >> x;
            if (f == 1)
                (rev == false) ? d.push_front(x) : d.push_back(x);
            else
                (rev == false) ? d.push_back(x) : d.push_front(x);
        }
    }
    if (rev == false)
        while (!d.empty())
        {
            cout << d.front();
            d.pop_front();
        }
    else
        while (!d.empty())
        {
            cout << d.back();
            d.pop_back();
        }
    return 0;
}


Measured memory_bytes: 976
ab=[list(map(int,input().split())) for _ in range(3)]
a,b,c,d=0,0,0,0
for k in ab:
    for t in k:
        if t==1:
            a+=1
        elif t==2:
            b+=1
        elif t==3:
            c+=1
        else:
            d+=1
z=[a,b,c,d]
if z.count(2)==2 and z.count(1)==2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38576
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 4/7/2019, 12:27:14 AM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll X[3];
ll K;
ll A[3][1010];
vector<ll> ans;

int main()
{
  for (auto i = 0; i < 3; i++)
  {
    cin >> X[i];
  }
  cin >> K;
  for (auto i = 0; i < 3; i++)
  {
    for (auto j = 0; j < X[i]; j++)
    {
      cin >> A[i][j];
    }
  }
  for (auto i = 0; i < 3; i++)
  {
    sort(A[i], A[i] + X[i]);
    reverse(A[i], A[i] + X[i]);
  }
  for (auto i = 0; i < X[0]; i++)
  {
    if (i + 1 > K)
    {
      break;
    }
    for (auto j = 0; j < X[1]; j++)
    {
      if ((i + 1) * (j + 1) > K)
      {
        break;
      }
      for (auto k = 0; k < X[2]; k++)
      {
        if ((i + 1) * (j + 1) * (k + 1) > K)
        {
          break;
        }
        ans.push_back(A[0][i] + A[1][j] + A[2][k]);
      }
    }
  }
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());
  for (auto i = 0; i < K; i++)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 1400
#__author__ = "tatuo"
#__date__ = "$Mar 3, 2018 12:34:20 PM$"

import math
import re
import sys


def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result




arr_data = getinputdata()

n = int(arr_data[0][0])

print(n*800 - n//15*200)

#x = "ABC" if n <1200 else "ARC"
#
#print(x)

#s1 = arr_data[0][0][0]
#s2 = arr_data[1][0][1]
#s3 = arr_data[2][0][2]
#
#print(s1+s2+s3)
#


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
ll MAX = 1000000007;
ll solver(ll *a, ll n)
{
    ll sum = 0, ans = 0;
    rep(i, 0, n)
    {
        sum += a[i];
        sum %= MAX;
    }
    rep(i, 0, n - 1)
    {
        sum -= a[i];
        if (sum < 0)
            sum += MAX;
        ans += (a[i] * sum % MAX);
        ans %= MAX;
    }
    return ans;
}
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    cout << solver(a, n) << endl;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int c = 0;
    vector<pair<int, int>> p;
    FOR(i, 1, n + 1) {
        FOR(j, i + 1, n + 1) {
            if ((n % 2 == 0 && n + 1 - i == j) || (n % 2 == 1 && n - i == j)) {
                continue;
            }
            c++;
            p.emplace_back(i, j);
        }
    }
    cout << c << endl;
    for (const auto x : p) {
        cout << x.first << " " << x.second << endl;
    }
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		try {
			s = br.readLine();
			System.out.println(s.toUpperCase());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

int main(){
  int n, a, b; cin >> n >> a >> b;
  int ans = 0;
  for(int x = 1; x <= n; x++){
  	int sum = 0;
    int y = x;
    while(y > 0){
      sum += y % 10;
      y /= 10;
    }
    
    if(a <= sum && sum <= b) ans += x;
  }
  
  cout << ans << endl;
  return 0;
}

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

const int INF = 1001001001;

int main(){
    int n,m,l;
    cin >> n >> m >> l;    
    vector<vector<int>> dist(n,vector<int>(n,INF));
    for(int i=0;i<m;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        dist.at(a).at(b) = c;
        dist.at(b).at(a) = c;
    }
    for(int i=0;i<n;i++){
        dist.at(i).at(i) = 0;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dist.at(i).at(j) = min(dist.at(i).at(j) , dist.at(i).at(k)+dist.at(k).at(j));
            }
        }
    }
    vector<vector<int>> dist2(n,vector<int>(n,INF));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(dist.at(i).at(j) <= l) dist2.at(i).at(j) = 1;
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dist2.at(i).at(j) = min(dist2.at(i).at(j) , dist2.at(i).at(k)+dist2.at(k).at(j));
            }
        }
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int s,t;
        cin >> s >> t;
        s--; t--;
        if(dist2.at(s).at(t) == INF){
            cout << -1 << endl;
        }else{
        cout << dist2.at(s).at(t) -1 << endl;
        }
    }
}

Measured memory_bytes: 1280
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let b: i32 = input();
    if (a + b) % 2 == 0 {
        println!("{}", (a + b) / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int x;
  cin>>x;
  int a= x/500;
  int b= x-a*500;
  b= b/5;
  cout<<1000*a+ 5*b;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

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

int main()
{
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; i++)
  {
    scanf("%d", &a[i]);
  }
  int ans = 1000000000;
  for (int i = 0; i < N; i++)
  {
    int cnt = 0;
    while (a[i] % 2 == 0)
    {
      cnt++;
      a[i] = a[i] / 2;
    }
    ans = min(ans, cnt);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 888
class SegmentTree:

    def __init__(self, ls, ide, seg_func):
        n = len(ls)
        self.num = 2 ** (n - 1).bit_length()
        self.seg_func = seg_func
        self.ide = ide
        self.tree = [self.ide] * (2 * self.num - 1)
        for i, l in enumerate(ls):
            self.tree[i + self.num - 1] = l

        for i in range(self.num - 2, -1, -1):  # 子を束ねて親を更新
            self.tree[i] = seg_func(self.tree[2 * i + 1], self.tree[2 * i + 2])

    def update(self, i, x):
        i += self.num - 1
        self.tree[i] = x
        while i:
            i = (i-1)//2
            self.tree[i] = self.seg_func(self.tree[2 * i + 1], self.tree[2 * i + 2])

    def query(self, l, r):
        if r < l:
            return ValueError('invalid index')

        l += self.num - 1
        r += self.num - 2
        res = self.ide
        while r - l > 1:  # 右から寄りながら結果を結合していくイメージ
            if l & 1 == 0:
                res = self.seg_func(res, self.tree[l])
            if r & 1 == 1:
                res = self.seg_func(res, self.tree[r])
                r -= 1
            l = l // 2  # 親の一つ右に移動
            r = (r - 1) // 2  # 親の一つ左に移動
        if l == r:
            res = self.seg_func(res, self.tree[l])
        else:
            res = self.seg_func(res, self.tree[l])
            res = self.seg_func(res, self.tree[r])
        return res


def f(a, b):
    return a | b


n = int(input())
s = [1 << (ord(r) - ord("a")) for r in input()]
q = int(input())
st = SegmentTree(s, 0, f)

for _ in range(q):
    m, i, c = input().split()

    if int(m) - 1:
        x = st.query(int(i)-1, int(c))
        print(bin(x).count("1"))
    else:
        st.update(int(i)-1, 1 << (ord(c) - ord("a")))


Measured memory_bytes: 48032
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
    int N;
    cin >> N;
    vector <vector <int>> h(N, vector <int>(3));
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 3; j++){
        cin >> h[i][j];
      }
    }
    vector <vector <int>> sum(N, vector <int>(3));
    for (int i = 0; i < 3; i++) {
      sum[0][i] = h[0][i];
    }

    for (int i = 1; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if ( j == k ) {
            continue;
          }
          sum[i][j] = max(sum[i][j], h[i][j] + sum[i-1][k]);
        }
      }
    }
    int ans = max({sum[N-1][0], sum[N-1][1], sum[N-1][2]});
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    ll a,b;
    cin >> a >> b;

    if(a<=0 && b>=0){
        cout << "Zero" << endl;
    }else if(a>0){
        cout << "Positive" << endl;
    }else if(b<0){
        if((abs(b-a)+1)%2==0)cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }

    return 0;
}


Measured memory_bytes: 3468
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    now = a[x-1] + b[y-1] - c
    ans = min(ans, now)
print(ans)


Measured memory_bytes: 18740
N, M, X = [int(x) for x in input().split()]

C = []
A = []

for _ in range(N):
    CA = [int(x) for x in input().split()]
    C.append(CA[0])
    A.append(CA[1:])

INF = 99999999999999999999999
minC = INF

for i in range(1<<N):
    tmpC = 0
    tmpA = [0] * M
    for j in range(N):
        if i & (1 << j):
            tmpC += C[j]
            for k in range(M):
                tmpA[k] += A[j][k]

    if min(tmpA) >= X:
        minC = min(tmpC, minC)

print(minC if minC!=INF else -1)
        
    
        

Measured memory_bytes: 9152
def main():
    A, B, C, D = map(int, input().split())
    lv = [[A, B], [C, D]]
    lv.sort(key = lambda x:x[0])
    if lv[0][1] < lv[1][0]:
        return 0
    return min(lv[0][1], lv[1][1]) - lv[1][0]


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if(op=='+')
	printf("%d",a+b);
	else if(op=='-')
	printf("%d",a-b);
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
F = [int(input().replace(' ', ''), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = float('-inf')

for i in range(1, 2**10):
    ans = max(ans, sum(p[bin(i & f).count('1')] for f, p in zip(F, P)))
print(ans)


Measured memory_bytes: 9220
#include<stdio.h>
#include<string.h>

int GCD(int x,int y)
{
  if(y==0)
    return x;
  return GCD(y,x%y);
}

int LCM(int x,int y)
{
  int i;
  for(i=1;i<=y;i++)
    {
      if((x*i)%y == 0)
	return x*i;
    }
  return x*y;
}



int main(void)
{
  int a,b,k;
  while(scanf("%d %d",&a,&b) != EOF)
    {
      if(a<b){
	 k = b;
	b = a;
	a = k;
      }
      printf("%d %d\n",GCD(a,b),LCM(a,b));
    }
}

Measured memory_bytes: 2568
import java.util.Map;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static Map<Integer, Point> map;
    public static void main(String[] args) throws Exception {
        int[] ary = {0,-1,-1,0,0,1,1,0};
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if (n == 0) break;
            int maxx = 0;
            int maxy = 0;
            int minx = 0;
            int miny = 0;
            map = new HashMap<>();
            map.put(0, new Point(0, 0));
            for (int i = 1; i < n; i++) {
                int c = sc.nextInt();
                int d = sc.nextInt();
                Point p = map.get(c);
                map.put(i, new Point(p.x+ary[d*2], p.y+ary[d*2+1]));
            }
            
            for (int i = 0; i < n; i++) {
                Point p = map.get(i);
                maxx = Math.max(maxx, p.x);
                maxy = Math.max(maxy, p.y);
                minx = Math.min(minx, p.x);
                miny = Math.min(miny, p.y);
            }
            
            int dx = maxx-minx+1;
            int dy = maxy-miny+1;
            System.out.println(dy + " " + dx);
        }
    }
}

class Point {
    public int x;
    public int y;
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

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

int main(){
    int H, W, x, y; cin >> W >> H >> x >> y;
    double ans = (double)H * W / 2;
    int num = (W == x + x && H == y + y) ? 1 : 0;
    printf("%.10f %d\n",ans,num);
}

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

#define lli long long int
#define pb push_back

vector<lli> graph[100001];
lli visited[100001];
lli dp[100001];

lli dfs(lli cur)
{
    lli i,node,a=0;
    if(visited[cur] == 1)
    {
        return dp[cur];
    }
    visited[cur] = 1;

    for(i=0;i<graph[cur].size();i++)
    {
        node = graph[cur][i];

        if(visited[node]  == 1)
        {
            a = max(a, 1+dp[node]);
        }
        else
        {
            a = max(a, 1+dfs(node));
        }
    }

    dp[cur] = a;
    return a;
}


main()
{
    lli n,m,i,j,a,b,c;

    cin>>n>>m;

    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        graph[a].pb(b);
    }
    a = 0;

    for(i=1;i<=n;i++)
    {
        if(graph[i].size() == 0)
        {
            dp[i] = 1;
            visited[i] = 1;
        }
        else
        {
            dp[i] = -1;
        }
    }

    for(i=1;i<=n;i++)
    {
        if(visited[i] == 0)
        {
            a = max(a,dfs(i));
        }
    }
    cout<<a-1;

}


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

int main(){
    int N; cin >> N;
    string S,T; cin >> S >> T;
    rep(i,N){
        cout << S[i] << T[i];
    }
}

Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

b = sorted(a)
max_ind = a.index(b[n - 1])

for i in range(n):
    if i == max_ind:
        print(b[n - 2])
    else:
        print(b[n - 1])

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



int main()
{
    std::string S;
    std::cin >>S;
    if(S[0]==S[1] && S[2]==S[0]){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

// G13E_5.cpp

LL n, m, x[100002];
const LL MOD = 1000000007;

void mat_prod(LL a[3][3], LL b[3][3], LL c[3][3]) { // a = b * c;
	LL d[3][3];
	inc(i, 3) {
	inc(j, 3) {
		d[i][j] = 0;
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
	inc(k, 3) {
		(d[i][j] += b[i][k] * c[k][j]) %= MOD;
	}
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = d[i][j];
	}
	}
	
	return;
}

void mat_exp(LL a[3][3], LL b[3][3], LL c) { // a = b ^ c;
	static bool flag = true;
	static LL t[30][3][3];
	if(flag) {
		inc(i, 3) {
		inc(j, 3) {
			t[0][i][j] = b[i][j];
		}
		}
		inc(i, 30 - 1) {
			mat_prod(t[i + 1], t[i], t[i]);
		}
		// flag = false;
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = 0;
	}
	}
	inc(i, 3) { a[i][i] = 1; }
	inc(i, 30) {
		if(c & (1 << i)) {
			mat_prod(a, a, t[i]);
		}
	}
	
	return;
}

int main() {
	cin >> n >> m;
	inc1(i, m) { cin >> x[i]; }
	x[0] = 0;
	x[m + 1] = n + 1;
	
	LL a[3][3] = { { 2, 1, 1 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL b[3][3] = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL c[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
	LL d[3][3];
	
	inc(i, m + 1) {
		if(i != 0) { mat_prod(c, b, c); }
		mat_exp(d, a, x[i + 1] - x[i] - 1);
		mat_prod(c, d, c);
	}
	
	cout << c[2][0] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>

using ll = long long;
ll dp[101][4][4][4];

int main()
{
    int mod = 1'000'000'007;

    int N;
    std::cin >> N;

    dp[0][3][3][3] = 1;

    for (int i = 0; i < N; i++)
    {
        for (int a3 = 0; a3 < 4; a3++)
        {
            for (int a2 = 0; a2 < 4; a2++)
            {
                for (int a1 = 0; a1 < 4; a1++)
                {
                    if (dp[i][a1][a2][a3] == 0)continue;
                    for (int c = 0; c < 4; c++)
                    {
                        if (a2 == 0 && a3 == 1 && c == 2)continue;
                        if (a2 == 0 && a3 == 2 && c == 1)continue;
                        if (a2 == 1 && a3 == 0 && c == 2)continue;
                        if (a1 == 0 && a3 == 1 && c == 2)continue;
                        if (a1 == 0 && a2 == 1 && c == 2)continue;
                        dp[i + 1][a2][a3][c] += dp[i][a1][a2][a3];
                        dp[i + 1][a2][a3][c] %= mod;
                    }
                }
            }
        }
    }

    ll ans = 0;
    for (int a1 = 0; a1 < 4; a1++)
    {
        for (int a2 = 0; a2 < 4; a2++)
        {
            for (int a3 = 0; a3 < 4; a3++)
            {
                ans += dp[N][a1][a2][a3];
                ans %= mod;
            }
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define dd double
using namespace std;

int main() 
{
    ios_base::sync_with_stdio(false);   
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector <int>v(m);
    rep(i,0,n)
    {
        cin>>v[i];
    }
    ll sum =accumulate(v.begin(),v.end(),0);
    if(n-sum<0)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }   
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main(){
	/*input*/
	int n;
	string s;
	cin >> n >> s ;

	/*calc*/
	if(n % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < n/2; i++){
		if(s[i] != s[i+(n/2)]){
		cout << "No" << endl;
		return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str1, str2, str3;
  cin >> str1;
  str2 = "a";
  str3 = "z";
  
  if (str2 <= str1  && str1 <= str3) {
    cout << "a" << endl;
  }
  else {
    cout << "A" << endl;
  }
 
}

Measured memory_bytes: 3624
import heapq


def dijkstra(start: int, edges: list):
    """print the shortet path  O(|E|log|V|)
    maybe verified
    """
    dist = [float('inf') for _ in range(N)]  # list dist[|V|]
    dist[start] = 0
    prev_v = [-1]*(len(dist))  # 最短経路でのひとつ前の頂点
    q = [(0, start)]  # （暫定的な距離，頂点）
    while q:
        d_cur, cur = heapq.heappop(q)
        if dist[cur] < d_cur:  # すでに探索済み
            continue
        for nex, cost in edges[cur]:
            if dist[nex] > dist[cur]+cost:
                dist[nex] = dist[cur]+cost
                heapq.heappush(q, (dist[nex], nex))
                prev_v[nex] = cur
    return dist

    # # 以下 path の復元
    # path = []
    # v = goal
    # while v != -1:
    #     path.append(v)
    #     v = prev_v[v]
    # path = path[::-1]  # reverse
    # print("Shortest path: ", path)


if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    X, Y = X-1, Y-1
    edges = [[] for _ in range(N)]
    for i in range(1, N):
        edges[i].append((i-1, 1))
    for i in range(N-1):
        edges[i].append((i+1, 1))
    edges[X].append((Y, 1))
    edges[Y].append((X, 1))
    # print(edges)

    cnt = [0]*N
    for i in range(N):
        d = dijkstra(i, edges)
        for di in d:
            cnt[di] += 1
    cnt = [ci//2 for ci in cnt]
    print(*cnt[1:], sep="\n")


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>a;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        a.push_back(k);
    }
    long sum=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum+=a[i]*a[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
# input関係の定義
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

# BEGIN CUT HERE
class RollingHash():
    BASE1 = 1007
    BASE2 = 2009
    MOD1 = 1000000007
    MOD2 = 1000000009

    def __init__(self, s):
        self.n = len(s)
        self.hash1 = [0] * (self.n + 1)
        self.hash2 = [0] * (self.n + 1)
        self.power1 = [1] * (self.n + 1)
        self.power2 = [1] * (self.n + 1)
        for i, e in enumerate(s):
            self.hash1[i + 1] = (self.hash1[i] * self.__class__.BASE1 + ord(e)) % self.__class__.MOD1
            self.hash2[i + 1] = (self.hash2[i] * self.__class__.BASE2 + ord(e)) % self.__class__.MOD2
            self.power1[i + 1] = (self.power1[i] * self.__class__.BASE1) % self.__class__.MOD1
            self.power2[i + 1] = (self.power2[i] * self.__class__.BASE2) % self.__class__.MOD2

    def get(self, l: int, r: int):
        res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
        if(res1 < 0):
            res1 += self.__class__.MOD1
        res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
        if(res2 < 0):
            res2 += self.__class__.MOD2
        return (res1, res2)
# END CUT HERE

def ABC131E():
    N = ii()
    S = li()
    rh = RollingHash(S)
    def check(n: int):
        d = dict()
        for i in range(N - n + 1):
            p = rh.get(i, i + n)
            if p in d:
                if(i - d[p] >= n):
                    return True
            else:
                d[p] = i
        return False
    ok, ng = 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(ok)



if __name__ == '__main__':
    ABC131E()


Measured memory_bytes: 5128
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String[] stra = (scan.nextLine()).split(" ");
			String[] strb = (scan.nextLine()).split(" ");
			
			int suma = 0;
			int sumb = 0;
			for(int i = 0;i < 4;i++){
				suma += Integer.parseInt(stra[i]);
				sumb += Integer.parseInt(strb[i]);
			}
			if(suma >= sumb){
				System.out.println(suma);
			}else{
				System.out.println(sumb);
			}
			
		}
	}
}

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

int main(){
	lint a,b,c,k;
	cin >> a >> b >> c >> k;
	lint total = 0;
	if (a == k)
		total = a;
	else if (a > k)
		total = k;
	else{
		total = a;
		if (a + b >= k){
			total = a;
		}
		else{
			rep(i,k-a-b)
				total -= 1;
		}
	}
	cout << total;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    string r, l;
    bool reversed = false;
    while(n--){
        int a;
        cin >> a;
        if(a == 1){
            reversed ^= 1;
            swap(r,l);
        }
	    else{
            int b;
            char c;
            cin >> b >> c;
            if(b == 1) r += c;
           else l += c;
        }
    }
    reverse(r.begin(), r.end());
    if(reversed) reverse(s.begin(), s.end());
    cout << r << s << l << endl;
    return 0; 
}

Measured memory_bytes: 1088
#include <stdio.h>
#include <math.h>
 
int main() {
    int xp1, xp2, yp1, yp2, p, xp, yp;
    scanf("%d%d%d%d%d", &xp1, &yp1, &xp2, &yp2, &p);
    while(p-- > 0) {
        scanf("%d%d", &xp, &yp);
        double r = ((xp2-xp1)*(xp-xp1)+(yp2-yp1)*(yp-yp1))/(pow(xp2-xp1,2)+pow(yp2-yp1,2));
        printf("%.8f %.8f\n", (1-r)*xp1+r*xp2, (1-r)*yp1+r*yp2);
    }
}



Measured memory_bytes: 2728
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (S[i] == T[i]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main (){
   double x1, x2, y1, y2, ans;
   cin >> x1 >> y1 >> x2 >> y2;
   ans = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
   cout << setprecision(10) << ans << endl;
   
}


Measured memory_bytes: 3296
import sys

N,M = map(int,input().split())

S = input()

slis = list(S)
slis.reverse()

ans = []

now = 0
#print (slis)

while now != N:

    flag = False

    for i in range(M):
        i = M - i

        if now + i <= N and slis[now + i] == "0":
            flag = True
            now = now + i
            ans.append(i)
            break

    if not flag:
        print (-1)
        sys.exit()

ans.reverse()

print (" ".join(map(str,ans)))


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

using namespace std;

#define M_DEBUG if (1)

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using lint = long long;
typedef unsigned long long int ullint;


/******************************************************************************
	Main
******************************************************************************/
#define L_MAX_STEPS 100000

int main()
{
    int n = 0, k = 0;
    cin >> n >> k;
    assert(n >= 2 && n <= pow(10, 5));
    assert(k >= 1 && k <= 100);

    int steps[L_MAX_STEPS] = {0}; // 第 i + 1 足場の高さ
    int costs[L_MAX_STEPS] = {0}; // 第 i + 1 足場までの最小コスト。
    rep(i, n)
    {
        cin >> steps[i];
        assert(steps[i] >= 1 && steps[i] <= pow(10, 4));
        if (i == 0) continue;
        // 0 - i までの最小コストを調べたい
        // i - 1 から飛んでくるのと、i - 2 から飛ぶのと、どっちがローコストか？
        costs[i] = abs(steps[i] - steps[i - 1]);
        costs[i] += costs[i-1];
        if (i > 1) {
            rep(j, k) {
                if (i - 1 - j < 0) continue;
                chmin(costs[i],
                      abs(steps[i] - steps[i - j - 1]) + costs[i - j - 1]);
            }
        }
    }

    cout << costs[n-1] << endl;

    return 0;
}


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

int main() {
  char c;
  char r;

  cin >> c;

  if (c == 'A')
    r = 'T';
  else if (c == 'T')
    r = 'A';
  else if (c == 'C')
    r = 'G';
  else if (c == 'G')
    r = 'C';

  cout << r << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (K, N) = nextLongList()
    val A = nextLongList()
    val B = (1 until N.toInt()).map { A[it] - A[it - 1] } + (K - A.last() + A.first())
    val ans = B.sum() - B.max()!!
    println(ans)
}

Measured memory_bytes: 64900
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;



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

    cin >> n;
    if (n % 2 != 0) cout << 0;
    else {
        ll fiv = 0;
        ll sec = 0;
        ll n1 = n;
        while (n1)
        {
            n1 /= 5;
            fiv += n1 / 2;
        }
        n1 = n;
        while (n1)
        {
            n1 /= 2;
            sec += n1;
        }
        cout << min(fiv, sec) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
from __pypy__ import builders
readline = sys.stdin.readline
N, Q = map(int, readline().split())
qs = [0]*N
for i in range(N):
    s, t, x = map(int, readline().split())
    qs[i] = (s-x, t-x, x)
qs.sort()

b = builders.StringBuilder(Q)
que = []
D = [int(readline()) for i in range(Q)]
j = 0
for d in D:
    while j < N and qs[j][0] <= d:
        s, t, x = qs[j]
        heappush(que, (x, t))
        j += 1
    while que and que[0][1] <= d:
        heappop(que)
    if que:
        b.append("%d\n" % que[0][0])
    else:
        b.append("-1\n")
sys.stdout.write(b.build())

Measured memory_bytes: 120784
#include <stdio.h> 

int main(void)
{
	int a, b, c, div, i ;
scanf("%d %d %d", &a, &b, &c);
for( i = a; i <= b; i++)
{
	if( c % i == 0)
	{
		div++;
	}
	
}
printf("%d\n", div);
return 0;	
}


Measured memory_bytes: 2752
#include<stdio.h>
int main() {
	int X, t;
	int n;
	scanf("%d", &X);
	scanf("%d", &t);
	n = X - t;
	if (n < 0) {
		printf("0");
	}
	else {
		printf("%d",n );
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n, ans;
	
	while (scanf("%d", &n), n){
		ans = 0;
		
		while (n - 1){
			n = (n % 2 == 0)? n / 2 : n * 3 + 1;
			ans++;
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 600
//ProblemD

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemD

class Solve {
private:
	void solve() {
		int a, b;
		char ca = '.', cb = '#';

		cin >> a >> b;

		a--;
		b--;

		string aa(100, ca);
		string ab(100, cb);
		vector<string> pa(20, aa);
		for (int i = 0; i < 40 && b; i += 2) {
			for (int j = 0; j < 100 && b; j += 2) {
				pa[i][j] = cb;
				b--;
			}
		}
		vector<string> pb(20, ab);
		for (int i = 0; i < 40 && a; i += 2) {
			for (int j = 0; j < 100 && a; j += 2) {
				pb[i][j] = ca;
				a--;
			}
		}

		vector<string> pc = {
			aa, ab, aa, ab
		};
		pc[1][0] = ca;
		pc[2].back() = cb;

		cout << 44 << ' ' << 100 << endl;
		for (auto& s : pa) {
			cout << s << endl;
		}
		for (auto& s : pc) {
			cout << s << endl;
		}
		for (auto& s : pb) {
			cout << s << endl;
		}
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try {
		    Scanner sc=new Scanner(System.in);
		    int n=sc.nextInt();
		    int m=sc.nextInt();
		    int sum=0;
		    for(int i=0;i<m;i++)
		    {
		        sum+=sc.nextInt();
		    }
		    n=n-sum;
		    if(n<0)
		    System.out.println(-1);
		    else
		    System.out.println(n);
		} catch(Exception e) {
		}
	}
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        u,v,w=MI()
        u-=1
        v-=1
        adj[u].append((v,w))
        adj[v].append((u,w))
        
    
    ans=[-1]*N
    import queue
    
    q=queue.Queue()
    q.put(0)
    ans[0]=0
    
    while not q.empty():
        v=q.get()
        for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
    for i in range(N):
        print(ans[i])
    
    

main()


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

int main() {
    string s;
    int k;
    cin >> k;
    cin >> s;
    if (int(s.size() <= k)) cout << s << endl;
    else
        cout << s.substr(0, k) + "..." << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1e9+7;
const int N = 5*1e5;



int main(){
    AC
    string s, t;
    cin>>s>>t;
    if(t.substr(0, s.size()) == s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

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

signed main() {
  int N, M;
  cin >> N >> M;
  
  map<int, int> kazu;
  int A;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    A *= -1;
    if( kazu.count(A) ){
      kazu.at(A)++;
    }else{
      kazu[A] = 1;
    }
  }
  
  int B, C;
  for( int i = 0; i < M; i++ ){
    cin >> B >> C;
    C *= -1;
    if( kazu.count(C) ){
      kazu.at(C) += B;
    }else{
      kazu[C] = B;
    }
  }
  
  int count = N;
  int ans = 0;
  for( auto p : kazu ){
    ans += p.first * min(p.second, count);
    if( count - p.second <= 0 ) break;
    else count -= p.second;
  }
  ans *= -1;
  cout << ans << endl;
  
  
}

Measured memory_bytes: 12800
#include <iostream>

using namespace std;

int main(){
  int N, M, ans=0;
  cin >> N >> M;
  long long int H[N], A[M], B[M];
  bool flags[N];
  for(int i=0; i<N; i++) cin >> H[i];
  for(int i=0; i<M; i++) cin >> A[i] >> B[i];
  for(int i=0; i<N; i++) flags[i] = true;
  for(int i=0; i<M; i++){
    if(H[A[i]-1] > H[B[i]-1]) flags[B[i]-1] = false;
    else if(H[A[i]-1] < H[B[i]-1]) flags[A[i]-1] = false;
    else{
      flags[A[i]-1] = false;
      flags[B[i]-1] = false;
    }
  }
  for(int i=0; i<N; i++){
    if(flags[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define MAX_N 200005
#define MAX_A 1000000005

long long A[MAX_N],N,b;
int main(){
    cin >> N;
    for(long long i=0;i<N;i++){
        cin >> A[i];
        A[i] -= i;
    }
    sort(A,A+N);

    if(N%2==0) b=A[N/2];
    else b=A[(N-1)/2];

    long long ans=0;

    for(long long i=0;i<N;i++){
        ans += abs(A[i]-b);
    }

    cout << ans << endl;

    
}

Measured memory_bytes: 1792
N,P=map(int, input().split())
*A,=map(int, input().split())

even=sum(1 for a in A if a&1==0)
odd =sum(1 for a in A if a&1==1)

def comb(n, r):
    p, q = 1, 1
    for i in range(min(r,n-r)):
        p *= n-i
        q *= i+1
    return p // q

ans=0
for i in range(P,odd+1,2):
    ans+=comb(odd, i)
ans *= 1<<even

print(ans)

Measured memory_bytes: 38384
#include <cstdio> 
typedef long long ll; 
int N;
ll L[87];
int main ()
{
scanf("%d",&N);
L[0]=2LL,L[1]=1LL;
for(int i=2;i<=N;i++) L[i]=L[i-2]+L[i-1]; 
printf("%lld\n",L[N]);
}

Measured memory_bytes: 128
eval"H,W,*A="+`dd`.split*?,
t,i=1e4,0
A.pop(H*W).zip(A){|a,b|a=(a-b).abs
i%W<1&&N=0
N|=$*[-W]||0**i<<t
$*<<N=N<<a|N>>a
i+=1}
p (0..t).find{|i|N[t+i]+N[t-i]>0}

Measured memory_bytes: 36996
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) break;

            for(int i=0; i<H; i++){
                for(int j = 0; j<W; j++){
                    System.out.print('#');
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 37828
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 1
cnt = [0, 0, 0]

for i in range(n):
    ans *= cnt.count(a[i])
    if a[i] not in cnt:
        print(0)
        exit()
    ind = cnt.index(a[i])
    cnt[ind] += 1

print(ans % mod)

Measured memory_bytes: 13964