akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int path[100000];
vector<int> graph[100000];

void dfs(vector<int>& ans, priority_queue<int>& que, vector<bool> used, int curr) {
  used[curr] = true;
  ans[curr] = que.top(); que.pop();
  for(auto g : graph[curr]) {
    if(used[g]) continue;
    dfs(ans, que, used, g);
  }
}

int main() {
  int N, c;
  ll ans_score = 0;
  cin >> N;
  vector<int> a(N - 1), b(N - 1);
  priority_queue<int> que;
  for(int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i];
    path[a[i]]++;
    path[b[i]]++;
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }
  for(int i = 0; i < N; i++) {
    cin >> c;
    ans_score += c;
    que.push(c);
  }
  ans_score -= que.top();

  vector<int> ans(N + 1, -1);
  vector<bool> used(N + 1, false);
  used[0] =true;
  dfs(ans, que, used, 1);
  
  cout << ans_score << endl;
  for(int i = 1; i < ans.size(); i++) {
    if(i == 1) cout << ans[i];
    else cout << " " << ans[i];
  }cout << endl;
  return 0;
}


Measured memory_bytes: 16896
def main(N):
    if L % 2 == 0 or L % 5 == 0:
        print(-1)
        return
    else:
        before = 10 % L
        if before == 1:
            print(1)
            return
        for i in range(L):
            before = (10 * before) % L
            if before == 1:
                print(i + 2)
                return
        print("error")
        return

K = int(input())
if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K
#print(L)
main(L)
#print("A")

Measured memory_bytes: 9140
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
const int inf=1e9;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int in[11][11];
    rep(i,11)rep(j,11)in[i][j]=inf;
    int maax=0;
    rep(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      in[a][b]=c;
      in[b][a]=c;
      maax=max(maax,a);
      maax=max(maax,b);
    }
    n=maax+1;
    int mini=inf;
    int out;
    rep(i,n){
      int sum=0;
      rep(j,n){
	if(i==j)continue;
	vector<vector<int> >tmp(n,vector<int>(n));
	rep(a,n)rep(b,n)tmp[a][b]=in[a][b];
	rep(k,n)rep(a,n)rep(b,n)tmp[a][b]=min(tmp[a][b],tmp[a][k]+tmp[k][b]);
	sum+=tmp[i][j];
	//cout<<" "<<i<<" "<<j<<" "<<sum<<endl;
      }
      if(mini>sum){
	mini=sum;
	out=i;
      }
      //cout<<i<<" ! "<<sum<<endl;
    }
    cout<<out<<" "<<mini<<endl;
  }
}

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

using namespace std;

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

    for (int i = 1; i <= n; i++)
    {
        x = i;
        if (i % 3 == 0)
        {
            cout << " " << i;
            continue;
        }
        while (true)
        {
            if (x % 10 == 3)
            {
                cout << " " << i;
                break;
            }
            if (x > 10)
            {
                x /= 10;
            }
            else
                break;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3096
#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(){
	int n;
	string s;
	cin >> n >> s;
	if(n >= 3200){
		cout << s << endl;
	}else{
		cout << "red" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */			
int n1;set<vector<vector<int>>>se;
void fun(int n,vector<vi>re)
{
    if(n==n1)
    {
        se.insert(re);
        return;
    }
    int i;
    for( i=0;i<15;i++)
    {   if(re[i].size()==0)break;
        re[i].pb(n);
        fun(n+1,re);
        re[i].pop_back();
    }
    re[i].pb(n);
    fun(n+1,re);
}
void solve()
{  
   cin>>n1;
   vector<vi> em(15);
   fun(0,em);
   set<string>se1;
   for(auto it:se)
   {   char chh[n1];char ch='a';
       for(int i=0;i<15;i++)
       {   if(it[i].size()==0)break;
           for(int j=0;j<it[i].size();j++)
           {
               chh[it[i][j]]=ch;
           }
           ch++;
       }
       string s1="";
       for(int i=0;i<n1;i++)s1+=chh[i];
      se1.insert(s1);   
   }
   for(auto it:se1)cout<<it<<endl;
  
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




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

#define ll long long
const int MOD = 1e9+7;
ll mod(ll x) {
	return (x%MOD + MOD) %MOD;
}
ll mul(ll a,ll b) {
	return mod(mod(a) * mod(b));
}

#define fi(a) for (ll i = 0; i < a; ++i)
#define fid(a) for (ll i = a; i >= 0; --i)
#define fjd(a) for (ll j = a; j >= 0; --j)
#define fj(a) for (ll j = 0; j < a; ++j)
#define rep(i, a, b) for (ll i = (a); ll <= int(b); ll++)


ll n,m,K;

bool issafe(int x,int y) {
	return (x>=0 && x < n) && (y>=0 && y<m);
}


int main() {

	cin >> n;
	string result;
	while(n > 0) {
		n -= 1;
		result.push_back('a' + n%26);
		n /= 26;
	}
	reverse(result.begin(),result.end());
	cout << result << endl;
// 664 B
/*	int sx,sy;
	cin >> n >> m >> sx >> sy;
	--sx,--sy;
	vector<vector<bool>> vis(n,vector<bool>(m,-1));
	for(int i = sy;i < m;i++)
		cout << sx+1 << " " << i+1 << endl;

	for(int i = sy-1;i >= 0;i--)
		cout << sx+1 << " " << i+1 << endl;
	sy = 0;
	for(int i = 0; i < n;i++) {
		if(i != sx) {
			if(sy == 0) {
				for(int j = 0;j < m;j++)
					cout << i+1 << " " << j+1 << endl;
				sy = m-1;
			}
			else {
				for(int j = m-1;j >=0;j--)
					cout << i+1 << " " << j+1 << endl;
				sy = 0;
			}
		}
	}*/
// 664 C
/*	cin >> n >> m;
	vector<ll> a(n);
	vector<ll> b(m);
	for(int i = 0;i<n;i++)
		cin >> a[i];
	for(int j = 0;j <m;j++)
		cin >> b[j];
	ll min_val = INT_MAX;
	ll  A = 0;
	for(A = 0;A < (1<<9);A++ )
	{
		ll count = 0;
		for(int i = 0;i<n;i++)
		{
			for(int j = 0;j<m;j++)
			{
				auto c = a[i]&b[j];
				if((A|c) == A)
				{
					count++;
					break;
				}
			}
		}
		if(count == n)
			break;
	}
	cout << A << endl;
*/
// 664 A
/*	int t;
	cin >> t;
	while(t--) {
		ll r,g,b,w;
		cin >> r >> g >> b >> w;
		auto min_value = min(r,min(g,b));
		int rgb_count = (r%2) + (g%2) + (b%2) + (w%2);
		if(rgb_count <= 1)
			cout << "Yes" << endl;
		else if(r > 0 && g > 0 && b > 0  && (((r-1)%2 +(g-1)%2+(b-1)%2+(w+1)%2) <=1 ))
			cout << "Yes" << endl;
		else
			cout << "No" <<  endl;

	}*/
	return 0;
}	

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int main()
{
	string s; cin >> s;
	bool valid = (count(s.begin(), s.end(), 'A') >= 1) and (count(s.begin(), s.end(), 'B') >= 1);
	cout << (valid ? "Yes" : "No");
	return 0;
}

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

using namespace std;
using lint = long long;

int main() {
    lint N, M;
    string s, t;
    cin >> N >> M >> s >> t;

    lint g = __gcd(M, N);
    lint res = N / g * M;
    N /= g, M /= g;
    bool ok = true;
    for (lint i = 0; i < g; ++i) {
        if (s[i * N] != t[i * M]) ok = false;
    }

    if (ok) {
        cout << res << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int n,m,k;
    int a,b;
    int asum=0,bsum=0;
    int sum=0,count=0;
    cin>>n>>m>>k;
    vector<int> va(n),vb(m),v;
    for(int i=0;i<n;i++){
        cin>>va[i];
    }
    for(int i=0;i<m;i++){
        cin>>vb[i];
    }
    
    for(a=0;a<n;a++){
        asum+=va[a];
        if(asum>k)
        {
            asum-=va[a];
            break;
        }
    }
    
    for(b=0;b<m;b++){
        bsum+=vb[b];
        if(bsum>k)
        {
            bsum-=vb[b];
            break;
        }
    }
    
    for(int i=a-1;i>=0;i--){
        v.push_back(va[i]);
    }
    for(int i=0;i<b;i++){
        v.push_back(vb[i]);
    }
    
    int fast=0;
    
    for(int i=0;i<v.size();i++){
        sum+=v[i];
        count++;
        if(sum>k){
            sum-=v[fast];
            count--;
            fast++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 6932
#include<stdio.h>
//小さい順にソート
int c[100002][2];
void merge(int i,int j,int s[][2]){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        b++;
      }
      else if(j<b){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        a++;
      }
      else if(s[a][0]<s[b][0]){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        a++;
      }
      else{
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        b++;
      }
    }
    for(d=i;d<=j;d++){
      s[d][0]=c[d][0];
      s[d][1]=c[d][1];
    }
  }
}

int main(){
  int n,i;
  long sum=0,k;
  scanf("%d%ld",&n,&k);
  int a[n+1][2];
  for(i=0;i<n;i++)
    scanf("%d%d",&a[i][0],&a[i][1]);
  merge(0,n-1,a);
  i=0;
  while(sum+(long)a[i][1]<k){
    sum+=(long)a[i][1];
    i++;
  }
  printf("%d\n",a[i][0]);
  return 0;
}


Measured memory_bytes: 3280
//ABC049C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main() {
	string s;
	cin >> s;
	int p = s.size()-1;
	while(1){
		if(4 <= p && s.substr(p-4,5) == "dream" || s.substr(p-4,5) == "erase"){
			p -= 5;
		}else if(6 <= p && s.substr(p-6,7) == "dreamer"){
			p -= 7;
		}else if(5 <= p && s.substr(p-5,6) == "eraser"){
			p -= 6;
		}else{
			cout << "NO" << endl;
			return 0;
		}
		if(p == -1){
			cout << "YES" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    dpi = dp[i - 1]
    for j in range(i + 1):     
        if j == 0:
            dp[i][j] = dpi[j] * pp
        elif j == i:
            dp[i][j] = dpi[j - 1] * p
        else:
            dp[i][j] = dpi[j - 1] * p + dpi[j] * pp


res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)

Measured memory_bytes: 222552
#include <stdio.h>

int main(void)
{
    int a,b;
    int i;
    int d[999];

    scanf("%d%d",&a,&b);
    d[0]=1;
    for (i = 1; i < 999; i++) {
        d[i] = d[i-1]+(i+1);               
    }
    for (i = 0; i < 998; i++) {
        if (d[i]-d[i+1] == a-b) {
            printf("%d\n",d[i]-a);
        }
    }


    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int a, b;
   cin >> a >> b;
   if (a % 2 == 0 || b % 2 == 0) cout << "Even" << endl;
   else cout << "Odd" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
using namespace std;
int main(){
	char w[6];
	scanf("%s",w);
	if(w[0]=='S'){
		cout<<"Cloudy"<<endl;
	}
	else if(w[0]=='C'){
		cout<<"Rainy"<<endl;
	}
	else cout<<"Sunny\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()
#include <cstdlib>
#include <cmath>

using namespace std;

//long a, b, c, d, i, j, k, n;


int main(){
//////////////////////////////////////////////////////

    int n, k;
    cin >> n >> k;

    //cout << "n:" << n << endl;
    //cout << "k:" << k << endl;
    //cin >> n;
    vector<long> input(n);
    for (int i = 0 ; i < n ; i ++ )
    {
        cin >> input[i];
        //cout << "input[" << i << "]=" << input[i] << endl  ;
    }

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

    uint64_t min = numeric_limits<uint64_t>::max();

    

    for ( int i = 0 ; i < n - k + 1 ; i ++ )
    {
        //cout << "input[ n + k - 1 ] : " << input[ i + k - 1 ] << endl;
        //cout << "input[ n ] : " << input[ i ] << endl;

        uint64_t delta = abs( input[ i + k - 1 ] - input[ i ] );
        //cout << "delta : " << delta << endl;
        if ( delta < min )
        {
            min = delta;
        }
    }


    // long sum = 0;
    // for ( int i = 0 ; i < n ; i ++ )
    // {
    //     sum += i;
    // }






    cout <<   min   << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}




Measured memory_bytes: 1024
#include<stdio.h>
int main(void) {
int N,K,X,Y,sumkx,sumky,sum;
	scanf("%d",&N);

	//printf("K");
	scanf("%d",&K);

	//printf("X");
	scanf("%d",&X);

	//printf("Y");
	scanf("%d",&Y);

	if(N>K) {
		sum=X*K+(N-K)*Y;
		printf("%d\n",sum);
}

	else if(N==K)  {
		sum=X*K;
		printf("%d\n",sum);
}

	else if(N<K)  {
		sum=X*K-(K-N)*X;
		printf("%d\n",sum);
}
return 0;
}

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

int main(){
  long long a = 100, X;
  cin >> X;
  int i;
  for(i = 0; true; i++){
    a =a * 1.01;
    if(X <= a){
      break;
    }
  }
  cout << i + 1 << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    String S = sc.next();
    String ans = "";

    String[] str = S.split("");
    str[K - 1] = str[K - 1].toLowerCase();

    for(int i = 0; i < str.length; i++) {
    	ans += str[i];
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 22356
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

long long n, k;
long long st = 0;
vector<long long> a(maxn, 0);
vector<bool> vis(maxn, false);
vector<long long> path;

void dfs(long long curr) {
	if (vis[curr] == true) {st = curr; return;}
	vis[curr] = true;
	path.push_back(curr);

	dfs(a[curr]);
}
int main() {

	cin >> n >> k;
	for (long long i = 1; i <= n; i++) cin >> a[i];

	dfs(1);

	debug(path);

	vector<long long> new_path;
	for (auto i : path) {
		if (new_path.empty() == false) new_path.push_back(i);
		else if (i == st) new_path.push_back(i);
	}
	debug(new_path);
	long long x = (long long)path.size() - (long long)new_path.size();

	if (k < x) {
		cout << path[k];
		exit(0);
	}

	k -= x;
	k %= ((long long)new_path.size());

	cout << new_path[k];
	return 0;
}

Measured memory_bytes: 29364
A,B  = input().split()

if B[0] == 0:
    BH =      B[2]+B[3]
else:
    BH = B[0]+B[2]+B[3]

ABH = str(int(A)*int(BH))
if len(ABH) <= 2:
    print('0')
else:
    print(ABH[:-2])

Measured memory_bytes: 9148
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>

using namespace std;

bool ok(int n) {
	for(int i=1;i<=n;i++)
		if(i*i==n) return 1;
	return 0;
}

int main() {
	int a,b;//1111111111
	cin>>a>>b;
	int c=b;
	int l=0;
	while(c>0) {
		c/=10;
		l++;
	}
	a=a*pow(10,l)+b;
	if(ok(a)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

string reverce(int,int,string);

int main(){

  string str;
  string command;
  int q;
  int a,b;

  cin >> str;
  cin >> q;

for(int j = 0;j < q;j++){

  cin >> command;

  if(command == "print"){
    cin >> a >> b;
    cout << str.substr(a,b-a+1) << endl;
  }else if(command == "reverse"){
    cin >> a >> b;
    str = reverce(a,b,str);
  }else if(command == "replace"){
    string s;
    cin >> a >> b >> s;
    str.replace(a,b-a+1,s);
  }
}
return 0;
}

string reverce(int a,int b,string s){
  string str = "";
  for(int i = b;i >= a; i--){
  str += s[i];
  }
  s.replace(a,str.size(),str);
  return s;
}

Measured memory_bytes: 3196
#include<iostream>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    if((A>=1&&A<=13)&&(B>=1&&B<=13)){
        if(A==1 || B==1){
            if(A>B){
                cout<<"Bob";
            }
            else if(A<B){
                cout<<"Alice";
            }
            else{
                cout<<"Draw";
            }
        }
        else if(A>B){
            cout<<"Alice";
        }
        else if(B>A){
            cout<<"Bob";
        }
        else if(A==B){
            cout<<"Draw";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

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

    int max = k + 1 ;
    long total = 0;
    rep(i, max) {
        rep(j, max) {
            rep(k, max) {
                int tmp_a = i;
                int tmp_b = j;
                int tmp_c = k;
                int mod;
                while ( (mod = tmp_a % tmp_b) != 0 ) {
                    tmp_a = tmp_b;
                    tmp_b = mod;
                }

                while ( (mod = tmp_b % tmp_c) != 0 ) {
                    tmp_b = tmp_c;
                    tmp_c = mod;
                }

                total += tmp_c;
            }
        }
    }

    cout << total << endl;

}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int A = line[0];
        int B = line[1];
        int T = line[2];
        Console.WriteLine((T / A) * B);
    }
}




Measured memory_bytes: 13396
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    int max = 0;
    int count = 0;
    for(int i=1;i<N;i++){
        if(h[i-1]>=h[i]){
            count = count +1;
            if(max<count){
                max = count;
            }
        } else {
            count = 0;
        }
    }
    cout << max << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string n;
    cin>>n;
    ll f=0;
    rep(0,i,n.length())f+=n[i]-'0';
    ll n0=atoi(n.c_str());
    if(n0%f)cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
using namespace std;

const int MAX = 2e5 + 5;

bitset<MAX> b[26], cur;
pair<int,int> que[MAX];

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


    int n, q;
    string s;
    cin >> n >> q >> s;


    for (int i = 0; i < n; ++i)
        b[s[i] - 'A'][i + 1] = 1;

    cur[0] = cur[n + 1] = 1;


    for (int i = 0; i < q; ++i)
    {
        static char c, d;
        cin >> c >> d;
        que[q - i - 1] = {c - 'A', d == 'L' ? -1 : 1};
    }

    int a = 0, b = n + 1;
    for (int i = 0; i < q; ++i)
    {
        if (que[i].second == -1)
        {
            if (s[a] - 'A' == que[i].first)
                ++a;
            if (b <= n && s[b - 1] - 'A' == que[i].first)
                ++b;
        }
        else
        {
            if (a > 0 && s[a - 1] - 'A' == que[i].first)
                --a;
            if (s[b - 2] - 'A' == que[i].first)
                --b;
        }
        if (b - a <= 1)
            break;
    }

    cout << b - a - 1;
}


Measured memory_bytes: 2836
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc163a
{
    class Program
    {
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input
            int input = int.Parse(Console.ReadLine());

            //==========================================================================================================================
            //2) output
            double output = 2*input* Math.PI;
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 27608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
 
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll ans = 0;  
	for (int z=0;z<n-2;z++){
		if (s[z] == 'A' && s[z+1] == 'B' && s[z+2] == 'C'){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def solve(N, K, V):
    # 右からi個、左からj個取り出す時の価値の最大値
    max_points = 0
    for i in range(N + 1):
        for j in range(min(N + 1, K - i + 1)):
            j = min(N - i, j)
            hand = list()
            hand.extend(V[N - i:])
            hand.extend(V[:j])
            points = sum(hand)
            minus = list(filter(lambda x: x < 0, hand))
            minus = sorted(minus)
            action = K - i - j
            points += abs(sum(minus) - sum(minus[action:]))
            max_points = max(max_points, points)
    return max_points


N, K = map(int, input().split())
V = list(map(int, input().split()))
print(solve(N, K, V))


Measured memory_bytes: 3064
#include <stdio.h>
int arr[105];
int a;

void solve() {
  scanf("%d",&a);
  for(int i = 1; i <= a; i = i + 1) {
    scanf("%d", &arr[i]);
    if(arr[i] % 2 ==0) {
        if(arr[i] % 3 != 0 && arr[i] % 5 != 0) {
          printf("DENIED\n");
          return;
        }
    }
  }
  printf("APPROVED\n");
  return;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 1640
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf = 1e18+2;
vector<int> vet;


int k;


bool p(int val){
    int s1 = 0, s2 = 0, soma = 0;

    for(int i = 0; i < vet.size(); i ++){
        if(vet[i] >= 0){
            int l = i, r = vet.size();

            while(r-l > 1){
                int m = (l+r)/2;
                if(vet[i]*vet[m] <= val)
                    l = m;
                else
                    r = m;
            }

            soma += (l-i);
            
        } else {
            int l = i, r = vet.size(), n = vet.size();

            while(r-l > 1){
                int m = (l+r)/2;
                if(vet[i]*vet[m] <= val)
                    r = m;
                else
                    l = m;
            }
    
            soma += n - r;

        }
    }
    return soma < k;

}


main(){
    int n;
    cin >> n >> k;
    vet.resize(n);
    for(int i = 0;i<n;i++) cin >> vet[i];
    sort(vet.begin(), vet.end());

    int l = -2*inf, r = 2*inf;
  
    while(r-l>1 ){

        int m = (l+r)/2;
        if(p(m))
            l = m;
        else
            r = m;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 1792
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
tanks = map(ord, "<^>v")
flat = ord(".")
brick = ord("*")
iron = ord("#")
water = ord("-")

case = input()
for t in xrange(case):
    h, w = map(int, raw_input().split())
    m = [map(ord, raw_input()) for i in xrange(h)]
    n = input()
    s = raw_input()
    x, y = 0, 0
    d = 0
    for i in xrange(h):
        for j in xrange(w):
            if m[i][j] in tanks:
                x = j
                y = i
                d = tanks.index(m[i][j])
                m[i][j] = flat
    for comm in s:
        if comm=="U":
            d = 1
            if y>0 and m[y-1][x]==flat:
                y -= 1
        elif comm=="D":
            d = 3
            if y<h-1 and m[y+1][x]==flat:
                y += 1
        elif comm=="L":
            d = 0
            if x>0 and m[y][x-1]==flat:
                x -= 1
        elif comm=="R":
            d = 2
            if x<w-1 and m[y][x+1]==flat:
                x += 1
        else:
            # "S"
            nx = x + dx[d]
            ny = y + dy[d]
            while 0<=nx<=w-1 and 0<=ny<=h-1:
                obj = m[ny][nx]
                if obj==brick:
                    m[ny][nx] = flat
                    break
                elif obj==iron:
                    break
                nx += dx[d]
                ny += dy[d]
    m[y][x] = tanks[d]
    for i in xrange(h):
        print "".join(map(chr, m[i]))
    if t<case-1:
        print

Measured memory_bytes: 4376
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    a,b,x=map(int, readline().rstrip().split())
    print(b//x - (a-1)//x)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
#define SIZE 1005
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, k;
string s;
int main() {
	io(); cin >> n >> m;
	ll res = n % m;
	ll ans = (ll)abs(m - res);
	cout << min(res, ans);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,nn,s = 0;
  cin >> n;
  nn = n;
  while(1){
    if(nn == 0) break;
    s += nn%10;
    nn /= 10;
  }
  if(n % s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 3608
#include <iostream>
#define ll long long

using namespace std;
int n;
const int NMAX = 200005;
const ll MOD = 1e9 + 7;
ll v[NMAX];
ll sp[NMAX];
ll s = 0;

int main()
{
   cin >> n; sp[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> v[i]; sp[i] = v[i];
        sp[i] += sp[i - 1];
        sp[i] %= MOD;
    }
    for(int i = 1; i <= n; i++) {
        int x = sp[i] - v[i];
        while(x <= 0)
            x += MOD;
        s += x * v[i];
        s %= MOD;
    }
    s %= MOD;
    cout << s;
    return 0;
}


Measured memory_bytes: 6724
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,tem;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        swap(a,b);
        swap(a,c);
        printf("%d %d %d\n",a,b,c);
    }
}


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

int main()
{
    // input
    int N, M;
    cin >> N >> M;
    set<int> broken;
    rep(i, M)
    {
        int a;
        cin >> a;
        broken.insert(a - 1);
    }

    // memoize search
    vector<long long> memo;
    rep(i, N)
    {
        long comb;

        if (broken.count(i))
        {
            comb = 0;
        }
        else if (i == 0)
        {
            comb = 1;
        }
        else if (i == 1)
        {
            comb = 1 + memo[i - 1];
        }
        else
        {
            comb = (memo[i - 1] + memo[i - 2]) % 1000000007;
        }

        memo.push_back(comb);

        // cout << "i: " << i << " Comb: " << memo[i] << endl;
    }

    cout << memo[N - 1] << endl;
}

Measured memory_bytes: 6136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>

using ll = long long;

int main()
{
  std::vector< std::string > vs;
  std::vector< std::string > vtmp;
  std::map< std::string, bool > mm;
  std::vector<std::string>::iterator it;

  for (ll i = 1; i <= 9; i++) {
    vs.push_back(std::to_string(i));
    vtmp.push_back(std::to_string(i));
  }

  for (ll num = 0; num < 9; num++) {
    std::vector< std::string > vtmp2;
    for (it = vtmp.begin(); it != vtmp.end(); it++) {
      char head = (*it)[0];
      char tail = (*it)[it->length()-1];
      for (int i = -1; i <= 1; i++) {
	int head_add = head - '0' + i;
	if (1 <= head_add && head_add <= 9) {
	  std::string s = std::to_string(head_add) + *it;
	  if (mm[s] == false) {
	    vtmp2.push_back(s);
	    mm[s] = true;
	  }
	}
	int tail_add = tail - '0' + i;
	if (0 <= tail_add && tail_add <= 9) {
	  std::string t = *it + std::to_string(tail_add);
	  if (mm[t] == false) {
	    vtmp2.push_back(t);
	    mm[t] = true;
	  }
	}
      }
    }
    vtmp.clear();
    std::copy(vtmp2.begin(), vtmp2.end(), std::back_inserter(vs));
    std::copy(vtmp2.begin(), vtmp2.end(), std::back_inserter(vtmp));
    vtmp2.clear();
  }

  ll K;
  std::cin >> K;

  std::vector< ll > va;
  for (it = vs.begin(); it != vs.end(); it++) {
    ll x;
    sscanf(it->c_str(), "%lld", &x);
    va.push_back(x);
  }

  std::sort(va.begin(), va.end());
  std::cout << va[K-1] << std::endl;
  return 0;
}


Measured memory_bytes: 30352
from collections import defaultdict
 
 
def main():
    _, S = open(0).read().split()
    indices, doubled_indices = defaultdict(list), defaultdict(set)
    for i, c in enumerate(S):
        indices[c].append(i)
        doubled_indices[c].add(2 * i)
    cnt = S.count("R") * S.count("G") * S.count("B")
    for x, y, z in ["RGB", "GBR", "BRG"]:
        cnt -= sum(i + j in doubled_indices[z] for i in indices[x] for j in indices[y])
    print(cnt)
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 9876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<ll> p1,p2,p3;
    for(int i=1;i<=a;i++)
    {
        ll val;
        cin>>val;
        p1.push(val);
    }
    for(int i=1;i<=b;i++)
    {
        ll val;
        cin>>val;
        p2.push(val);
    }
    for(int i=1;i<=c;i++)
    {
        ll val;
        cin>>val;
        p3.push(val);
    }
    vector<ll> red;
    vector<ll> green;
    for(int i=1;i<=x;i++)
    {
        red.push_back(p1.top());
        p1.pop();
    }
    for(int i=1;i<=y;i++)
    {
        red.push_back(p2.top());
        p2.pop();
    }
    sort(red.begin(),red.end());
    int i=0;
    int sz=red.size();
    while(p3.size()>0 && i<sz)
    {
        ll x1=p3.top();
        if(x1>red[i])
        {
            red[i]=x1;
            p3.pop();
        }
        i++;
    }
    ll sum=0;
    for(i=0;i<sz;i++)
    {
        sum +=red[i];
    }
    cout<<sum<<endl;




}


Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c,d;
		c=a*b;
		d=2*(a+b);
		System.out.println(c+" "+d);
		scan.close();
	}
	
}



Measured memory_bytes: 26120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
void solve()
{
    int n;
    cin >> n;
    if(n>=30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int X, Y, Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int dp[n+2];
    dp[0]=0;
    dp[1]=fabs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        int ret1=dp[i-1]+fabs(arr[i]-arr[i-1]);
        int ret2=dp[i-2]+fabs(arr[i]-arr[i-2]);
        dp[i]=min(ret1,ret2);
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4324
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

h,w=nii()
ch,cw=nii()
ch-=1
cw-=1
dh,dw=nii()
dh-=1
dw-=1
s=[list(input()) for i in range(h)]

dist=[[-1]*w for i in range(h)]

def BFS(que):
  while que:
    y,x=que.popleft()

    if y==dh and x==dw:
      print(dist[y][x])
      exit()

    for dy,dx in [[1,0],[-1,0],[0,1],[0,-1]]:
      ny=y+dy
      nx=x+dx
      if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#':
        que.appendleft((ny,nx))
        s[ny][nx]='#'
        dist[ny][nx]=dist[y][x]
    for dy,dx in [[-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],\
                  [-1,-2],[-1,-1],[-1,1],[-1,2],\
                  [0,-2],[0,2],\
                  [1,-2],[1,-1],[1,1],[1,2],\
                  [2,-2],[2,-1],[2,0],[2,1],[2,2]]:
      ny=y+dy
      nx=x+dx
      if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#' and dist[ny][nx]==-1:
        que.append((ny,nx))
        dist[ny][nx]=dist[y][x]+1

dist[ch][cw]=0

que=deque()
que.append((ch,cw))

BFS(que)

print(-1)

Measured memory_bytes: 135784
import sys
sys.setrecursionlimit(10**6)
from itertools import product
while True:
  w,h = map(int,input().split())
  if w == h == 0: exit()
  islands = []
  for _ in range(h):
    islands.append(list(map(int,input().split())))

  seen = [ [False]*w for _ in range(h) ]
  def dfs(row,col):
    seen[row][col] = True

    for x,y in product(range(-1,2), repeat=2):
      if x==0 and y==0: continue
      nrow, ncol = row+x, col+y
      if nrow>=h or nrow<0 or ncol>=w or ncol<0: continue
      if seen[nrow][ncol]: continue

      if islands[nrow][ncol] == 1:
        dfs(nrow, ncol)

  res = 0
  for i in range(h):
    for j in range(w):
      if islands[i][j] == 1 and not seen[i][j]:
        dfs(i,j)
        res += 1

  print(res)



Measured memory_bytes: 8372
# int(input()) # 入力が1つ
import math
a, b, h, m = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

short = h * (360 / 12) + m * 0.5
lon = m * 6
angle = abs(lon - short)
angle = min(angle, 360 - angle)
ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle))
print(ans ** 0.5)

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
int a[5][5];
bool f[5][5];
int main()
{
	int n,i,j,x;
	for(i=1;i<4;i++)
		for(j=1;j<4;j++)
			cin>>a[i][j];
	cin>>n;
	while(n--)
	{
		cin>>x;
		for(i=1;i<4;i++)
			for(j=1;j<4;j++)
				if(a[i][j]==x)
					f[i][j]=true;
	}
	if(f[1][1]&&f[1][2]&&f[1][3]||f[2][1]&&f[2][2]&&f[2][3]||f[3][1]&&f[3][2]&&f[3][3]||f[1][1]&&f[2][1]&&f[3][1]||f[1][2]&&f[2][2]&&f[3][2]||f[1][3]&&f[2][3]&&f[3][3]||f[1][1]&&f[2][2]&&f[3][3]||f[1][3]&&f[2][2]&&f[3][1])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll a[n], suma[n];
    ll eplus = 0, eminus = 0, ans;
    rep(i, n) {
        cin >> a[i];
    }

    rep(i, n) {
        suma[i] = 0;
    }
    suma[0] = a[0];
    if(suma[0] <= 0) {
        eplus += 1 - suma[0];
        suma[0] = 1;
    }
    for(int i = 1; i < n; i++) {
        suma[i] = suma[i-1] + a[i];
        if(i%2 == 1) {
            if(0 <= suma[i]) {
                eplus += 1 + suma[i];
                suma[i] = -1;
            }
        }
        else if(i%2 == 0) {
            if(suma[i] <= 0) {
                eplus += 1 - suma[i];
                suma[i] = 1;
            }
        }
    }

    rep(i, n) {
        suma[i] = 0;
    }
    suma[0] = a[0];
    if(0 <= suma[0]) {
        eminus += 1 + suma[0];
        suma[0] = -1;
    }
    for(int i = 1; i < n; i++) {
        suma[i] = suma[i-1] + a[i];
        if(i%2 == 1) {
            if(suma[i] <= 0) {
                eminus += 1 - suma[i];
                suma[i] = 1;
            }
        }
        else if(i%2 == 0) {
            if(0 <= suma[i]) {
                eminus += 1 + suma[i];
                suma[i] = -1;
            }
        }
    }

    ans = min(eplus, eminus);

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main(){
	fast;
	ll x,t;
	cin>>x>>t;
	if(x>t)
		cout<<x-t;
	else
		cout<<0;
	return 0;
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
long long s[100007],t[100007];
int main(){
    long long n,m,q;
    scanf("%lld%lld%lld",&n,&m,&q);
    for(int i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    s[n+1]=1e18;
    s[0]=-1e18;
    sort(s,s+n+2);
    for(int i=1;i<=m;i++)
        scanf("%lld",&t[i]);
    t[m+1]=1e18;
    t[0]=-1e18;
    sort(t,t+m+2);
    long long x=0;
    long long tmp1=0,tmp2=0;
    long long ans=0;
    for(int i=1;i<=q;i++){
        scanf("%lld",&x);
        tmp1=lower_bound(s,s+n+2,x)-s;
        tmp2=lower_bound(t,t+m+2,x)-t;
        ans=1e18;
        for(int j=tmp1-1;j<tmp1+1;j++){
            for(int k=tmp2-1;k<tmp2+1;k++){
                long long tmp3=abs(x-s[j])+abs(s[j]-t[k]);
                long long tmp4=abs(x-t[k])+abs(s[j]-t[k]);
                ans=min(ans,tmp3);
                ans=min(ans,tmp4);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b,c;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	cout<<min(b/a,c);
	return 0;
}

Measured memory_bytes: 256
main = do
    [k,n] <- map read . words <$> getLine :: IO [Int]
    an <- map read . words <$> getLine :: IO [Int]
    let an' = zip (zipWith (-) ((tail an) ++ [k + (head an)]) an) [1..n]
    let m = maximum $ an'
    print $ foldl (\acc (x,y) -> acc+x) 0 $ filter (/=m) an'


Measured memory_bytes: 64244
S = input()
count = 0

if S[0] == 'R' or S[1] == 'R' or S[2] == 'R':
    count = 1

if (S[0] == 'R' and S[1] == 'R') or (S[1] == 'R' and S[2] == 'R'):
    count = 2
if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    count = 3

print(count)

Measured memory_bytes: 9044
#include <stdio.h>

int main (void){
    char c[4] = {0};
    char b[4] = {0};
    int i,j;


    scanf("%s",c);
    scanf("%s",b);

    
    if(c[0] == b[2] && c[1] == b[1] && b[0] == c[2]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
   
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define TMAX 100001
#define THALF 50000

void fill(int *p, int T, int d)
{
	int i;
	for(i=0; i<T; i++){
		*(p+i) = d;
	}
}
void stak(int *p, int head, int end, int d)
{
	int i;
	for(i=head; i<end; i++){
		*(p+i) += d;
	}
}

int main(void){
    int N, T, t[TMAX], in, out, d, sw, max=0, i, j;
    scanf("%d%d", &N, &T);
	scanf("%d%d", &in, &out);
	sw = (THALF > out - in ? 1 : 2);
	switch(sw){
		case 1:
			fill(t, T, 0);
			stak(t, in, out, 1);
			for(i=1; i<N; i++){
				scanf("%d%d", &in, &out);
				stak(t, in, out, 1);
    		}
		    for(j=0; j<T; j++){
		        max = (max < *(t+j) ? *(t+j) : max);
		    }
			break;
		case 2:
			fill(t, T, N);
			stak(t, 0, in, -1);
			stak(t, out, T, -1);
			for(i=1; i<N; i++){
				scanf("%d%d", &in, &out);
				stak(t, 0, in, -1);
				stak(t, out, T, -1);
			}
			for(j=0; j<T; j++){
				max = (max < *(t+j) ? *(t+j) : max);
			}
			break;
		default:
			break;
	}
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 992
/*****include*****/
#include <iostream>
#include <fstream>
#include <string>
#include <map>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	string word;
	int max_length;
	int max_appear;
	string max_string;
	string max_word;
	map<string,int> appear;
	/*****処理部*****/
	max_length = 0;
	max_appear = 0;
	while(1){
		cin >> word;
		if(cin.eof())	break;
		if(appear.find(word) == appear.end()){
			appear[word] = 1;
		}else
			
			appear[word]++;
		if(appear[word] > max_appear){
			//cout << word << " " << appear[word] << " " << max_appear << endl;
			max_appear = appear[word];
			max_word = word;
			//cout << max_word << " " << max_appear << " " << appear[word] << endl;
		}
		if(word.length() > max_length){
			max_length = word.length();
			max_string = word;
		}
	}
	cout << max_word << " " << max_string << endl;
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
int main(int argc, char *argv[]) {
  int K, S;
  std::cin >> K >> S;

  int count = 0;
  for (int x = 0; x <= K; ++x)
    for (int y = 0; y <= K; ++y) {
      int s = S - (x + y);
      if (0 <= s && s <= K)
        ++count;
    }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));
$s = array();
$c = array();
for ($i = 0; $i < $n; $i++) {
    $s = trim(fgets(STDIN));
    foreach(count_chars($s, 0) as $k => $v) {
        if (!isset($c[$k])) {
            $c[$k] = array($i => $v);
        } else {
            $c[$k][$i] = $v;
        }
    }
}
foreach ($c as $k => $v) {
    $min = min($v);
    if ($min > 0) {
        for ($i = 0; $i < $min; $i++) {
            print chr($k);
        }
    }
}
print "\n";
?>


Measured memory_bytes: 5620
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        h: [usize;n],
        e: [[Usize1;2];m]
    }

    let mut graph: Vec<Vec<usize>> = vec![vec![]; n];

    for v in e {
        let (from, to) = (v[0], v[1]);
        graph[from].push(to);
        graph[to].push(from);
    }

    let mut ans = 0;

    for i in 0..n {
        let mut good_flg = true;
        for &other in &graph[i] {
            if h[i] <= h[other] {
                good_flg = false;
                break;
            }
        }

        if good_flg {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 13588
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for i in range(n)]
ans=100000000000000000
for i in range(2**n):
    check=[0]*m
    ans_=0
    for j in range(n):
        if ((i>>j)&1):
            ans_+=ca[j][0]
            for k in range(m):
                check[k]+=ca[j][k+1]
    #print(ans_)
    if all([l>=x for l in check]):
        #print(ans_)
        ans=min(ans,ans_)
if ans==100000000000000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9224