akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define DB(x)            cout << '>' << #x << ':' << x << endl;
#define DB2(x,y) 	 cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define rep(i,a,b)       for (ll i = a; i < b; i++)
#define repr(i,a,b)      for (ll i = a; i >= b; i--)
#define pb               push_back
#define F                first
#define S                second
#define mp               make_pair
#define MOD              1000000007
#define MAX              1e9
#define MIN              -1e9
#define vec(i)           vector<i>
#define PLL           	 pair<ll,ll>
#define mem(a,v)         memset(a,v,sizeof(a))
#define pf               printf
#define sc               scanf
#define _s               "%s"
#define _d               "%d"
#define _ll              "%lld"
#define _c               "%c"
#define FAST_IO          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define min(a,b)         a>b?b:a
#define max(a,b)         a>b?a:b
typedef long long ll;
using namespace std;
int main()
{
    ll n,l;
    cin>>n>>l;
    string s[n];
    rep(i,0,n)
        cin>>s[i];
    sort(s,s+n);
    rep(i,0,n)
    	cout<<s[i];
    return 0;
}

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

int main() {
	string o, e;
	cin >> o >> e;
	for (ll i = 0; i < e.size(); ++i) {
		cout << o[i] << e[i];
	}
	if (o.size() > e.size())cout << o.back();
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n,a[5],mi=1e18;
    cin>>n;
    for(int i=0;i<5;i++){
        cin>>a[i];
        mi=min(mi,a[i]);
    }
    ll ans=4+n/mi;
    cout<<((n%mi)?ans+1:ans)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;

  int ans=0;
  int ma=max({A,B,C});
  int count=0;
  ans+=(ma-A)/2;
  ans+=(ma-B)/2;
  ans+=(ma-C)/2;
  count+=(ma-A)%2;
  count+=(ma-B)%2;
  count+=(ma-C)%2;
  if(count==1)  ans+=2;
  if(count==2)  ans++;
  cout << ans << endl;

  return 0;
}


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

int main() {
    string in;
    cin >> in;
    if (in[0] == 'S') {
        cout << "Cloudy" << endl;
    } else if (in[0] == 'C') {
        cout << "Rainy" << endl;
    } else if (in[0] == 'R') {
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] d = new int[N];
        for(int i=0; i<N; i++){
            d[i] = nextInt();
        }

        int count = 0;
        for(int i=0; i<N; i++){
            for(int j=i+1; j<N; j++){
                count += d[i]*d[j];
            }
        }
        println(count);
    }

    static long a(long n){
        return n < 2L ? 1L : n*a(n-2);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
const int MOD = 1e9 + 7;
const int INV_2 = 5e8 + 4;
typedef long long ll;

int n, tot = 0, fa[N], id[N]; 

vector <int> son[N];

struct tData {
	ll _0, _1, _2; 
} ;

vector <tData> v[N];

inline ll ksm( ll a, ll b ) 
{
	ll ret = 1; 
	for( ; b; b >>= 1, a = a * a %MOD )
		if( b & 1 ) ret = ret * a %MOD;
	return ret;
}

inline ll inv( ll a ) { return ksm( a, MOD-2 ); }

inline ll add( ll a, ll b ) { ll ret = a + b; if( ret >= MOD ) ret -= MOD; return ret; }
inline ll dec( ll a, ll b ) { ll ret = a - b; if( ret < 0 ) ret += MOD; return ret; }

inline int merge( int x, int y ) 
{
	int size_x = v[x].size();
	int size_y = v[y].size();
	if( size_x < size_y )
		swap( x, y ), swap( size_x, size_y );
	
	ll sum_0, sum_1, sum_2;	
	for( int j = 1 ; j <= size_y; j ++ )
	{
		int xi = size_x - j;
		int yi = size_y - j;
		sum_0 = sum_1 = sum_2 = 0;
		
		sum_0 = v[x][xi]._0 * v[y][yi]._0 %MOD;
		
		sum_1 = add( sum_1, v[x][xi]._1 * v[y][yi]._0 %MOD );	
		sum_1 = add( sum_1, v[x][xi]._0 * v[y][yi]._1 %MOD );
		
		sum_2 = add( sum_2, v[x][xi]._2 * v[y][yi]._2 %MOD );
		sum_2 = add( sum_2, v[x][xi]._2 * v[y][yi]._1 %MOD );
		sum_2 = add( sum_2, v[x][xi]._2 * v[y][yi]._0 %MOD );
		sum_2 = add( sum_2, v[x][xi]._1 * v[y][yi]._2 %MOD );
		sum_2 = add( sum_2, v[x][xi]._1 * v[y][yi]._1 %MOD );
		sum_2 = add( sum_2, v[x][xi]._0 * v[y][yi]._2 %MOD );
		
		v[x][xi]._0 = sum_0;
		v[x][xi]._1 = sum_1;
		v[x][xi]._2 = sum_2;
	} 
	
	return x;
} 

inline void dfs( int u )
{
	int size = son[u].size(), dep = 0; 
	for( int i = 0; i < size; i ++ )
	{
		int _v = son[u][i];
		dfs( _v );
		
		if( !id[u] ) id[u] = id[_v];
		else id[u] = merge( id[u], id[_v] ),
			 dep = max( dep, int( v[id[u]].size() ) );
	}
	
	if( !size ) {
		id[u] = ++tot; 
		v[tot].push_back( { INV_2, INV_2, 0 } ); 
		return;
	}
	
	v[id[u]].push_back( { INV_2, INV_2, 0 } );
	
//	printf( "%d\n", v[id[u]].size() - dep );

	size = v[id[u]].size(); int i; 
	for( int j = 2; j <= dep+2 && j <= size; j ++ )
		i = size - j,
		v[id[u]][i]._0 = add( v[id[u]][i]._0, v[id[u]][i]._2 ),
		v[id[u]][i]._2 = 0;
}

int main()
{
//	freopen( "example.in", "r", stdin );
	scanf( "%d", &n );
	
	for( int i = 1; i <= n; i ++ ) 
		scanf( "%d", &fa[i] ),
		son[fa[i]].push_back( i );
	
	dfs( 0 );
	
	ll ans = 0; int size = v[id[0]].size();
	
	for( int i = 0; i < size; i ++ ) 
		ans = add( ans, v[id[0]][i]._1 );
	
	ans = ans * ksm( 2, n+1 ) %MOD;
	
	printf( "%lld\n", ans ); 
	
	return 0;
}

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

int main(void)
{
    long long n;
    cin >> n;
    long long t;
    long long ans = 0;
    for (long long j = 1; j <= n; j++)
    {
        t = n / j;
        ans += t * (t + 1) * j / 2;
    }
    cout << ans << endl;
}


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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	for (auto c : S) {
		char ans = c + N;
		if (ans > 'Z') ans -= 26;
		cout << ans;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

vector<int> vec;

ll jyou[400]; 

int hoge(int x){
	if (x >= 200){
		return 200 - x;
	}
	return x;
}

int main(){
	ll x;
	cin >> x;
	for (ll i = 0; i < 200; i++){
		jyou[i] = i*i*i*i*i;
	}
	for (int i = 200; i < 400; i++){
		jyou[i] = -1*jyou[i-200];
	}

	for (int i = 0; i < 400; i++){
		for (int j = 0; j < 400; j++){
			if (jyou[i] - jyou[j] == x){
				cout << hoge(i) << " " << hoge(j) << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define int long long int
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define mod 1000000007
int in(){
int n;cin>>n;
return n;}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
	int t=1;
	while(t--){
		int n=in();
		int a[n+1];
		rep(i,0,n+1)a[i]=0;
		rep(i,1,n){
			int z=in();
			a[z]++;
		}
		rep(i,1,n+1){
			cout<<a[i]<<endl;
		}
	}
	return 0;
	}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
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; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;

//ll dp[3100][3100];// dp[i][j]=
int keta10(ll n){
	return log10(n)+1;
}
int main(){
	ll N; cin>>N;
	ll ans=INF;
	for(ll i=1; i*i<=N;i++){
		if(N%i!=0) continue;
		ll A=i,B=N/i;
	    ll sub=max(keta10(A),keta10(B));
		ans=min(ans,sub);
	}
  
	cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

/** dp[n][v]: n番目の荷物までで価値がv以上の時の重さの最小値 */
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = Integer.parseInt(scanner.next());
    int w = Integer.parseInt(scanner.next());
    int[][] wv = new int[n][2];
    int wi, vi;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 2; j++) {
        wv[i][j] = Integer.parseInt(scanner.next());
      }
    }
    int v = 100000;
    long[][] dp = new long[n + 1][v + 1];
    for (int i = 0; i < n + 1; i++) {
      for (int j = 0; j < v + 1; j++) {
        dp[i][j] = 100000000000L;
      }
    }
    dp[0][0] = 0;
    for (int i = 1; i < n + 1; i++) {
      wi = wv[i - 1][0];
      vi = wv[i - 1][1];
      for (int j = 0; j < v + 1; j++) {
        dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
        if (j - vi >= 0) {
          dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - vi] + wi);
        }
      }
    }
    for (int j = v; j >= 0; j--) {
      if (dp[n][j] > w) {
        continue;
      }
      System.out.println(j);
      break;
    }
  }
}


Measured memory_bytes: 126416
n = int(input())
if n%7 == 0 or n%4 == 0:
    print("Yes")
    exit()

for i in range(4,101,4):
    for j in range(7,101,7):
        if i+j > 100: break
        if i+j == n:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define M 1000000007
int main()
{
    int v[3][3];
    for(int a = 0;a < 3;a++){
        for(int b = 0;b < 3;b++){
            cin >>v[a][b];
        }
    }
    bool x,y;
    if(v[0][0]-v[0][1]==v[1][0]-v[1][1]&&v[0][1]-v[0][2]==v[1][1]-v[1][2]&&v[1][0]-v[1][1]==v[2][0]-v[2][1]&&v[1][1]-v[1][2]==v[2][1]-v[2][2]){
        x = true;
    }else{
        x = false;
    }
    if(v[0][0]-v[1][0]==v[0][1]-v[1][1]&&v[1][0]-v[2][0]==v[1][1]-v[2][1]&&v[0][0]-v[1][0]==v[0][2]-v[1][2]&&v[1][0]-v[2][0]==v[1][2]-v[2][2]){
        y = true;
    }else{
        y = false;
    }
    if(x&&y){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
table = []
 
for i, a in enumerate(A):
    table.append([a,i])
table.sort()
 
# DP[i][j] 左端に i 個, 右端に j 個貪欲に詰めたときのうれしさ
DP = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(1,N+1):
    # i 人目 table[i-1] の幼児を移動させる
    baby, pos = table.pop()
    
    DP[i][0] = DP[i-1][0] + baby * abs(pos-i+1)
    DP[0][i] = DP[0][i-1] + baby * abs(pos-(N-i))
    for x in range(1,i):
        y = i - x
 
        #左端に置く場合と右端に置く場合でmax
        DP[x][y] = max(DP[x-1][y] + baby * abs(pos-x+1),\
                     DP[x][y-1] + baby * abs(pos-(N-y)))
 
ans = 0
for i in range(N+1):
    ans = max(ans, DP[i][N-i])
print(ans)

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

int main(){
	int H, W;
	for(int i=0 ; ; i++){
		cin >> H >> W;
		if(H==0 && W==0){
			break;
		}else{
			for(int ii=0 ;ii<H; ii++){
				for(int iii=0 ;iii<W; iii++){
					cout << "#";
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, temp, answer;
    int A[200000];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    temp = A[0];
    for(int i=1; i<N; i++){
        temp = temp ^ (int)A[i];
    }
    for(int i=0; i<N; i++){
        answer = temp ^ (int)A[i];
        cout << answer;
        if(i<N-1){
            cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 4428
from collections import deque
n, m = map(int, input().split())
adjacent_list = [[] for i in range(3*n + 3)]
for i in range(m):
    u, v = map(int, input().split())
    for j in range(1,4):
        p = j + 3 * u - 3
        q = (j % 3) + 3 * v - 2
        #print("{} -> {}".format(p, q))
        adjacent_list[p].append(q)
s, t = map(int, input().split())

def bfs(start, target):
    que = deque()
    finished = set()
    que.append([start, 0])
    while que:
        node, dist = que.popleft()
        if (node, dist % 3) in finished:
            continue
        if node == target:
            return dist // 3
        for i in adjacent_list[node]:
            que.append([i, dist+1])
            finished.add((node, dist % 3))
    return -1
print(bfs(s*3 -2, 3*t-2))



Measured memory_bytes: 77076
#include<bits/stdc++.h>
using namespace std;
int t=0,n,p;
long long ans=0;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) 
	{
		scanf("%d",&p);
		if (p>=t) t=p;
		else ans+=t-p;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3756
# D - RGB Triplets
from collections import defaultdict


def main():
    _ = int(input())
    S = input().rstrip()
    indices = defaultdict(set)
    for i, c in enumerate(S):
        indices[c].add(2 * i)
    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for c1, c2, c3 in ["RGB", "GBR", "BRG"]:
        cnt -= sum(
            (i + j) // 2 in indices[c3] for i in indices[c1] for j in indices[c2]
        )
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9912
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

if N%2==0:
    sums =0
    for i in range(1,26):
        sums += (N//2)//(5**i)
    print(int(sums))
else:
    print(0)

Measured memory_bytes: 38256
#include<iostream>
#include<sstream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a>=2&&a<=13&&b>=2&&b<=13)
if(a>b)
cout<<"Alice";
else if(a==b)
cout<<"Draw";
else
cout<<"Bob";
if(a>=1&&a<=13&&b>=1&&b<=13)
if(a==1&&b==1)
cout<<"Draw";
else if(b==1)
cout<<"Bob";
else if(a==1)
cout<<"Alice";

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for(int i=0;i<N;i++){
        cin >> v[i] ;
    }
    sort(v.begin(),v.end());
    for(int i=1;i<N;i++){
        v[i]= (v[i-1]+v[i])/2 ;
    }
    cout << v[N-1] << endl;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint factorial(ll n) {
  mint answer = 1;
  while (n > 1) {
    answer *= n;
    n--;
  }
  return answer;
}

mint combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

mint permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

// setprecision(8) 桁数指定
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int ans = 0;
  x -= z;
  while (x >= y + z) {
    x -= y;
    x -= z;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

long long a[10000],dp[1000][1000];


main(){
	long long k,sum[10000];
	cin>>k;
	for(int i=0;i<k;i++){
		cin>>a[i];
		if(i==0)
			sum[i]=a[i];
		else
			sum[i]=a[i]+sum[i-1];
	}
	for(int i=0;i<k;i++){
		for(int j=i-1;j>=0;j--){
			dp[j][i]=10000000000000;
			for(int o=j;o<i;o++){
				long long s=sum[i];
				if(j>0)
	 				s-=sum[j-1];
	 			dp[j][i]=min(dp[j][i],dp[j][o]+dp[o+1][i]+s);
			}
		}
	}
	cout<<dp[0][k-1]<<endl;
}

Measured memory_bytes: 5864
program main
	implicit none
    
    integer n, i
    character, allocatable, dimension(:) :: s
    read *, n
    allocate(s(n))
    read (*, *)(s(i), i = 1, n)
    do i = 1, n
    	if (s(i) == "Y") then
        	print *, "Four"
            exit
        else if (i == n) then
        	print *, "Three"
        end if
    end do
end program main

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;

int main()
{
    int N, T;
    cin >> N >> T;
    int inf = 1e9;
    int ans = inf;
    for (int i = 0; i < N; i++)
    {
        int c, t;
        cin >> c >> t;
        if (t <= T)
            ans = min(ans, c);
    }
    if (ans == inf)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<" is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int n,m;
	cin>>n>>m;
	int sum=0;
	for(int i=0;i<m;i++)
	{
		int t;
		cin>>t;
		sum+=t;
	}
	if(sum>n) cout<<-1;
	else cout<<n-sum;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

char str[10001];
int len;

struct Node
{
	int value;
	vector <Node> child;
	bool operator < (const Node &a) const
	{
		return value < a.value;
	}
};

int travel(Node &cur, int ind)
{
	int v = 0;
	while(1)
	{
		if(str[ind] == '[')
		{
			cur.child.push_back(Node());
			Node &child = cur.child[cur.child.size() - 1];
			ind = travel(child, ind + 1) + 1;
		}
		else if (str[ind] == ']') break;
		else
		{
			for(;str[ind] != ']';ind++) v = v * 10 + str[ind] - '0';
			cur.value = v / 2 + 1;
			return ind;
		}
	}

	sort(cur.child.begin(), cur.child.end());
	int cN = cur.child.size();
	cur.value = 0;
	for(int i=0;i<=cN / 2;i++) cur.value += cur.child[i].value;

	return ind;
}

int main(void)
{
	int T;
	scanf("%d", &T);
	while(T--)
	{
		scanf("%s", str);
		Node root;
		travel(root, 1);

		printf("%d\n", root.value);
	}				

	return 0;
}

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


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

    ll num = 7;
    for (ll i = 1; i <= 10000000; ++i) {
        num %= K;
        if (num == 0) {
            cout << i << endl;
            return 0;
        }
        num *= 10;
        num += 7;
    }
    cout << -1 << endl;
}




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

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

    a = n / 1000;
    n = n - a * 1000;
    b = n / 100;
    n = n - b * 100;
    c = n / 10;
    d = n % 10;

    if(a == b && b == c || b == c && c == d ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		sc.close();
		if(X % Y == 0) {
			System.out.println(-1);
		}else {
			System.out.println(X);
		}
	}
}

Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000009LL
#define MOD 1000000007LL

ll dp[105][100005];

int main() {
  int N, K; cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= K; j++) {
      if (j == 0) dp[i][j] = 1;
      else if (j - a[i-1] - 1 >= 0) {
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j - a[i-1] - 1] + MOD;
      } else {
        dp[i][j] = dp[i-1][j] + dp[i][j-1];
      }
      dp[i][j] %= MOD;
    }
  }
  
  cout << dp[N][K] << endl;
  
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N;
int cnt[222222];

signed main(){
	cin>>N;
	for(int i=1;i<N;i++){
		int a;cin>>a;a--;
		cnt[a]++;
	}

	rep(i,N)cout<<cnt[i]<<endl;
    return 0;
}


Measured memory_bytes: 5188
#include<stdio.h>

int main(){
  int x,y,a;
  scanf("%d%d",&x,&y);
  while(1){
    if(x>=y){
      a=x%y;
      if(a==0){
        printf("%d\n",y);
        break;
      }
      x=y;
      y=a;
    }
    else{
      a=y%x;
      if(a==0){
        printf("%d\n",x);
        break;
      }
      y=x;
      x=a;
    }
  }
  return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int n, a;
    double t;
    cin >> n >> t >> a;
    vi h(n);
    rep(i, n) cin >> h[i];
    int ans = 1;
    double amin = abs(a - (t - 0.006 * h[0]));
    rem(i, 1, n)
    {

        double _amin = abs(a - (t - 0.006 * h[i]));
        //cout << _amin << "\n";
        if (_amin < amin)
        {
            amin = _amin;
            ans = i + 1;
        }
    }

    cout << ans << "\n";

    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AColorfulTransceivers {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c, d;
	    in >> a >> b >> c >> d;
	    if(abs(a-b) <= d && abs(b-c) <= d) ans(true, out);
	    else if(abs(a-c) <= d) ans(true, out);
	    else ans(false, out);
	}
};


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


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> v(n);
    REP(i, n) cin >> v[i];

    sort(ALL_OF(v), greater<ll>());

    ld ans = 0;
    ld base = 0.5L;
    REP(i, n) {
        ans += base * v[i];
        if (i < n-2) {
            base *= 0.5L;
        }
    }
    cout << setprecision(20) << ans << endl;
    
}

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

int main() {
	string s;
	cin >> s;
	cout << count(s.begin(), s.end(), '1') << endl;
}


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

int main(){
    int h, w;
    while (1){
        cin >> h >> w;
        if (h==0 and w==0) break;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  bool flag = true;
  cin >> n >> k;
  vector<int> d(k);
  for(int i = 0; i < k; i++) cin >> d.at(i);
  while(flag) {
    flag = false;
    int tmp = n;
    while(tmp) {
      for(int i = 0; i < k; i++) {
        if ((tmp%10) == d.at(i)) {
          tmp = 0;
          flag = true;
          break;
        }
      }
      tmp /= 10;
    }
    if (flag) n++;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int> can;
  vector<int> ans;
  for(int i=0;i<n;i++) {
    if(s[i] == 'o') can.emplace_back(i);
  }
  int m = can.size();
  vector<int> days(m); 
  for(int i=m-1;i>=0;i--) {
    auto it = upper_bound(can.begin(), can.end(), can[i]+c);
    if(it == can.end()) days[i] = 1;
    else {
      int j = distance(can.begin(), it);
      days[i] = days[j] + 1;
    }
  }
  if(days.front() > k) {
    cout << endl;
    return 0;
  }
  int lim = -1;;
  for(int i=0;i<m;i++) {
    if(i == 0) {
      if(days[i] != days[i+1]) ans.emplace_back(can[i]+1);
      lim = can[i] + c;
    }
    else if(can[i] <= lim) continue;
    else if(i == m-1) ans.emplace_back(can[i]+1);
    else {
      lim = can[i] + c;
      if(days[i] != days[i+1]) ans.emplace_back(can[i]+1);
    }
  }
  if(!ans.size()) cout << endl;
  else for(auto& el : ans) cout << el << endl;
  return 0;
}


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

#define mod 1'000'000'007
typedef long long ll;

template<typename T>
void deb(initializer_list<T> l)
{
	for (auto &e : l)
		cout << e << ' ';
	cout << endl;
}

void solve()
{
	ll a;
	long double b;
	cin >> a >> b;
	b = a * b;
	a = b;
	cout << a << '\n';
}

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}


Measured memory_bytes: 3744
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    string s,t;
    cin>>s;
    cin>>t;

    int ans=0;
    for(int st=0;st<=s.size()-t.size();st++){
        int cur=0;
        rep(i,t.size()){
                if(t[i] == s[st+i]) cur++;
        }

        ans= max(ans,cur);
    }

    cout<<t.size()-ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update> */

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

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
	
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)
            ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3644
// Shift-JIS（シフトジス）

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

int main()
{
    int N, K;
    cin >> N >> K;
    if (K == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << N - K << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n,ma,mb;
  cin>>n>>ma>>mb;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  int dp[n+1][401][401];
  for(int i=0;i<n+1;i++){
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        dp[i][j][k]=(int)1e9;
      }
    }
  }
  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        if(dp[i][j][k]==(int)1e9) continue;
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }
  int ans=-1;
  for(int i=1;i<=400;i++){
    for(int j=1;j<=400;j++){
      if(dp[n][i][j]==(int)1e9) continue;
      if(i*mb==j*ma){
        if(ans<0) ans=dp[n][i][j];
        else ans=min(ans,dp[n][i][j]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 29332
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long W, long long H, long long x, long long y){
  cout << double(H*W)/double(2) << " " << (2*x==W&&2*y==H ? 1 : 0) << endl;
}

int main(){
  long long W;
  scanf("%lld",&W);
  long long H;
  scanf("%lld",&H);
  long long x;
  scanf("%lld",&x);
  long long y;
  scanf("%lld",&y);
  solve(W, H, x, y);
  return 0;
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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

int main( void )
{
	string s;
	cin >> s;

	ll n = s.length();
	ll pos[n] = {};
	s = s + 'R';
	ll x = 0, y = 0;
	ll cnt = 0;
	rep( i, n ) {
		cnt++;
		if ( (s[i] == 'R') && (s[i + 1] == 'L') ) {
			x = i;
		}
		if ( (s[i] == 'L') && (s[i + 1] == 'R') ) {
			if ( (x - y) % 2 ) {
				pos[x    ] = cnt / 2;
				pos[x + 1] = cnt / 2 + cnt % 2;
			}
			else {
				pos[x    ] = cnt / 2 + cnt % 2;
				pos[x + 1] = cnt / 2;
			}
			cnt = 0;
			y = i + 1;
		}
	}

	rep( i, n - 1 ) {
		cout << pos[i] << " ";
	}
	cout << pos[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 1404
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int x, y, z, k;
ll a[1010], b[1010], c[1010];

vector<ll>ans;


int main() {
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < y; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < z; i++) {
		cin >> c[i];
	}
	sort(a, a + x, greater<ll>());
	sort(b, b + y, greater<ll>());
	sort(c, c + z, greater<ll>());
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			for (int l = 0; l < z; l++) {
				if ((i + 1) * (j + 1) * (l + 1) > k) {
					break;
				}
				else {
					ans.push_back(a[i] + b[j] + c[l]);
				}
			}
		}
	}
	sort(ans.begin(), ans.end(), greater<ll>());

	for (int i = 0; i < k; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#define max(x, y) (x > y ? x : y)
int main()
{
	int h, w, n;
	scanf("%d%d%d", &h, &w, &n);
	int x = max(h, w);
	printf("%d\n", (n - 1) / x + 1);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

void Common(int,int);

int main(){
  int x,y;

  scanf("%d%d",&x,&y);

  Common(x,y);

  return 0;
}

void Common(int a,int b){
  int n,tmp;

  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }

  n = a % b;
  while(n != 0){
    a = b;
    b = n;
    n = a % b;
  }

  printf("%d\n",b);
}



Measured memory_bytes: 2128
/************************************************
*Author        :  lrj124
*Created Time  :  2018.10.24.19:28
*Mail          :  1584634848@qq.com
*Problem       :  d
************************************************/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int n,k,a[maxn],b[maxn];
long long ans;
int main() {
	//freopen("d.in","r",stdin);
	//freopen("d.out","w",stdout);
	scanf("%d%d",&n,&k);
	for (int i = 1;i <= n;i++) {
		scanf("%d%d",&a[i],&b[i]);
		if ((a[i]|k) == k) ans += b[i];
	}
	for (int i = 1;i <= 30;i++)
		if (k&(1<<i)) {
			int K = k^(1<<i)|(1<<i)-1;
			long long cnt = 0;
			for (int j = 1;j <= n;j++)
				if ((a[j]|K) == K) cnt += b[j];
			ans = max(ans,cnt);
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [x, y] <- getIntList
  if odd y
    then putStrLn "No"
    else do
      let minus = y - x * 2
      if minus == 0
        then putStrLn "Yes"
        else do
          if minus < 0
            then putStrLn "No"
            else do
              if minus <= 2 * x
                then putStrLn "Yes"
                else putStrLn "No"


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
char a[3][101010 * 2];

bool deal(char x, char y, int cnt, const int maxv){
    for(int i = 1; a[1][i]; i ++){
        if(a[1][i] == x) cnt --;
        if(cnt == 0) return true;
        if(a[2][i] == y) cnt ++;
        cnt = min(maxv, cnt);
    }
    return false;
}
int main(){
    int h, w, n, x, y;
    scanf("%d%d%d%d%d", &h, &w, &n, &x, &y);
    scanf("%s%s", a[1] + 1, a[2] + 1);
    bool flag = false;
    flag = flag | deal('R', 'L', w - y + 1, w);
    flag = flag | deal('L', 'R', y, w);
    flag = flag | deal('U', 'D', x, h);
    flag = flag | deal('D', 'U', h - x + 1, h);
    printf("%s\n", flag ? "NO" : "YES");
}

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

int main()
{
int N;scanf("%d",&N);
vector<int> A(N);vector<int> B(N);
for(int i=0;i<N;i++){scanf("%d ",&A[i]);A[i]--;B[A[i]]=i;}
for(int i=0;i<N;i++)printf("%d ",B[i]+1);
}

Measured memory_bytes: 1536
n = int(input())
S =list(map(int,input().split(" ")))
l =int(input())
T =list(map(int,input().split(" ")))
ans =0
for t in T:
    left=0
    right=n
    while left < right:
        mid=(left+right)//2
        if  S[mid] == t:
           ans+=1
           break
        elif S[mid] > t:
            right = mid
        else:
            left = mid +1
print(ans)



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

int main () {
  vector<int> line ;
  line = {0,1,3,1,2,1,2,1,1,2,1,2,1} ;
  
  int a , b ;
  cin >> a >> b ;
  
  if ( line.at(a) == line.at(b) ) {
    cout << "Yes" << endl ;
  } else {
    cout << "No" << endl ;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
int keta(int a){
    int ans = 1;
    while(a > 9){
        ans ++;
        a/=10;
    }
    return ans;
}
int main(){
    int n;
    cin >> n;

    int cnt =0;
    for(int i =1;i<=n; i++){
        int f = keta(i);
        if(f%2!=0){
            cnt++;
        }
    }
    cout << cnt <<endl;
}






Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_H=1000,MAX_W=1000;
ll H,W;
typedef pair<ll,ll> P;
char A[MAX_H][MAX_W+1];
ll dst[MAX_H][MAX_W];
const ll dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>H>>W;
	REP(i,H)cin>>A[i];
	queue<P> que;
	REP(i,H)REP(j,W){
		if(A[i][j]=='#'){
			dst[i][j]=0;
			que.push(P(i,j));
		}else{
			dst[i][j]=-1;
		}
	}
	while(!que.empty()){
		P p=que.front();
		que.pop();
		REP(i,4){
			ll i2=p.first+dy[i],j2=p.second+dx[i];
			if(i2>=0&&i2<H&&j2>=0&&j2<W&&dst[i2][j2]==-1){
				dst[i2][j2]=dst[p.first][p.second]+1;
				que.push(P(i2,j2));
			}
		}
	}
	ll ans=0;
	REP(i,H)REP(j,W)ans=max(ans,dst[i][j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 25396
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LL long long
#define MX 55

int h,w;
char s[MX][MX];
char num[MX][MX];

char check(int x,int y)
{
    int tot = 0;
    if (s[x-1][y-1]=='#') tot++;
    if (s[x-1][y]=='#') tot++;
    if (s[x-1][y+1]=='#') tot++;

    if (s[x][y-1]=='#') tot++;
    if (s[x][y+1]=='#') tot++;

    if (s[x+1][y-1]=='#') tot++;
    if (s[x+1][y]=='#') tot++;
    if (s[x+1][y+1]=='#') tot++;
    return tot+'0';
}

int main()
{
    scanf("%d%d",&h,&w);
    for (int i=1;i<=h;i++)
        scanf("%s",s[i]+1);

    for (int i=1;i<=h;i++)
    {
        for (int j=1;j<=w;j++)
        {
            if (s[i][j]=='#')
            {
                num[i][j] = s[i][j];
                continue;
            }
            num[i][j] = check(i,j);
        }
    }
    for (int i=1;i<=h;i++)
    {
        for (int j=1;j<=w;j++)
            printf("%c",num[i][j]);
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256