akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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


int main(){
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u){
        cout<<a-1<<" "<<b<<endl;
    }else if(t==u){
        cout<<a<<" "<<b-1<<endl;
    }else{
        cout<<a<<" "<<b<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] input = new int[n];
        int [] output = new int[n];
        int k = 0;
        for(int i=0;i<n;i++){
            input[i] = sc.nextInt();
            if(input[i] > k) k = input[i];
        }
        int [] C = new int[k+1];
        Arrays.fill(C,0);
        for(int i=0;i<n;i++) C[input[i]]++;
        for(int i=1;i<=k;i++) C[i] += C[i-1];
        for(int i=n-1;i>=0;i--){
            output[C[input[i]]-1] = input[i];
            C[input[i]]--;
        }
        StringBuilder ans = new StringBuilder();
        ans.append(output[0]);
        for(int i=1;i<n;i++) ans.append(" "+output[i]);
        System.out.println(ans);
    }
}


Measured memory_bytes: 549112
def solve():
    from collections import deque
    n = int(input())
    g = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append((b, c))
        g[b].append((a, c))
    dist = [0] * n

    def dfs(v, p=-1, d=0):
        q = deque()
        q.append((v, p, d))
        while q:
            v, p, d = q.pop()
            dist[v] = d
            for i, x in g[v]:
                if i == p:
                    continue
                q.append((i, v, d + x))

    m, k = map(int, input().split())
    k = k - 1
    dfs(k)
    for _ in range(m):
        e, f = map(int, input().split())
        res = dist[e - 1] + dist[f - 1]
        print(res)


solve()


Measured memory_bytes: 108076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int k,x;
	cin>>k>>x;
	if(k*500>=x)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

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

typedef long long ll;

using namespace std;

int main(){
    int n;
    deque<int> dq;

    cin >> n;

    if(n & 1){
        rep(i, n){
            int in;
            cin >> in;
            if(i & 1) dq.push_back(in);
            else dq.push_front(in);
        }
    }
    else{
        rep(i, n){
            int in;
            cin >> in;
            if(i & 1) dq.push_front(in);
            else dq.push_back(in);
        }
    }

    rep(i, n){
        if(i) cout << " ";
        cout << dq[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/


int main()
{
	cin >> n;
	cout <<n*n*n << endl;
}

Measured memory_bytes: 3208
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

int h, w;
int m[1000][1000];
int mem[1000][1000];

int type(int i, int j){
  rep(k, 4){
    int p = i + dx[k];
    int q = j + dy[k];
    if(0 <= p && p < h && 0 <= q && q < w && m[p][q] < m[i][j]){
      int t = mem[p][q];
      if(t == 0 || (mem[i][j] != -1 && mem[i][j] != t)){
        return mem[i][j] = 0;
      }
      mem[i][j] = t;
    }
  }
  return mem[i][j] != -1 ? mem[i][j] : mem[i][j] = m[i][j];
}

int main(){
  scanf("%d%d", &h, &w);
  rep(i, h){
    rep(j, w){
      scanf("%d", &m[i][j]);
    }
  }
  rep(i, h){
    fill_n(mem[i], w, -1);
  }
  vector<PP> v;
  rep(i, h){
    rep(j, w){
      v.push_back(PP(m[i][j], P(i, j)));
    }
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for(vector<PP>::iterator it = v.begin(); it != v.end(); ++it){
    ans += type(it->second.first, it->second.second) == 0;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 22428
#include<bits/stdc++.h>
using namespace std;
int N, a[1001000], b[1001000];
string s;

void solve(int x) {
  if( x == 0) return;
  int k = 1;
  while(2*k <= x) k*=2;
  
  for(int i=0; i+k <= x; ++i) {
    b[i] = a[i] ^ a[i+k];
  }
  for(int i=0;i+k<=x;++i) a[i] = b[i];
  solve(x - k);
}

int main() {
  cin>>N>>s;
  int ok = 0;
  for(int i=0;i<N;++i) {
    if(s[i] == '2') ok = 1;
    a[i] = s[i] - '1'; 
  }
  if(ok) {
    for(int i=0;i<N;++i) {
      a[i] %= 2;
    }
  } else {
    for(int i=0;i<N;++i) {
      a[i] /= 2;
    }
  }
  
  solve(N-1);
  
  if(!ok) a[0] *= 2;
  cout<<a[0]<<endl;
  
  return 0;
}


Measured memory_bytes: 8964
#include<iostream>
using namespace std;
int main(){
  int n, tmp, ans = 0;
  int a[n], b[n], c[n-1];
  cin >> n;
  for(int i=0; i<n; i++){cin >> tmp;a[i] = tmp - 1;}
  for(int i=0; i<n; i++){cin >> b[i];}
  for(int i=0; i<n-1; i++){cin >> c[i];}
  ans = b[a[0]];
  for(int i=1; i<n; i++){ans += b[a[i]];if(a[i] - a[i-1] == 1)ans += c[a[i-1]];}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4352
import math
def solve():

    N = int(input())
    A = list(map(int, input().split()))

    if(N == 0 and A[0] == 1):
        print(1)
        return
    
    leaf_list = [0] * (N+1)
    

    for d in range(N, -1 , -1):
        if(d == N):
            leaf_list[d] = (A[d],A[d])
        else:
            Min = math.ceil(leaf_list[d+1][0]/2) + A[d]
            Max = leaf_list[d+1][1] + A[d]
            leaf_list[d] = (Min,Max)
            
    if(not(leaf_list[0][0] <= 1 and leaf_list[0][1] >= 1)):
        print(-1)
        return
            
    node_list = [0] * (N+1)
    node_list[0] = 1
    
    for d in range(1, N+1):
        node_list[d] = min((node_list[d-1] - A[d-1]) * 2, leaf_list[d][1])
        
    print(sum(node_list))
solve()

Measured memory_bytes: 31980
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){
	
	int a, b, ans;
	cin >> a >> b;
	
	ans=max(a-b, a+b);
	ans=max(a*b, ans);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
num_floors = 3
num_rooms = 10
num_houses = 4
houses = {house: [[0 for room in range(num_rooms)] for floor in range(num_floors)] for house in range(1, num_houses+1)}

num_moves = int(input())

for _ in range(num_moves):
    b, f, r, v = map(int, input().split())
    houses[b][f-1][r-1] += v

for i in range(1, num_houses+1):
    for j in houses[i]:
        for k in j:
            print(' {:d}'.format(k), end='')
        print()
    if not i == num_houses:
        print('#' * 20)


Measured memory_bytes: 5632
#include<iostream>

int main(){
    int a[10],i,j,n;
    for(i=0;i<10;i++){
        std::cin>>a[i];
        }
        
        for(i=0;i<9;i++){
        	for(j=i+1;j<10;j++){
        		if(a[i]<a[j]){
			n=a[i];
			a[i]=a[j];
			a[j]=n;
			}
		}	
	}
	for(i=0;i<3;i++){
	std::cout<<a[i]<<std::endl;
	}       	
	
	return 0;
}

Measured memory_bytes: 1160
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
	int n;
	cin>>n;


   string s;
   cin>>s;
   int count = 0;
   for(int i = 0; i < n-2; i++)
   {
   	if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
   	{
   		count++;
   	}
   }     
        
   cout<<count;











    return 0;
}		


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val X = Array.fill(N)(sc.nextInt())
    val SX = X.zipWithIndex.sortBy(_._1)
    val itoi = SX.zipWithIndex.map(e => (e._1._2, e._2)).toMap
    val medianL = SX(N / 2 - 1)._1
    val medianR = SX(N / 2)._1

    val r = new Array[Int](N)
    var i = 0
    while (i < N) {
      if (itoi(i) < N / 2)
        r(i) = medianR
      else
        r(i) = medianL
      i += 1
    }
    println(r.mkString(" "))
  }

}

Measured memory_bytes: 159544
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int A, B, N, M, K, Q, W, H, R, C;
string S;

int main() {
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    int a_min = INF, b_min = INF;
    for (int i = 0; i < A; i++) {
        cin >> a.at(i);
        chmin(a_min, a[i]);
    }
    for (int i = 0; i < B; i++) {
        cin >> b.at(i);
        chmin(b_min, b[i]);
    }

    int ans = a_min + b_min;
    for (int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        chmin(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        System.out.println(s <= w ? "unsafe" : "safe");
    }

}

Measured memory_bytes: 35620
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    P = il()

    cnt = 0
    for n in range(N):
        if P[n] != n + 1:
            cnt += 1
        if cnt > 2:
            print('NO')
            exit()
    else:
        print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10124
#include<stdio.h>
int main(void){
  int n,i,j,a,p[200000],s=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  a=p[0];
  for(i=1;i<n;i++){
    if(a>=p[i]){
      a=p[i];
      s++;
    }
  }
  printf("%d",s);
  return 0;
}
  


Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
//#define MAX(a,b) a>b?a:b
//#define MIN(a,b) a<b?a:b

int main() {
	double n;
	S(lf, n);
	P(.10g, n*sqrt(2) < floor(n) + 1 ? floor(n) + 1 : n*sqrt(2));
	return 0;
}

Measured memory_bytes: 656
# coding: utf-8
from math import sqrt

def main():
    X = int(input())

    for i in range(X, 100004):
        tmp = int(sqrt(i))
        flg = False
        for j in range(2, tmp + 1):
            if (i % j == 0):
                flg = True
                break
        if flg == False:
            ans = i
            break

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int M = sc.nextInt();
 
        int A[][] = new int[N][M];
        int B[] = new int[M];
 
        for(int row = 0; row < N; row++){
            for(int col = 0; col < M; col++){
                A[row][col] = sc.nextInt();
            }
        }
 
        for(int row = 0; row < M; row++){
            B[row] = sc.nextInt();
        }
 
        int ans;
 
        for(int row = 0; row < N; row++){
            ans = 0;
            for(int col = 0; col < M; col++){
                ans += A[row][col]*B[col];
            }
            System.out.printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 41112
# AOJ 0238 Time to Study
# Python3 2018.6.25 bal4u
 
while 1:
    t = int(input())
    if t == 0: break
    n = int(input())
    sm = 0
    for i in range(n):
        s, f = map(int, input().split())
        sm += f-s
    print("OK" if sm >= t else t - sm)


Measured memory_bytes: 5600
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())

ans = 0

for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i

print(ans)


Measured memory_bytes: 65408
import sys
import numpy as np
input = sys.stdin.readline

h, w = map(int, input().split())

a = [list(input()) for _ in range(h)]

a = np.array(a)

i = 0
j = 0


while i < len(a):
    if np.sum(a[i,:] == '#') == 0:
        a = np.delete(a, i, 0)
        i -=1
    i +=1

while j < w:
    if np.sum(a[:,j] == '#') == 0:
        a = np.delete(a, j, 1)
        j -= 1
    j += 1
    h, w = a.shape



h, w = a.shape
for i in range(h):
    for j in range(w):
        print(a[i, j], end="")
    print('')
    


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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    //cin>>t;
    
    while(t--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int x=max(a*c,b*d);
        x=max(x,a*d);
        x=max(x,b*c);
        cout<<x;
    }
}

Measured memory_bytes: 3652
n,x = map(int,input().split())
burger = [1]
patty = [1]

for i in range(n):
    burger.append(burger[i]*2+3)
    patty.append(patty[i]*2+1)

def f(n,x):
    if n == 0:
        return 1
    elif x == 1:
        return 0
    elif x <= 1+burger[n-1]:
        return f(n-1,x-1)
    elif x == 2+burger[n-1]:
        return 1+patty[n-1]
    elif x <= 2+2*burger[n-1]:
        return 1+patty[n-1]+f(n-1,x-2-burger[n-1])
    else:
        return patty[n]

print(f(n,x))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;





bool CheckHonests(
  const vector<int> &flags,
  const vector<vector<pair<int,int>>> &testimonies
)
{
  for ( int i = 0; i < testimonies.size() ; ++ i )
  {
    if ( flags[i] == 0 ) continue;
    for ( const auto it : testimonies[i] )
    {
      if ( it.second == 1 && flags[it.first-1] == 0 )
        return false; 
      if ( it.second == 0 && flags[it.first-1] == 1 )
        return false;  
    }
  }
  return true;
}


//gen flag array
vector<int> GenIthBinaryArray(int i, int n)
{
  vector<int> flags(n,0); 
  int tmp = i;
  int num = 0;
  for ( int j = 0; j < n; ++j)
  {
    if ( tmp % 2 == 0 ) 
    { 
      flags[j] = 1;
      num++;
    }
    tmp = tmp >> 1;
  }
  return flags;
}


int main()
{
//2^15 = 1024 * 32 = 32k通り --> brute force
  
  int N;
  cin >> N;
  
  vector<vector<pair<int,int>>> testimonies(N); //証言
  for ( int i = 0; i < N; ++i )
  {
    int num;
    cin >> num;
    testimonies[i].resize(num);

    for ( int j = 0; j < num; ++j ) 
    {
      int x, y;
      cin >> x >> y;
      testimonies[i][j] = make_pair(x,y);
    }
  }

  int max_honests = 0;

  for( int i = 0, s = (int)pow(2,N); i < s; ++i)
  {
    //gen flag array
    vector<int> flags = GenIthBinaryArray(i,N);
    int num = 0;
    for ( auto i : flags ) num += i;
    
    if ( CheckHonests( flags, testimonies) && num > max_honests )
    {
      max_honests = num;
    }
  }
  
  cout << max_honests;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int ans=0;
  for(int i=0;i<n;i++){
    if(i<k){
      ans+=x;
    }
    else if(i>=k){
      ans+=y;
    }
  }
  cout<<ans<<endl;
}

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

int main(){
	/*input*/
	int n;	cin >> n;
	vector<string>w(n);
	for(int i = 0; i < n; i++){
		cin >> w[i];
	}
	/*calculation*/
	bool rule = true;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < i; j++){
			if(w[i] == w[j]){
				rule = false;
				break;
			}
		}
		if(i < n - 1){
			if(w[i].back() != w[i + 1].front()){
					rule = false;
					break;
			}
		}
	}
	/*output*/
	if(rule){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
ans = 10**18

if A%2==0:
    ans = 0
else:
    ans = min(ans, B*C)

if B%2==0:
    ans = 0
else:
    ans = min(ans, C*A)

if C%2==0:
    ans = 0
else:
    ans = min(ans, A*B)

print(ans)

Measured memory_bytes: 61724
n, t, e = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
answer = -1
arr.sort.uniq.each{|x|
    [(t.to_f / x).floor, (t.to_f / x).ceil].each{|q|
        if (q * x).between?(t - e, t + e)
            answer = arr.index(x) + 1
            break
        end
    }
    break if answer != -1
}
puts answer


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

int main() {
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    string ans="";
    rep(i,n) cin>>s[i];
    sort(s.begin(),s.end());
    rep(i,n) ans+=s[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
visited = [0] * D
def dfs(s, c):
  temp = 10 ** 3
  for i in range(D):
    if visited[i] == 0:
      visited[i] = 1
      if s >= p[i][0] * (i + 1) * 100 + p[i][1]:
        temp = min(temp, dfs(s - p[i][0] * (i + 1) * 100 - p[i][1], c + p[i][0]))
      else:
        temp = min(temp, -(-s // ((i + 1) * 100)) + c, p[i][0] + c)
      visited[i] = 0
  return temp
print(dfs(G, 0))

Measured memory_bytes: 49884
H, W = map(int, input().split())
board = ['.'*(W+2)]
for i in range(H):
    line = "." + input() + "."
    board.append(line)
board.append("."*(W+2))

for h in range(1, H+1):
    for w in range(1, W+1):
        if board[h][w] == "#" and board[h-1][w]=="." and board[h+1][w]=="." and board[h][w-1]=="." and board[h][w+1]==".":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N;
cin>>N;
ll ans=0;
  for(ll i=sqrt(N);i*i>=1;i--){
 if(N%i==0){
   
ans=i;
   break;
    }
  }

  cout<<ans-1+N/ans-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    long n,m;
    cin >> n >> m;

    long ans = 0;
    if(m >= n*2){
        ans += n;
        m -= n*2;
    }else{
        ans += m/2;
        m = 0;
    }

    ans += m/4;

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

Measured memory_bytes: 256
H = int(input())
W = int(input())
N = int(input())
if W >= H:
  if N % W == 0:
    print(N//W)
  else:
    print(N//W+1)
else:
  if N % H == 0:
    print(N//H)
  else:
    print(N//H+1)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

const ll INF = 1LL<<60;

int main() {
    int n, w;
    cin >> n >> w;
    vector<ll> weight(n), value(n);
    rep(i, n) cin >> weight[i] >> value[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
    for(int i = 0; i < n; i++) {
        rep(j, w + 1) {
            if(j - weight[i] >= 0) chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>

using namespace std;

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

    if(a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

vi vecint(1);
int main() {
	pii temp;
	while (1) {
		cin >> temp.first >> temp.second;
		if (temp.first == 0 && temp.second == 0)break;
		if (temp.first > temp.second) swap(temp.first, temp.second);
		cout << temp.first << " " << temp.second << endl;
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define sec second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

int color[100001] = {};
int dist[100001] = {};
vector <int>edge[100001];

void dfs(int v, int d, int c){
  if(color[v] == 0) color[v] = c; //未訪問なら色づけ
  if(dist[v] >= d) return; // すでにその点からd以下の点は訪問済み
  dist[v] = d;
  REP(i,edge[v].size()){
    dfs(edge[v][i],d-1,c);
  }
}

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

  int n,m;
  cin >> n >> m;
  

  REP(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  
  int q;
  cin >> q;
  
  vector<tuple<int,int,int>> tp;
  REP(_,q){
    int v,d,c;
    cin >> v >> d >> c;
    tp.pb(make_tuple(v-1,d,c));
  }
  
  RREP(i,q){
    int v,d,c;
    tie(v,d,c) = tp[i];
    dfs(v,d,c);
  }
  
  REP(i,n) cout << color[i] << endl;

  return 0;
}

Measured memory_bytes: 12400
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;
const int M = 1001;
int main() {
  int n;
  cin >> n;
  vector<ll> p(M);
  rep(i,n){
    int x = i + 1;
    int m = 2;
    for(int m=2;m*m<=x;++m){
      while(x%m==0){
        p[m]++;
        x /= m;
      }
    }
    if(x>1) p[x]++;
  }
  ll ans = 1;
  rep(i,M) ans = (ans*(p[i]+1))%mod;
  cout << ans << endl;
}


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

using namespace std;

int main(){
  int k, n;
  std::cin >> k >> n;
  vector<int> a(n);
  for(int idx = 0; idx < n; idx++) std::cin >> a[idx];

  vector<int> distance(n);
  for(int idx = 0; idx < n; idx++){
    if(idx != n - 1){
      distance[idx] = a[idx + 1] - a[idx];
    }else{
      distance[idx] = a[0] + k - a[idx];
    }
  }

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

  long long ans = 0;
  for(int idx = 0; idx < distance.size() - 1; idx++){
    ans += distance[idx];
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];
  ll m;
  cin >> m;
  vector<ll> p(m), x(m);
  rep(i, m) {
    cin >> p[i] >> x[i];
    p[i]--;
  }
  ll sum = accumulate(t.begin(), t.end(), 0l);

  rep(i, m) {
    cout << sum - t[p[i]] + x[i] << endl;
  }

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size(), u = 1, v = 1;
  bool b = false;
  rep(i, n / 2) if(s[i] != s[n - 2 - i]) b = true;
  if(b || s[0] != '1' || s[n - 1] != '0') {
    cout << -1 << endl;
    return 0;
  }
  rep(i, n / 2 + 1) s[n / 2 + 1 + i] = '0';
  rep(i, n - 1) {
    cout << u << ' ' << ++v << '\n';
    if(s[n - 2 - i] == '1') u = v;
  }
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>a>>b;
  if(a==b){
    for(int i=0;i<a;i++)
      cout<<a;
    cout<<endl;
  }else{
    ll mi=min(a,b);
    ll ma=max(a,b);
    for(int i=0;i<ma;i++)
      cout<<mi;
    cout<<endl;
  }
  return 0;
}


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

int main () {
  int N,sum_min = 100000000;
  
  cin >> N;
  vector<int>vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  } 
  for (int i = 0; i < 100; i ++) {
    int sum = 0;
    for (int j = 0; j < N; j ++) {
      sum += (vec.at(j) - i) * (vec.at(j) - i);
    }
     sum_min = min(sum_min,sum);
  }
  cout << sum_min << endl;
}





Measured memory_bytes: 256
'''input
2
ip cc
'''
# A coding delight
from sys import stdin
from collections import defaultdict


# main starts
n = int(stdin.readline().strip())
s, t = stdin.readline().split()
ans = []
for i in range(n):
	ans.append(s[i])
	ans.append(t[i])
print(''.join(ans))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;
const int W = 10005;

ll dp[W];

struct info {
    int w,s;
    ll v;
    bool operator< (const info& another) const {
        return s+w < another.s+another.w;
    }
};

info goods[1005];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        int w,s,v;
        cin >> w >> s >> v;
        goods[i] = (info){w,s,v};
    }
    sort(goods, goods+n);
    ll ans = 0;
    rep(i,n){
        rrep(j,goods[i].s+1){
            cmx(ans,dp[j]+goods[i].v);
            if(j < W-goods[i].w){
                cmx(dp[j+goods[i].w], dp[j]+goods[i].v);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
def solve(string):
    n, m, *a = map(int, string.split())
    while m > 0:
        a.sort(reverse=True)
        if a[0] == 0:
            break
        b = a[0] // 2
        for i, _a in enumerate(a):
            if m == 0 or _a <= b:
                break
            a[i] //= 2
            m -= 1
    return str(sum(a))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 15176
N,K=map(int,input().split())
mod=10**9+7
ans=0
cmb=K
for i in range(1,K+1):
	ans+=(-1)**(K-i)*cmb*pow(i,N,mod)%mod
	ans%=mod
	cmb=cmb*(K-i)*pow(i+1,mod-2,mod)
print(ans)


Measured memory_bytes: 5612
// Aizu Vol0 0058: Orthogonal
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);

#define LLONG long long

#define MAX 500
char buf[MAX + 5], *p;

int GetInt(void)
{
	int minus = 0, len = 0, n = 0;

	while (isspace(*p)) p++;
	if (*p == '-') p++, minus = 1;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	if (*p == '.') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0'), len++;
#define MAGIC 5
	while (len < MAGIC) n = 10 * n, len++;
	if (minus) n = -n;
	//	printf("%10d\n", n);
	return n;
}

int main()
{
	int ax1, ay1, ax2, ay2;
	int bx1, by1, bx2, by2;

	while (gets(p = buf) != NULL) {
		ax1 = GetInt(), ay1 = GetInt();
		ax2 = GetInt(), ay2 = GetInt();
		bx1 = GetInt(), by1 = GetInt();
		bx2 = GetInt(), by2 = GetInt();

		if (ax1 == ax2 && ay1 == ay2) goto NO;
		if (bx1 == bx2 && by1 == by2) goto NO;

		if (ax1 == ax2) {
			if (by1 == by2) goto YES;
			goto NO;
		}

		if (bx1 == bx2) {
			if (ay1 == ay2) goto YES;
			goto NO;
		}

		if ((LLONG)(ay2 - ay1)*(LLONG)(by2 - by1) == -(LLONG)(ax2 - ax1)*(LLONG)(bx2 - bx1)) goto YES;

NO:		puts("NO");
		continue;
YES:	puts("YES");
	}
	return 0;
}

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

int main(){
  char id1[10],id2[11];
  int length1,length2;
  
  scanf("%s",id1);
  length1 = (int)strlen(id1);
  
  scanf("%s",id2);
  length2 = (int)strlen(id2);
  
  if (length1 + 1 == length2){
    if (strncmp(id1,id2,length1) == 0)
      printf("Yes\n");
    else 
      printf("No\n");
  }
  else 
    printf("No\n");

  return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;

int A, B, C;

int main() {
	cin >> A >> B >> C;
	//如果吃C必须立刻吃一个A或者B
	//B无论如何都要吃完、关键是C能吃几个
	int mx = A+B+1; //每个C后吃一个A或者B，最后一个C之后不用吃
	C = min(C, mx);
	cout << B + C << endl;
	return 0;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 142 - 1
# -*- encoding: UTF-8 -*-

n = float(input())
p = 0

if n == 1 :
  p = float(1.0)
elif (n % 2) == 0 : 
  p = float(0.5)
else :
  p = float(0.5 + 0.5 / n)
  
print(p)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll const MAX = 100008;
ll x, y, a, b, c, p[MAX], q[MAX], r[MAX], cp[MAX], cq[MAX], cr[MAX];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> x >> y >> a >> b >> c;
	rep(i, 1, a){cin >> p[i];}
	rep(i, 1, b){cin >> q[i];}
	rep(i, 1, c){cin >> r[i];}
	sort(p+1, p+a+1, greater<>());
	sort(q+1, q+b+1, greater<>());
	sort(r+1, r+c+1, greater<>());
	
    cp[0] = 0;
    cq[0] = 0;
    cr[0] = 0;
	rep(i, 1, a){cp[i] = cp[i-1]+p[i];}
	rep(i, 1, b){cq[i] = cq[i-1]+q[i];}
	rep(i, 1, c){cr[i] = cr[i-1]+r[i];}
	
	ll ai, bi;
    ll ci = min(c, x+y);
	ll ans = 0;
	rep(i, 0, x){
		if(0 <= x+y-(i+ci) && x+y-(i+ci) <= y && ans < cp[i]+cq[x+y-(i+ci)]+cr[ci]){
			ai = i;
			bi = x+y-(i+ci);
			ans = cp[ai]+cq[bi]+cr[ci];
		}
	}
    //cout << c << ai << bi << endl;

    ll memo = ans;
    rrep(k, ci-1, 0){
        memo -= r[k+1];
        //cout << p[ai+1] << q[bi+1] << endl;
        if(ai == x || (bi < y && p[ai+1] <= q[bi+1])){
            bi++;
            memo += q[bi];
        }
        else{
            ai++;
            memo += p[ai];
        }
        //cout << k << ai << bi << endl;
        ans = max(ans, memo);
    }
	print(ans)
	return 0;
}

Measured memory_bytes: 4992
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m, x, y) = in.readLine.split(" ").map(_.toInt)
  val xi = in.readLine.split(" ").map(_.toInt)
  val yi = in.readLine.split(" ").map(_.toInt)
  val maxX = xi.max
  val minY = yi.min
  val z = for(i <- (x+1) to y if i > maxX && i <= minY) yield {
    i
  }
  val ans = if(maxX < minY && z.nonEmpty) "No War" else "War"
  println(ans)
}

Measured memory_bytes: 25436
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;

using namespace std;

ll gcd(ll a, ll b) {
    return b?gcd(b,a%b):a;
}

int main() {
    int N;
    long long L = 1, T;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> T;
        L = T / gcd(L,T) * L;
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,int> P;
typedef long double ld;
const ll MAX_D = 1LL << 60;

int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);
	vector<pair<int, int> > graph[n];
	ll d[n + 1] = {};
	fill(d + 1, d + n + 1, MAX_D);
	rep (i, m) {
		int l, r, c;
		scanf("%d %d %d", &l, &r, &c);
		graph[l - 1].push_back(make_pair(r - 1, c));
	}
	repp (i, 1, n) {
		graph[i].push_back(make_pair(i - 1, 0));
	}
	priority_queue<P, vector<P>, greater<P>> que;
	bool used[n] = {};
	que.push(make_pair(0LL, 0));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (used[v]) continue;
		used[v] = true;
		// d[v] = min(d[v], p.first);
		// cout << p.second << " " << p.first << endl;
		// if (d[v] < p.first) continue;
		for (auto e : graph[v]) {
			// cout << x.first << " " << d[x.first] << endl;
			if (d[e.first] > d[v] + e.second) {
				d[e.first] = d[v] + e.second;
				que.push(make_pair(d[e.first], e.first));
			}
		}
	}
	printf("%lld\n", (d[n - 1] >= MAX_D ? -1 : d[n - 1]));
	return 0;
}


Measured memory_bytes: 8056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 string s,t;
	 cin>>s>>t;
	 int ans=0;
	 for(int i=0;i<s.length();i++)
	 {
		 if(s[i]!=t[i])
		 ans++;
	 }
	 cout<<ans<<'\n';
	 return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long inv[1000000];
long long fact[1000000];
long long factinv[1000000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	inv[1]=1;
	for(int i=2;i<1000000;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	fact[0]=1;
	factinv[0]=1;
	for(int i=1;i<1000000;i++){
		fact[i]=fact[i-1]*i%mod;
		factinv[i]=factinv[i-1]*inv[i]%mod;
	}
	
	long long ret=0LL;
	for(int i=0;i<=c;i++){
		long long val=fact[a+b+c+c]*factinv[b+c+c-2*i]%mod*factinv[a+2*i]%mod;
	//	printf("%lld %lld\n",((fact[a+2*i]*factinv[a+i]%mod*factinv[i]%mod+mod-fact[a+2*i]*factinv[a+i-1]%mod*factinv[i+1]%mod)%mod)%mod,((fact[b+c+c-2*i]*factinv[b+c-i]%mod*factinv[c-i]%mod+mod-fact[b+c+c-2*i]*factinv[b+c-i-1]%mod*factinv[c-i+1]%mod)%mod)%mod);
		ret=(ret+val*
			((fact[a+2*i]*factinv[a+i]%mod*factinv[i]%mod+mod-fact[a+2*i]*factinv[a+i+1]%mod*(i?factinv[i-1]:0)%mod)%mod)%mod*
			((fact[b+c+c-2*i]*factinv[b+c-i]%mod*factinv[c-i]%mod+mod-fact[b+c+c-2*i]*factinv[b+c-i+1]%mod*(i<c?factinv[c-i-1]:0)%mod)%mod)%mod
			)%mod;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 24464
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
 
int main() {
    int n, w;
    scanf("%d", &n);
    scanf("%d", &w);
    int weight[n + 1];
    int value[n + 1];
    for (int i = 1; i <= n; i++) {
        scanf("%d", &weight[i]);
        scanf("%d", &value[i]);
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));// dp[i][j] = dp[i-1][j - weight[i]] + v[i]
    for (int j = 1; j <= w; j++ ) {
        for (int i = 1; i <= n; i++) {
            if (j >= weight[i]) {
                dp[i][j] = max(dp[i - 1][j - weight[i]] + value[i], dp[i - 1][j]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][w] <<endl;
    return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (n < 1000 ? "ABC" : "ABD") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[1111][1111],mod=1e9+7,n,m;
string s[1000];
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>s[i];
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(i+1<n&&s[i+1][j]=='.')(dp[i+1][j]+=dp[i][j])%=mod;
			if(j+1<m&&s[i][j+1]=='.')(dp[i][j+1]+=dp[i][j])%=mod;
		}
	}
	cout<<dp[n-1][m-1]<<endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int AB,BC,CA;
int main(){
	cin >> AB >> BC >> CA;
	vector<int> vec;
	vec.pb(CA+BC);
	vec.pb(AB+BC);
	vec.pb(AB+CA);
	int ans = INF;
	for(int i=0;i<vec.size();i++){
		ans = min(ans,vec[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/* ****Tciitb**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a-1;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;
#define N 1000005 



 
int main()
{
  io
  ll a,b;
  cin>>a>>b;
  ll n=abs(a-b);
  ll x=(n)*(n-1)/2;
  cout<<abs(a-x);
}
       

Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
#from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

def chmax(a, b):
    if a < b:
        return b
    else:
        return a

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, w = map(int, input().split())
    wv = [tuple(map(int, input().split())) for _ in range(n)]
    dp = [[0] * (w+1) for _ in range(n+1)]

    for i in range(n):
        for sum_w in range(w+1):
            if (sum_w - wv[i][0] >= 0):
                dp[i+1][sum_w] = chmax(dp[i+1][sum_w], dp[i][sum_w - wv[i][0]] + wv[i][1])

            dp[i+1][sum_w] = chmax(dp[i+1][sum_w], dp[i][sum_w])

    print(dp[n][w])

if __name__ == '__main__':
    main()

Measured memory_bytes: 124164