akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
  fast;
  ll A;
  cin>>A;
  string ch={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    string ans="";
    while(A){
        if(A%26){
        ans+=ch[abs(A%26 - 1)];
        A=A/26;}
        else
        {
            ans+="z";
            A/=26;
            A--;
        }
    }
    int n = ans.length();
    for (int i = 0; i < n / 2; i++) 
        swap(ans[i], ans[n - i - 1]);
    cout<<ans;
  return 0;
}

Measured memory_bytes: 3648
from collections import defaultdict, deque
def solve():
    N,M = map(int,input().split())
    G = defaultdict(list)

    for i in range(M):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    
    visited = [False] * N
    ans = [float('inf')] * N

    q = deque()
    q.append((0,-1))
    visited[0] = True
    while len(q) > 0:
        now,before = q.popleft()
        ans[now] = min(before + 1,ans[now])

        # print("now",now)
        for next in G[now]:
            if not visited[next]:
                # print(next)
                q.append((next,now))
                visited[next] = True


    print('Yes')
    print(*ans[1:],sep='\n')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 110136
def primeFactor(N):
    i = 2
    ret = {}
    n = N
    if n < 0:
        ret[-1] = 1
        n = -n
    if n == 0:
        ret[0] = 1
    while i**2 <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
            ret[i] = k
        i += 1
    if n > 1:
        ret[n] = 1
    return ret

def isPrime(N):
    if N <= 1:
        return False
    return sum(primeFactor(N).values()) == 1

def findPrime(N):
    if N < 0:
        return -1
    i = N
    while True:
        if isPrime(i):
            return i
        i += 1

def divisor(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)
    
N, M = map(int, input().split(" "))

for i in divisor(M):
    if i >= N:
        print (M//i)
        break

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>



int main(int argc, char *argv[])
{
	double n;
	cin >>n;
	
	cout<< setprecision(10)<<n*3.14159265258979323*2<<endl;
	return 0;
}



Measured memory_bytes: 3776
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){for(s=26;s--;)r=i.replace(/[a-z]/g,function(j){return String.fromCharCode((j.charCodeAt(0)-97+s)%26+97)}),r.match(/th(e|is|at)/)?console.log(r):0})

Measured memory_bytes: 9308
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
bl = inpl()
ans = bl[0]
for i in range(0, n):
    if(i == n - 2):
        ans += bl[n - 2]
        break
    ans += min(bl[i], bl[i + 1])
print(ans)


Measured memory_bytes: 74900
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    int a, b, c, x, y, i, k;

    int m = 1000000000; 

    
    cin >> a >> b >> c >> x >> y;


    for( i = 0 ; i <= 200000 ; i = i + 1 ){

         k = 2 * c * i + a * max( x - i, 0 ) + b * max( y - i, 0 );

         if( m > k ) m = k;

         }

    cout << m << endl;

    return 0;

}

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

int main(int argc, char *argv[])
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int N;
    bool flag = false;

    cin >> N;

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (N == i * j) {
                flag = true;
                break;
            }
        }
        if (flag) {
            break;
        }
    }

    if (flag) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
 
a,b,c,k = LI()

result = 0
if(a > k):
    result = k
else:
    if(a + b > k):
        result = a
    else:
        result = a - (k - a - b)

print(result)

Measured memory_bytes: 9200
import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for i in range(A)]
T = [int(input()) for i in range(B)]
X = [int(input()) for i in range(Q)]

def solve(x):
  ids = bisect.bisect_left(S, x)
  idt = bisect.bisect_left(T, x)
  if 0 < ids <  A:
    sm, sp = S[ids-1], S[ids]
  elif ids == 0:
    sm, sp = -10**20, S[ids]
  else:
    sm, sp = S[ids-1], x + 10**20
  if 0 < idt < B:
    tm, tp = T[idt-1], T[idt]
  elif idt == 0:
    tm, tp = -10**20, T[idt]
  else:
    tm, tp = T[idt-1], x + 10**20
  
  ans = max(tp - x, sp - x)
  ans = min(ans, max(x - tm, x - sm))
  min_ds = min(sp - x, x - sm)
  min_dt = min(tp - x, x - tm)
  ans = min(ans, 2*min(min_ds, min_dt)+max(min_ds, min_dt))
  return ans

for x in X:
  print(solve(x))

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;
typedef long double LB;

int main(){
  LB n,m,d;
  LB ans;
  cin >> n >> m >> d;
  LB count;
  if(d==0) count=n;
  else count=2*(n-d);
  ans=count*(m-1)/n/n;
  cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int i;
  int ch = 0;
  for(i = 0; i < s.size()-1; i++)
  {
    if(s.at(i) == 'A' && s.at(i+1) == 'C')
    {
      ch = 1;
      break;
    }
  }
  if(ch == 1)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll ans = 0;
  ll b;
	for(int i = 0; i < 5; i++) {
    cin >> b;
	if(b == 0) break;
    else ans++;
  }
  cout << ans +1;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    bool cards[4][13] ={
        {false}
    };
    int rank;
    char suit;
    for(int i = 0; i < n; i++){
        
        cin >> suit >> rank;
        
              if(suit=='S'){
            cards[0][rank - 1] = true;
            
        }else if(suit=='H'){
            cards[1][rank - 1] = true;
            
        }else if(suit=='C'){
            cards[2][rank - 1] = true;
            
        }else if(suit=='D'){
            cards[3][rank - 1] = true;
            
        }
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(cards[i][j]==false){
                if(i==0) cout << "S " << j + 1 << endl;
                if(i==1) cout << "H " << j + 1 << endl;
                if(i==2) cout << "C " << j + 1 << endl;
                if(i==3) cout << "D " << j + 1 << endl;
            }
        }
    }
}

Measured memory_bytes: 1160
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ans = 753;
		for (int i = 0; i < S.length() - 2; i++) {
			int num = 753 - Integer.parseInt(S.substring(i, i+3));
			if (num < 0) num *= -1;
			if (num < ans) ans = num;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
    int nagasa;
    string s;
    string t;

    cin >> nagasa;
    cin >> s;
    cin >> t;

    int result = 0;

    for(int i = 1; i <= nagasa; i++){

        string sdash = s.substr(nagasa - i,i);
        string tdash = t.substr(0,i);

        if(sdash == tdash){

            result = i;

        }

    }

    cout << (nagasa * 2 - result) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



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

    map<ll,ll> m;
    
    rep(i,0,n){
        int a;
        cin >> a;

        m[a]++;
        m[a-1]++;
        m[a+1]++;
    }	

    ll ans = -linf;
    for(auto i:m)ans = max(ans,i.sd);

    P(ans);
	return  0;
}

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



int main(){
	long long n;
	cin >> n;
	bitset<32> a(n);
	cout << a << endl;
	a.flip();
	cout << a << endl;
	a.flip();
	cout << (a<<1) << endl;
	cout << (a>>1) << endl;
}


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

struct Nbase {
    int n;
    int sz = 1;
    long long max = 1e18;

    Nbase(int k = 2){
        n = k;
        while(max != 0){
            max /= n;
            sz++;
        }
    };

    //繰り返し二乗法
    long long EX(long long x,long long n){
        if(n == 0) return 1;
        else if(n%2 == 1) return EX(x,n-1)*x;
        else return EX(x*x,n/2);
    }

    vector<int> to_n(long long num){
        vector<int> ret(sz);
        long long subtraction = EX(n,sz-1);
        for(int i = sz-1; i >= 0; i--){
            long long quotient = num/subtraction;
            ret[i] = quotient;
            num -= ret[i]*subtraction;
            subtraction /= n;
        }
        return ret;
    }

    long long re_n(vector<int>& vec){
        long long ret = 0;
        vec.resize(sz);
        for(int i = 0; i < sz; i++){
            ret += vec[i]*EX(n,i);
        }
        return ret;
    }

    void supress(const vector<int>& lim,vector<int>& at){
        bool upper = true;
        for(int i = sz; i >= 0; i--){
            if(upper && lim[i] > 0) upper = false;
            if(lim[i] > at[i]) break;
            else if(upper || lim[i] < at[i]) at[i] = lim[i];
        }
    }
};

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    Nbase base = 2;
    vector<int> xnum(base.sz,0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        vector<int> num = base.to_n(a[i]);
        for(int i = 0; i < num.size(); i++){
            xnum[i] += num[i];
        }
    }
    for(int i = 0; i < xnum.size(); i++){
        if(xnum[i] <= n/2) xnum[i] = 1;
        else xnum[i] = 0;
    }
    vector<int> knum = base.to_n(k);
    base.supress(knum,xnum);
    ll x = base.re_n(xnum);
    ll ans = 0;
    for(int i = 0; i < n; i++) ans += x^a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4016
t = input()
for _ in range(int(input())):
    order = input().split()
    cmd = order[0]
    a, b = map(int,  order[1:3])
    if cmd == 'print':
        print(t[a:b+1])
    elif cmd == 'reverse':
        t = t[:a] + t[a:b+1][b::-1] + t[b+1:]
    else:
        c = order[3]
        t = t[:a] + c + t[b+1:]

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i += 2){
    int cnt = 0;
    for(int j = 1; j <= i; ++j){
      if(i%j == 0) ++cnt;
    }
    if(cnt == 8) ++ans;
  }
  cout << ans << endl;
}

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

namespace C___Attack_Survival
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] Numbers = Console.ReadLine().Split(' ');
            var NumberOfPeople = int.Parse(Numbers[0]);
            int[] PointOfPeople = new int[NumberOfPeople];

            var NumberOfPoint = int.Parse(Numbers[1]);
            var NumberOfCorrect = int.Parse(Numbers[2]);

            int[] Ai = new int[NumberOfCorrect];

            for (int i = 0; i < NumberOfCorrect; i++)
            {
                Ai[i] = int.Parse(Console.ReadLine());
            }
            
            for (int i = 0; i < NumberOfCorrect; i++)
            {
                PointOfPeople[Ai[i]-1]++;
            }

            var Point = NumberOfPoint - NumberOfCorrect;
            for (int i = 0; i < PointOfPeople.Length; i++)
            {
                PointOfPeople[i] += Point;
                int temp = PointOfPeople[i];
                if(temp > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }

            }
        }
    }
}


Measured memory_bytes: 17560
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int Mod=998244353;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
string S;
int F(string);
int G(string);
map<string,int>f,g;
int mod(int x){return x>=Mod?x-Mod:x;}
int F(string s){
	if(f.find(s)!=f.end())return f[s];
	int len=s.length(),ans=0;
	for(int i=0;i<len;i++){
		ans=mod(ans+1ll*F(s.substr(0,i))*G(s.substr(i,len-i))%Mod);
	}
	return f[s]=ans;
}
int G(string s){
	if(g.find(s)!=g.end())return g[s];
	int len=s.length(),ans=0;
	if(len==1)return g[s]=s[0]-'0'+1;
	for(int i=1;i<=len/2;i++){
		if(len%i)continue;
		string t="";
		for(int j=0;j<i;j++){
			char c='1';
			for(int k=j;k<len;k+=i){
				if(s[k]=='0'){c='0';break;}
			}
			t=t+c;
		}
		ans=mod(ans+F(t));
	}
	return g[s]=ans;
}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	f[""]=1;cin>>S;cout<<F(S);
	return 0;
}

Measured memory_bytes: 12640
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;

int a,b,k,t;
int f[100000];
int main(void){
    cin>>a>>b>>k;
    rep(i,1,min(a,b)+1){
        if(a%i==0 && b%i==0){f[t]=i;t++;}
    }
    p(f[t-k]);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));

    int ans = 0;
    rep(i, K) ans += A[i];

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
vector<int>v[60];
bool seen[60],ck;
bool dab[70][70];
int res;
void dfs(int x,int par,int child)
{
    if(seen[x])return;
    res++;
    seen[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
        if(x==par && v[x][i]==child){
        }
        else dfs(v[x][i],par,child);
    }
}
int main()
{
    int m,x,y,n,cnt=0;cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        ck=false;
        bool olala=false;
        for(int j=0;j<v[i].size();j++){
        res=0;
        memset(seen,0,sizeof(seen));
        if(dab[i][v[i][j]]==false){
        dfs(i,i,v[i][j]);
        if(res!=n)cnt++;
        dab[i][v[i][j]]=true;
        dab[v[i][j]][i]=true;

        }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main()
{ 
  int s, i = 2;
  vector<bool> a(1000001, false);

  cin >> s;
  a[s] = true;
  while(true)
  {
    if (s % 2 == 0)
      s /= 2;
    else
      s = 3 * s + 1;
    if (a[s])
      break;
    a[s] = true;
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

int main() {
    long long n;
    cin >> n;

    string ans = "";

    while(n > 0) {
        n -= 1;
        ans += char(n%26 + 97);
        n /= 26;
    }

    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3060
/*input
6
abcadc
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    string a;
    cin>>a;
    if(a.length()%2){
        cout<<"No";
        return 0;
    }
    bool wk=true;
    REP(i,a.length()/2){
        if(a[i]!=a[i+a.length()/2]) wk=false;
    }
    if(wk) cout<<"Yes";
    else cout<<"No";
}

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

using namespace std;
typedef long long ll;

string s;
ll K;

int main(){
    cin >> K;
    cin >> s;
    if(s.size() <= K){
        cout << s << endl;
    }else{
        for(int i=0;i<K;i++) cout << s[i];
        cout << "...";
        cout << endl;
    }
    return 0;
}

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

int main() {
  int X, N;
  cin >> X >> N;

  if(N == 0){
    cout << X << endl;
  }
  else{
    vector<int> A(N);
    for(int i = 0; i < N; i++){
      cin >> A.at(i);
    }
    
    bool a = false;
    
    for(int i = 0; i < 51; i++){
      for(int j = 0; j < N; j++){
        if(A.at(j) == X - i){
          break;
        }
        else if(j == N - 1){
          int q = X - i;
          cout << q << endl;
          a = true;
        }
      }
      if(a){
        break;
      }
      
      for(int j = 0; j < N; j++){
        if(A.at(j) == X + i){
          break;
        }
        else if(j == N - 1){
          int q = X + i;
          cout << q << endl;
          a = true;
        }
      }
      if(a){
        break;
      }
    }
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main() {
  lli N, H;
  scanf("%lld %lld",&N,&H);
  vector<int> a, b;
  for (int i=0; i<N; i++) {
    int x, y;
    scanf("%d %d",&x,&y);
    a.push_back(x);
    b.push_back(y);
  }
  int a_max=(*max_element(a.begin(),a.end()));
  sort(b.begin(),b.end(),greater<int>());
  lli ans=0;
  for (int i=0; H>0 && b[i]>a_max; i++) {
    H-=b[i];
    ans++;
  }
  while (H>0) {
    H-=a_max;
    ans++;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1276
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> dp(3);
    cin >> dp;
    forn (i, 1, n) {
        vector <int> a(3);
        cin >> a;
        auto new_dp = vector <int> (3);
        forn (j, 0, 3)
            forn (k, 0, 3)
                if (j != k)
                    chkmax(new_dp[j], dp[k] + a[j]);
        dp = new_dp;
        //cout << dp << "\n";
    }
    cout << *max_element(all(dp));
    return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while(A > 0 || C > 0){
      C -= B;
    //   std::cout << C << std::endl;
      if(C <= 0){
          std::cout << "Yes" << std::endl;
          break;
      }
      A -= D;
    //   std::cout << A << std::endl;
      if(A <= 0){
          std::cout << "No" << std::endl;
          break;
      }
  }
  

}

Measured memory_bytes: 3516
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		Map<Integer, Set<Integer>> map = new HashMap<>();
		for(int i = 1; i <= n; i++){
			map.put(i, new HashSet<Integer>());
		}
		int x, y;
		for(int i = 0; i < m; i++){
			x = sc.nextInt();
			y = sc.nextInt();
			map.get(x).add(y);
			map.get(y).add(x);
		}
		Set<Integer> now = new HashSet<Integer>();
		Set<Integer> tmp = new HashSet<Integer>();
		Set<Integer> zan = new HashSet<Integer>();
		Set<Integer> set = new HashSet<Integer>();
		now.add(1);
		for(int i = 2; i <= n; i++){
			zan.add(i);
		}
		int[] ans = new int[n+1];
		while(zan.size() > 0){
			for(Integer p : now){
				set = map.get(p);
				for(Integer i : set){
					if(ans[i] > 0)continue;
					ans[i] = p;
					zan.remove(i);
					tmp.add(i);
				}
			}
			if(tmp.isEmpty()){
				System.out.println("No");
				return;
			}
			now = tmp;
			tmp = new HashSet<Integer>();
		}
		System.out.println("Yes");
		for(int i = 2; i <= n; i++){
			System.out.println(ans[i]);
		}
	}
}

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

vector<vector<int>>g;
bool mark[1000000];
int mx=0;

void dfs(int i){
mx++;
mark[i]=true;
for(int j=0;j<g[i].size();j++){
    if(!mark[g[i][j]])dfs(g[i][j]);
}
}


main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i,j,k,l,m,n,o,p;
    while(cin>>m>>n)
    {
        for(i=0; i<=m; i++)mark[i]=false;
        g.assign(m+1,vector<int>());
        for(i=0; i<n; i++)
        {
            cin>>j>>k;
            g[j].push_back(k);
            g[k].push_back(j);
        }
        j=0;
        for(i=1; i<=m; i++)
        {
            if(!mark[i])
            {
                mx=0;
                dfs(i);
            }
            j=max(j,mx);
        }
        cout<<j<<endl;

    }
    return 0;
}


Measured memory_bytes: 23728
import sys

S = input()

for i, letter in enumerate(list(S)):
    if letter == 'U' or letter == 'D':
        continue
    
    if ((i+1) % 2 == 0 and letter == 'R') or ((i+1) % 2 == 1 and letter == 'L'):
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, mx = -INF;
    int a[111111];
    cin>>n;
    rep(i, n) {
        cin>>a[i];
        chmax(mx, a[i]);
    }
    int half = (mx + 1) / 2;
    int itr = 0, best = INF;
    rep(i, n) {
        if( chmin(best, abs(half - a[i])) ) {
            itr = i;
        }
    }
    cout<<mx<<' '<<a[itr]<<endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader
import java.util.*
import kotlin.system.exitProcess

fun main() = agc031b()

@OptIn(ExperimentalStdlibApi::class)
fun agc031b() = SimpleFastIOWithToken_agc031b().exec {
    val n = readInt()
    val colors = IntArray(n) { readInt() - 1 }
    val mod = 1_000_000_007L

    val beforeAppearedIndexByColor = hashMapOf<Int, Int>()
    val patterns = LongArray(n)
    patterns[0] = 1

    for ((i, c) in colors.withIndex()) {
        if (i != 0) {
            patterns[i] = patterns[i - 1]
            beforeAppearedIndexByColor[c]
                ?.takeIf { it != -1 && it != i - 1 }
                ?.let { patterns[i] += patterns[it] }
            patterns[i] %= mod
        }
        beforeAppearedIndexByColor[c] = i
    }

    val answer = patterns.last()

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_agc031b(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_agc031b.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); exitProcess(1) } }
            .apply { start() }.join()
    }.run { kotlin.io.print(sb) }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 67196
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int INF = 0x3f3f3f3f;
int edge[15][15];
int dp[1 << 15][15];
int pres[1 << 15][15];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	rep (i, 1, m) {
		int u, v, w;
		cin >> u >> v >> w;
		edge[u - 1][v - 1] = w;
		edge[v - 1][u - 1] = w;
	}
	rep (msk, 0, (1 << n) - 1) {
		rep (u, 0, n - 1) if (!(msk >> u & 1)) {
			rep (v, 0, n - 1) if (msk >> v & 1) {
				pres[msk][u] += edge[u][v];
			}
		}
	}
	memset(dp, 0x3f, sizeof(dp));
	rep (msk, 0, (1 << n) - 1) {
		if (!(msk & 1)) continue;
		if (msk >> (n - 1) & 1) continue;
		dp[msk][0] = 0;
		rep (i, 0, n - 1) if (msk >> i & 1) {
			rep (j, 0, n - 1) if (!(msk >> j & 1)) {
				dp[msk][0] += edge[i][j];
			}
		}
	}
	rep (msk, 0, (1 << n) - 1) {
		rep (u, 0, n - 1) if (dp[msk][u] != INF) {
			int las = (1 << n) - 1 - msk;
			for (int nmsk = las; nmsk; nmsk = (nmsk - 1) & las) {
				int ndp = 0, rmsk = msk | nmsk;
				rep (i, 0, n - 1) if (!(rmsk >> i & 1)) ndp += pres[nmsk][i];
				rep (v, 0, n - 1) if ((nmsk >> v & 1) && edge[u][v]) {
					dp[rmsk][v] = min(dp[rmsk][v], dp[msk][u] - edge[u][v] + ndp);
				}
			}
		}
	}
	int res = INF;
	rep (msk, 0, (1 << n) - 1) {
		res = min(res, dp[msk][n - 1]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4096
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 07, 2020 9:19 PM
 *    Problem Name  : C - Welcome to AtCoder
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc151/tasks/abc151_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;

    bool vis[n+1] = {};
    ll ac=0, wa=0;
    vector<ll>w(n,0);
    for(ll i=0; i<m; i++) {
        ll x;
        string s;
        cin >> x >> s;

        if(s == "AC") {
            if(vis[x-1] == false){
                ac++;
                vis[x-1] = true;
                wa += w[x-1];

            }
        }
        else  w[x-1]++;
    
    }
    if(ac == 0) cout << "0" << " " << "0" << endl;
    else cout << ac << " " << wa << endl;

    return 0 ;
}


Measured memory_bytes: 4012
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),A=in(),B=in();
	for(int i=A;i<=B;i++){
		if(!(i%N)){
			out("OK");
			return 0;
		}
	}

	out("NG");
	return 0;
}


Measured memory_bytes: 3608
from collections import deque

H,W = map(int, input().split())
Ss = [str(input()) for _ in range(H)]

yoko = [[0 for _ in range(W)] for _ in range(H)]
tate = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if Ss[i][j] == "#" or yoko[i][j] != 0:
            continue
        else:
            paths = [[i,j]]
            temp = 1
            for k in range(j+1, W):
                if Ss[i][k] == ".":
                    temp+=1
                    paths.append([i,k])
                else:
                    break
            for path in paths:
                yoko[path[0]][path[1]] = temp

for i in range(H):
    for j in range(W):
        if Ss[i][j] == "#" or tate[i][j] != 0:
            continue
        else:
            paths = [[i,j]]
            temp = 1
            for k in range(i+1, H):
                if Ss[k][j] == ".":
                    temp+=1
                    paths.append([k,j])
                else:
                    break
            for path in paths:
                tate[path[0]][path[1]] = temp

answer = 0
for i in range(H):
    for j in range(W):
        if answer < tate[i][j]+yoko[i][j]-1:
            answer = tate[i][j]+yoko[i][j]-1
print(answer)

Measured memory_bytes: 156428
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  string c1, c2;
  cin >> c1;
  cin >> c2;

  if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]) cout << "YES" << endl;
  else cout <<"NO" << endl;  
}


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

int n, t;
int c[3000], v[3000];
int dp[3001][3001];
int dq[3001][3001];
int main() {
  cin >> n >> t;
  --t;
  for (int i = 0; i < n; ++i) {
    cin >> c[i] >> v[i];
  }
  
  for (int i = 1; i <= n; ++i) {
    for (int k = 0; k <= t; ++k) {
      int pk = k - c[i - 1];
      dp[i][k] = max(dp[i][k], dp[i - 1][k]);
      if (pk >= 0) dp[i][k] = max(dp[i][k], dp[i - 1][pk] + v[i - 1]);
    }
  }
  
  for (int i = n - 1; i >= 0; --i) {
    for (int k = 0; k <= t; ++k) {
      int pk = k - c[i];
      dq[i][k] = max(dq[i][k], dq[i + 1][k]);
      if (pk >= 0) dq[i][k] = max(dq[i][k], dq[i + 1][pk] + v[i]);
    }
  }
  
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    for (int k = 0; k <= t; ++k) {
      mx = max(mx, dp[i][k] + dq[i + 1][t - k] + v[i]);
    }
  }
  cout << mx << endl;
}

Measured memory_bytes: 70656
void main() {
    int s = readln.chomp.to!int;
    bool[] a = new bool[1000001];
    int cnt = 1;
    while (!a[s]) {
        a[s] = true;
        ++cnt;
        if (s % 2) s = 3 * s + 1;
        else s /= 2;
    }
    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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;
}
ll h,w;
void walk(ll &i,ll &j){
    if(i%2==0){
        j++;
        if(j==w){
            j=w-1;i++;
        }
    }
    else{
        j--;
        if(j==-1){
            j=0;i++;
        }
    }
}
int main(){
    cin >> h >>w;
    ll n;cin >> n;
    vvl g(h,vl(w));
    ll i=0,j=0;
    rep(k,n){
        ll a;cin >> a;
        rep(l,a){
            g[i][j]=k+1;
            walk(i,j);
        }
    }
    rep(i,h){
        rep(j,w){
            cout << g[i][j] <<" ";
        }
        cout <<endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cin>>a>>b;
    if(a<=b)
        swap(a,b);
    vector<ll>num;
    int cnt=1;
    for(ll i=2;i*i<=a;i++)
    {
        if(a%i==0)
        {
            num.pb(i);
            while(a%i==0) a/=i;
        }
    }
    if(a>1)
    {
       num.pb(a);
    }
    map<ll,int>mp;
    for(ll i=2;i*i<=b;i++)
    {
        if(b%i==0)
        {
            mp[i]=1;
            while(b%i==0) b/=i;
        }
    }
    if(b>1)
        mp[b]=1;
    for(auto &v:num)
    {
        if(mp[v])
            cnt++;
    }
    cout<<cnt<<'\n';





}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
string s; cin>>s;
int S[s.size()+1],L[s.size()+1];
ll cntS=0,cntL=0;
S[0] = 0;
for(int i = 1; i < s.size()+1; i++){
    if(s[i-1] == '<') {
        cntS++;
        S[i] = cntS;
    }else
    {
        cntS = 0;
        S[i] = 0;
    }//左側にある＜の数を数える
}
L[s.size()] = 0;
for(int i = s.size()-1; i >= 0; i--){
    if(s[i] == '>'){
        cntL++;
        L[i] = cntL;
    }else
    {
        cntL = 0;
        L[i] = 0;
    }    
}//右側にある＞の数を数える
ll ans = 0;
rep(i,s.size()+1){
  //  cout<<"S[i] =="<<S[i]<<" L[i]=="<<L[i]<<endl;
ans += max(S[i],L[i]);
//cout<<ans<<endl;
}//＜と＞の数が大きい方を数える

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


Measured memory_bytes: 7696
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read::<usize>();
    println!("{}", n * n - a);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define UNIQ(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

void func(std::string N){
    // cout << N << endl;
    // cout << N.at(0) << endl;
    // cout << N.length() << endl;
    ll len= N.length();

    ll sum = 0;
    rep(i, len) {
        // cout << N.at(i) - '0' << endl;
        sum += (N.at(i) - '0');
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(){
    // cout << fixed << setprecision(5);

    std::string N;
    std::cin >> N;
    func(N);
    return 0;
}


Measured memory_bytes: 3932
fn answer() {
    fn read<T: std::str::FromStr>() -> T {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.trim().parse().ok().unwrap()
    }
    fn read_vec<T: std::str::FromStr>() -> Vec<T> {
        read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
    }

    fn primes(max:i64) -> Vec<i64>{
        let mut k = vec![2,3];
        for c in 1..(max/6)+1 {
            let a = c*6-1;
            let b = c*6+1;
            let mut af = true;
            let mut bf = true;
            for d in 0..k.len() {
                if k[d]^2 > b {
                    break;
                }
                if af && (a % k[d]) == 0 {
                    af = false;
                }
                if bf && (b % k[d]) == 0 {
                    bf = false;
                }
            }
            if af { k.append(&mut vec![a]) }
            if bf { k.append(&mut vec![b]) }
        }
        return k
    }
    fn invmod(p:i64, g:i64) -> i64 {
        fn euclidean(px:i64, py:i64, pgcd:i64, x:i64, y:i64, gcd:i64) -> i64 {
            match  pgcd % gcd {
                0 => x,
                _ => {
                    let d = pgcd /gcd;
                    let m = pgcd % gcd;
                    return euclidean(x, y, gcd, px-(d*x), py-(d*y), m)
                }
            }
        }
        return (euclidean(1,0,p,0,1,g)+g)%g;
    }
    fn multiper(n:i64, m:i64, c:i64) -> (i64, i64) {
        match m % n {
            0 => multiper(n, m/n, c+1),
            _ => (m,c)
        }
    }

    fn comb(n:i64, k:i64, p:i64)-> i64 {
        let mut ans = 1;
        for c in 1..k+1 {
            ans = remain(multi(ans , n-c+1), p);
            ans = remain(multi(ans, invmod(c, p)), p);
        }
        return ans
    }

    fn fac(l:Vec<i64>, m:i64) -> Vec<i64> {
        match l.len() {
            0 => vec![1],
            _ => {
                let mut ll = l;
                let a = match multiper(ll.pop().unwrap(), m, 0) {
                    (1, 0) => vec![],
                    (1, y) => vec![y],
                    (x, 0) => {
                        return fac(ll, m)
                    }
                    (x, y) => {
                        let mut k = vec![y];
                        k.append(&mut fac(ll,x));
                        return k
                    }
                };
                return a;
            }
        }
    }

    fn multi(a:i64, b:i64) -> i64 {a*b}
    fn remain(a:i64, b:i64) -> i64 {a%b}
    fn main() {
        let max = 1000000007;
        let nk = read_vec::<i64>();
        let n:i64 = nk[0];
        let m:i64 = nk[1];
        let primes = primes((m as f64).sqrt() as i64);

        let f = fac(primes, m);
        let mut a = 1;
        for c in f {
            a = remain(multi(a,comb(n+c-1, c, max)),max)
        }
        println!("{}", a);
    }
    main()
}

fn main() {
	answer()
}

Measured memory_bytes: 4860