akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string a,b,c;
    cin>>a>>b>>c;
    int x=1;
    
    while(1){
        if(x==1){
            if(a.size()==0){
                cout<<"A"<<endl;
                return 0;
            }
            if(a[0]=='a')x=1;
            else if(a[0]=='b')x=2;
            else x=3;
            a.erase(a.begin());
        }else if(x==2){
            if(b.size()==0){
                cout<<"B"<<endl;
                return 0;
            }
            if(b[0]=='a')x=1;
            else if(b[0]=='b')x=2;
            else x=3;
            b.erase(b.begin());
        }else if(x==3){
            if(c.size()==0){
                cout<<"C"<<endl;
                return 0;
            }
            if(c[0]=='a')x=1;
            else if(c[0]=='b')x=2;
            else x=3;
            c.erase(c.begin());
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1
//#define INFTY 1000000000000000000

LL N;
vector<vector<LL>> d(300, vector<LL>(300, NIL));

void floyd(){
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(d[i][k]==NIL || d[k][j]==NIL){
                    continue;
                }
                if(d[i][j]==NIL){
                    d[i][j]=d[i][k]+d[k][j];
                }else{
                    d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
                }
            }
        }
    }
}

int main(){
    LL M;
    LL R;
    cin >> N >> M >> R;
    vector<LL> r(R);
    for(LL i=0; i<R; i++){
        cin >> r[i];
        r[i]--;
    }
    sort(r.begin(), r.end());

    LL a;
    LL b;
    LL c;
    for(LL i=0; i<M; i++){
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b]=c;
        d[b][a]=c;
    }

    floyd();

    LL min_sum=NIL;
    LL sum;
    do{
        sum=0;
        for(LL i=0; i<R-1; i++){
            sum+=d[r[i]][r[i+1]];
        }
        if(min_sum==NIL){
            min_sum=sum;
        }else{
            min_sum=min(min_sum,sum);
        }
    }while(next_permutation(r.begin(), r.end()));

    cout << min_sum << endl;

    return 0;
}


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

using namespace std;

int main()
{
    string s;
    string t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 4005


struct Info{

	bool operator<(const struct Info &arg) const{

		if(F != arg.F){
			return F < arg.F; //Fの単調非減少数列を作る
		}else{
			return point < arg.point;
		}
	}
	ll length,point,F;
};

struct Line{
	ll slope,section;
};

ll N,T;
int head[SIZE],tail[SIZE];
Info info[SIZE];
Line DEQ[SIZE][SIZE];


ll calc(Line line,ll x){

	return line.slope*x+line.section;
}

//直線f2が単独最大値を取り得ないなら、trueを返す
bool can_f2_remove(Line f1,Line f2,Line f3){

	return (f2.slope-f1.slope)*(f3.section-f2.section) >= (f2.section-f1.section)*(f3.slope-f2.slope);
}

int main(){

	scanf("%lld %lld",&N,&T);

	for(int i = 0; i < N; i++){

		scanf("%lld %lld %lld",&info[i].length,&info[i].point,&info[i].F);
	}

	sort(info,info+N);

	//DEQは総時間毎に持つ(時間に収まらない歌の情報を利用しないため)
	for(int k = 0; k <= T; k++){

		head[k] = 0;
		tail[k] = 0;
	}

	ll ans = 0;

	for(int i = 0; i < N; i++){ //今回歌う歌のインデックス

		Line tmp_line;
		tmp_line.slope = 2*info[i].F;

		for(int current = T,pre; (pre = current-info[i].length) >= 0; current--){

			//DEQの先頭の直線が今後単独最大値を取り得ないなら、論理削除する
			while(tail[pre]-head[pre] >= 2 && calc(DEQ[pre][head[pre]],info[i].F) <= calc(DEQ[pre][head[pre]+1],info[i].F))head[pre]++;

			bool FLG = false;
			ll tmp_ans = -HUGE_NUM;

			if(pre > 0){

				if(head[pre] < tail[pre]){
					tmp_ans = info[i].point-info[i].F*info[i].F+calc(DEQ[pre][head[pre]],info[i].F);
					FLG = true;
				}

			}else{ //pre == 0 iが初めての歌

				tmp_ans = info[i].point;
				FLG = true;
			}

			if(!FLG)continue;

			ans = max(ans,tmp_ans);

			tmp_line.section = tmp_ans-info[i].F*info[i].F; //★★切片にtmp_ansを足す★★

			//DEQの末尾から単独最大値をとる可能性がなくなった直線を取り除く
			while(tail[current]-head[current] >= 2 && can_f2_remove(DEQ[current][tail[current]-2],DEQ[current][tail[current]-1],tmp_line) == true)tail[current]--;

			//DEQに新しい直線を追加
			DEQ[current][tail[current]++] = tmp_line;
		}
	}

	printf("%lld\n",ans);

	return 0;
}



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

int n;

void cut(int card[],int k){
    int card_c[200];
    for(int i=0,j=k;j<n*2;i++,j++){
        card_c[i] = card[j];
    }
    for(int i=n*2-k,j=0;j<k;i++,j++){
        card_c[i] = card[j];
    }
    for(int i=0;i<n*2;i++){
        card[i]=card_c[i];
    }
}

void rifutooo(int card[]){
    int card_c[200];
    for(int i=0;i<n;i++){
        card_c[i*2] = card[i];
        card_c[i*2+1] = card[n+i];
    }
    for(int i=0;i<n*2;i++){
        card[i]=card_c[i];
    }
}

int main(){
    int m,k,card[200];
    cin>>n>>m;
    for(int i=0;i<n*2;i++){
        card[i] = i+1;
    }
    for(int i=0;i<m;i++){
        cin>>k;
        if(k==0) rifutooo(card);
        else cut(card,k);
        //for(int j=0;j<n*2;j++) printf("%d ",card[j]); puts("");
    }
    for(int i=0;i<n*2;i++){
        printf("%d\n",card[i]);
    }
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
cin >> a;
  vector<int> d(a);
  vector<int> e(a);
  for(int i = 0;i < a;i++)
  {cin >> d.at(i);}
  for(int i = 0;i < a;i++)
  {cin >> e.at(i);}
  int ans = 0;
  if(d > e){
    swap(d,e);}
  for(int i = 0;i < 50000;i++){
    if(d == e){
      ans = i;
      break;}
  next_permutation(d.begin(), d.end());
}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
  int n;
  while( 1 ){
    string s="";
    cin>>n;
    if( cin.eof() ) break;
    for( int i=0; i<10; i++ ){
      if( n & (1<<i) ){ cout << s << (1<<i); s = " "; }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,j;
    cin>>n>>j;
    unordered_map<int,vector<int>> m;
    for(int i=0;i<j;i++)
    {
        int a,b;
        cin>>a>>b;
        m[a].push_back(b);
        m[b].push_back(a);
    }
    vector<int> ans(n+1,0);
    int count=0;
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int s=q.size();
        for(int k=0;k<s;k++)
        {
            int front=q.front();
            q.pop();
            int a=m[front].size();
            for(int i=0;i<a;i++)
            {
                if(ans[m[front][i]]!=0||m[front][i]==1)
                    continue;
                ans[m[front][i]]=front;
                count++;
                q.push(m[front][i]);
            }
        }
    }
    if(count!=n-1)
    {
        cout<<"No"<<endl;
    }else
    {
        cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++)
        {
            cout<<ans[i]<<endl;
        }
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

 
 


int32_t  main() {

	IOS;
  
	int A, B, C, D;

	cin >> A >> B >> C >> D;

	while (A > 0 && C > 0) {

		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}

	}
 
	 
}

Measured memory_bytes: 3104
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/



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

const int INF=(long long)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;
int sz=262144;complex<double> y[262160],A[262160],B[262160];
#define int long long

void dft(complex<double> *x,bool inv);
#define P pair<int,int>





signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;cin >>n;
    int ans=(n/500)*1000;n%=500;
    cout <<ans+(n/5)*5<<endl;

}

void dft(complex<double> *x,bool inv){
    for(int i=sz>>1;i>=1;i>>=1){
        complex<double> zeta=polar(1.0,2.0*acos(-1)*i/sz*(inv?-1.0:1.0)),now=1;
        for(int j=0;2*j<sz;j+=i){//i飛ばし
            rep(k,i) {
                y[k+j]=x[2*j+k]+now*x[2*j+i+k];
                y[j+k+(sz/2)]=x[2*j+k]-now*x[2*j+i+k];//sz/2以上のやつ。原点対称を利用
            }
            now*=zeta;
        }
        rep(i,sz)x[i]=y[i];//探索の区間の幅を狭める前にこぴー
    }

    if(inv)rep(i,sz)x[i]/=sz;

}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
// template <class V> class BIT {
// public:
// 	vector <V> bit;
// 	int M;
// 	BIT( int M ) :
// 		bit( vector <int>( M + 1, 0 )), M( M ) {
// 	}
// 	V sum( int e ) {
// 		if(e < 0) return 0;
// 		V s = 0;
// 		e++;
// 		while(e)
// 			s += bit[ e - 1 ], e -= e & -e;
// 		return s;
// 	}
// 	void add( int e, V v ) {
// 		e++;
// 		while(e <= M)
// 			bit[ e - 1 ] += v, e += e & -e;
// 	}
// };

class BIT {
public:
	vector <int> bit;
	int M;

	BIT( int M ) :
		bit( vector <int>( M + 1, 0 )), M( M ) {
	}
	int sum( int i ) {
		if (!i) return 0;
		return bit[ i ] + sum( i - ( i & -i ));
	}
	void add( int i, int x ) {
		if (i > M) return;
		bit[ i ] += x;
		add( i + ( i & -i ), x );
	}
};

int main( void ){
	// initialize();
	int N;
	cin >> N;
	vector <BIT> vec( 26, BIT( N ));
	string str; cin >> str;
	rep( i, 0, N ){
		vec[ ( int )( str[ i ] - 'a' ) ].add( i+1, 1 );
	}
	int Q; cin >> Q;
	rep( i, 0, Q ){
		int a;
		cin >> a;
		if (a == 1){
			int b;
			char c; cin >> b >> c;
			b--;
			vec[ ( int )(( char )str[ b ] - 'a' ) ].add( b+1, -1 );
			str[ b ] = c;
			vec[ ( int )( c - 'a' ) ].add( b+1, 1 );

		}
		else {
			int b, c; cin >> b >> c;
			int ans = 0;
			rep( i, 0, 26 ){
				if (vec[ i ].sum( c ) - vec[ i ].sum( b - 1 ) > 0)
					ans++;
			}
			printf("%d\n", ans);
		}
	}


}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
	cin.tie( 0 );
	ios::sync_with_stdio( false );
}


Measured memory_bytes: 53120
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    int all = n*(2*l+n-1)/2;
    int minn = 1<<30;
    int ans = 0;
    for(int i=1;i<=n;i++){
      if(minn>Math.abs(l+i-1)){
        minn = Math.abs(l+i-1);
        ans = all-(l+i-1);
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21588
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

struct Edge {
  int to, cost;
};

vector<vector<Edge>> edge;

void dijkstra(int s, int c, vvi& dp)
{
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  dp[s][c] = 0;
  pq.push(mp(0, s));

  while (!pq.empty()) {
    pii p = pq.top(); pq.pop();
    int cur = p.Se;
    if (dp[cur][c] < p.Fi) continue;
    for (auto e : edge[cur]) {
      int t = c == 0 ? dp[cur][c] + e.cost : min(dp[cur][c] + e.cost, dp[cur][c - 1] + e.cost / 2);
      if (dp[e.to][c] > t) {
        dp[e.to][c] = t;
        pq.push(mp(dp[e.to][c], e.to));
      }
    }
  }
}

signed main()
{
  int c, n, m, s, d;

  while (cin>>c>>n>>m>>s>>d, c||n||m||s||d) {
    s--; d--;
    edge = vector<vector<Edge>>(n);
    vvi dp(n, vi(c + 1, INF));
    REP(i, m) {
      int a = in() - 1, b = in() - 1, f = in();
      edge[a].pb(Edge{b, f});
      edge[b].pb(Edge{a, f});
    }
    REP(i, c + 1) {
      dijkstra(s, i, dp);
    }
    print(dp[d][c]);
  }

  return 0;
}

Measured memory_bytes: 3192
#include <iostream>

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



Measured memory_bytes: 3080
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    m = 1000
    s = 0
    ans = 1000
    for i in range(n-1):
        if s > 0:
            if la[i] <= la[i+1]:
                continue
            m += s*la[i]
            s = 0
        else:
            if la[i] >= la[i+1]:
                continue
            s = m//la[i]
            m -= s*la[i]
        ans = max(ans, m+s*la[i])
    ans = max(ans, m+s*la[n-1])
    print(ans)
        



if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
import java.util.Arrays;
import java.util.Scanner;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		Integer[] d = new Integer[3];
		d[0] = a;
		d[1] = b;
		d[2] = c;
		
		Arrays.sort(d,Collections.reverseOrder());
		
		if(d[0] == d[1]+d[2]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int[] a = new int[9];
        for (int i = 0; i < 9; i++) {
            a[i] = in.nextInt();
        }

        int n = in.nextInt();
        Set<Integer> b = new HashSet<>();
        for (int i = 0; i < n; i++) {
            b.add(in.nextInt());
        }

        for (int i = 0; i < 9; i++) {
            if (b.contains(a[i])) {
                a[i] = -1;
            }
        }

        if ((a[0] + a[1] + a[2]) == -3 || (a[3] + a[4] + a[5]) == -3 || (a[6] + a[7] + a[8]) == -3
                || (a[0] + a[3] + a[6]) == -3 || (a[1] + a[4] + a[7]) == -3 || (a[2] + a[5] + a[8]) == -3
                || (a[0] + a[4] + a[8]) == -3 || (a[6] + a[4] + a[2]) == -3) {
            out.println("Yes");
        } else {
            out.println("No");
        }

    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int h,w;
int Left[2005][2005];
int Right[2005][2005];
int Up[2005][2005];
int Down[2005][2005];
int arr[2005][2005];

int main(){
	cin>>h>>w;
	for(int i=1; i<=h; i++){
		string s;
		cin>>s;
		for(int j=0; s[j]; j++){
			if(s[j]=='#') arr[i][j+1] = 1;
		}
	}
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(arr[i][j]) Right[i][j] = 0;
			else Right[i][j] = Right[i][j-1]+1;
		}
	}
	for(int i=1; i<=h; i++){
		for(int j=w; j>=1; j--){
			if(arr[i][j]) Left[i][j] = 0;
			else Left[i][j] = Left[i][j+1]+1;
		}
	}
	for(int i=1; i<=w; i++){
		for(int j=1; j<=h; j++){
			if(arr[j][i]) Down[j][i] = 0;
			else Down[j][i] = Down[j-1][i]+1;
		}
	}
	for(int i=1; i<=w; i++){
		for(int j=h; j>=1; j--){
			if(arr[j][i]) Up[j][i] = 0;
			else Up[j][i] = Up[j+1][i]+1;
		}
	}
	int maxlight = 0;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(arr[i][j]) continue;
			int light = Left[i][j]+Right[i][j]+Up[i][j]+Down[i][j]-4;
			maxlight = max(maxlight,light+1);
		}
	}
	cout<<maxlight;
}

Measured memory_bytes: 81956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
const int inf = 100100100;

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> g(h);
  rep(i,h) cin >> g[i];

  vector<int> H(0), W(0);

  rep(i,h){
    bool flag = 0;
    rep(j,w) if(g[i][j] == '#') flag = 1;
    if(flag)H.push_back(i);
  }
  rep(j,w){
    bool flag = 0;
    rep(i,h) if(g[i][j] == '#') flag = 1;
    if(flag) W.push_back(j);
  }
  for(auto i : H){
    for(auto j : W){
      cout << g[i][j];
    }
    cout << endl;
  }
}



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


int main()
{
	int n; cin >> n;
	int A[1001], ok = 1;
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
		if (A[i] % 2 == 0)
			if (A[i] % 3 != 0 & A[i] % 5 != 0)
				ok = 0;
	}
	cout << (ok ? "APPROVED" : "DENIED") << endl;
}



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

int main() {
  int n; cin >> n;
  
  vector<int> slimes(n);
  for (int i = 0; i < n; i++) cin >> slimes.at(i);
  
  int answer = 0;
  for (int i = 0; i < n;) {
    int count = 1;
    for (int j = i + 1; j < n; j++) {
      if (slimes.at(i) == slimes.at(j)) {
        count++;
        i = j;
      } else {
        break;
      }
    }
    if (count == 1) i++; 
    else if (count % 2 == 1) answer += (count - 1) / 2;
    else answer += count / 2;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int N, M;
vector<int> broken;

lint dp[114514];

lint move(int now){
    if(now == N){
        return 1;
    }else if(now > N || broken[now]){
        return 0;
    }else if(dp[now] != -1){
        return dp[now];
    }
    return dp[now] = (move(now + 1) + move(now + 2)) % mod;
}

int main(){
    cin >> N >> M;
    broken.resize(N, 0);
    for(int i = 0; i < M; i++){
        int a;
        cin >> a;
        broken[a] = 1;
    }
    memset(dp, -1, sizeof(dp));
    cout << move(0) << endl;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h> 
using namespace std; 
string firstLetterWord(string str) 
{ 
	string result = ""; 
	bool v = true; 
	for (int i=0; i<str.length(); i++) 
	{ 
		if (str[i] == ' ') 
			v = true;
		else if (str[i] != ' ' && v == true) 
		{ 
			result.push_back(toupper(str[i])); 
			v = false; 
		} 
	} 

	return result; 
} 
int main() 
{ 
	string str;
  getline(cin,str);
	cout << firstLetterWord(str); 
	return 0; 
} 

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int k = scanner.nextInt();
    int n = scanner.nextInt();
    int[] a = new int[n];
    int max = 0;

    for (int i = 0; i < n; i++) {
      a[i] = scanner.nextInt();
    }
    Arrays.sort(a);

    for (int i = 0; i < n; i++) {
      max = Math.max(max,
          Math.min(Math.abs(a[(i + 1) % n] - a[i % n]), k - Math.abs(a[(i + 1) % n] - a[i % n])));
    }
    System.out.println(k - max);
  }

}


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

int main()
{
  int n, sum = 0;
  cin >> n;
  int a[n];
  int m = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
    m = max(m, a[i]);
  }
  
  cout << (sum - m > m ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3648
//https://atcoder.jp/contests/dp/tasks/dp_i
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    scanf("%d",&n);
    vector<double> dp(n+1);
    //dp[i] probability that there are i heads so far
    dp[0]=1;
    for(int coin=0;coin<n;++coin){
        double p_heads;
        scanf("%lf",&p_heads);
        for(int i=coin+1;i>=0;--i){
            dp[i]=(i==0?0:dp[i-1]*p_heads)+dp[i]*(1-p_heads);
        }
    }
    // for(int i=0;i<=n;++i)
    //     cout<<dp[i]<<" ";
    // cout<<endl;
    double ans=0.0;
    for(int heads=0;heads<=n;++heads){
        int tails=n-heads;
        if(heads>tails)
            ans+=dp[heads];
    }
    printf("%.10lf",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int x, n; cin >> x >> n;
	bool cnt[110] = {};
	rep(i,n) {
		int p; cin >> p;
		cnt[p] = true;
	}
	int ans = 0, diff = INF;
	for(int i = 0; i < 110; ++i) {
		if(not cnt[i]) {
			if(abs(i - x) < diff) {
				ans = i;
				diff = abs(i - x);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n, k; cin >> n >> k;
 	vector<int> v(n); for(int& x : v) cin >> x;

	vector<int> dp(n,1000000000);
	
	dp[0] = 0;

	for(int i = 1 ; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(i-j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i-j]));
		}
	}

	cout << dp[n-1];


	#ifdef LOCAL
	cerr << "\n";
	#endif
	return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e9
string s,t;
int dp[3003][3003];
int rec(int i=0,int j=0)
{
    if(i==s.size() || j==t.size())
        return 0;
    if(dp[i][j]+1)
        return dp[i][j];
    int T,S,B;
    T = S = B = -INF;
    if(s[i]==t[j])
    {
        B = 1+rec(i+1,j+1);
    }
    else
    {
        T = rec(i,j+1);
        S = rec(i+1,j);
    }
    return dp[i][j] = max(B,max(T,S));
}

void path(int i=0,int j=0)
{
    if(i==s.size() || j==t.size())
        return ;
    int T,S,B;
    T = S = B = -INF;
    int optimal = rec(i,j);

    if(s[i]==t[j])
    {
        B = 1+rec(i+1,j+1);
    }
    else
    {
        T = rec(i,j+1);
        S = rec(i+1,j);
    }

    if(optimal==B)
    {
        cout << s[i];
        path(i+1,j+1);
        return;
    }
    else if(optimal==T)
    {
        path(i,j+1);
        return ;
    }
    else if(optimal==S)
    {
        path(i+1,j);
        return ;
    }
}

int main()
{
    memset(dp,-1,sizeof(dp));
    cin >> s >> t;
    if(rec()==0)
        return cout << " ",0;
    path();
    return 0;
}


Measured memory_bytes: 35968
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define vpush(v,x) v.push_back(x);
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,w,h;
    vint v;
    rep(i,5){
        cin>>a;
        vpush(v,a);
    }
    cin>>a;
    if(v[4]-v[0]<=a){
        cout<<"Yay!";
    }
    else{
        cout<<":(";
    }
    return(0);
}

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

public class Main {
	static int n, k, p;
	static final int MAX_P = 100000 * 10000;
	static int[] w;

	public static boolean isload(int p) {
		int truck, i = 0, j = 0;
		while (i < k && j < n) {
			truck = 0;
			while (j < n && truck + w[j] <= p) {
				truck += w[j++];
			}
			i++;
		}
		if (j == n) {
			return true;
		} else {
			return false;
		}
	}

	public static int whatIsP() {
		int left = 1, right = MAX_P + 1, ans = 0;
		while (left < right) {
			p = (left + right) / 2;
			if (isload(p)) {
				ans = p;
				right = p;
			} else {
				left = p + 1;
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		try(BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));) {
			String[] str = br.readLine().split(" ");
			n = Integer.parseInt(str[0]);
			k = Integer.parseInt(str[1]);
			w = new int[n];
			for (int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(br.readLine());
			}
			System.out.println(whatIsP());
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 35180
import java.util.Scanner;

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

        for (int i=0; i<in.length(); i++) {
            char c = in.charAt(i);
            if (Character.isUpperCase(c)) {
                out.append(Character.toLowerCase(c));
            } else if (Character.isLetter(c)) {
                out.append(Character.toUpperCase(c));
            } else {
                out.append(c);
            }
        }

        System.out.println(out);

    }
}



Measured memory_bytes: 26232
#include<stdio.h>
void main(){
   int n,m;
   scanf("%d%d",&n,&m);
   int a[n];
   int i;
   int count=0;
   int  sum=0;;
   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      sum=sum+a[i];
   }
   for(i=0;i<n;i++){
      if(a[i]*4*m>=sum){
         count++;
      }
   }
   if(count>= m){
      printf("Yes");
   }else{
      printf("No");
   }
}
     

Measured memory_bytes: 1704
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
struct BIT {
	vector<ll> bit;
	int n;
	BIT(int n) :n(n) {
		bit = vector<ll>(n + 1, 0);
	}
	ll sum(int i) {
		i++;
		ll s = 0;
		while (i > 0) {
			(s += bit[i]) %= MOD;
			i -= i & -i;
		}
		return s;
	}
	ll get(int i) {
		ll ret = sum(i);
		if (i > 0) (ret += MOD - sum(i - 1)) %= MOD;
		return ret;
	}
	void add(int i, ll x) {
		i++;
		while (i <= n) {
			(bit[i] += x) %= MOD;
			i += i & -i;
		}
	}
};
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> x(N);
	vector<int> y(M);
	for (int i = 0; i < N; i++) cin >> x[i];
	for (int i = 0; i < M; i++) cin >> y[i];
	vector<P> v;
	for (int i = 0; i < N; i++) {
		if (x[i] < y[0] || y[M - 1] < x[i]) continue;
		int l = x[i] - *(lower_bound(y.begin(), y.end(), x[i]) - 1);
		int r = *(upper_bound(y.begin(), y.end(), x[i])) - x[i];
		v.emplace_back(l, -r);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	vector<int> a, b;
	b.push_back(0);
	for (int i = 0; i < v.size(); i++) {
		a.push_back(-v[i].second);
		b.push_back(-v[i].second);
	}
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	for (int i = 0; i < a.size(); i++) {
		a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
	}
	BIT dp(b.size() + 1);
	dp.add(0, 1);
	for (int i = 0; i < a.size(); i++) {
		ll s = dp.sum(a[i] - 1);
		dp.add(a[i], s);
	}
	cout << dp.sum(b.size()) << endl;
}

Measured memory_bytes: 3448
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();

        var wList = Console.ReadLine().ToIntArray();

        int ans = int.MaxValue;

        for(int i = 1; i < wList.Length; i++)
        {
            var val = wList.Take(i).Sum();
            var val2 = wList.Skip(i).Sum();
            ans = Math.Min(ans, Math.Abs(val - val2));
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
import collections
from collections import deque
def tree(s,m):
    INF=-10**9
    visited = [INF for i in range(n)]

    def bfs():
        d = deque()
        d.append(s)
        ans=m
        mod=10**9+7
        count=0
        visited[s]=0
        while len(d):
            v = m
            x = d.popleft()
            if count<2:
                count+=1
            v-=count
            for i in range(len(b[x])):
                y=b[x][i]
                if visited[y] == INF:
                    visited[y]=0
                    d.append(y)
                    ans*=v
                    ans%=mod
                    v-=1
        return ans
    return bfs()



n,m= map(int, input().split())
a = [list(map(int, input().split())) for i in range(n-1)]
b = [[] for i in range(n)]

for i in range(n-1):
    b[a[i][0]-1].append(a[i][1]-1)
    b[a[i][1]-1].append(a[i][0]-1)

c=tree(0,m)
print(c)

Measured memory_bytes: 79960
#include <iostream>
#include <vector>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define repp(i,l,r,k) for((i)=(l);(i)<(r);(i)+=(k))
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    if(n>9||m>9)cout<<"-1"<<endl;
    else cout<<n*m<<endl;
}

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

int main(void){

  int wide,height,x,y,r;

  cin >> wide >> height >> x >> y >> r;

  if(0<=x-r && x+r<=wide && y-r>=0 && y+r<=height)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solve());
            return;
        }

        private static int solve()
        {
            var array = Console.ReadLine();
            return Enumerable.Range(0, array.Length - 2)
                .Select(x => Math.Abs(int.Parse(array.Substring(x, 3)) - 753))
                .Min();
        }
    }
}




Measured memory_bytes: 11348
mod = 10 ** 9 + 7

n, k = gets.split.map(&:to_i)

a = [1] * (k+1)
# b = Array.new(k+1){|i| i }

ans = 0
(k/2).downto(1) do |i|
  cnt = ( k/i ).pow( n, mod )
  (i*2).step(k, i){|j| cnt = ( cnt - a[j] ) % mod }
  a[i] = cnt
  ans += i * cnt % mod
  ans %= mod if ans >= mod
end

puts (ans + (k-k/2) * ( k + k/2+1) / 2 ) % mod

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, c, x[200001], v[200001];

LL solve() {
	LL s = 0;
	pair<LL, LL> a[100001];
	incII(i, 0, n) { a[i] = MP(0, n); }
	inc1(i, n) {
		s += v[n - i] - (x[n - i + 1] - x[n - i]) * 2;
		// cout << "s: " << s << endl;
		a[n - i] = max(a[n - i + 1], MP(s, n - i));
	}
	
	LL b = 0;
	s = 0;
	inc1(i, n) {
		s += v[n + i] - (x[n + i] - x[n + i - 1]);
		setmax(b, s + a[n + i - n].FI);
	}
	
	return b;
}

void flip() {
	inc(i, n / 2) {
		swap(x[i], x[n - 1 - i]);
		swap(v[i], v[n - 1 - i]);
	}
	inc(i, n) { x[i] = c - x[i]; }
	
	inc(i, n) {
		x[n + 1 + i] = c + x[i];
		v[n + 1 + i] = v[i];
	}
}

int main() {
	cin >> n >> c;
	inc(i, n) { cin >> x[i] >> v[i]; }
	x[n] = c;
	v[n] = 0;
	inc(i, n) {
		x[n + 1 + i] = c + x[i];
		v[n + 1 + i] = v[i];
	}
	
	LL ans = 0;
	setmax(ans, solve()); flip();
	setmax(ans, solve());
	
	cout << ans << endl;
	
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll a , b , x  ;
  cin >> a >> b >> x  ;
  
  intll ans = b/x - (a-1)/x ;
  if(a == 0) ans = b/x+1;
  
  cout << ans ;
 

}


Measured memory_bytes: 256
// Example program
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;


int main() {
    int n;
    cin >> n;
    n--;
    int C[600], S[600], F[600];
    rep(i,0,n) cin >> C[i] >> S[i] >> F[i];
    rep(i,0,n) {
        int at = 0;
        rep(j,i,n) {
            if(at < S[j]) at = S[j]+C[j];
            else {
                while((at - S[j]) % F[j] != 0) at++;
                at += C[j];
            }
        }
        
        cout << at << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int a; cin >> a;
  int ans = a + a * a + a * a * a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#define N 100

int main(){
  int A[N],n,i,j,key,count=0,flag;

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

  flag=1;
  while(flag==1){
    flag=0;
    for(j=n-1;j>0;j--){
      if(A[j]<A[j-1]){
	key=A[j];
	A[j]=A[j-1];
	A[j-1]=key;
	count++;
	flag=1;
      }
    }
  }

  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[n-1],count);
  return 0;
}
  



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

int main()
{
        int week;
        long long int debt = 100000;

        cin >> week;
        for(int i=0;i<week;i++){
                debt = debt + debt*0.05;
                if((debt%1000)!=0){
                        debt = (debt/1000 +1)*1000;
                }
        }

        cout << debt << "\n";

        return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define INF 1e9;
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(m), y(m);
    vector<vector<int>> work(n+1);
    rep(i, m) {
        cin >> p[i] >> y[i];
        work[p[i]].push_back(y[i]);
    }
 
    rep(i, n) {
        sort(work[i+1].begin(), work[i+1].end());
    }
 
    rep(i, m) {
        printf("%012lld\n", ll(p[i])*1000000 + int(lower_bound(all(work[p[i]]), y[i]) - work[p[i]].begin()) + 1);
    }
 
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

std::vector<int> g[N];

int main() {

  int n, m, x, y;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> x >> y;
    g[x].pb(y); g[y].pb(x);
  }
  queue<int> Q;
  Q.push(1);
  std::vector<int> d(n + 1, -1), ans(n + 1);
  d[1] = 0;
  while(!Q.empty()){
    auto u = Q.front(); Q.pop();
    for(auto v : g[u]){
      if(d[v] == -1 or d[v] > d[u] + 1){
        d[v] = d[u] + 1;
        ans[v] = u;
        Q.push(v);
      }
    }
  }
  bool flag = false;
  for(int i = 2; i <= n; i++) flag |= d[i] == -1;
  if(flag){
    cout << "No\n"; return 0;
  }
  cout << "Yes\n";
  for(int i = 2; i <= n; i++)cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 12992
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

LL ksm(LL a, LL b) { LL ans = 1LL; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; }  return ans; }

LL dp[N];
int a[N];

void solve() {

    int n, m;
    scanf("%d %d", &n, &m);
    rep(i, 1, n) {
        scanf("%d", &a[i]);
    }

    LL ans = 0;

    rep(i, 1, n) {
        if(a[i] == m) ans = (ans + 1LL * i * (n - i + 1) % mod) % mod;
        else if(m > a[i]) ans = (ans + dp[m - a[i]] * (n - i + 1) % mod) % mod;
        dep(j, a[i], m) {
            dp[j] = (dp[j] + dp[j - a[i]]) % mod;
            if(j == a[i]) dp[j] = (dp[j] + i) % mod;
        }
    }

    printf("%lld\n", ans);

}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();


    solve();

    return 0;
}


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

using namespace std;


long long say,k;

long long minp[1000013];

vector<long long> pr;

void sieve(){
	for(long long i=2;i<=(long long)sqrt(k);i++){
		if(minp[i]==0){
			minp[i]=i;
			pr.push_back(i);
		}
		for(int j=0;j<pr.size() && pr[j]<=minp[i] && i*pr[j]<=(int)sqrt(k);j++){
			minp[i*pr[j]]=pr[j];
		}
	}
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long a,b;
	cin>>a>>b;
	k=__gcd(a,b);
	sieve();
	for(int i=0;i<pr.size();i++){
		if(k%pr[i]==0){
			while(k%pr[i]==0){
				k/=pr[i];
			}
			say++;
		}
		if(k==1){
			break;
		}
	}	
	if(k!=1){
		say++;
	}
	cout<<say+1<<endl;




	return 0;
}



Measured memory_bytes: 9208
# refactored
n, m = map(int, input().split())
ab = []
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
# a の少ない順
ab.sort(key=lambda a: a[0])
ans = 0
for i in ab:
    buy = min(m, i[1])
    ans += buy * i[0]
    m -= buy

print(ans)


Measured memory_bytes: 18176
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef unsigned long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
    string S;cin>>S;
    cout<<S.substr(0,3)<<endl;
    return 0;
}

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

int main() {
  int N,a=99;
  cin >> N;
  for(int i=1; i<N; i++){
    int e=100000,f=0;
    for(; e!=1; e=e/10){
      f+=i%e/(e/10)+(N-i)%e/(e/10);
    }
    a=min(a,f);
  }
  cout << a << endl;
}

Measured memory_bytes: 256