akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

ll dp[10001][1001] = {0};

int main()
{
    string S;

    cin >> S;

    int ansLen = 0;

    set<char> st{'A', 'G', 'C', 'T'};

    for (int i = 0; i < S.size(); i++)
    {
        int tmpLen = 0;
        for (int j = i; j < S.size(); j++)
        {
            if (st.count(S[j]) == 0)
            {
                tmpLen = j - i;
                ansLen = max(ansLen, tmpLen);
                break;
            }

            if (j == S.size() - 1)
            {
                ansLen = max(ansLen, (int)S.size() - i);
                break;
            }
        }
    }

    cout << ansLen << endl;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

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


*/


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int main() 
{
    fastio();

    ll x;
    cin>>x;

    int time = 0;
    ll now = 100;
    while( 1 )
    {
        if( now >= x )
            break;
        now = now + (now/100);
        time++;
    }
    cout<<time,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main(){

  int N;
  cin >> N;
  string S;
  map<string,int> card;
  for(int i=0; i<N; i++){
    cin >> S;
    card[S]++;
  }

  int M;
  cin >> M;
  for(int i=0; i<M; i++){
    cin >> S;
    card[S]--;
  }
  
  int max_card = 0;
  for(auto x:card){
    if(max_card < x.second){
      max_card = x.second;
    }
  }

  cout << max_card << endl;
  
}

Measured memory_bytes: 3576
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner scanner = new Scanner(System.in);   
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int ans;
    
    if(a == b && a == c){
      ans = 1;
    }else if(a != b && a != c && b != c){
      ans = 3;
    }else{
      ans = 2;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
H, W = map(int, input().split())
while True:
 if H == 0 and W == 0:
  break
 for h in range(H):
  if h%2 == 0:
   print("#."*(W//2) + "#"*(W%2))
  else:
   print(".#"*(W//2) + "."*(W%2))
 print()

 H, W = map(int, input().split())

Measured memory_bytes: 7644
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ret = 0;
        // 差が偶数
        if((b-a)%2==0){
            ret = (b-a)/2;
        }
        // 差が奇数
        else{
            ret = a-1 < n-b ? (a-1)+1+(b-a-1)/2 : (n-b)+1+(b-a-1)/2;
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 23252
#include<stdio.h>
#define N 100000

int RoundOut(int x);

main(){
  int i, n, x;

  x = N;
  scanf("%d", &n);

  for(i=0; i<n; i++){
    x *= 1.05;
    x = RoundOut(x);
  }
  printf("%d\n", x);

  return 0;
}

int RoundOut(int x){
  int y;

  y = x % 1000;
  if(y > 0)
    x = (x - y) + 1000;

  return x;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	cout << (n - 2) * 180 << endl;

	return 0;
}

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

int main(void) {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	double ans = (double)W*H/2;
	int num = (W==x*2 && H==y*2) ? 1: 0;
	printf("%.10f %d\n", ans, num);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int N, Y;
    cin >> N >> Y;

    if (Y % 1000 != 0) {
	    cout << "-1 -1 -1" << endl;
    }

    string ans = "-1 -1 -1";
    for (int i = 0; i <= N; i++) {
	    // 10000円を管理
	    for (int j = 0; j <= N; j++) {
	    // 5000円を管理
	       int k = N - i - j;
	       if (0 > k) {
		       continue;
	       }

	       int sum = (10000 * i) + (5000 * j) + (1000 * k);
	       if (sum == Y) {
		       ans = to_string(i) + " " + to_string(j) + " " + to_string(k);
	       }
	    }
    }

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


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

int main(void) {
	
	int A, B, K;
	cin >> A >> B >> K;
	
	int c = 0;
	
	while(c<K) {
		if(A+c<=B) {
			cout << A+c << endl;
			c++;
		} else {
			return 0;
		}
	};
	int lb = A+c;
	c=K-1;
	while(c>=0) {
		if(lb<=B-c) {
			cout << B-c << endl;
		}
		c--;
	}
	
	return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
    [n, m] <- map read . words <$> getLine
    xs <- map read . words <$> getLine
    let xs' = reverse . sort $ xs
        dxs = zipWith (-) xs' (tail xs')
        dxs' = reverse . sort $ dxs
        width = head xs' - last xs'
    print $ width - sum (take (n - 1) dxs')

Measured memory_bytes: 32764
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int a[5005],b[5005];
signed main()
{
	int n,k;
	cin>>n>>k;
	for (int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	for (int i=0;i<n;i++){
		cin>>b[i];
	}
	int ans=-1e15;
	for (int i=0;i<n;i++){
		vector<int>v;
		int j=a[i]; v.pb(b[j]);
		while (j!=i){
			j=a[j];
			v.pb(v[sz(v)-1]+b[j]);
		}
		int maxe=-1e15;
		if (v[sz(v)-1]<=0 || sz(v)>=k){
			for (int j=0;j<sz(v) && j<k;j++){
				maxe=max(maxe,v[j]);
			}
		}
		else {
			int tim=k/sz(v)*v[sz(v)-1];
			int siz=k%sz(v)-1;
			for (int j=0;j<sz(v);j++){
				if (j<=siz)
					maxe=max(maxe,tim+v[j]);
				else
					maxe=max(maxe,tim-v[sz(v)-1]+v[j]);
			}
	//		cout<<tim<<' '<<siz<<' ';
		}
	//	cout<<i<<' '<<maxe<<'\n';
	//	for (int j=0;j<sz(v);j++)  cout<<v[j]<<' ';cout<<'\n';
		ans=max(ans,maxe);
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}
// power with modulo
ll powMod(ll b, ll e, const ll m = MOD)
{
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
// factrial with modulo
ll factMod(const ll n, const ll m = MOD)
{
    ll x = 1;
    for (ll i = 1; i <= n; ++i)
        x = (x * i) % m;
    return x;
}
class Combi
{
private:
    const int n_, mod_;
    vector<ll> fac_, finv_;

public:
    Combi(int n = 10000, int mod = MOD);
    ll count(int n, int k);
};
Combi::Combi(int n, int mod) : n_(n), mod_(mod)
{
    fac_.resize(n_);
    finv_.resize(n_);
    vector<ll> inv(n_);

    fac_[0] = fac_[1] = 1;
    finv_[0] = finv_[1] = 1;
    inv[1] = 1;

    for (int i = 2; i < n_; i++)
    {
        fac_[i] = fac_[i - 1] * i % mod_;
        inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
        finv_[i] = finv_[i - 1] * inv[i] % mod_;
    }
}
ll Combi::count(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac_[n] * (finv_[k] * finv_[n - k] % mod_) % mod_;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

// *****************************************************************************

void solve()
{
    ll n;
    cin >> n;

    ll ans = 0;

    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
        if (i % 2)
            ans += a[i];
        else
            ans -= a[i];
    }

    for (int i = 0; i < n; i++)
    {
        ans *= -1;
        if (i > 0)
            ans += 2 * a[i - 1];

        cout << ans << (i < n - 1 ? " " : "\n");
    }
}

// *****************************************************************************

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

    solve();
}


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

int main() {
  string s;
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3588
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int[] cards=new int[N];
		int sum=0;
		for(int i=0; i<N; i++) {
			cards[i]=sc.nextInt();
			sum+=cards[i];
		}
		long[][][] dp=new long[N+1][sum+1][N+1];	//dp[今までに見たカードの枚数][部分和][部分和が達成できる枚数]
		//部分和が達成できる枚数とは 7が[1,2,4]でつくれるなら 3。 7が[1,1,1,1,1,1,1]で作れるなら7。
		//dp[i][j][k]にはいっているのは,今までに見たカードの枚数i枚の中で、部分和jをk枚で達成できる場合の数である
		for(int i=0; i<=N; i++) {
			for(int j=0; j<=sum; j++) {
				for(int k=0; k<=N; k++) {
					dp[i][j][k]=0;		//クソみたいな3重ループから繰り出される初期化
				}
			}
		}
		dp[0][0][0]=1;

		for(int i=0; i<N; i++) {
			for(int j=0; j<sum; j++) {
				for(int k=0; k<=i; k++) {
					if(dp[i][j][k]>0) {
						dp[i+1][j][k]+=dp[i][j][k];	//いま見ているカードを使わない 総和はそのまま 部分和を達成する枚数もそのまま
						dp[i+1][j+cards[i]][k+1]+=dp[i][j][k];	//いま見ているカードを使う 総和は増える　部分和を達成する枚数も増える
					}
				}
			}
		}
		long SOUWA=0;
		for(int i=1; i<=Math.min((sum/A),N); i++) {
			SOUWA+=dp[N][i*A][i];
		}
		pl(SOUWA);
		sc.close();
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 87352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 1000000007;
long long factorial(long long a,long long m){
  long long ret=1;
  for (long long i = 1; i <= a; i++) {
    ret*=(i%m);
    ret%=m;
  }
  return ret;
}
long long partial_factorial(long long a,long long n,long long m){
  long long ret=1;
  for (long long i = 0; i < n; i++) {
    ret*=(a-i)%m;
    ret%=m;
  }
  return ret;
}
const long long max_cache=1000000;
long long cache_fact[max_cache],cache_inv_fact[max_cache];
long long combination_cached(long long n,long long r,long long m){
  if(r<0||r>n)return 0;
  if(r==0||r==n)return 1;
  static bool cached=false;
  if(cached==false){
    cached=true;
    cache_inv_fact[1]=1;
    for (long long i = 2; i < max_cache; i++) {
      cache_inv_fact[i]=(m-m/i)*cache_inv_fact[m%i]%m;
    }
    for (long long i = 2; i < max_cache; i++){
      cache_inv_fact[i]=cache_inv_fact[i]*cache_inv_fact[i-1]%m;
    }
    cache_fact[0]=1;
    for (long long i = 1; i < max_cache; i++) {
      cache_fact[i]=cache_fact[i-1]*i%m;
    }
  }
  r=min(r,n-r);
  return cache_fact[n]*cache_inv_fact[r]%m*cache_inv_fact[n-r]%m;
}
void solve(long long X, long long Y){
  ll a = 2*Y-X;
  if(a%3!=0){
    cout<<0<<endl;
    return;
  }
  a/=3;
  ll N=Y-a;
  cout<<combination_cached(N,a,MOD)<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
#include<string.h>

int main(){
	char s1[100];
	char s2[100];
	char s3[100];
	int len;
	int flag=0;
	char tmp;
	int i;
	char *p;
	
	scanf("%s",s1);
	strcpy(s3,s1);
	len=strlen(s3);
	scanf("%s",s2);
	
	while(1){       //  ????????????????????°??¶????????¢
		tmp=s3[0];
		for(i=1;i<len;i++){
			s3[i-1]=s3[i];
		}
		s3[len-1]=tmp;
		if((p=strstr(s3,s2))!=NULL){
			flag=1;
			break;
		}
		else if(strcmp(s1,s3)==0){
			break;
		}
	}
	
	if(flag==1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 540
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;

/** 幾何ライブラリ **/
#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-11;

typedef double D;
typedef complex<D> P; // Point

struct L { // Line
	P a, b;
	L(){}
	L(P aa, P bb) : a(aa), b(bb){}
};

// 共役複素数 conj(a);

// 符号
int sig(D a, D b=0) { return a < b - EPS ? -1 : (a > b + EPS ? 1 : 0); }

// 内積
D dot(P a, P b) { return (conj(a)*b).real(); }

// 外積
D cross(P a, P b) { return (conj(a)*b).imag(); }

// 多角形
typedef vector<P> G; // 反時計回りに追加

D area(G g)
{
	D res = 0.0;
	for (int i=0; i<g.size(); i++) {
		res += cross(g[i], g[(i+1)%g.size()]);
	}
	return res/2;
}


/** Problem1100 : Area of Polygons **/
int main()
{
	int N;
	int cnt=1;
	while (cin>>N, N) {
		G g;
		rep(i, N) {
			P p;
			cin>>p.X>>p.Y;
			g.push_back(p);
		}
		
		cout << fixed << setprecision(1);
		cout << cnt++ << " " << abs(area(g)) << endl;
	}
}

Measured memory_bytes: 1304
n = gets.to_i
t, a = gets.strip.split.map(&:to_i)
h = gets.strip.split.map(&:to_i)

abs_arr = []

n.times do |i|
    abs_arr << ((t - h[i] * 0.006) - a).abs
end

puts abs_arr.index(abs_arr.min) + 1

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

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

inline bool check(int ux, int uy, int x, int y) {
  return (0 <= x and x < ux and 0 <= y and y < uy);
}

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll n, k;
string s;

int main() {
  cin >> s;
  cin >> k;

  n = s.size();

  for (int i = 0; i < n; ++i) {
    if (s[i] == 'a' and i < n - 1) continue;
    
    if (ll('z' - s[i]) + 1 <= k) {
      k -= (int('z' - s[i]) + 1);
      s[i] = 'a';
      if (i == n - 1) {
        k %= 26;
        rep(j,k) {
          if (s[i] == 'z') {
            s[i] = 'a';
          }
          else {
            s[i] = char(s[i] + 1);
          }
        }
      }
    }
    else {
      if (i == n - 1) {
        k %= 26;
        rep(j,k) {
          if (s[i] == 'z') {
            s[i] = 'a';
          }
          else {
            s[i] = char(s[i] + 1);
          }
        }
      }
    }
  }
 
  cout << s << endl; 
  
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

void pre(){

}

void solve(){
  ll n,k; cin>>n>>k;
  ll a[n+1];
  rep(i,n) cin>>a[i+1];
  unordered_map <ll,ll> m1;
  m1.reserve(1024);
  m1.max_load_factor(0.24);
  unordered_map <ll,ll> m2;
  m2.reserve(1024);
  m2.max_load_factor(0.24);

  int temp=1,i=1;

  while(1){
    if(m2[a[i]]==0){
      m2[a[i]]=temp;
      m1[temp]=a[i];
      i=a[i];
      temp++;
    }
    else{
      ll diff=m2[a[i]]-1;
      if(k<=diff){
        cout<<m1[k]<<"\n";
        break;
      }
      else{
        k=k-diff;
        ll prev=temp-m2[a[i]];
        ll pos=m2[a[i]];
        ll rem=k%prev;
        if(rem==0) rem=prev;
        cout<<m1[pos+rem-1]<<"\n";
        break;
      }
    }
  }
}

int main(){
  #ifndef ONLINE_JUDGE
    // freopen("in.txt","r",stdin);
  #endif
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


Measured memory_bytes: 40700
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int x,y,z;
  cin>>x>>y>>z;
  x-=z;
  cout<<x/(y+z)<<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
    int i,j;
    int a[10000];
    for(i=0;i<10000;i++){
        scanf("%d",&a[i]);
        if(a[i]==0){
            break;
        }
    }
    j=i;
    for(i=0;i<j;i++){
        printf("Case %d: %d\n",i+1,a[i]);
    }
    return 0;
}


Measured memory_bytes: 1952
a=[int(i) for i in input().split()]
if len(set(a))==1 and a[0]%2==0:
  print(-1)
  exit()
n=0
while all(i%2==0 for i in a):
  n+=1
  a=[(a[1]+a[2])/2,(a[0]+a[2])/2,(a[0]+a[1])/2]
print(n)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,c,n,m,k,x,y=0,ans=1;
    string str,s="",t,u;


    cin>>x>>y;
    if(x%y==0){
        cout<<-1;
        return 0;
    }
    Int cnt=1;
    while(x<=1000000000000000000){
        if((cnt*x)%y!=0){
            cout<<(cnt*x);
            return 0;
        }else{
            cnt++;
        }
    }
    cout<<-1;





    cout<<endl;
    return 0;
}




Measured memory_bytes: 256
def count(n,x):
    n_1_element = 2**(n+1)-3
    if x == 0:
        return 0
    if n == 0:
        return 1
    if (x <= n_1_element+1):
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-n_1_element-2)

N, X = map(int,input().split())
a = count(N,X)
print(a)

Measured memory_bytes: 3060
s=input()
l=len(s)
a=[[0,0,0] for i in range(l)]
num=1
for i in range(l):
    if s[i]=='A':
        a[i][0]=a[i-1][0]+1*num
        a[i][1]=a[i-1][1]
        a[i][2]=a[i-1][2]
    if s[i]=='B':
        a[i][0]=a[i-1][0]
        a[i][1]=a[i-1][1]+a[i-1][0]
        a[i][2]=a[i-1][2]
    if s[i]=='C':
        a[i][0]=a[i-1][0]
        a[i][1]=a[i-1][1]
        a[i][2]=a[i-1][2]+a[i-1][1]
    if s[i]=='?':
        
        a[i][0]=a[i-1][0]*3+1*num
        a[i][1]=a[i-1][1]*3+a[i-1][0]
        a[i][2]=a[i-1][2]*3+a[i-1][1]
        
        num=(num*3)%1000000007


    a[i][0]=a[i][0]%1000000007
    a[i][1]=a[i][1]%1000000007
    a[i][2]=a[i][2]%1000000007
print(a[-1][2])

Measured memory_bytes: 22860
#include<stdio.h>
#include<string.h>
#include<ctype.h>


int main(){

  char w[10], t[1000];
  int i, n=0;

  scanf("%s", w);
  for(i=0;i<strlen(w);i++) w[i]=tolower(w[i]);

  while(1){
    scanf("%s", t);
    if(strcmp(t, "END_OF_TEXT")==0) break;
    for(i=0;i<strlen(t);i++) t[i]=tolower(t[i]);
    if(strcmp(w, t)==0) n++;
  }

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

  return 0;
}

Measured memory_bytes: 552
#include<stdio.h>
#define MAX 100000

 struct Node{
  int parent;
  int left;
  int right;
};
 
struct Node Three[MAX];
 
int getDepth(int num){
  int depth = 0;
 
  for(depth = 0; Three[num].parent != -1; depth++){
    num = Three[num].parent;
  }
return depth;
}
 
int main(){
  int i,j,n;
  int num,deg,child,k = 0;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    Three[i].parent = -1;
    Three[i].left = -1;
    Three[i].right = -1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d",&num,&deg);
 
    for(j=0;j<deg;j++){
      scanf("%d",&child);
      if(j==0) Three[num].left=child;
      else Three[k].right=child;
      k=child;
      Three[child].parent=num;
    }
  }
 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d",i,Three[i].parent,getDepth(i));
 
    if(getDepth(i) == 0){
      printf(", root, [");
    }
    else if(Three[i].left == -1){
      printf(", leaf, [");
    }
    else{
      printf(", internal node, [");
    }
 
    j=Three[i].left;
 
    while(j != -1){
      printf("%d", j);
      j = Three[j].right;
 
      if(j != -1){
    printf(", ");
      }
    }
    printf("]\n");
  }
 
  return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  set<char> s;
  string t;
  cin >> t;
  for(int i = 0; i < t.size(); i++){
    s.insert(t.at(i));
  }
  int cnt = s.size();
  char c;
  bool flag = true;
  for(int i = 0; i < 26; i++){
    c = 'a' + i;
    s.insert(c);
    if(s.size() > cnt) break;
    if(i == 25) flag = false;
  }
  if(flag) cout << c<<endl;
  else cout << "None" <<endl;
}
  
  
  

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;
int main(){
//	FILE* fp_in = freopen("2012_input.txt", "r", stdin);
//	FILE* fp_out = freopen("result.txt", "w", stdout);

	int x,sum;
	int e;
	while(1) {
		int max = 1000000;
		cin >>e ;
		if(e == 0) break;
		for(int i=0;i*i*i<=e;i++){
			for(int j=0;j*j<=e-i*i*i;j++){
				x = e-i*i*i-j*j;
				sum = x+i+j;
				if (sum<max) max =sum;
			}
		}
		cout << max <<endl;
	}
//	fclose(fp_in);
//	fclose(fp_out);

		return 0;
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N, W;
    scanf("%d%d",&N,&W);

    unordered_map<long, long> dp; dp[0] = 0;
    times(N, i) {
        int w, v;
        scanf("%d%d",&w,&v);

        unordered_map<long, long> dq = dp;
        for(auto& p: dp) {
            long w0, v0; tie(w0, v0) = p;
            dq[w0 + w] = max(dq[w0 + w], v0 + v);
        }
        dp = dq;
        if(debug) for(auto& p: dp) cout << "[" << p.first sp << p.second << "] ";
    }

    long ans = 0;
    for(auto& p: dp) if(p.first <= W) ans = max(ans, p.second);

    cout << ans ln;

    return 0;
}


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


int main() {
    int K, S;
    cin >> K >> S;

    int num = 0;
    for (int x = 0; x <= K && x <= S; x++) {
        for (int y = 0; y <= K && x + y <= S; y++) {
            if (S - x - y <= K) num++;
        }
    }

    cout << num << endl;
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 1*1000*1000+10;
int n, mn, bmn, cur;
pair<int, int> p[maxn];
string s[maxn];
char c[maxn];
vector<char> vec;
vector<pair<int, int>> neg, pos, idk;

bool cpos(pair<int, int> &a, pair<int, int> &b)
{
    return a.first < b.first || (a.first == b.first && a.second - a.first < b.second - b.first);
}

bool cneg(pair<int, int> &a, pair<int, int> &b)
{
    return a.second > b.second || (a.second == b.second && a.second - a.first < b.second - b.first);
}

int main()
{
    ios::sync_with_stdio(0);
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", c);
        s[i] = c;
        vec.clear();
        for (auto &w : s[i])
        {
            if (w == '(')
                p[i].second++;
            else
            {
                if (p[i].second > 0)
                    p[i].second--;
                else
                    p[i].first++;
            }
        }
        if (p[i].second - p[i].first < 0)
            neg.pb(p[i]);
        else if (p[i].second == p[i].first)
            mn = min(mn, -p[i].first);
        else
            pos.pb(p[i]);
    }
    sort(all(neg), cneg);
    sort(all(pos), cpos);
    for (auto &w : neg)
        idk.pb(w);
    for (auto &w : pos)
        idk.pb(w);
    for (auto &w : idk)
    {
        cur -= w.first;
        mn = min(mn, cur);
        cur += w.second;
        bmn = min(bmn, cur);
    }
    if (cur != 0)
    {
        cout << "No";
        return 0;
    }
    if (bmn <= mn)
        cout << "Yes";
    else
        cout << "No";
	return 0;
}


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

using namespace std;
using ll = long long;

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> T(N);
  for (int i = 0; i < N; i++)
    cin >> T[i];
  ll l = T[0];
  for (int i = 1; i < N; i++)
    l = lcm(l, T[i]);
  cout << l << '\n';
  return 0;
}


Measured memory_bytes: 256
r, c = map(int, input().split())
a = []
for _ in range(r):
    a.append(list(map(int, input().split())))
for row in a:
    row.append(sum(row))
s = []
for column in range(c + 1):
    tmp = 0
    for row in range(r):
        tmp += a[row][column]
    s.append(tmp)
a.append(s)
for row in a:
    count = 0
    for i in row:
        if count != c:
            print('{} '.format(i), end = '')
        else:
            print('{}'.format(i), end = '')
        count += 1
    print('')



Measured memory_bytes: 6236
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;

string g[10];


bool ok(const vector<int>&ro,const vector<int>&col,int r,int c,int k)
{
    char gg[10][10];

     for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            gg[i][j] = g[i][j];

    for(int x:ro)
    {
        for(int i=0;i<c;i++)
            gg[x][i] = '.';
    }

    for(int y:col)
    {
        for(int i=0;i<r;i++)
            gg[i][y] = '.';
    }

    int cnt = 0;

    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            if(gg[i][j]=='#')
                cnt++;

    if(cnt==k) return true;
    return false;
}

int main()
{
    optimizeIO();

    int r,c,k;
    cin>>r>>c>>k;

    for(int i=0;i<r;i++)
        cin>>g[i];

    int ans = 0;

    for(int i=0;i<(1<<r);i++)
    {
        for(int j=0;j<(1<<c);j++)
        {

            char gg[10][10];

            for(int ii=0;ii<r;ii++)
                for(int jj=0;jj<c;jj++)
                    gg[ii][jj] = g[ii][jj];

            for(int ii=0;ii<r;ii++)
            {
                for(int jj=0;jj<c;jj++)
                {
                    if(i&(1<<ii))
                        gg[ii][jj] = '.';
                    if(j&(1<<jj))
                        gg[ii][jj] = '.';
                }
            }

            int cnt = 0;

            for(int ii=0;ii<r;ii++)
                for(int jj=0;jj<c;jj++)
                    if(gg[ii][jj]=='#')
                        cnt++;

            if(cnt==k)
                ans++;
        }
    }

    cout<<ans<<endl;


    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 3656
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N

for i in range(N):
    x[i],y[i],h[i] = map(int,(input().split()))

for i in range(101):
    for j in range(101):
        
        for k in range(N):
            if h[k] == 0:
                continue
            H = abs(i-x[k]) + abs(j-y[k]) + h[k]
            break

        for k in range(N):
            if h[k] == 0:
                continue
            if H != abs(i-x[k]) + abs(j-y[k]) + h[k]:
                break
        else:
            for k in range(N):
                if h[k] != max( H - abs(i-x[k]) - abs(j-y[k]) ,  0):
                    break
            else:
                print(i,j,H)

Measured memory_bytes: 45424
import java.util.*;

public class Main {
    //K-th Common Divisor
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(a, b, k));
        sc.close();
    }

    public static int helper(int a, int b, int k) {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    }
}


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

using namespace std;

int main() {
	int n,c=0;
	int w[101];
	cin >> n;
	for(int i=0;i<n;i++)cin >> w[i];
	int a=0,b=0;
	int ans=20000;
	for(int i=0;i<n;i++){
		a+=w[i];
		for(int j=0;j<n;j++){
		if(i<j) b+=w[j];
		}
		ans=min(ans,abs(a-b));
		b=0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,q,c,ans,sz;
multiset <long long> s;
int main(){
	cin>>q;
	cin>>c>>a>>b;
	s.insert(a),ans=b,sz++;
	set<long long>::iterator f=s.begin();
	for(int i=0;i<q-1;i++){
		cin>>c;
		if(c==1){
			cin>>a>>b;
			ans+=b;
			if(a>=*f && sz%2==0){
				s.insert(a);
				f++;
				ans=ans+a-*f;
			}
			else if(a<*f && sz%2==1){
				s.insert(a);
				ans=ans+*f-a;
				f--;
			}
			else if(a<*f && sz%2==0){
				s.insert(a);
				ans=ans+*f-a;
			}
			else {
				ans=ans+a-*f;
				s.insert(a);
			}
			sz++;
		}
		else{
			cout<<*f<<" "<<ans<<'\n';
		}
//		cout<<*f<<" "<<ans<<endl;
	}
}

Measured memory_bytes: 9600
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n, min,loop;
	int x[12][13];
	int y[13];
	int i, j, k;
	bool flag = true;
	bool first = false;
	vector <long long int> e;
	cin >> n >> m >> l;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m + 1; j++) {
			cin >> x[i][j];
		}
	}
	for (i = 0; i < n; i++) {
		e.push_back(1);
	}
	min = 0;
	for (i = 0; i < n; i++) {
		min += x[i][0];
	}
	for (; e[0] > -1;) {
		for (j = 0; j <= m; j++) {
			y[j] = 0;
		}
		for (i = 0; i < n; i++) {
			if (e[i] == 1) {
				for (j = 0; j <= m; j++) {
					y[j] += x[i][j];
				}
			}
		}
		for (i = 1; i <= m; i++) {
			if (y[i] < l)flag = false;
		}
		if (flag && y[0] <= min) min = y[0];
		else if (first == false) {
			min = -1;
			break;
		}
		first = true;
		flag = true;
		for (i = 0; i < n; i++) {
			
			if (e[e.size() - 1] == 0)e.pop_back();
			else break;
			if (e.size() == 0)break;
		}
		if (e.size() == 0)break;
		e[e.size() - 1]--;
		for (i = 0; e.size() < n; i++) {
			e.push_back(1);
		}
	}
	cout << min << endl;
		/*if(flag)cout << "Yes" << endl;
			else cout << "No" << endl;*/
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> sa(n+1, 0), sb(m+1, 0);
  rep(i, n){
    int in;
    cin >> in;
    sa.at(i+1) = sa.at(i) + in;
  }
  rep(i, m){
    int in;
    cin >> in;
    sb.at(i+1) = sb.at(i) + in;
  }

  int ans = 0;
  rep(i, n+1){
    ll t = sa.at(i);
    if(t > (ll)k) continue;
    int nt = k - t;
    auto itr = upper_bound(sb.begin(), sb.end(), nt);
    int j = itr - sb.begin();
    j--;
    ans = max(ans, i+j);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6424
h, w=map(int, input().split())
s=['.'*(w+2)]+['.'+input()+'.' for _ in range(h)]+['.'*(w+2)]
ans='Yes'
for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j]=='#':
      if '#' not in {s[i-1][j], s[i+1][j], s[i][j-1], s[i][j+1]}:
        ans='No'
        break
        break
print(ans)

Measured memory_bytes: 3064
function equal(a, b) {
    var aP = Object.getOwnPropertyNames(a);
    var bP = Object.getOwnPropertyNames(b);
    if (aP.length != bP.length)
        return false;
    for (var i = 0; i < aP.length; i++)
        if (a[aP[i]] !== b[aP[i]])
            return false;
    return true;
}
function pi(text) {
    return parseInt(text, 10);
}
function main(input) {
    var tmp = input.split(" ").map(_ => pi(_));
    var tmp2 = tmp[1] - tmp[0];
    console.log(tmp2 * (tmp2 + 1) / 2 - tmp[1]);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <cstdio>
#include <math.h>

using namespace std;

long long ans(long long a, long long b) {
  if (a == b) {
    return 2*b-2;
  } else {
    double n2 = a*b*1.0;
    double n = sqrt(n2);
    //printf("%lf\n", n);
    long long N = (long long int)n;
    //printf("%d\n", N);
    if (n2 == N*N) {
      return 2*N-3;
    } else {
      if (N*(N+1) >= a*b) {
	return 2*N-2;
      } else {
	return 2*N-1;
      }
    }
  }
}

    

int main() {
  int q;
  int i;
  long long a[100], b[100];
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%lld %lld", &a[i], &b[i]);
  }
  for (i = 0; i < q; i++) {
    printf("%lld\n", ans(a[i], b[i]));
  }
  return 0;
}
  
    

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int a[100005], b[100005], c[100005];

int main()
{
    int n;
    cin >> n;
    for(int i = 1;i <= n; ++i)
      cin >> a[i] >> b[i] >> c[i];
    for(int i = 1;i <= n; ++i)
    {
        a[i] += max(b[i-1],c[i-1]);
        b[i] += max(a[i-1],c[i-1]);
        c[i] += max(a[i-1],b[i-1]);
    }
    cout << max(a[n],max(b[n],c[n]));
    return 0;
}


Measured memory_bytes: 4744
import java.io.*;

public class Main{
    public static void main(String[]args)throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int[][] matrix = new int[n][m];
        int[] vector = new int[m];
        int[] result = new int[n];

        //??????????????¨???????????????
        for(int i=0; i<n; i++){
            String[] str2 = br.readLine().split(" ");
            for(int k=0; k<m; k++){
                matrix[i][k] = Integer.parseInt(str2[k]);
            }
        }
        for(int i=0; i<m; i++){
            vector[i] = Integer.parseInt(br.readLine());
        }

        //???????????? x ??????
        for(int i=0; i<n; i++){
            for(int k=0; k<m; k++){
                result[i] += matrix[i][k] * vector[k];
            }
        }

        //??????
        for(int i=0; i<n; i++){
            System.out.println(result[i]);
        }

    }
}

Measured memory_bytes: 27708
import java.util.*;
public class Main{

     public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        int temp=y;
        if(y%2==0 && y>=(x*2) && y<=x*4)
        {
            
                  System.out.print("Yes");
        }
        else
      System.out.print("No");   
     }
}

Measured memory_bytes: 35716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n;
			if((n = Integer.parseInt(br.readLine())) == 0)
				break;

			String[] pointsStr = br.readLine().split(" ");
			int[] points = new int[n];
			for(int i = 0;i < n;i++){
				points[i] = Integer.parseInt(pointsStr[i]);
			}

			int sum = 0;
			for(int point : points){
				sum += point;
			}
			double mean = (new Double(sum)) / n;
			double disp = 0;
			for(int point : points){
				disp += (point - mean) * (point - mean);
			}
			disp /= n;
			System.out.printf("%.8f%n", Math.sqrt(disp));
		}
	}

}

Measured memory_bytes: 19304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int x;
int main() {
 cin>>x;
if(x==3 || x==5 || x==7) cout << "YES" << endl;
else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

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

  long i=0;
  long tmph = h;
  while(true){
    if(tmph == 1)
      break;
    else{
      tmph = tmph/2;
      i++;
    }
  }

  long j;
  long result=0;
  for(j=0;j<i+1;j++){
    result = result + pow(2,j);
  }

  cout << result << endl;
}

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

int main() {
    int num[3];
    int A, B, C, K, max_num = 0, idx = 0;

    for (int i = 0; i < 3; i++) cin >> num[i];

    cin >> K;

    for (int i = 0; i < K; i++) {
        for (int j = 0; j < 3; j++) {
            if (max_num < num[j]) {
                idx = j;
                max_num = num[j];
            }
        }
        num[idx] *= 2;
    }

    int sum = 0;

    for (int i = 0; i < 3; i++) sum += num[i];

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

int main(void) {
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;
}

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

using namespace std;

#define int long long
#define sz(x) (int)x.size()
#define yes cout << "Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ft first
#define sd second
#define FOR(i, b, n) for(int i=b;i<n;i++)
#define REP(i, n) FOR(i, 0, n)
using pii = pair<int, int>;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vd = vector<double>;
mt19937_64 rnd(time(0));
int N = 1e7+1, n, ans=0;
void start() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    // cerr << fixed << setprecision(10);
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    N=100;
#endif
}
vi a(N);
signed main() {
    cin >> n;
    for (int i = 1; i <= n; ++i){
        for (int j = i; j <= n; j+=i)
            a[j]++;
        ans+=i*a[i];
    }
    cout << ans;


}








Measured memory_bytes: 81204