akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	string s;
	cin >> s;
	if(sz(s) % 2 == 1) cout << "No";
	else {
		for(int i = 0; i < sz(s); i += 2){
			if(s[i] != 'h' || s[i + 1] != 'i'){
				cout << "No";
				return;
			}
		}
		cout << "Yes";

	}
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		while(true) {
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();

			if(m == -1 && f == -1 && r == -1) {
				break;
			}

			int sum = m + f;

			if((m == -1 || f == -1) || sum < 30) {
				System.out.println("F");
			}
			else if(sum < 50) {
				if(r >= 50) {
					System.out.println("C");
				}
				else {
					System.out.println("D");
				}

			}
			else if(sum < 65) {
				System.out.println("C");
			}
			else if(sum < 80) {
				System.out.println("B");
			}
			else {
				System.out.println("A");
			}
		}

		scan.close();
	}
}


Measured memory_bytes: 26248
#include <bits/stdc++.h>
#define int long long
#define eb emplace_back
#define endl "\n"
#define FOR(P,Q) for(P=0;P<Q;P++)
#define FORR(P,Q) for(P=1;P<=Q;P++)
#define pb push_back
typedef long long ll;
using namespace std;

int dp[100005];
    
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif

	int n,h[100005],i;
	cin>>n;
	FORR(i,n){
		cin>>h[i];
	}
	dp[1]=0;
	dp[2]=fabs(h[2]-h[1]);
	for(i=3;i<=n;i++){
		dp[i]=min(fabs(h[i]-h[i-2])+dp[i-2],fabs(h[i]-h[i-1])+dp[i-1]);
	}
	cout<<dp[n];
	cerr<<"success";

return 0;
}

Measured memory_bytes: 1792
function Main(inp) {
    var input = inp.split("\n");
    var s = input[0];
    var t = input[1];
    s = s.split('').sort().join('');
    t = t.split('').sort().reverse().join('');
    if (s < t) {
        console.log('Yes');
        return;
    }
    console.log('No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int H, W;
int a[500][500];

void step(int &y, int &x) {
	if (y & 1) {
		if (x == 0) y++;
		else x--;
	}
	else {
		if (x == W - 1) y++;
		else x++;
	}
}

int main() {
	cin >> H >> W;
	REP(i, H) REP(j, W) scanf("%d", &a[i][j]);
	
	vector<pair<pii, pii> > query;
	int curx = 0, cury = 0;
	
	while (cury < H) {
		while (cury < H && a[cury][curx] % 2 == 0) step(cury, curx);
		if (cury == H) break;
		
		pii prevpos = pii(cury + 1, curx + 1);
		step(cury, curx);
		if (cury == H) break;
		
		vector<pair<pii, pii> > curquery;
		while (cury < H && a[cury][curx] % 2 == 0) {
			pii curpos = pii(cury + 1, curx + 1);
			curquery.push_back(make_pair(prevpos, curpos));
			prevpos = curpos;
			
			step(cury, curx);
		}
		if (cury == H) break;
		
		curquery.push_back(make_pair(prevpos, pii(cury + 1, curx + 1)));
		
		REP(i, curquery.size()) query.push_back(curquery[i]);

		step(cury, curx);
	}
	
	cout << query.size() << endl;
	REP(i, query.size()) printf("%d %d %d %d\n", query[i].fi.fi, query[i].fi.se, query[i].se.fi, query[i].se.se);
	
	
	
	return 0;
}

Measured memory_bytes: 5232
#include<iostream>
#include<set>
using namespace std;
int main()　{
	int n, y;
  	cin >> n >> y;
  	int count10000 = -1, count5000 = -1, count1000 = -1;
  	
  	for(int a = 0; a <= n; a++){
    	for(int b = 0; a+b <= n; b++){
        	int c = n - a - b;
          	int total = 10000*a + 5000*b + 1000*c;
          	if (total == y) {
            	count10000 = a;
              	count5000 = b;
              	count1000 = c;
            }
        }
    }
  	
  	cout << count10000 << " " << count5000 << " " << count1000 << endl;
  
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define pai 3.14159265359
int main(){
    // Your code here!
    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    h = 30 * h + 0.5 * m;
    m *= 6;
    long double deg = max(h,m) - min(h,m);
    // cout << deg << endl;
    long double rad = deg*(pai/180);
    long double c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    printf("%16.12Lf",c);
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 1e9+7;
const int N = 2e3+23;

int dp[N];

int rek(int n) {
  if (n < 3) return 0;
  if (n < 6) return 1;
  int &ret = dp[n];
  if (ret != -1) return ret;
  ret = 1;
  for (int i = 3; i <= n-3; ++i) {
    ret = (ret+rek(n-i))%mod;
  }
  return ret;
}

void solve() {
  memset(dp, -1, sizeof(dp));
  int n; scanf("%d", &n);
  printf("%d", rek(n));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

bool dp[10010];

int main(){
	int N;
	cin >> N;
	vector<int> s(N);
	for(int i=0; i < N; ++i) {
		cin >> s[i];
	}
	dp[0] = true;
	for(int i = 0; i < N; ++i) {
		for(int j = 10000; j >= s[i]; --j) {
			dp[j] = dp[j] || dp[j-s[i]];
		}
	}
	int res = 0;
	for(int i = 0; i <= 10000; ++i) {
		if (i % 10 != 0 && dp[i]) res = i;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
eval"N,K,S,T,*A,C=#{`tr -! ,`}[1]*51"
A.select!{1>~_1&S|_1&~T}
C.map{$*<<C[K]-1
t=0
C.map!{t+t=_1}}
p (S..T).sum{|u|~u&S|u&~T<1?A.map{_1&u}.tally.sum{$*[_2]}*(1-('%b'.%u-S).count(?1)%2*2):0}

Measured memory_bytes: 14416
using System;
using System.Collections.Generic;

class program{

  static void Main(){
    int N;
    N = int.Parse(Console.ReadLine());
    int[] D= new int[N]; 
    string[] s = Console.ReadLine().Split(' ');
  for(int i=0;i<N;i++){
    D[i] = int.Parse(s[i]);
  }
  int sum=0;
  for(int i=0;i<N-1;i++){
    for(int k=i+1;k<N;k++){
        sum+=D[i]*D[k];
    }
  }
  Console.WriteLine(sum);
  }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a=0;
  int u=0;
  int k;
  bool b=false;
  cin>>k;
  for(int i=0;i<k;i++){
    string w;
    cin>>w;
    if(w=="A"){
      a++;
  }
    else if(w=="Un"){
      u++;
      if(u>a){
        cout<<"NO"<<endl;
        return 0;
      }
    }
  }
  if(a!=u)cout<<"NO"<<endl;
 else cout<<"YES"<<endl;
}



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

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

    int n, d, x;
    cin >> n >> d >> x;

    int res = x;
    rep(i, n) {
        int a;
        cin >> a;

        res += (d%a!=0) + d/a;
    }
    cout << res << endl;
}

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


int main() {
    int n,k;
    cin >> n >> k; 
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,k){
        bool t=true;
        rep(j,n){
            if (a[j]!=n) t=false;
        }
        if (t) break;
        vector<int> b(n,0);
        int p=0;
        rep(j,n){
            if (j-a[j]<0)p++;
            else b[j-a[j]]++;
            if (j+a[j]+1<n) b[j+a[j]+1]--;
        }
        rep(j,n){
            p=p+b[j];
            a[j]=p;
        }
    }
    rep(i,n){
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4848
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456];
signed main() {
	int n; string s; cin >> s;
	int notkuri = (s[s.size() - 1] - '0'), kuri = 10 - (s[s.size() - 1] - '0');
	for (int h = s.size() - 2; h >= 0; h--) {
		int afternotkuri = min(notkuri + (s[h] - '0'), kuri + (s[h] - '0') + 1);
		int afterkuri = min(notkuri + 10 - (s[h] - '0'), kuri + 10 - ((s[h] - '0') + 1));
		notkuri = afternotkuri; kuri = afterkuri;
	}
	if (notkuri > kuri) { cout << kuri + 1 << endl; }
	else { cout << notkuri << endl; }
}

Measured memory_bytes: 1412
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();
      int X = sc.nextInt();
      int Y = sc.nextInt();
      int total = 0;
      if (N >= K) {
        total = K * X + (N-K) * Y;
      } else {
        total = N * X;
      }
      System.out.println(total);
    }
}

Measured memory_bytes: 21204
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i;
  int n;
  cin>>n;
  pair<int,int> a[1000];
  for(i=0;i<n;++i)
    cin>>a[i].second>>a[i].first;
  sort(a,a+n);
  priority_queue<int> b;
  int sm=0;
  for(i=0;i<n;++i){
    if(sm+a[i].second>a[i].first){
      if(!b.empty()&&b.top()>a[i].second){
	sm-=b.top()-a[i].second;
	b.pop();
	b.push(a[i].second);
      }
    }else{
      b.push(a[i].second);
      sm+=a[i].second;
    }
  }
  cout<<b.size()<<endl;
  return 0;
}

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

int n;
long long dp[100010][2], mod = 1e9+7;
class Edge{
public:
	long long cost;
	int from, to;
	Edge(long long c, int f, int t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void readGraph(Graph &g, int E, bool D, bool C){ // E:NumofEdges, D:Directed, C:Costed
	for(int i=0; i<E; ++i){
		Edge e(0, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		--e.from;
		--e.to;
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}

long long func(Graph &g, int v, int c, int p){
	if(dp[v][c] != 0) return dp[v][c];
	long long res = 1;
	for(int i=0; i<g[v].size(); ++i){
		long long tmp = 0;
		if(g[v][i].to == p) continue;
		tmp += func(g, g[v][i].to, 1-c, v);
		if(c == 0) tmp += func(g, g[v][i].to, c, v);
		res *= tmp;
		res %= mod;
	}
//	cout << v << " " << c << " " << res << "\n";
	return dp[v][c] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	Graph g(n);
	readGraph(g, n-1, false, false);
	cout << (func(g, 0, 0, -1) + func(g, 0, 1, -1)) % mod << "\n";
}

Measured memory_bytes: 17792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;


vector<pair<double , double> > cor;

int factrial (int n) {
  if(n == 0) return 1;
  else return n*factrial(n-1);
}

int main() {
  int N;
  cin >> N;
  int ord[N];
  rep(i,N) {
    double x,y;
    cin >> x >> y;
    cor.push_back(make_pair(x,y));
    ord[i] = i;
  }
  double ans = 0;
  
  do{
    double sum = 0;
    rep(i,N-1) {
      double x = cor[ord[i]].first - cor[ord[i+1]].first;
      double y = cor[ord[i]].second - cor[ord[i+1]].second;
      sum += sqrt(x*x + y*y);
    }
    ans += sum;
    // cout << sum << endl;
  }while(next_permutation(ord,ord + N));

  ans /= factrial(N);
  printf("%.10lf\n", ans);

  return 0;
}










Measured memory_bytes: 3208
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define rep(i,a,b) for(ll i = a;i <= b;i++)
#define repv(i,a,b) for(ll i = a;i >= b;i--)
#define e endl
#define all(v) v.begin(), v.end()
typedef pair<ll,ll> pp;

int lcm(int a, int b)
{
    int lar = max(a, b);
    int small = min(a, b);
    for (int i = lar; ; i += lar) {
        if (i % small == 0)
            return i;
    }
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) {
    return (a.second < b.second);
}

ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

bool isPowerOfTwo (ll x)
{
    return x && (!(x&(x-1)));
} //cout << h[i] << " " << cnt[i] << " " << good[i] << " " << bad[i] << e;


void solve(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll y = x/d;
    if(k <= y){
        cout << x - k*d << e;
    }
    else{
        x -= y*d;
        k -= y;
        if(k%2 == 0){
            cout << x << e;
        }
        else{
            cout << abs(x-d) << e;
        }
    }
}
        
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    //ll t; cin >> t; while(t--)
        solve();
}



Measured memory_bytes: 3652
from itertools import product
import operator

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

value, cost, ans = [0, 0, 0]
for x in product([0, 1], repeat=n):
    value = sum(map(operator.mul, v, x))
    cost = sum(map(operator.mul, c, x))
    ans = max(ans, value - cost)

print(ans)

Measured memory_bytes: 42348
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
    cin>>x;
  	priority_queue<long long int> small;
  	priority_queue<long long int,vector<long long int>, greater<long long int> > large;
  	map<long long int,int> cnt;
  	long long int total=0,s=0,l=0;
  	int c=0;
  	for(long long int i=0;i<x;i++){
    	int sub;
        cin>>sub;
        if(sub==1){
            c++;
            long long int a,b;
            cin>>a>>b;
            cnt[a]++;
            total+=b;
            large.push(a);
            l+=a;
            small.push(large.top());
            l-=large.top(),s+=large.top();
            large.pop();
            large.push(small.top());
            l+=small.top(),s-=small.top();
            small.pop();
            if(large.size()>small.size()){
                small.push(large.top());
                l-=large.top(),s+=large.top();
                large.pop();
            }
        }else{
            //cout<<total<<' '<<l<<' '<<s<<endl;
            cout<<small.top()<<' '<<total+l-s+((c)%2)*small.top()<<endl;
        }

    }
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,sum=0;
cin>>n;
vector<int>x(n),v1;
for(int j=0;j<n;j++){
cin>>x[j];
}
 for(int i=-100;i<=100;i++){

int sum=0;
for(int j=0;j<n;j++){

sum+=((x[j]-i)*(x[j]-i));
	
}
v1.push_back(sum);
}
sort(v1.begin(),v1.end());

cout<<v1[0];

return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;

int main() {
    string S; cin >> S;
    bool flag = true;
    for (int i = 0; i < S.size(); i++) {
        if ((i + 1) % 2 == 1 && S[i] == 'L') flag = false;
        if ((i + 1) % 2 == 0 && S[i] == 'R') flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple


signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	multiset<int> s;
	while (n--) {
		int x;
		cin >> x;
		s.insert(x);
	}
	int ans = 0;
	while (s.size()) {
		int x = *s.rbegin();
		s.erase(s.find(x));
		for (int t = 62; t >= 1; --t) {
			int y = (1LL << t) - x;
			if (s.find(y) != s.end()) {
				s.erase(s.find(y));
				++ans;
				break;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 9600
import math
n = int(input())
mylist = [int(math.sqrt(i)) for i in range(1,n+1)]
mylist = [0]+mylist

def main():
    for N in range(1,n+1):
        result = 0
        for x in range(1,mylist[N//3]+1):
            tempx = x**2
            for y in range(x, mylist[(N-x**2)//2]+1):
                tempy = y**2
                tempxy = x*y
                tempxandy = (x+y)/2
                tempnum = N-tempx-tempy-tempxy+tempxandy**2
                if tempnum <= 0:
                    break
                else:
                    if math.sqrt(tempnum)*2 == int(math.sqrt(tempnum)*2):
                        z = math.sqrt(tempnum)-tempxandy
                        #print(x,y,z,N)
                        if z < y:
                            break
                        elif x != y and y != z:
                            result += 6
                        elif x == y and y == z:
                            result += 1
                        else:
                            result += 3
        print(result)
main()


Measured memory_bytes: 69072
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i, N) cin >> W.at(i);

    int D = 1000000;
    rep(i , N - 1) {
        int S1 = 0;
        rep(j, i + 1) {
            S1 += W.at(j);
        }
        int S2 = accumulate(all(W), 0) - S1;
        int DS = abs(S1 - S2);
        D = min(D, DS);
    }

    cout << D << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define INVALID 2000000000

int main(void){
    int n,k;
    int h[N] = {};
    int memo[N];
    int i,j;
    
    scanf("%d %d", &n, &k);
    for(i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    
    memo[0] = 0;
    for(i = 1; i < n; i++){
        memo[i] = INVALID;
    }
    
    for(i = 1; i < n; i++){
        for(j = 1; (i-j) >= 0 && j <= k; j++){
            if(memo[i] > (memo[i-j] + abs(h[i]-h[i-j]))){
                memo[i] = memo[i-j] + abs(h[i]-h[i-j]);
            }
        }
    }
    
    
    printf("%d\n", memo[n-1]);
    
    return 0;
}

Measured memory_bytes: 896
loop do
  d = gets.split.map(&:to_i)
  break if d[0]+d[1]+d[2] == -3
  if d[0] == -1 || d[1] == -1
    puts "F"
  elsif d[0]+d[1]>=80
    puts "A"
  elsif d[0]+d[1]>=65
    puts "B"
  elsif d[0]+d[1]>=50
    puts "C"
  elsif d[2] >=50
    puts "C"
  elsif d[0] +d[1]>=30
    puts"D"
  else
    puts "F"
  end
end



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

// Q: What is the runtime of this
// solution?

const int MAX_STONES = pow(10,5);
const int INF = 99999999;
int height[MAX_STONES];
vector<int> dp(MAX_STONES, INF);

int cost(int cur) {
    if (cur == 0) {
        return dp[0] = 0;
    } else if (cur < 0) {
        return INF;
    } else if (dp[cur] != INF) {
        return dp[cur];
    }

    return dp[cur] = min(cost(cur-1)+abs(height[cur]-height[cur-1]), 
                        cost(cur-2)+abs(height[cur]-height[cur-2]));
}

int main() {
    int n;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &height[i]);
    }

    // Top-down DP approach.
    // Q: How do we formulate it as a top-down?
    int result = cost(n-1);


    // Start from every stone
    // and use previous computed
    // to compute minimum.
    
    // dp[0] = 0;
    // for(int i = 0; i < n; i++) {
    //     for (int j = i + 1; j < n, j <= i + 2; j++) {
    //         // the min cost at jth stone
    //         dp[j] = min(dp[j], dp[i]+abs(height[j]-height[i])); 
    //     }
    // }

    printf("%d", result);

    return 0;
}

Measured memory_bytes: 3328
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	I, O, _, J, L, _, _ := ReadInt(), ReadInt(), ReadInt(), ReadInt(), ReadInt(), ReadInt(), ReadInt()
	ans := O
	v1 := I/2*2 + L/2*2 + J/2*2
	if I%2 == 1 && L%2 == 1 && J%2 == 1 {
		v1 += 3
	}
	v2 := 0
	if I > 0 && L > 0 && J > 0 {
		I--
		L--
		J--
		v2 += 3
		v2 += I/2*2 + L/2*2 + J/2*2
	}
	fmt.Println(ans + Max(v1, v2))
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


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

using namespace std;

typedef long long ll;

struct Edge
{
    int y, a, b;

    Edge(int y = 0, int a = 0, int b = 0) : y(y), a(a), b(b) {}
};

struct Node
{
    int x, w;
    ll t;

    Node(int x = 0, int w = 0, ll t = 0) : x(x), w(w), t(t) {}

    bool operator < (const Node& Other) const
    {
        return t > Other.t;
    }
};

const int N = 55;
const int M = N * N;
const ll Inf = 1e18;

int C[N];
int D[N];
ll Dist[N][M];
vector <Edge> Adj[N];

void Dijkstra(int n, int m, int s)
{
    priority_queue <Node> q;

    for(int x = 1; x <= n; x++)
        for(int w = 0; w <= m; w++)
            Dist[x][w] = Inf;

    Dist[1][s] = 0;
    q.push(Node(1, s, 0));

    while(!q.empty())
    {
        Node node = q.top();   q.pop();

        int x = node.x;
        int w = node.w;
        ll t = node.t;

        if(Dist[x][w] < t)  continue;

        if(Dist[x][min(w + C[x], m)] > t + D[x])
        {
            Dist[x][min(w + C[x], m)] = t + D[x];
            q.push(Node(x, min(w + C[x], m), t + D[x]));
        }

        for(const Edge& E : Adj[x])
        {
            if(w >= E.a && Dist[E.y][w - E.a] > t + E.b)
            {
                Dist[E.y][w - E.a] = t + E.b;
                q.push(Node(E.y, w - E.a, t + E.b));
            }
        }
    }
}

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

    while(m--)
    {
        int x, y, a, b; scanf("%d%d%d%d", &x, &y, &a, &b);

        Adj[x].push_back(Edge(y, a, b));
        Adj[y].push_back(Edge(x, a, b));
    }

    for(int x = 1; x <= n; x++) scanf("%d%d", C + x, D + x);

    m = 50 * n;
    s = min(s, m);

    Dijkstra(n, m, s);

    for(int x = 2; x <= n; x++)
    {
        ll Ans = Inf;

        for(int w = 0; w <= m; w++) Ans = min(Ans, Dist[x][w]);

        printf("%lld\n", Ans);
    }
}


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

#define DEBUG 1
 


int main() {

    int N;
    cin >> N;

    vector <int> a(N);

    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }

    int counter_odd = 0;

    for(int i = 0;i < N; i++){
        if((i % 2 == 0)&&(a.at(i) % 2 == 1)){
            counter_odd++;
        }
    }
    
    cout << counter_odd << endl;




    return 0;

 
}



Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<functional>
#include<iomanip>
#include<climits>

using namespace std;
typedef unsigned long long int ll;
////  ll gcd(ll a, ll b)
////  {
////      if(b%a == 0) return a;
////      else return gcd(b%a, a);
////  }

int main()
{
    ll a, b;
    cin >> a>> b;
    if(a > b) swap(a,b);
    for(ll i = 1; ; i++)
    {
        if((b*i)%a==0)
        {
            cout << b*i;
            break;
        }
    }

    return 0;
}


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

int main() {
	int n;
	cin>>n;
	int a[n];
	
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	int b[n];
	b[0]=0;
	b[1]=abs(a[0]-a[1]);
	int k,l;
	for(int j=2;j<n;j++)
	{
	    k=abs(a[j-2]-a[j])+b[j-2];
	    l=abs(a[j-1]-a[j])+b[j-1];
	    if(k>l)
	    b[j]=l;
	    else
	    b[j]=k;
	}
	cout<<b[n-1];
}

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

using namespace std;
using ll = long long;

int main()
{
    ll ans=0;

    ll A,B;
    cin >> A >> B;

    ll num = 1;

    if(B==1)
    {
        cout << 0 << endl;
        return 0;
    }

    ans=A;
    while(ans < B)
    {
        num++;

        ans = A * num;
        ans -= (num - 1);
    }

    cout << num << endl;

    return 0;
}

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

int main(){
  string n;
  cin>>n;
  if((n[0]==n[1] && n[1]==n[2])||(n[1]==n[2] && n[2]==n[3])){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main(void)
{
    ll a,b,c,d,ans=0;
	cin>>a>>b>>c>>d;
	if(a<=d&&d>0)
    {
        ans+=a;d-=a;
    }
    else
    {
        ans+=d;d=0;
    }
    if(b<=d&&d>0)
    {
        d-=b;
    }
    else
    {
        d=0;
    }
    if(d>0)
    {
        ans-=d;
    }
    cout<<ans;
	return 0;
}


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

int main(void)
{
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;

	bool flg = true;

	for (int i = 0; i < A; ++i) {
		if (!iswdigit(S[i]))	flg = false;
	}
	if (S[A] != '-')	flg = false;
	for (int i = A + 1; i < A + B + 1; ++i) {
		if (!iswdigit(S[i]))	flg = false;
	}

	if (flg) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll X; cin >> X;
    ll mon = 100;
    int ans = 0;
    
    while (mon<X)
    {
      ans++;
      mon = mon*0.01 + mon;
    }
    
    

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

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <array>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int x;
  cin >> x;
  array<bool, 1000001> vis;
  vis[0] = true;
  for (int i = 1; i <= x; ++i)
    for (int j = 100; j <= 105 && j <= i; ++j)
      vis[i] |= vis[i - j];
  cout << vis[x];

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long

signed main(void)
{
	int ans, a, b, c, d; cin >> a >> b >> c >> d;
	ans = a * c;
	if (ans < a * d) ans = a * d;
	if (ans < b * c) ans = b * c;
	if (ans < b * d) ans = b * d;
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,i=1,x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			cout<<" "<<i;
			continue;
		}
		//printf("%d\n",x);
		while(x){
			if(x%10==3){
				cout<<" "<<i;
				break;
			}
			x/=10;
		}
	}
	cout<<endl;
	return 0;
}


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

int main() {
  char a, b;
  cin >> a >> b;
  if (a == 'H') {
    if (b == 'H')
      cout << 'H' << endl;
    else
      cout << 'D' << endl;
  } else {
    if (b == 'H')
      cout << 'D' << endl;
    else
      cout << 'H' << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

int main () {
    string s; cin >> s;
    int l = s.size();
    if(s[l-1] == '3') {
        cout << "bon";
    }else if (s[l-1] == '0' || s[l-1] == '1' || s[l-1] == '6' || s[l-1] == '8') {
        cout << "pon";
    }else {
        cout << "hon";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 15

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, money;
  sscanf(line, "%d %d", &num, &money);
  // 10x+5y+z=money
  // x+y+z=num
  //  solve 9x+4y=(money-num);
  int res = money/1000-num;
  if(res < 0) {
    printf("-1 -1 -1\n");
    return 0;
  }

  int i;
  int x_10000 = -1, y_5000 = -1, z_1000 = -1;
  for(i = res/9; i >= 0; i--) {
    if((res - i*9)%4 == 0) {
      x_10000 = i; y_5000 = (res - i*9)/4;
      z_1000 = num - x_10000 - y_5000;
      if(z_1000 < 0) {
        x_10000 = y_5000 = z_1000 = - 1;
      }
      break;
    }
  }
  printf("%d %d %d\n", x_10000, y_5000, z_1000);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

vector<ll> dijkstra(ll s, vector<vector<P>>& adj) {
	vector<ll> dir(adj.size(),INF*INF);
	dir[s]=0;
	priority_queue<P,vector<P>,greater<P>> q;
	q.push(P(0,s));
	while(!q.empty()) {
		ll d=q.top().first;
		ll p=q.top().second;
		q.pop();
		if(dir[p]!=d) continue;
		REP(i,adj[p].size()) {
			ll c=adj[p][i].second;
			ll np=adj[p][i].first;
			if(dir[np]>d+c) {
				dir[np]=d+c;
				q.push(P(dir[np],np));
			}
		}
	}
	return dir;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,s,t;
	cin>>n>>m>>s>>t;
	s--; t--;
	vector<vector<P>> adj(n);
	REP(i,m) {
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		adj[x].pb(P(y,1));
		adj[y].pb(P(x,1));
	}
	vector<ll> froms=dijkstra(s,adj);
	vector<ll> fromt=dijkstra(t,adj);
	map<ll,ll> cnt;
	REP(i,n) cnt[fromt[i]]++;
	ll ans=0;
	REP(i,n) ans+=cnt[froms[t]-froms[i]-2];
	cout<<ans<<endl;
}




Measured memory_bytes: 16968
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int N;
	cin >> N;

	Int ans = 1e18;
	for (Int i = 1; i * i <= N; ++i) {
		if (N % i != 0) { continue; }
		ans = min(ans, i + N / i - 2);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  string s;cin >> s;
  vector<set<int>> st(26);
  for(int i=0;i<n;i++){
    int p=s[i]-'a';
    st[p].insert(i+1);
  }
  int q;cin >> q;
  while(q--){
    int x;cin >> x;
    if(x==1){
      int i;cin >> i;
      i--;
      char c;cin >> c;
      int p=c-'a',q=s[i]-'a';
      st[q].erase(i+1);
      st[p].insert(i+1);
      s[i]=c;
    }
    else{
      int l,r;cin >> l >> r;
      int res=0;
      for(int i=0;i<26;i++){
        auto itr=st[i].lower_bound(l);
        int t=*itr;
        if(t>=l&&t<=r){
          res++;
        }
      }
      cout << res << endl;
    }
  }
}

Measured memory_bytes: 24196
# ABC95 C -Half and Half
a,b,c,x,y = map(float,input().split())
ans = 0
if a+b > 2*c:
    while x != 0.0 and y != 0.0:
        ans += 2*c
        x -= 1.0
        y -= 1.0
        if y == 0.0:
            while x != 0.0:
                if a > 2*c:
                    ans += 2*c
                    x -= 1.0
                else:
                    ans += a
                    x -= 1.0
        if x == 0.0:
            while y != 0.0:
                if b > 2*c:
                    ans += 2*c
                    y -= 1.0
                else:
                    ans += b
                    y -= 1.0
else:
    ans += a*x + b*y
print(int(ans))

    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int n, i, t;
	ll ans = 0;
	cin >> n;
	vector<long long> a(n);
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	for(i = 1; i < n; i++){
		if (a[i-1] >= a[i]){
			t= a[i-1] - a[i];
			ans += t;
			a[i] += t;  
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
	int n{ 0 };
	int k{ 0 };
	char s[50]{ 0 };
	char sResult[50]{ 0 };

	cin >> n >> k;
	cin >> s;

	for (int i = 0; i < n; i++)
	{
		if ((i + 1) == k)
		{
			sResult[i] = tolower(s[i]);
		}
		else
		{
			sResult[i] = s[i];
		}
	}

	cout << sResult;

	return 0;

}

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

const int N = 220000;

int a[N], b[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, k; cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	for (int times = 0; times < min(k, 500); times++) {
		for (int i = 0; i <= n + 1; i++) b[i] = 0;
		for (int i = 1; i <= n; i++) b[max(1, i - a[i])]++, b[min(n + 1, i + a[i] + 1)]--;
		a[0] = b[0];
		for (int i = 1; i <= n; i++) a[i] = a[i - 1] + b[i];
	}
	for (int i = 1; i <= n; i++) cout << a[i] << " \n"[i == n];
	
	return 0;
}


Measured memory_bytes: 5192
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
    
def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)

n=int(input())
koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

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

    int n = s.size();

    /* これだとオーバーフローするし無茶 
    string t[n + 1];
    t[0] = "0";
    REP(i,n){
        t[i+1] = s.substr(n-i-1);
    }
    */

    long long keta = 1;
    long long current_number = 0;
    vector<long long> reminder(2019, 0); //[0]-[2018]を0個で初期化

    reminder[0]++; //最初
    REP(i,n){
        long long add_number = s[n-i-1] - '0';
        current_number = (current_number + keta * add_number) % 2019;
        keta = (keta * 10) % 2019;
        reminder[current_number]++;
    }

    long long ans = 0;
    int m = reminder.size();
    for(int i = 0; i < m; i++){
        ans += reminder[i] * (reminder[i] - 1) / 2;
    }

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

Measured memory_bytes: 3680
def main():
    n = int(input())
    p = list(map(int, input().split()))
    count = 0

    for i in range(n):

        if p[i] == i+1:
            count += 1

    if n - count <= 2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9024
n, m, l = map(int, input().split(' '))

a = [ [0 for j in range(m)] for i in range(n)]
b = [[0 for k in range(l)] for j in range(m)]
c = [[0 for k in range(l)] for i in range(n)]

for i in range(n):
    ls =  list(map(int, input().split(' ')))
    for j in range(m):
        a[i][j] = ls[j]

for j in range(m):
    lst =  list(map(int, input().split(' ')))
    
    for k in range(l):
        b[j][k] = lst[k]
        
for i in range(n):
    for k in range(l):
        for j in range(m):
            c[i][k] += a[i][j] * b[j][k]
    
for i in range(n):
    print(' '.join(list(map(str, c[i]))))




Measured memory_bytes: 6892
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int N;
    cin >> N;
    vector<int> c(N);
    for (int i = 0; i < N; i++){
        cin >> c[i];
    }
    int i,flag=1,count=0;
    while(flag==1){
        for(i=0;i<N;i++){
            if(c[i]%2==0){
                c[i]=c[i]/2;
            }else{
                flag=0;
                break;
            }
        }
        if(flag==1)count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int distance, time, speed;
    std::cin >> distance >> time >> speed;

    if (distance <= time * speed)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

int main(){

	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
		std::cout << "Yes\n";
	}
	else{
		std::cout << "No\n";
	}
}


Measured memory_bytes: 3100
n = int(input())

ans = ''

if n == 0:
    print('0')

while n != 0:
    r = n % 2 

    if r < 0:
        r = r + 2
    
    n = (n-r) / (-2)

    ans = ans + str(int(r))

ans = list(ans)    
ans.reverse()
print(''.join(ans))

Measured memory_bytes: 3060
#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,M;
    cin >> N >> M;
    vector<int> data(M,0);
    for(int i=0;i<N;i++){
        int K;
        cin >> K;
        for(int j=0;j<K;j++){
            int A;
            cin >> A;
            data[A-1]++;
        }
    }
    int ans =0;
    for(int i=0;i<M;i++){
        if(data[i]==N){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
import std;

void main() {
    readln;
    auto S = readln.split[0].to!string;
    auto N = S.length;
    
    size_t[][char] rgb;
    rgb['R'] = [], rgb['G'] = [], rgb['B'] = [];
    foreach (n, c; S) {
        rgb[c] ~= n;
    }
    
    size_t ans;
    
    ans += rgb['R'].length * rgb['G'].length * rgb['B'].length;
    // j - i = k - j
    foreach (i; 0 .. N-2) {
        foreach (k; iota(i+2, N, 2)) {
            auto j = (k+i)/2;
            bool[char] set;
            set[S[i]] = true; set[S[j]] = true; set[S[k]] = true;
            if (set.keys.length == 3) ans--;
        }
    }
    
    writeln(ans);
}

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

int main(){
  long long ans=0; 
  long long  n,a[100000],b[100000]; cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=n-1;i>=0;i--){
    a[i]+=ans;
    long long r=a[i]%b[i];
    if(r) ans+=b[i]-r;
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

string K = "MARCH";
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt[5] = {};
    rep(i, N) {
        string S; cin >> S;
        rep(j, 5) if (S[0] == K[j]) cnt[j]++;
    }
    int ans = 0;
    rep(i, 5) {
        REP(j, i + 1, 4) {
            REP(k, j + 1, 4) {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;

       


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	do
	{
		c=c-b;
		if(c<=0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		a=a-d;
		if(a<=0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}while(a*c>0);
	return 0;
 } 

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
using P = pair<long double, long double>;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    long double W, H; cin >> W >> H;
    long double x, y; cin >> x >> y;
    long double area = W * H / 2.0L;

    bool flag = false;
    if(x * 2 == W and y * 2 == H) flag = 1;
    cout << area << " " << flag << endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        cout << cnt << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
    cnt++;
  }
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    vector<vector<char>> ans(100, vector<char>(100, ' '));
    vector<bool> memo(100, false);
    vector<bool> memo2(100, false);
    for(int i = 0;i < H;i++){
        for(int k = 0;k < W;k++){
            cin >> a.at(i).at(k);
        }
    }
    for(int i = 0;i < H;i++){
        for(int k = 0;k < W;k++){
            if((a.at(i).at(k)) == '.'){
                if(k == W-1){
                    memo.at(i) = true;
                }
            }
            else{
                break;
            }
        }
    }
     for(int i = 0;i < W;i++){
        for(int k = 0;k < H;k++){
            if((a.at(k).at(i)) == '.'){
                if(k == H-1){
                    memo2.at(i) = true;
                }
            }
            else{
                break;
            }
        }
    }
    for(int i = 0;i < H;i++){
        if(memo.at(i)){
            continue;
        }
        for(int k = 0;k < W;k++){
            if(memo2.at(k)){
                if(k == W-1) cout << endl;
                continue;
            }
            else{
                cout << a.at(i).at(k);
                if(k == W-1) cout << endl;
            }
        }
    }
}

Measured memory_bytes: 256
def check v
	return true if (v&v).count == 1
	return true if v[0]+1==v[1] && v[1]+1==v[2]
	return false
end

gets.to_i.times{
	an=gets.split(" ").map{|e|e.to_i}
	ac=gets.split(" ")
	count=0
	c=[[],[],[]]
	ac.each_with_index{|v,i|
		c[0].concat [an[i]] if v == "R"
		c[1].concat [an[i]] if v == "G"
		c[2].concat [an[i]] if v == "B"
	}
	max=0
	3.times{|i|
		maxCount=0
		c[i].permutation{|pset|
			count=0
			(pset.length/3).times{|t|
				break if !check(pset[3*t..3*t+2])
				count += 1
			}
			maxCount = count if maxCount < count
		}
		max += maxCount

	}
	p 1 if max >= 3
	p 0 if max < 3
}

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

using namespace std;

typedef long long int ll;

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

    int i=0;
    while(s[i]!='\0'){
        s[i]+=n;    //printf("a:%d\n",s[i]);
        if(s[i]>'Z'){
            s[i]-='A';
            s[i]%=26;   //printf("[d,c]=%d,%c\n",s[i],s[i]);
            s[i]='A'+s[i];
        }
        i++;
    }

    cout << s << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int cookie(int *n1, int *n2, int k, int i){
    if(i == k){
        return 0;
    }
    else{
        if((*n1) % 2 != 0){
            (*n1) = (*n1) - 1;
        }
        (*n2) += (*n1) / 2;
        (*n1) /= 2;
        i++;
        return cookie(n2, n1, k, i);
    }
}

int main(){
    int a, b;
    int k;
    int i = 0;

    scanf("%d %d %d", &a, &b, &k);

    cookie(&a, &b, k, i);

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

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define st stack<ll>
#define v vector<ll>
#define s set<ll>
#define p pair<ll,ll>
#define mp map<char,ll>
#define us unordered_set<ll>
#define pq priority_queue<ll>
#define q queue<ll>
#define pb push_back
#define pf push_front
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	boost;
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0,count=0;
	while(count!=k)
	{
		if(a>0)
		{
			sum+=1;
			count++;
			a--;	
		}
		else if(b>0)
		{
			sum+=0;
			count++;
			b--;
			
		}
		else if(c>0)
		{
			sum+=(-1);
			count++;
			c--;
		}
	}
	cout<<sum<<endl;	
	return 0;
}

Measured memory_bytes: 3652