akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int ans=0;
  vector<int> indexes;
  indexes.push_back(0);
  REP(i,n){
    if(i!=0 && s[i]!=s[i-1]){
      indexes.push_back(i);
    }
  }
  indexes.push_back(n);
  
  int len=indexes.size();
  if(s[0]=='0'){
    ans = indexes[min(2*k,len-1)]-indexes[0];
    int i=0;
    int pre=0;
    int suf=min(2*k,len-1);
    while(1){
      if(suf>len-1){
        suf=len-1;
      }
      ans = max(ans,indexes[suf]-indexes[pre]);
      if(suf==len-1){
        break;
      }
      if(i==0){
        pre +=1;
        suf +=2;
        i++;
      }else{
        pre +=2;
        suf +=2;
        i++;
      }
    }
    cout<<ans<<endl;
  }else{
    ans = indexes[min(2*k+1,len-1)]-indexes[0];
    int i=0;
    int pre=0;
    int suf=min(2*k+1,len-1);
    while(1){
      if(suf>len-1){
        suf=len-1;
      }
      ans = max(ans,indexes[suf]-indexes[pre]);
      if(suf==len-1){
        break;
      }
      pre +=2;
      suf +=2;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 4000007
#define mo 19930726
#define ll long long
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll a,b,c,x,y,ans;
int main()
{
	cin>>a>>b>>c>>x>>y;
	ll minn=min(x,y);
	if(a+b<=2*c){
		cout<<x*a+y*b;
	} else {
		ans+=minn*c*2;
		if(x<y){
			if(2*c<=b) b=2*c;
			ans+=b*(y-x);
		} else {
			if(2*c<=a) a=2*c;
			ans+=a*(x-y);
		}
		cout<<ans;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int c1,c5,c10,c50,c100,c500;
    scanf("%d%d%d%d%d%d",&c1,&c5,&c10,&c50,&c100,&c500);
    if(1*c1+5*c5+10*c10+50*c50+100*c100+500*c500>=1000){
        printf("1\n");
    }
    else{printf("0\n");}
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
typedef long long ll;
ll A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;

    int ans = 1;
    ll x = A;
    while (x * 2 <= B) {
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int H, W, N;
int sx, sy;
string S, T;

void cswap(char &c) {
	if(c == 'U') c = 'D';
	else if(c == 'D') c = 'U';
	else if(c == 'L') c = 'R';
	else if(c == 'R') c = 'L';
}

bool pre() {
	int x = sx, y = sy;
	rep(i, 0, N) {
		if(S[i] == 'U') x--;
		if(S[i] == 'L') y--;
		if(x < 0 || y < 0) return true;
		if(T[i] == 'D' && x != H - 1) x++;
		if(T[i] == 'R' && y != W - 1) y++;
	}
	return false;
}

void solve() {
	cin >> H >> W >> N;
	cin >> sx >> sy; sx--; sy--;
	cin >> S >> T;
	if(pre()) {
		cout << "NO\n";
	}
	else {
		sx = H - 1 - sx;
		sy = W - 1 - sy;
		rep(i, 0, N) {
			cswap(S[i]);
			cswap(T[i]);
		}
		// debug("omo");
		if(pre()) cout << "NO\n";
		else cout << "YES\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 920
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
void o(ll a,ll b){
    cout<<a<<" "<<b<<endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    rep(i,0,30){
        ll u=Pow(2,i);
        if(u==n){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    ll las=4;
    for(int i=3;i<=n;i+=4){
        if(i>=7)o(i-3,i-2);
        o(i-2,i);
        o(i,i-1);
        if(i>=7){
            o(i-1,i-3+n);
            o(i-3+n,i-2+n);
        }
        else o(i-1,i-2+n);
        o(i-2+n,i+n);
        o(i+n,i-1+n);
        if(n%4==1||n%4==2)o(1,i+1);
        if(n%4==3&&i<n)o(i-2,i+1);
        if(n%4==0){
            if(i+1==n)break;
            if(i==3)o(i-2,i+1);
            else{
                ll t=1;
                for(;;){
                    t*=2;
                    if(t>i+1){
                        o(i-2,i+1);
                        break;
                    }
                    if(i+1==t){
                        if((n&t)==t){
                            o(t,las);
                            las=t;
                        }
                        else{
                            o(i-2,i+1);
                            
                        }
                        break;
                    }
                }
            }
        }
    }
    if(n%4==1){
        o(n,n-1);
        o(1+n,n+n);
        o(n+n,n-1+n);
    }
    if(n%4==2){
        o(n-1,n-2);
        
        o(1+n,n+n-1);
        o(n+n-1,n-2+n);
        o(n,n-2);
        o(3,n+n);
    }
    if(n%4==0){
        ll u=1;
        ll uu=1;
        for(;;){
            u*=2;
            if(u>n){
                u/=2;
                break;
            }
        }
        for(;;){
            uu*=2;
            if((n&uu)==uu){
                break;
            }
        }
        o(n,u);
        o(n+n,uu);
    }
}


Measured memory_bytes: 2688
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/13/20 21:03:09
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string s; cin>>s;
  cout << s.substr(0,3) << endl;

  return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def bubble(cards):
    for i in range(len(cards)):
        for j in range(len(cards)-1, i, -1):
            if cards[j][1] < cards[j-1][1]:
                cards[j], cards[j-1] = cards[j-1], cards[j]


def selection(cards):
    for i in range(len(cards)):
        mini = i
        for j in range(i, len(cards)):
            if cards[j][1] < cards[mini][1]:
                mini = j
        cards[i], cards[mini] = cards[mini], cards[i]


def stable_test(orders, cards):
    for order in orders:
        n = -1
        for c in order:
            p = n
            n = cards.index(c)
            if p > n:
                return False
    return True


stdin.readline()
data1 = stdin.readline().split()
data2 = data1[:]
orders = [[c for c in data1 if c.endswith(str(i))] for i in range(1, 10)]
orders = [o for o in orders if len(c) > 1]

bubble(data1)
print(*data1)
print('Stable' if stable_test(orders, data1) else 'Not stable')

selection(data2)
print(*data2)
print('Stable' if stable_test(orders, data2) else 'Not stable')

Measured memory_bytes: 4272
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int max = 0, sum = 0;
			for(int i = 0; i < N; i++) {
				final int L = sc.nextInt();
				
				max = Math.max(max, L);
				sum += L;
			}
			
			System.out.println(max < (sum - max) ? "Yes" : "No");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main(){
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int cnt=0;
  for(int i=0; i<=n/r; i++){
    for(int j=0; j<=n/g; j++){
      if(n-r*i-g*j>=0 && (n-r*i-g*j)%b==0)cnt++;
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val Ts = readLine()!!.split(" ").map(String::toInt)
  val S = Ts.sum()
  for(i in 1..readLine()!!.toInt()){
    val (P,X) = readLine()!!.split(" ").map(String::toInt)
    println(S - Ts[P-1] + X)
  }
}

Measured memory_bytes: 37992
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

bool isok(int tmp){ //1が隣り合っていないか
  for(int i = 0; i < 7; i++){
    if((tmp >> i) & (tmp >> i+1)) return false;
  }
  return true;
}

int main(){
  ll H, W, K;
  cin >> H >> W >> K;
  K--;

  if(W == 1){
    if(K == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
  }

  vll count(W-1, 0); //count.at(i)はi~i+1に線をはったときの他の部分の線の張り方
  vll count2(W, 0); //W本目の左右に線なし
  ll total = 0; //全ての線の張り方
  for(int bit = 0; bit < (1 << W-1); bit++){
    if(!isok(bit)) continue;
    total++;
    
    for(int i = 0; i < W-1; i++){
      if((bit >> i) & 1){
        count.at(i)++;
      }
    }

    for(int i = 0; i < W; i++){
      if(i >= 1 && ((bit >> (i-1)) & 1)) continue;
      if(i <= W-2 && ((bit >> i) & 1)) continue;
      count2.at(i)++;
    }
  }

  vvll dp(H+2, vll(W, 0));
  dp.at(1).at(0) = 1;
  for(int i = 2; i < H+2; i++){
    for(int j = 0; j < W; j++){
      //左からくる場合
      if(j >= 1){
        dp.at(i).at(j) += dp.at(i-1).at(j-1) % MOD * count.at(j-1) % MOD;
        dp.at(i).at(j) %= MOD;
      }
      //右からくる場合
      if(j <= W-2){
        dp.at(i).at(j) += dp.at(i-1).at(j+1) % MOD * count.at(j) % MOD;
        dp.at(i).at(j) %= MOD;
      }
      //上からくる場合
        dp.at(i).at(j) += dp.at(i-1).at(j) % MOD * count2.at(j) % MOD;
        dp.at(i).at(j) %= MOD;
    }
  }
  cout << dp.at(H+1).at(K) << endl;
}

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

int main(void)
{
  int n, hanako_p=0, taro_p=0,i;
  char hanastr[101], tarostr[101];
  scanf("%d", &n);
  for(i=0;i<n;i++) {
    scanf("%s", tarostr);
    scanf("%s", hanastr);
    if(strcmp(tarostr,hanastr)==0) {
      hanako_p++;taro_p++;
    }
    else if(strcmp(tarostr, hanastr)>0){
      taro_p += 3;
    }
    else if(strcmp(tarostr, hanastr)<0){
      hanako_p +=3;
    }
  }
  printf("%d %d\n", taro_p, hanako_p);
  return 0;
}

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

int main()
{
    int p;
    cin >> p;
    int a[3000];
    for(int i = 0; i < p; i++) cin >> a[i];
    int b[3000];
    b[p] = b[0] = a[0];
    for(int i = p - 1; i > 0; i--){
        b[i] = p * p;
        for(int j = 0; j < p; j++) b[i] -= a[j];
        b[i] %= p;
        for(int j = 0; j < p; j++) a[j] = a[j] * j % p;
    }
    for(int i = 0; i < p; i++) cout << b[i] << " ";
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		long mod=1_000_000_007L;
		long ans=0L;
		for (int i=0;i<M;i++) {
			ans+=(N*i%mod*(M-i)%mod*N%mod)%mod;
			ans=ans%mod;
		}
		for (int i=0;i<N;i++) {
			ans+=(M*i%mod*(N-i)%mod*M%mod)%mod;
			ans=ans%mod;
		}
		long cnt=calcNumOfCombination(N*M-2,K-2);
		System.out.println((ans*cnt)%mod);
	}

    static long calcNumOfCombination(int n, int r){
    	long mod=1_000_000_007L;
    	return ((factorial(n)*modinv(factorial(n-r),mod))%mod*modinv(factorial(r),mod))%mod;
    }

    static long factorial(int n) {
    	long num=1L;
    	long mod=1_000_000_007L;
    	for (int i=n;i>0;i--) {
    		num=num*i;
    		num%=mod;
    	}
    	return num;
    }

    static long pow(long a,long n) {
    	long mod=1_000_000_007L;
    	long res=1;
    	while (n>0) {
    		if ((n-n/2*2)==1) {
    			res=res*a%mod;
    		}
    		a=a*a%mod;
    		n>>=1;
    	}
    	return res;
    }

    static long modinv(long a,long mod) {
        return pow(a,mod-2);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int lis(int n,vector<int>& A){
  vector<int> L(A.size()+1,0);
  L[0] = A[0];
  int length = 1;
  for(int i=1; i<n; i++){
    if(L[length-1]<=A[i]){
      L[length++] = A[i];
    }else{
      *upper_bound(L.begin(),L.begin()+length,A[i]) = A[i];
    }
  }
  return length;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  reverse(A.begin(),A.end());
  cout << lis(N,A) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    
    int n;
    int ai;
    long long x=10000000000,y=(-100000000000),z=0;
    
    cin>>n;
    
    for(int i=0;i<n;i++){
     cin>>ai;   
        
        if(ai<x){
        x=ai;    
        }
        
        if(ai>y){
            y=ai;
        }
        
        z=ai+z;
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
}



Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int ans = 0;
		for (int x = 111; x <= 999; x += 111) {
			if (x >= N) {
				System.out.println(x);
				break;
			}
		}
	}
}


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

int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	cout << 360 / gcd(n, 360) << '\n';
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

bool u_c[17][17];

void shokika(){
	for(int i = 0; i < 17; ++i){
		for(int j = 0; j < 17; ++j){
			u_c[i][j] = false;
		}
	}
	for(int i = 0; i < 17; ++i){
		u_c[0][i] = true;
		u_c[i][0] = true;
	}
}

//階乗を求める関数
int f(int n){
	if(n == 0){
		return 1;
	}
	else{
		return f(n - 1) * n;
	}
}

int calc_road(int x, int y){
	if(x == 1 && y == 1){
		return 1;
	}
	else if(x <= 0 || y <= 0){
		return 0;
	}
	else{
		int num;
		if(u_c[x - 1][y] && u_c[x][y - 1]){
			return 0;
		}
		else if(u_c[x - 1][y]){
			num = calc_road(x, y - 1);
			return num;
		}
		else if(u_c[x][y - 1]){
			num = calc_road(x - 1, y);
			return num;
		}
		else{
			num = calc_road(x - 1, y) + calc_road(x, y - 1);
			return num;
		}
	}

}

int main(){
	int a, b;
	while(std::cin >> a >> b){
		if(a == 0 && b == 0){
			break;
		}
		//2行目の入力
		int n;
		std::cin >> n;
		//3行目以降の入力と処理（工事中の箇所）
		shokika();
		for(int i = 0; i < n; ++i){
			int x, y;
			std::cin >> x >> y;
			u_c[x][y] = true;
		}
		
		std::cout << calc_road(a, b) << std::endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
#define A_MAX 1000000
#define A_MAX_HALF 500000
 
using namespace std;
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
int N;
 
int main() {
    vector<int> primes{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
    for (int i = 2; i <= A_MAX_HALF; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
        }
        int min_factor_i = min_factor[i];
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor_i) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    char c = getchar_unlocked();
    do {
        N = 10 * N + c - '0';
    } while ((c = getchar_unlocked()) >= '0');
    for (int i = 0; i < N; ++i) {
        int A = 0;
        c = getchar_unlocked();
        do {
            A = 10 * A + c - '0';
    	} while ((c = getchar_unlocked()) >= '0');
        ++a[A];
    }
 
    int is_pairwise_coprime = 1;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = 0;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15332
void main(){
	int n = _scan();
	int a, b;
	if(n==2){
		a = _scan();
		b = _scan();
	}
	writeln( n==1? "Hello World": ( a+b ).to!string);
}

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

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

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


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

int main(){
	int h, w;
	int i, j;
	
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)
			break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i%2==0){
					if(j%2==0)
						cout << '#';
					else
						cout << '.';
				}
				else{
					if(j%2==0)
						cout << '.';
					else
						cout << '#';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

//#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

template< typename T >
struct FordFulkerson {

	struct FlowEdge {
		int to;
		T cap;
		int rev;
		FlowEdge() {}
		FlowEdge(int to,T cap,int rev):to(to),cap(cap),rev(rev) {}
	};

	vector< vector<FlowEdge> > G;
	vector<int> used;
	const T INF;
	int timestamp;

	FordFulkerson() {}
	FordFulkerson(int n):INF(numeric_limits<T>::max()),timestamp(0) {
		used.assign(n,-1);
		G.resize(n);
	}

	void add_edge(int from,int to,T cap) {
		G[from].emplace_back(to,cap,(int)G[to].size());
		// undirected
		// G[to].emplace_back(from,cap,(int)G[from].size()-1);
		// directed
		G[to].emplace_back(from,0,(int)G[from].size()-1);
	}

	T dfs(int v,const int t,T flow) {
		if(v==t) return flow;
		used[v]=timestamp;
		for(auto &e:G[v]) {
			if(used[e.to]!=timestamp&&e.cap>0) {
				T d=dfs(e.to,t,min(flow,e.cap));
				if(d>0) {
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}

	T max_flow(int s,int t,T lim) {
		T flow=0;
		for(T f;(f=dfs(s,t,lim))>0;timestamp++) {
			flow+=f;
			//cout<<"flow="<<flow<<endl;
		}
		return flow;
	}

	T max_flow(int s,int t) {
		return max_flow(s,t,INF);
	}
};


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

	int v,e;cin>>v>>e;
	FordFulkerson<int> F(v);
	while(e--) {
		int u,v,c;cin>>u>>v>>c;
		F.add_edge(u,v,c);
	}
	cout<<F.max_flow(0,v-1)<<endl;

	return 0;
}



Measured memory_bytes: 3212
import bisect
import sys
sys.setrecursionlimit(10**6)
INF = 10**10

N = int(input())
A = [0] + list(map(int,input().split()))

adj = [[] for n in range(N+1)]
for n in range(N-1):
    u, v = map(int,input().split())
    adj[u].append(v)
    adj[v].append(u)

ans= [0 for i in range(N+1)]
depth = [-1 for n in range(N+1)]
def dfs(s, d, dp): # 頂点番号、深さ、LIS
    depth[s] = d
    idx = bisect.bisect_left(dp,A[s])
    history = dp[idx] # 巻き戻すために保存
    dp[idx] = A[s]
    ans[s] = bisect.bisect_left(dp, INF)
    for i in adj[s]:
        if depth[i]==-1:
            dfs(i, d+1, dp)
    dp[idx] = history # 探索が終わったら巻き戻す
dp = [INF] * len(A)
dfs(1, 0, dp)
for n in range(1,N+1):
    print(ans[n])


Measured memory_bytes: 232352
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
/////////////////////////

int main(void){
   int n; cin >> n;
   vector<int> a(n);rep(i,n) cin >> a[i];
   bool even = true;
   rep(i,n) if(a[i] %2 != 0) even = false;
   
   if(even) cout << "second" << endl;
   else cout << "first" << endl;
   
   return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;

string str;
int n;

ll dp[4005][4005];

int main(){
  cin>>str;
  n=str.size();
  dp[0][0]=1;

  ll cnt=0;
  for(int i=0;i<n*2;i++){

    if(i<n)cnt+=2;
    
    for(int j=0;j<=4000;j++){
      if(dp[i][j]==0)continue;
      ll R=j;

      if(i<n){
        if(str[i]=='0'){
          R+=2;
        }else if(str[i]=='1'){
          R++;
        }
      }
      
      ll B=cnt-R;
      assert(B>=0);
      
      if(R>0){
        int nj=j;
        if(R==j+2)nj++;
        if(R==j)nj--;
        
        assert(nj>=0);
        dp[i+1][nj]+=dp[i][j];
        dp[i+1][nj]%=mod;
        
      }
      
      if(B>0){
        int nj=j;
        if(R==j+2)nj+=2;
        if(R==j+1)nj++;
        dp[i+1][nj]+=dp[i][j];
        dp[i+1][nj]%=mod;
      }
    }
    

    cnt--;
  }
  /*
  for(int i=0;i<=n*2;i++){
    for(int j=0;j<=n*2;j++){
      printf("%02d ",(int)dp[i][j]);
    }
    cout<<endl;
  }
*/
  cout<<dp[2*n][0]<<endl;
  return 0;
}


Measured memory_bytes: 123520
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;cin>>s;
    string t="CODEFESTIVAL2016";
    int ans=0;
    rep(i,16){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int N;
    cin>>N;
    vector<string>v;
    string s;
    for(int i=0;i<N;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    int check = 0;
    for(int i=0;i<v.size();i++)
    {
        for(int k=i+1;k<v.size();k++)
        {
            if(v[i]==v[k])
            {
                check = 1;
                break;
            }
        }
        if(check) break;
    }
        for(int i=1;i<v.size();i++)
        {
            if(v[i][0]!=v[i-1][v[i-1].length()-1])
            {
                check = 1;
                break;
            }
            if(check)
                break;
        }
    if(check)
        cout<<"No"<<endl;
    else if(!check)
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*input
3 2
1 7 2
7 8 1
8 12 1
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
int c[100005],n,enter[100005],leave[100005];
int en[31][100005],lv[31][100005];
pair<int,int> a[100005];
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>a[i].first>>a[i].second>>c[i];
		++en[c[i]][a[i].first];
		++lv[c[i]][a[i].second];
	}
	for(int i=1;i<=m;++i){
		for(int j=1;j<100005;++j){
			assert(en[i][j]<2 && lv[i][j]<2);
			if(en[i][j]&&lv[i][j]);
			else if(en[i][j]) enter[j]++;
			else if(lv[i][j]) leave[j+1]++;
		}
	}
	sort(a,a+n);
	long long run=0;
	for(int i=1;i<100005;++i){
		run+=enter[i] - leave[i];
		ans=max(ans,run);
	}
	cout<<ans;
}

Measured memory_bytes: 25984
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

std::string IntToString(long long a){
  char x[100];
  sprintf(x,"%lld",a);
  std::string s = x;
  return s;
}
long long StringToInt(std::string a){
  char x[100]; long long res;
  strcpy(x,a.c_str());
  sscanf(x,"%lld",&res);
  return res;
}
inline void printIntVal(long long a) {
  std::cout << "The Value is: "<< IntToString(a) << std::endl;
}
inline void printStringVal(std::string a) {
  std::cout << "The Value is: "<< a << std::endl;
}
inline std::string GetString(){
  char x[1000005];
  scanf("%s",x);
  std::string s = x;
  return s;
}
inline std::string uppercase(std::string s){
  int n = (int)s.size();
  for(int i = 0; i < n; i++) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
inline std::string lowercase(std::string s){
  int n = (int)s.size();;
  for(int i = 0; i < n; i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
inline void OPEN (std::string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}
inline long long CharToInt(char c) {
    return (c - '0');
}

// ---------------------------------------------------------



int main() {

  std::string a = GetString();
  std::string b = GetString();
  std::string c = GetString();

  if ((a[a.length()-1] == b[0]) && (b[b.length()-1] == c[0])) {
    std::cout << "YES" << std::endl;
  }else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

array<array<int64_t, 100001>, 101> dp;

int main()
{
    int64_t n, w;
    cin >> n >> w;

    for (auto& v : dp)
    {
        fill(v.begin(), v.end(), 0);
    }

    vector<int64_t> ws(n), vs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ws[i] >> vs[i];
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            dp[i][j] = dp[i - 1][j];
        }
        for (int j = 0; j <= w - ws[i - 1]; j++)
        {
            dp[i][j + ws[i - 1]] = max(dp[i][j + ws[i - 1]], dp[i - 1][j] + vs[i - 1]);
        }
    }

    int64_t ans = 0;
    for (int i = 0; i <= w; i++)
    {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 79104
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
        sc.close();
    }
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Edge
{
    int from;
    int to;
    ll cost;
};

Edge E[2005];
ll D[1005];

int main()
{
    ll N, M, R;
    cin >> N >> M >> R;
    REP(i, M)
    {
        ll s, t, d;
        cin >> E[i].from >> E[i].to >> E[i].cost;
    }
    REP(i, N)
    {
        D[i] = INF;
    }

    ll l = 0;
    bool neg = false;
    D[R] = 0;
    while (true)
    {
        bool update = false;
        REP(i, M)
        {
            Edge e = E[i];
            if (D[e.from] == INF)
                continue;
            ll cost = D[e.from] + e.cost;
            if (D[e.to] <= cost)
                continue;
            D[e.to] = cost;
            update = true;
        }
        if (!update)
            break;
        if (l++ >= N)
        {
            neg = true;
            break;
        }
    }

    if (neg)
        cout << "NEGATIVE CYCLE" << endl;
    else
    {
        REP(i, N)
        {
            if (D[i] == INF)
                cout << "INF";
            else
                cout << D[i];
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int h,n;
  cin >> h >> n;
  rep(i,n){
    int f;
    cin >> f;
    h-=f;
  }
  if (h<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
/* 

	CODE TEMPLATE APRATIM

*/

#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define veci vector<ll>
#define it map<string, vv>::iterator
#define MOD 1000000007
#define N (ll)3e+5
#define test int T;cin>>T;while(T--)
#define nl "\n"
#define FULL(iii) iii.begin(),iii.end()
#define setbit(_) __builtin_popcount(_)
#define INF 9223372036854775807 
#define TOUPR(str) transform(str.begin(), str.end(),str.begin(), ::toupper)
#define TOLWR(str) transform(str.begin(), str.end(),str.begin(), ::tolower)
#define pb push_back
#define len(s) s.length()
#define pb push_back
#define eb emplace_back
#define S second
#define F first
#define len(s) s.length()
#define coutp cout<<setprecision(15)
#define pow(a,b) (ll)(pow(a,b)+0.5)
#define bin(x) stoull(x,0,2)
#define lld long double 
int main()
{
	ll n;
	cin>>n;
	if(n>=30)cout<<"Yes"<<nl;
	else cout<<"No"<<nl;
}





Measured memory_bytes: 3628
let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let bs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let acc = Array.fold_left ( lxor ) 0 bs in
  Printf.printf "%d\n" @@ fst @@ 
    Array.fold_left (fun (ans, bs) i ->
      let mask = (1 lsl i) - 1 in
      let bs' =
        List.filter (fun b -> 1 lsl (i - 1) <= (b land mask)) bs @
        List.filter (fun b -> (b land mask) < 1 lsl (i - 1)) bs in
      let bs = Array.of_list bs' in
      (ans lor (Array.fold_left ( lxor ) 0 @@ 
      Array.map (fun a ->
        if
          ((a land (1 lsl i)) <> 0 && n mod 2 <> 0) <>
          (acc land (1 lsl i) <> 0) <>
          match 
            upper_bound 0 n (fun j ->
              (1 lsl i) - (a land mask) <= (bs.(j) land mask))
          with
          | 0 -> (1 lsl i) - (a land mask) <= (bs.(0) land mask)
          | i -> i mod 2 = 0
        then 1 lsl i
        else 0) as_), bs')) (0, Array.to_list bs) @@ Array.init 29 @@ fun i -> i


Measured memory_bytes: 54012
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double ret;
        if (n % 2 == 0) {
            ret = 0.5d;
        } else {
            ret = (double) ((n + 1) / 2) / n;
        }
        sc.close();
        System.out.println(ret);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    int n,m,q;
    cin >> n >> m >> q;
    vector<int> a(q),b(q),c(q),d(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    queue<string> qq;
    qq.push("0");
    queue<string> s;
    while(!qq.empty()){
        string f=qq.front();
        qq.pop();
        if (f.size()==n) s.push(f);
        else{
            int u=f[f.size()-1]-'0';
            for (int i=u;i<m;i++){
                qq.push(f+to_string(i));
            }
        }
    }
    int ans=0;
    while(!s.empty()){
        string f=s.front();
        s.pop();
        int r=0;
        rep(i,q){
            int g=f[a[i]-1]-'0',h=f[b[i]-1]-'0';
            if (h-g==c[i]) r+=d[i];
        }
        ans=max(ans,r);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4864
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


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



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

	vector<string> str;
	REP(i, n) {
		string s;
		cin >> s;
		str.push_back(s);
	}

	SORT(str);

	REP(i, n) {
		cout << str[i];
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    if (k%2 == 0 || k%5 == 0) {
        cout << "-1" << endl;
        return 0;
    }
    

    int l = 7;
    int ans = 0;
    while(1){
        l %= k;
        if (l == 0) break;
        l *= 10;
        l += 7;
        ans++;
    }
    cout << ans+1 << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<n); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  int w, h, n;
  cin >> w >> h >> n;
  vec x(n), y(n), a(n);
  rep(i,n){
    cin >> x[i] >> y[i] >> a[i];
  }

  bool is_black[w][h];
  rep(i,w){
    rep(j,h){
      is_black[i][j]=false;
    }
  }

  rep(i,n){
    switch(a[i]){
      case 1:{
        rep(j,h){
          rep(k,x[i]){
            is_black[k][j]=true;
          }
        }
        break;
      }
      case 2:{
        rep(j,h){
          REP(k,x[i],w){
            is_black[k][j]=true;
          }
        }
        break;
      }
      case 3:{
        rep(j,y[i]){
          rep(k,w){
            is_black[k][j]=true;
          }
        }
        break;
      }
      default:{
        REP(j,y[i],h){
          rep(k,w){
            is_black[k][j]=true;
          }
        }
        break;
      }
    }
  }

  int ans=0;
  rep(i,w){
    rep(j,h){
      if(!is_black[i][j]) ans++;
    }
  }

  prt(ans);

}


Measured memory_bytes: 256
#!/usr/bin/env python3
from math import ceil
count=0
n,k=map(int,input().split())
s=list(input())
for i in range(n-1):
    if s[i]!=s[i+1]:
        count+=1
kaisu=ceil(count/2)
if k>=kaisu:
    print(n-1)
else:
    print(n-1-2*(kaisu-k)+(count%2))


Measured memory_bytes: 49392
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    a=parseMap(split(readline()))
    println(1+parseInt(ceil((n-k)/(k-1))))
end
main()

Measured memory_bytes: 115812
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  string S,T;
  cin >> S >> T;
  vint s(S.length()+1,0),t(T.length()+1,0);
  repeat(i,S.length()){
    s[i+1] += (S[i]=='A'? 1:2) + s[i];
  }
  repeat(i,T.length()){
    t[i+1] += (T[i]=='A'? 1:2) + t[i];
  }
  int q;
  cin >> q;
  repeat(i,q){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (((s[b]-s[a-1])-(t[d]-t[c-1]))%3==0? "YES":"NO") << endl;
  }
  return 0;
}


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

int main(void)
{
    using namespace std;

    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

    printf("%f\n", sqrt(pow(x2-x1, 2) + pow(y2-y1, 2)));
    return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>

 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 



int main(){
	vi v(30,0);
	int t;
	rep(i, 28) cin>>t,v[--t]+=1;
	rep(i, 30) if(!v[i]) cout<<i+1<<endl;
}

Measured memory_bytes: 1192