akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x >> y;
    cout << x + (y / 2);
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	FOR(i, 1, n + 1) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += (ll)i;
		}
	}

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




Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, C; cin >> n >> C;
  V<> a(n); for (auto&& e : a) cin >> e;
  struct Edge { int to, c; };
  VV<Edge> g(n);
  for (int _ = 0; _ < n - 1; ++_) {
    int u, v, c; cin >> u >> v >> c, --u, --v;
    g[u].emplace_back(Edge{v, c});
    g[v].emplace_back(Edge{u, c});
  }
  constexpr lint inf = 1e18;
  auto dfs = [&](const auto& dfs, int v, int p, V<lint> dp, int c) -> V<lint> {
    for (auto e : g[v]) if (e.to != p) {
      auto cdp = dfs(dfs, e.to, v, dp, e.c);
      for (int i = 0; i <= C; ++i) {
        dp[i] = max(dp[i], cdp[i]);
      }
    }
    for (int i = C; i >= 0; --i) {
      if (i >= c) dp[i] = dp[i - c] + a[v];
      else dp[i] = -inf;
    }
    return dp;
  };
  V<> par(n);
  auto dfs_par = [&](const auto& dfs_par, int v, int p) -> void {
    par[v] = p;
    for (auto e : g[v]) if (e.to != p) {
      dfs_par(dfs_par, e.to, v);
    }
  };
  dfs_par(dfs_par, 0, -1);
  lint res = 0;
  for (int v = 0; v < n; ++v) {
    V<lint> dp(C + 1, -inf);
    dp[0] = 0;
    dp = dfs(dfs, v, par[v], dp, 0);
    res = max(res, *max_element(begin(dp), end(dp)));
  }
  cout << res << '\n';
}


Measured memory_bytes: 62364
from itertools import permutations

n = int(input())
a = [i+1 for i in range(n)]
a = permutations(a)
p = list(map(int, input().split()))
q = list(map(int, input().split()))

dict_order = sorted(a)
pi = dict_order.index(tuple(p))
qi = dict_order.index(tuple(q))

print(abs(pi - qi))

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

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


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

    ll n;
    cin>>n;
    vll a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }

    ll ans=INF;
    ll iter=0;
    rep(i,n){
        iter+=a[i];
        if(i+1<n)ans=min(ans,abs(sum-2*iter));
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll mo=1000000007;
int A,B;
ll memo[2020][2020];
ll C[2040][2040];
ll CS[2040][2040];


ll dfs(int A,int B) {
	if(A==0 || B==0) return 1;
	if(memo[A][B]>=0) return memo[A][B];
	// take A;
	ll ret=dfs(A-1,B);
	// take B;
	int a=A,b=B-1;
	// take until a+b==A;
	ret += CS[b][min(a,b)+1]-CS[b][0]+mo;
	return memo[A][B]=ret%mo;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(memo);
	cin>>A>>B;
	if(A==0 || B==0) {
		cout<<1<<endl;
		return;
	}
	for(i=0;i<=2020;i++) {
		C[i][0]=C[i][i]=1;
		if(i) for(j=1;j<i;j++) (C[i][j]=C[i-1][j-1]+C[i-1][j])%=mo;
		FOR(j,2020) (CS[i][j+1]=CS[i][j]+C[i][j])%=mo;
	}
	
	ll ret=0;
	B--;
	for(int a=0;a<=A;a++) {
		for(i=0;i<=a;i++) if(a-i<=B) {
			(ret += C[B][a-i]*dfs(i,a-i))%=mo;
		}
	}
	
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 97280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define test cout<<"debuged\n";
#define INF 10000000000
#define si 1000000
#define debug(x) cout<<x<<"\n";


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    ll n,m;
    cin>>n>>m;
    char grid[n][m];
    for(ll i=0;i<n;i++)
      for(ll j=0;j<m;j++)
      {
        cin>>grid[i][j];
      }
    ll dp[n][m];
    for(ll i=0;i<n;i++)
    {
      for(ll j=0;j<m;j++)
      {
        if(i==0 and j==0)
        {
          dp[i][j]=1;
          continue;
        }
        if(grid[i][j]=='.')
        {
            if(i==0 and j-1>=0)
            {
              dp[i][j]=dp[i][j-1];
            }
            else if(j==0 and i-1>=0)
            {
               dp[i][j]=dp[i-1][j];
            }
            else
            {
              dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;  
            }
        }
         else
          dp[i][j]=0;
      }
    }
    cout<<dp[n-1][m-1];  
   
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;


P makepair(int x){
    int first, last;
    last = x % 10;
    while (x != 0){
        first = x;
        x /= 10;
    }
    return P(first, last);
}

int main(){
    int N; cin >> N;
    map<P, int> counter;
    for (int i = 1; i <= N; i++){
        P p = makepair(i);
        counter[p]++;
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++){
        P p = makepair(i);
        P r = P(p.second, p.first);
        ans += counter[r];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
using System;

public class Program
{
    public static long loop;

    static long n;
    static long k;
    static long x;
    static long y;

    static string output;

    public static void Main(string[] args)
    {
        loop = 0;

        Input();
        Proc();
        Output();
    }

    static void Input()
    {
        string[] input = null;

        // スペース区切りの整数の入力(横、個別)
        input = Console.ReadLine().Split(' ');

        n = long.Parse(input[0]);   // 回数

        // スペース区切りの整数の入力(横、個別)
        input = Console.ReadLine().Split(' ');

        k = long.Parse(input[0]);   // 閾値

        // スペース区切りの整数の入力(横、個別)
        input = Console.ReadLine().Split(' ');

        x = long.Parse(input[0]);   // 前

        // スペース区切りの整数の入力(横、個別)
        input = Console.ReadLine().Split(' ');

        y = long.Parse(input[0]);   // 後
    }

    static void Proc()
    {
        long money = 0;

        for (long i = 1; i <= n; i++)
        {
            if (i <= k)
            {
                money += x;
            }
            else
            {
                money += y;
            }
        }

        output = string.Format("{0}", money);
    }

    static void Output()
    {
        // 出力
        Console.WriteLine(output);
        output = string.Empty;
    }
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+1];
    int ans=0;
    for(int i=1;i<=n;i++)
       cin>>arr[i];
    
    for(int i=1;i<=n;i++)
    {
        if(i%2==1 && arr[i]%2==1)
           ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int N;
double dp[301][301][302];

int main(){
  cin >> N;

  vector<int> a(N);
  REP(i,N) cin >> a[i];

  dp[0][0][0] = 0.0;
  map<int, int> m;
  REP(i,N){
    m[a[i]] += 1;
  }


  REP(i,N+1)REP(j,N+1)REP(k,N+1){
    if(i == 0 && j == 0 && k ==0)continue;
    if(i + j + k > N )continue;

    int res = N;
    double p = 1.0;

    if(i > 0){
      p += dp[i-1][j+1][k] * i / N;
      res -= i;
    }

    if(j > 0){
      p += dp[i][j-1][k+1] * j / N;
      res -= j;
    }

    if(k > 0){
      p += dp[i][j][k-1] * k / N;
      res -= k;
    }

    dp[i][j][k] = p * N / (N-res);
  }


  cout << setprecision(10) << dp[m[3]][m[2]][m[1]] << endl;
}

Measured memory_bytes: 213248
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long count = n / 11;
        long mod = n % 11;
        int plus = 0;
        if (mod > 0 && mod <= 6) {
            plus++;
        } else if (mod > 6) {
            plus+=2;
        }
        long res = count * 2 + plus;
        System.out.println(res);
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7;
const int INF=1<<30;
const int MAX_N=100000;

int main(){
  string s,ans="";
  rep(i,3){
    cin >> s ;
    ans+=s[0]-0x20;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    int cost = 0;
    sort(A, A+3);
    cost += abs(A[0] - A[1]);
    cost += abs(A[1] - A[2]);
    cout << cost << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    int n = s.size();
    vvl dp(n+1,vl(2,L_INF)); //dp[i][j] 上からi桁目までの精算の最小, j = 払い過ぎか
    dp[0][1] = 1;
    dp[0][0] = 0;
    rep(i,n){
        int num = s[i] - '0'; //上からi桁目の数字
        chmin(dp[i+1][0],dp[i][0]+num); //ぴったり精算
        chmin(dp[i+1][0],dp[i][1]+(10-num) );
        chmin(dp[i+1][1],dp[i][0]+num+1);
        //以下の漸化式の理由 https://algo-logic.info/abc155e/
        chmin(dp[i+1][1],dp[i][1]+(10-num-1) );
    }
    out(dp[n][0]);
}


Measured memory_bytes: 58928
#include<bits/stdc++.h> 
using namespace std; 
# define INF 0x3f3f3f3f 
typedef pair<int, int> iPair; 

class Graph 
{ 
	int V;
	list< pair<int, int> > *adj; 

public: 
	Graph(int V); 
	void addEdge(int u, int v, int w); 
	void shortestPath(int s); 
}; 
Graph::Graph(int V) 
{ 
	this->V = V; 
	adj = new list<iPair> [V]; 
} 

void Graph::addEdge(int u, int v, int w) 
{ 
	adj[u].push_back(make_pair(v, w)); 
	adj[v].push_back(make_pair(u, w)); 
} 

void Graph::shortestPath(int src) 
{ 
	priority_queue< iPair, vector <iPair> , greater<iPair> > pq; 
        vector<int> dist(V, INF); 
        vector<int> p(V, -1); 
	pq.push(make_pair(0, src)); 
	dist[src] = 0; 
	while (!pq.empty()) 
	{ 
		int u = pq.top().second; 
		pq.pop(); 
		list< pair<int, int> >::iterator i; 
		for (i = adj[u].begin(); i != adj[u].end(); ++i) 
		{ 
			 
			int v = (*i).first; 
			int weight = (*i).second; 
			if (dist[v] > dist[u] + weight) 
			{ 
				dist[v] = dist[u] + weight; 
				p[v] = u;
				pq.push(make_pair(dist[v], v)); 
			} 
		} 
	} 
	bool ok=true;
	vector<int>ans;
	for(int i=2;i<V;i++)
	  if(p[i]==-1)
	    {ok=false;break;}
	  else
	    ans.push_back(p[i]);
    if(!ok)
      cout<<"No\n";
    else
    {
      cout<<"Yes\n";
      for(auto x:ans)
        cout<<x<<"\n";
    }
} 
int main() 
{ 
   int n,m;
   cin>>n>>m;
   Graph g(n+1);
   for(int i=1;i<=m;i++)
   {
     int a,b;
     cin>>a>>b;
     g.addEdge(a,b,1);
   }
   g.shortestPath(1); 
   return 0; 
} 


Measured memory_bytes: 20472
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N = ri()
    d = {s: i for i, s in enumerate('MARCH')}
    l = [0] * 5
    for i in range(N):
        s = rs()[0]
        if s in d:
            l[d[s]] += 1
    ans = 0
    for i in range(3):
        for j in range(i + 1, 4):
            for k in range(j + 1, 5):
                ans += l[i] * l[j] * l[k]
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 8928
require 'pp'

n = gets.chomp!.chars
t = gets.chomp!.chars

if n.length + 1 != t.length 
    puts "No"
    exit 0
end

ok = true
n.each_with_index do |ch, i|
    if ch != t[i]
        puts "No"
        exit 0
    end
end

puts "Yes"


Measured memory_bytes: 14660
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	getLine
	as <- reverse . sort <$> readInts
	let
		s = sum as
		alice = sum $ map snd $ filter ( ( == 0 ) . ( `mod` 2 ) . fst ) $ zip [ 0 .. ] as
		bob = s - alice
	print $ alice - bob


Measured memory_bytes: 1020
from fractions import gcd
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

lcm = A[0]
for i in range(1, N):
    lcm = (lcm*A[i]) // gcd(lcm, A[i])

ans = 0
for i in range(N):
    ans += lcm // A[i]
ans %= mod
print(ans)


Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
ll power_pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    const ll MAXX = 1000000000000001;
    ll N;
    cin >> N;
    vector<ll> v;
    v.push_back(26);
    while(v.back() <= MAXX){
        v.push_back(v.back() * 26);
    }
    rep(i,v.size()-1){
        v[i+1] += v[i];
    }
    ll len = 0;
    rep(i,v.size()){
        if(N<=v[i]){
            len = i+1;
            if(i >= 1)N -= v[i-1];
            break;
        }
    }
    vector<ll> beki(1,1);
    while(beki.back() <= MAXX){
        beki.push_back(beki.back() * 26);
    }
    /*
    dump(N);
    print(beki);
    print(v);
    dump(len);
    */
    string ans = "";
    N--;
    for(int i = 1; i <= len; i++){
        //dump(N);
        //dump(N%26);
        if(N == 0)ans.push_back(char('a'));
        else {
            ans.push_back(char('a' + N%26));
            N /= 26;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
}

Measured memory_bytes: 3660
import math

N = int(input())

A_list = list()
B_list = list()
A_list.append(0)
B_list.append(0)

for i in range(N):
    A,B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

#末尾から考える
ans = 0
for i in range(N):
    A = A_list.pop(-1)
    B = B_list.pop(-1)
    #print(A,B,"→",end="")
    A += ans
    goal = B*math.ceil(A/B)
    #print(":",goal)
    ans += goal - A
    
print(ans)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,k;
	t = 1;
	while(t--) {
	 cin >> n >> k;
	 if(n % k)
	  cout << 1 << endl;
	 else
	  cout << 0 << endl;
	}
	return 0;
}



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



int main(void){
    int a,b,v,w,t;
    scanf("%d %d",&a,&v);
    scanf("%d %d",&b,&w);
    scanf("%d",&t);
    if(v<=w){printf("NO");return 0;}//鬼より子が早いor同速度なら永遠に追いつけない
    if(abs(a-b)-abs(w-v)*t<=0){printf("YES");}//t秒後にab間の距離はwvの差*t分縮む
    else{printf("NO");}

}


Measured memory_bytes: 1712
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;





int main(void) {

    int n,k;
    cin>>n>>k;
    if((n-1)*(n-2)/2 < k){
        fin(-1);
        return 0;
    }
    vector<vector<int> > g(n);
    for(int i=1;i<n;i++){
        g[0].push_back(i);
        g[i].push_back(0);
    }
    int ans=(n-1)*(n-2)/2;
    int pos=1;
    while(ans>k){
        // cout<<pos<<" "<<ans<<" "<<k<<endl;
        int next=max(pos+1,g[pos][g[pos].size()-1]+1);
        g[pos].push_back(next);
        g[next].push_back(pos);
        ans--;
        if(g[pos].size()==n-1)pos++;
    }
    
    vector<pair<int,int> > v;
    for(int i=0;i<n;i++){
        for(int j=i;j<g[i].size();j++){
            v.push_back(mp(i+1,g[i][j]+1));
        }
    }
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++){
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }

}



Measured memory_bytes: 384
n, m = list(map(int, input().split()))
sc = [list(map(int,input().split())) for i in range(m)]

for i in range(0, 10**n):
  str_i = str(i)
  if len(str_i) != n: continue

  chk = True
  for s, c in sc:
    chk &= str_i[s-1] == str(c)
  if chk:
    print(i)
    exit()

print(-1)
     
    
  

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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

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

#define rep1(i,n) for(ll (i)=1;(i)<=(n);++i)

#define rrep(i,n) for(ll (i)=(n)-1;(i)>=(0);--i)

#define rrep1(i,n) for(ll (i)=(n);(i)>=(1);--i)

#define pb push_back

#define fr first

#define sc second

ll N,M;

ll a[100000],b[100000];

vector<ll> v;

P p1[100000],p2[100000];

ll cnt;

ll ans[500];

ll res;



int main()

{

	cin>>N>>M;
rep1(i,N){
	cin>>p1[i].fr>>p1[i].sc;
}
rep1(i,M) cin>>p2[i].fr>>p2[i].sc;
rep1(i,N){
	res=0xfffffff;
	rep1(j,M){
	ll x=abs(p1[i].fr-p2[j].fr)+abs(p1[i].sc-p2[j].sc);
		if(res>x){
			res=x;
				ans[i]=j;
		}
	}
}
	rep1(i,N){
	cout<<ans[i]<<endl;
}

}

Measured memory_bytes: 2304
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        fast;
        int t=1;  //cin>>t;
        while(t--)
        {
        int n,x,ans=x;
        cin>>x>>n;
        vector<int> a(n);
        int flag=0;//check if x is present in the array or not,,,, find the position of x
        for(int i=0;i<n;i++)
        {
                cin>>a[i];
                if(x==a[i])
                    flag=1;

        }
        sort(a.begin(),a.end());
      
        if(n==0 || flag==0)
                cout<<x<<endl;
        else// 1 2 4 6 7 9 10      x=6
        {
                        auto it=find(a.begin(),a.end(),x);
                        auto it1=a.begin();
                        int pos=it-it1;
                        if(x==a[0] )//case 2: x is equal to leftmost element
                                ans=(a[0]-1);
                        else//element present somewhere in middle
                        {
                                int ans1=-2,ans2=-2;
                                for(int i=pos;i>0;i--)
                                {
                                        if((a[i]-a[i-1])>1)
                                        {
                                                ans1=a[i]-1;
                                                break;
                                        }
                                }
                                if(ans1==-2)
                                ans1=a[0]-1;

                                for(int i=pos;i<n-1;i++)
                                {
                                        if((a[i+1]-a[i])>1)
                                        {
                                                ans2=a[i]+1;
                                                break;
                                        }
                                }
                                if(ans2==-2)
                                        ans2=a[n-1]+1;
                                        //cout<<"ans1="<<ans1<<"\t"<<"ans2="<<ans2<<endl;
                                ans=((x-ans1)<=(ans2-x))?ans1:ans2;
                        }
                        cout<<ans<<endl;

        }


        }
        }
//         88 57 95 16 100 50 20 19 52 66 87 14 84 78 5 85 31 89 58 49 70 23 54 6 62 21 63 86 61 30 65 34 44 29 76 13 90 1 22 7 48 15 45 94 38 98 32 83 96 40 11 37 24 46 47 35 79 10 74 97 42 81 80 56 73  92 4 17 93 36 41 55 18 12 68 91 53 28 67 82 60 27 2 75 9 43 26 77 72 59 25 8 69 71 33 64 3 51 39 99





Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int h,w;
    char s[114][114];
    scanf("%d%d\n",&h,&w);
    REP(i,h) scanf("%s",&s[i]);

    REP(i,h*2) printf("%s\n",s[i/2]);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

# dp
dp_a = [0 for _ in range(N)]
dp_b, dp_c = dp_a.copy(), dp_a.copy()
dp_a[0] = abc[0][0]
dp_b[0] = abc[0][1]
dp_c[0] = abc[0][2]

for i in range(N - 1):
    dp_a[i + 1] = max(dp_b[i], dp_c[i]) + abc[i + 1][0]
    dp_b[i + 1] = max(dp_a[i], dp_c[i]) + abc[i + 1][1]
    dp_c[i + 1] = max(dp_a[i], dp_b[i]) + abc[i + 1][2]
print(max(dp_a[-1], dp_b[-1], dp_c[-1]))

Measured memory_bytes: 97664
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

int const N = 200000;

int main(){
    int n;cin>>n;
    int as[n+1];
    ll sum=0;
    ll sub=0;
    rep(i,n) {
        int a;
        cin>>a;
        as[i+1]=a;
        sum+=a;
        if((i+1)%2==0)sub+=2*a;
    }
    int ans[n+1];
    ans[1] = sum-sub;
    rep(i,n-1){
        ans[i+2]=2*as[i+1] - ans[i+1];
    }
    rep(i,n) cout<<ans[i+1] << " ";
    cout << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>

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

  std::sort(a, a + n, std::greater<int>());
  int ans = 0;
  for ( int i = 0; i < k; i++ ) {
    ans += a[i];
  }
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

int arr[100005], dp[100005], n,k,t;

int solve(int pos)
{
    if(pos==n) return 0;

    int &res=dp[pos];

    if(res!=-1)
        return res;

    res=1e9;

    if(pos+1<=n)
    {
        res = min(res, solve(pos+1)+abs(arr[pos+1]-arr[pos]));
    }
    if(pos+2<=n)
    {
        res = min(res, solve(pos+2)+abs(arr[pos+2]-arr[pos]));
    }

    return res;
}

int main()
{
    cin >> n;

    for(int i=1; i<=n; i++)
    {
        cin >> arr[i];
    }

    memset(dp, -1, sizeof(dp));

    int ans=solve(1);

    cout << ans << endl;

    return 0;
}


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

#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define INF 1e9

ll solveA(int i,int j,vector <int>& A,ll sum, vector <vector <ll> >& dp){
    if(dp[i][j]>=0) return dp[i][j];
    if(i==j){ dp[i][j]=A[i]; return A[i];}
    dp[i][j] = max(sum-solveA(i+1,j,A,sum-A[i],dp),sum-solveA(i,j-1,A,sum-A[j],dp));
    return dp[i][j];
}

int main(){
    int n;
    cin>>n;
    vector <int> A (n);
    ll sum = 0;
    for(int i=0;i<n;i++){ cin>>A[i]; sum+=A[i]; } 
    vector <vector <ll> > dp (n+1,vector <ll> (n+1,-1));
    cout<<(ll)2*solveA(0,n-1,A,sum,dp)-(ll)sum<<"\n";
	return 0;
}


Measured memory_bytes: 71040
s=list(input())
s1=reversed(s)
l=["dream","dreamer","erase","eraser"]
s2=[]
for item in s1:
  s2.insert(0,item)
  str=''.join(s2)
  if str in l:
    s2=[]
  elif len(s2)>7:
    break
if len(s2)==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define MAXN 100005
#define reg register
#define inl inline
#define int long long
using namespace std;
const int Mod=1e9+7;
int n,m,a[MAXN],t[MAXN];
struct Matrix
{
	int cnt[5][5];
	inl void Init()
	{
		memset(cnt,0,sizeof(cnt));
		for(reg int i=0;i<3;i++) cnt[i][i]=1;
	}
	friend Matrix operator * (const Matrix &x,const Matrix &y)
	{
		reg Matrix res;
		memset(res.cnt,0,sizeof(res.cnt));
		for(reg int i=0;i<3;i++)
		{
			for(reg int j=0;j<3;j++)
			{
				for(reg int k=0;k<3;k++) res.cnt[i][j]=(res.cnt[i][j]+x.cnt[i][k]*y.cnt[k][j]%Mod)%Mod;
			}
		}
		return res;
	}
}A,B,ans;
inl Matrix Pow(reg Matrix x,reg int y)
{
	reg Matrix res;
	res.Init();
	for(;y;y>>=1,x=x*x) if(y&1) res=res*x;
	return res;
}
signed main()
{
	scanf("%lld %lld",&n,&m);
	for(reg int i=1;i<=m;i++) scanf("%lld",&a[i]);
	for(reg int i=1;i<=m;i++) t[i]=a[i]-a[i-1]-1;
	t[++m]=n-a[m-1];
	A.cnt[0][0]=1,A.cnt[0][1]=0,A.cnt[0][2]=0;
	A.cnt[1][0]=1,A.cnt[1][1]=1,A.cnt[1][2]=0;
	A.cnt[2][0]=1,A.cnt[2][1]=2,A.cnt[2][2]=1;
	for(reg int i=0;i<3;i++) B.cnt[i][2]=1;
	for(reg int i=0;i<3;i++)
	{
		for(reg int j=0;j<3;j++) B.cnt[i][j]+=A.cnt[i][j];
	}
	ans.Init();
	for(reg int i=1;i<=m;i++)
	{
		ans=ans*Pow(B,t[i]);
		if(i<m) ans=ans*A;
	}
	printf("%lld\n",ans.cnt[2][0]);
	return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  int a[N];
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  vector<int> pressed(N);
  int i = 1;
  int ret = 0;
  while (true) {
    if (pressed[i - 1] == 1) {
      cout << "-1" << endl;
      return 0;
    } else if (i == 2) {
      cout << ret << endl;
      return 0;
    }
    pressed[i - 1] = 1;
    i = a[i - 1];
    ++ret;
  }


  return 0;
}

Measured memory_bytes: 1024
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 result = 0;
		if (n <= k) {
			result = x * n;
		} else {
			for (int i = 0; i < k; i++) {
				result += x;
			}
			int h = n - k;
			for (int j = 0; j < h; j++) {
				result += y;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 35816
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <iostream>
#include <cmath>
#include <algorithm>
 
typedef long long ll;
 
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a == b && b == c ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int b[11];
int g[11];
int r[11];
int t[10];
char tc[11];

void in(int, char);
int hantei();
void sort(int, int);
void change(int, int);

main(){
  int i, j, n, ans;
  
  scanf("%d", &n);
  
  for(i=0;i<n;i++){
    b[0]=g[0]=r[0]=-1;
    for(j=0;j<9;j++){
      scanf("%d", &t[j]);
    }
    getchar();
    for(j=0;j<9;j++){
      scanf("%c", &tc[j]);
      getchar();
    }
    
    sort(0, 8);

    for(j=0;j<9;j++){
      in(t[j], tc[j]);
    }
    
    ans=hantei();
    
    printf("%d\n", ans);
  }
  return 0;
}

void in(int a, char c){
  int i;
  
  if(c=='B'){
    for(i=0;i<10;i++){
      if(b[i]==-1){
	b[i]=a;
	b[i+1]=-1;
	return;
      }
    }
  }
  
  else if(c=='G'){
    for(i=0;i<10;i++){
      if(g[i]==-1){
	g[i]=a;
	g[i+1]=-1;
	return;
      }
    }
  }
  
  else if(c=='R'){
    for(i=0;i<10;i++){
      if(r[i]==-1){
	r[i]=a;
	r[i+1]=-1;
	return;
      }
    }
  }
}

int hantei(){
  int i, eb, eg, er, count=0, renzoku, temp, j;
  int fb[11], fg[11], fr[11];
  
  for(i=0;i<10;i++){
    if(b[i]==-1){
      eb=i-1;
      break;
    }
  }
  for(i=0;i<10;i++){
    if(g[i]==-1){
      eg=i-1;
      break;
    }
  }
  for(i=0;i<10;i++){
    if(r[i]==-1){
      er=i-1;
      break;
    }
  }
  
  for(i=0;i<11;i++){
    fb[i]=fg[i]=fr[i]=0;
  }
  
  if((eb+1)%3==0 && (eg+1)%3==0 && (er+1)%3==0){
    for(i=0;i<=eb;i+=3){
      if(b[i]==b[i+1] && b[i+1]==b[i+2]){
	count++;
	b[i]=b[i+1]=b[i+2]=-2;
      }
    }
    for(i=0;i<=eg;i+=3){
      if(g[i]==g[i+1] && g[i+1]==g[i+2]){
	count++;
	g[i]=g[i+1]=g[i+2]=-2;
      }
    }
    for(i=0;i<=er;i+=3){
      if(r[i]==r[i+1] && r[i+1]==r[i+2]){
	count++;
	r[i]=r[i+1]=r[i+2]=-2;
      }
    }
    for(j=0;j<3;j++){
      temp=-1;
      for(i=0, renzoku=0;i<=eb;i++){
	if(b[i]==-2) continue;
	if(renzoku==3) break;
	if(temp==-1){
	  temp=b[i];
	  b[i]=-2;
	  renzoku++;
	}
	if(temp==b[i]-1){
	  temp=b[i];
	  b[i]=-2;
	  renzoku++;
	}
      }
      if(renzoku==3) count++;
    }
    for(j=0;j<3;j++){
      temp=-1;
      for(i=0, renzoku=0;i<=eg;i++){
	if(g[i]==-2) continue;
	if(renzoku==3) break;
	if(temp==-1){
	  temp=g[i];
	  g[i]=-2;
	  renzoku++;
	}
	if(temp==g[i]-1){
	  temp=g[i];
	  g[i]=-2;
	  renzoku++;
	}
      }
      if(renzoku==3) count++;
    }

    for(j=0;j<3;j++){
      temp=-1;
      for(i=0, renzoku=0;i<=er;i++){
	if(r[i]==-2) continue;
	if(renzoku==3) break;
	if(temp==-1){
	  temp=r[i];
	  r[i]=-2;
	  renzoku++;
	}
	if(temp==r[i]-1){
	  temp=r[i];
	  r[i]=-2;
	  renzoku++;
	}
      }
      if(renzoku==3) count++;
    }

    if(count==3) return 1;
    else return 0;
  }
  else return 0;
}

void sort(int left, int right){
  int i, j, n;
  
  i=left;
  j=right;
  n=t[(left+right)/2];
  
  while(1){
    while(n>t[i]) i++;
    while(n<t[j]) j--;
    
    if(i>=j) break;
    
    change(i, j);
    i++;
    j--;
  }

  if(left<i-1) sort(left, i-1);
  if(j+1<right) sort(j+1, right);
}


void change(int a, int c){
  int temp;
  char temp1;

  temp=t[a];
  t[a]=t[c];
  t[c]=temp;

  temp1=tc[a];
  tc[a]=tc[c];
  tc[c]=temp1;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctype.h>
using namespace std;
int main(void){
int N;
cin>>N;
long num[N];
for(int i=0;i<N;i++){
    cin>>num[i];
}
int c=0;

for(int i=0;i<1000;i++){ 
    int ans=0;
    for(int j=0;j<N;j++){
        if(num[j]%2==0) ans++;
    }
    if(ans==N) {for(int k=0;k<N;k++){
        num[k]=num[k]/2;
    } 
    c++;
}
}

    cout<<c;
return 0;
}

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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a[5];
    for (int i = 0; i < 5; ++i) {
        cin >> a[i];
        if(a[i] == 0){
            cout << i + 1 << endl;
            exit(0);
        }
    }
}

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

int main (){
  int n;cin>>n;string a;cin>>a;int k;cin>>k;k--;char x=a[k];
  for (int i=0;i<n;i++){
    if (a[i]==x) cout<<x;
    else cout<<"*";
  }
  return 0;
}

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

int s[50][50];

int main() {
	int H, W;
	char c;
	cin >> H >> W;
	for(int h = 0; h < H; h++)
	{
		for(int w = 0; w < W; w++)
		{
			cin >> c;
			if(c == '#')
				s[h][w] = 1;
		}
	}
	bool can = true;
	for(int h = 0; h < H; h++)
	{
		for(int w = 0; w < W; w++)
		{
			if(s[h][w] == 1)
			{
				bool can_will = false;
				if(h > 0)
				{
					if(s[h - 1][w] == 1)
					{
						can_will = true;
					}
				}
				if(h < H - 1)
				{
					if(s[h + 1][w] == 1)
					{
						can_will = true;
					}
				}
				if(w > 0)
				{
					if(s[h][w - 1] == 1)
					{
						can_will = true;
					}
				}
				if(w < W - 1)
				{
					if(s[h][w + 1] == 1)
					{
						can_will = true;
					}
				}
				if(!can_will)
				{
					can = false;
					break;
				}
			}
		}
	}
	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int P;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> P;
    int ans = P / 500 * 500;
    cout << ans << endl;
}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N, K;
int A[2200];
int mod = 1e9 + 7;
signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) { cin >> A[i]; }
    int X = 0, Y = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) { if (A[i] < A[j]) { X++; }}
        for (int j = 0; j < N; j++) { if (A[i] < A[j]) { Y++; }}
    }
    int k1 = K, k2 = K - 1;
    if (k1 & 1) { k2 /= 2; }
    else { k1 /= 2; }
    cout << (K * X % mod + Y * k1 % mod * k2 % mod) % mod << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    char s[111];
    cin>>k>>s + 1;
    int len = strlen(s + 1);
    if(len <= k){
        puts(s + 1);
    }
    else{
        for(int i = 1;i <= k; i++)putchar(s[i]);
        puts("...");
    }
    return 0;
}


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

int dfs(int i, vector<vector<int> > &edges, vector<int> &maxDistance) {
    if(maxDistance[i] != -1) {
        return maxDistance[i];
    }
    maxDistance[i] = 0;
    for(auto e: edges[i]) {
        maxDistance[i] = max(maxDistance[i], 1 + dfs(e, edges, maxDistance));
    }
    return maxDistance[i];
}

int main() {
    int n, m, u, v;
    cin>>n>>m;
    vector<vector<int> > edges(n+1, vector<int>(0));
    for(int i = 0; i<m; i++) {
        cin>>u>>v;
        edges[u].push_back(v);
    }
    vector<int> maxDistance(n+1, -1);
    for(int i = 1; i<=n; i++) {
        if(maxDistance[i] == -1) {
            maxDistance[i] = dfs(i, edges, maxDistance);
        }
    }
    cout<<*max_element(maxDistance.begin(), maxDistance.end())<<endl;
}


Measured memory_bytes: 11152
def main()
  a = gets.chomp.to_i
  ans = 0
  for i in 1..a do
    for j in 2..(a+1) do
      tmp = i ** j
      if tmp > a
        break
      elsif tmp <= a
        ans = [tmp,ans].max
      end
    end
  end
  puts ans
end

main()

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];
  sort(v.begin(),v.end());

	double ans = v[0];
  for(int i = 1; i < N; i++){
    ans = (ans + v[i])/2;
  }
  cout << fixed << setprecision(15) << ans << endl;

	return 0;
}


Measured memory_bytes: 3684
main :: IO ()
main = do
  s <- getLine
  let
    l = length s - 7
    t = "keyence"
    (tx, sx) = test ("keyence", s)
  putStrLn $ if tx == drop l sx then "YES" else "NO"

test :: (String, String) -> (String, String)
test lxy@(x : xs, y : ys) = if x == y then test (xs, ys) else lxy
test lxy = lxy


Measured memory_bytes: 380
import sys
import collections
n,p=map(int,input().split())
s=list(input())
s.reverse()
ans=0

if p==2:
  for i in range(n):
    if int(s[i])%2==0:
      ans+=n-i
  print(ans)
  sys.exit()

if p==5:
  for i in range(n):
    if int(s[i])%5==0:
      ans+=n-i
  print(ans)
  sys.exit()

l=[0,int(s[0])%p]
x=int(s[0])
y=1
for i in range(1,n):
  y*=10
  y%=p
  x+=(y*int(s[i]))%p
  x%=p
  l.append(x)
L=collections.Counter(l)
for j in L.values():
  ans+=int(j*(j-1)/2)
print(ans)

Measured memory_bytes: 61936
// ------------------------------------
// Date:2018/ 3/ 4
// Problem:ABC 060 Shiritori a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] and
      b[b.size() - 1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a = 0;
    int b = 0;
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '0') {
        a++;
      } else {
        b++;
      }
    }
    int ans = 2 * (Math.min(a, b));
    System.out.println(ans);
  }
}

Measured memory_bytes: 26196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define max(x, y) (x) > (y) ? (x):(y)


using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;

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

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

bool pairbool(pLL &a, pLL &b)
{
	return (a.first < b.first);
}

int main(void)
{
	LL N, a, b, sum = 0L;
	vector<pLL> x;
	cin >> N;
	for (int i = 1; i <= N;i++) {
		cin >> a >> b;
		x.push_back(pLL(b, a));
	}
	sort(x.begin(), x.end(), pairbool);
	for (int i = 0; i < N; i++) {
		sum += x[i].second;
		//cout << sum << endl;
		if (sum > x[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;

}

Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
char c;
cin>>c;
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
{
    cout<<"vowel";
}
else
{
    cout<<"consonant";
}
return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
#include<string.h>
int main()
{
	char a[15];
	int n,i,s=0,c=0;
	scanf("%s",a);
	n=strlen(a);
	for(i=2;i<=n-2;i++)
	{
		if(a[i]=='C')
		s++;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]>='a'&&a[i]<='z')
		c++;
	}
	if(a[0]=='A'&&s==1&&c==n-2)
	printf("AC");
	else
	printf("WA");
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--, b--;
        g[a].push_back(b), g[b].push_back(a);
    }
    for (int i = 0; i < n; i++) {
        cout << g[i].size() << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n;
  while (scanf("%d", &n) != EOF)
  {
    lli ans = 0;
    for (int i = 1; i <= n; i++)
      if (!(i % 3 == 0 || i % 5 == 0))
        ans += i;
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3812