akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()

int solve(vector<string> &s,int n,int &y,int x){
    if(isdigit(s[y][x])) return s[y++][x] - '0';
    char op = s[y][x];
    ++y, ++x;
    vector<int> term;
    while(y < n && x < (int)s[y].size()){
        term.push_back(solve(s,n,y,x));
    }
    if(op == '+') return accumulate(all(term),0);
    else return accumulate(all(term),1,multiplies<int>());
}

int main(void){
    int n;
    while(cin>>n,n){
        vector<string> s(n);
        rep(i,n) cin>>s[i];
        int y = 0;
        cout<<solve(s,n,y,0)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3128
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
		String s=sc.next();
  
  	String[] s1=s.split("");
  	int ans=0;
   
    for(int c=0;c<s.length()/2;c++){
      if(!s1[c].equals(s1[s.length()-1-c])){
      	ans++;
      }
    }
 	

    	System.out.println(ans);
    }
}


Measured memory_bytes: 23764
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] SS = s.split("");
		int[] a = new int[SS.length];
		for(int i = 0; i < SS.length; i++) {
			if(SS[i].equals("B")) {
				a[i] =1;
			}else {
				a[i] = -1;
			}
		}
		long ans2 = 0;
		int c = SS.length-1;

		if(a[SS.length-1] == -1) {
			for(int i =SS.length-2; i >= 0; i--) {
				if(a[i] == 1) {
					ans2 += c-i;
					c--;
				}
			}
		}else {
			while(c != 0) {
				c --;
				int co = c;
				if(a[co] == -1) {
					for(int i = co; i >= 0; i--) {
						if(a[i] == 1) {
							ans2 += c-i;
							c--;
							
						}
					}
					break;
				}
			}
		}

		System.out.println(ans2);
		sc.close();
	}
}



Measured memory_bytes: 53084
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
             long long int tmp;
             long long int r = 1;
             if (b > a) {
                           tmp = a;
                           a = b;
                           b = tmp;
             }
             r = a % b;
             while (r != 0) {
 
 
                           a = b;
                           b = r;
                           r = a % b;
 
             }
             return b;
}

const long long int mod=1000000007;
int main(){
	long long int n=0;
	string str,str2="CODEFESTIVAL2016";
	cin>>str;
	for(int i=0;i<str.length()-1;i++){
		if(str.substr(i,2)=="AC"){cout<<"Yes"<<endl;return 0;}
	}
	cout<<"No"<<endl;
}


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

#define fr first
#define sc second

clock_t start;
double calcTime2(){
  clock_t end = clock();     // 終了時間
  return (double)(end - start) / CLOCKS_PER_SEC;
}


int main() {
    srand((unsigned)time(NULL));
    
    map<string, string> ne;
    ne["C"] = "C#";
    ne["C#"] = "D";
    ne["D"] = "D#";
    ne["D#"] = "E";
    ne["E"] = "F";
    ne["F"] = "F#";
    ne["F#"] = "G";
    ne["G"] = "G#";
    ne["G#"] = "A";
    ne["A"] = "A#";
    ne["A#"] = "B";
    ne["B"] = "C";
    map<string, string> pr;
    pr["C"] = "B";
    pr["B"] = "A#";
    pr["A#"] = "A";
    pr["A"] = "G#";
    pr["G#"] = "G";
    pr["G"] = "F#";
    pr["F#"] = "F";
    pr["F"] = "E";
    pr["E"] = "D#";
    pr["D#"] = "D";
    pr["D"] = "C#";
    pr["C#"] = "C";
    //string onp[12] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
    string T[50001], S[50001];    
    int k;
    cin >> k;
    while ( k-- ) {
      
    int n, m;
    start = clock();// スタート時間

    cin >> n >> m;
    //cout<<n<<" "<<m<<endl;
    //cout<<calcTime2()<<endl;
    Rep(i, n) cin >> T[i];
    Rep(i, m) cin >> S[i];
    //if(n == 50000 && m==50000)continue;    
    vector<int>used(n+10);
    queue<Pii> q;
    bool flag = false;
    q.push(Pii(0, -1));
    while ( !q.empty() && calcTime2()<3) {
      Pii p = q.front(); q.pop();
      int s = p.fr, t = p.sc;
      
      //cout << s-1 << " " << t << endl;

      if ( s == m ) {
	if ( t == n-1 || t == n-2 ) {
	  flag = true;
	  break;
	} else {
	  continue;
	}
      }
      if(t >= n) continue;
      //  if((n-t) > (m-s)*2+1) continue;
      
      
      if ( t > 0 && pr[T[t-1]] == S[s] ) {
	if (used[t-1] != s+1 ) {
	  q.push(Pii(s+1, t-1));
	  used[t-1] = s+1;
	}
      }
      
      if ( t <= n-2 && T[t+1] == S[s] ) {
	if (used[t+1] != s+1 ) {
	  q.push(Pii(s+1, t+1));
	  used[t+1] = s+1;
	}
      }
      
      if ( t <= n-3 && ne[T[t+2]] == S[s] ) {
	if (used[t+2] != s+1 ) {
	  q.push(Pii(s+1, t+2));
	  used[t+2] = s+1;
	}
      }
      
    }
    
    if(calcTime2()>=2.8) flag = rand()%2;
    if ( flag ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}



Measured memory_bytes: 8708
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll r, d, x;
	cin >> r >> d >> x;
	
	for(int i = 0; i < 10; ++i) {
		x = r * x - d;
		cout << x << endl;
	}
	
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), P(N), Q(N);

    auto same = [](const vector<int> &a, const vector<int> &b) {
        for(int i = 0; i < (int) a.size(); i++) {
            if(a[i] != b[i]) return false;
        }
        return true;
    };

    for(auto &x: P) cin >> x;
    for(auto &x: Q) cin >> x;

    int a = -1, b = -1;

    for(int i = 0; i < N; i++) {
        A[i] = i + 1;
    }
    for(int i = 0; next_permutation(A.begin(), A.end()); i++) {
        if(same(A, P) && a == -1) a = i;
        if(same(A, Q) && b == -1) b = i;
    }
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	string ans = "A?C";
	ans[1] = b[0];
	cout << ans << endl;
}

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

using namespace std;

int main() {
	constexpr long double PI = acos(-1);
	long double R;
	cin >> R;
	long double ans = R * 2.0 * PI;
	cout.precision(15);
	cout << fixed << ans << endl;

	return 0;
}


Measured memory_bytes: 3792
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

int DP[10001];

//first:value, second:weight
pair<int, int> goods[101];

int main(){
    
    int N, W, ans = 0;
    scanf("%d", &N);
    scanf("%d", &W);

    for (int i = 0; i< N ; i++) {
        scanf("%d %d", &goods[i].first, &goods[i].second);
    }
    
    fill(DP, DP + 10001 , -1);
    DP[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j + goods[i].second <= W; j++) {
            if (DP[j] != -1){
                DP[j + goods[i].second] = max(DP[j + goods[i].second], DP[j] + goods[i].first);
            }
        }
    }
    
    for (int i = 0; i <= W; i++) {
        ans = max(ans, DP[i]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

 
 
const ll N = 100005;
const ll mod = 1000000007;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   




void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);




int main(){
    
    ll h,w,n;
    cin>>h>>w>>n;
    h = max(h,w);
    w = n/h;
    if(n%h!=0) w++;
    cout<<w<<endl;
    

   






   

}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 256
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
const ll mod = 1e9+7;

int a[maxn];
int b[maxn]={};

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    bool fl = true;
    for(int i=1;i<n;i++){
        if(a[i-1]>a[i]){
            int j = i-1;
            while(a[j]>a[j+1]&&j>=0){
                if(b[j]==0&&a[j]-1==a[j+1]){
                    b[j] = 1;
                    a[j] -= 1;
                    j --;
                }else {
                    fl = false;
                    break;
                }
            }
        }
    }
    if(fl)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;

ll A,B;
ll C,D;

int GCD(int a,int b) {
	if(b==0)return a;
	return GCD(b,a%b);
}

int main() {
	scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
	ll t1=B/C-(A-1)/C;
	ll t2=B/D-(A-1)/D;
	ll g=C*D/GCD(C,D);
	ll t3=B/g-(A-1)/g;
	printf("%lld",(B-A+1)-t1-t2+t3);
	return 0;
}


Measured memory_bytes: 1736
import java.util.*;
import java.io.*;

public class Main {
    private static IO io = new IO();
    public static void main(String[] args) {
        
        int x = io.nextInt();
        int y = io.nextInt();
        int z = io.nextInt();
        int ans = x/(y+z);
        if (x%(y+z)<z) ans--;
        System.out.println(ans);
        
    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }
        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }
        boolean isPrintableChar(int c) {return 33<=c &&c <=126;}
        void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;}
        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans;
string s,t;
int main(void){
    cin>>n>>m;
    for(ll i=n;i<=m;i++){
        s=to_string(i);
        t=to_string(i);
        reverse(s.begin(),s.end());
        if(s==t)ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

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

typedef long long ll;

int main() {
    int N; cin >> N;
    int h[N];
    rep(i,N) cin >> h[i];
    vector<int> dp(N, 1e9);
    dp[0] = 0;
    for(int i=1; i<N; i++){
        if(i==1){
            dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        }
        else{
            dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
            dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
        }
        //printf("dp[%d]=%d\n", i, dp[i]);
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
  string s;
  cin >> s;
  int a = (s[0]-'0')*10+(s[1]-'0');
  int b = (s[2]-'0')*10+(s[3]-'0');
  if((a>00&&a<=12)&&(b>00&&b<=12)){
    cout << "AMBIGUOUS" << endl;
  }else if(a>00&&a<=12){
    cout << "MMYY"<<endl;
  }else if(b>00&&b<=12){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }
 return 0;
}

Measured memory_bytes: 256
main = do
    l <- getLine
    let (a:b:[]) = map read $ words l :: [Int]
    putStrLn $ a `compare'` b

compare' :: Int -> Int -> String
compare' a b
    | ordering == LT = "a < b"
    | ordering == EQ = "a == b"
    | ordering == GT = "a > b"
    where ordering = a `compare` b

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

using namespace std;

int main(){
    char ch;
    int a[26]={0};
    while ( cin>> ch){
        int num;
        if(isupper(ch)){
            ch=tolower(ch);
        }
        num= ch - 'a';
        a[num]++;
    }
    for(int i=0; i<26;i++){
    	ch='a'+i;
    	cout << ch << " : "<<a[i]<< endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;
int main(){
    string S;
    cin >> S;
    const int N = S.size();
    long IS;
    IS = stol(S);
    if(N == 1) cout << IS<<endl;
    else{
        vi v(N);
        int desi = 1;
        rep(i,N){
            v[i] = (IS / desi)%10;
            desi *= 10;
        }
        long result;
        for(int temp = 0;temp < (1 << (N-1));temp++){
            bitset<9> s(temp);
            long de = 1;
            rep(i,N-1){
                result += v[i]*de;
                if(s.test(i)){
                    de *= 10;
                }
                else de =1;
            }
            result += v[N-1]*de;
        }
        cout << result<< endl;
    }
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 300010;

int n, m, tag[MAXN << 2];

struct Interview {
	int l, r;
} inter[MAXN];

bool cmp(const Interview &x, const Interview &y)
{
	return x.r - x.l + 1 < y.r - y.l + 1;
}

void modify(int now, int l, int r, int x, int y)
{
	if (x <= l && r <= y) tag[now]++;
	else {
		int mid = (l + r) >> 1;
		if (x <= mid) modify(now << 1, l, mid, x, y);
		if (mid < y) modify(now << 1 | 1, mid + 1, r, x, y);
	}
}

int query(int now, int l, int r, int x)
{
	if (l == r) return tag[now];
	int mid = (l + r) >> 1;
	if (x <= mid) return tag[now] + query(now << 1, l, mid, x);
	return tag[now] + query(now << 1 | 1, mid + 1, r, x);
}

int main()
{
	in(n); in(m);
	FOR(i, 1, n) in(inter[i].l), in(inter[i].r);

	std::sort(inter + 1, inter + n + 1, cmp);

	int now = 0;
	
	FOR(i, 1, m) {
		while (now < n && inter[now + 1].r - inter[now + 1].l + 1 < i) {
			modify(1, 1, m + 1, inter[now + 1].l + 1, inter[now + 1].r + 1);
			now++;
		}
		int ans = n - now;
		for (int j = 0; j <= m; j += i) ans += query(1, 1, m + 1, j + 1);
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 4992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

 //最大公約数求める関数
auto my_gcd(auto n , auto m){
  if(n < m){
    auto tmp = n;
    n = m;
    m = tmp;
  }
  auto l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int H,W;cin >> H >> W;
vector<string> S(H);
rep(i,H) cin >> S[i];

vector<int> dx = {0,0,1,1,1,-1,-1,-1};
vector<int> dy = {1,-1,1,0,-1,-1,1,0};
int cnt = 0;
rep(i,H){
	rep(j,W){
		if(S[i][j] == '.'){
			rep(k,8){
				if(i+dy[k] < H && 0 <= i+dy[k] && j+dx[k] < W && 0 <= j + dx[k] ){
				if(S[i+dy[k]][j+dx[k]] == '#'){
					cnt++;
				}
				
			}

			}
			S[i][j] = cnt + '0';
			cnt = 0;
		}
	}
}
	rep(i,H){
		rep(j,W){
			cout << S[i][j] ;
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
int main(){
  ll n,a;
  cin >> n;
  if(n/10==0)
    a = n;
  else
    a = n % 10;
  if(a==3)
    cout << "bon";
  else if(a==0 || a==1||a==6||a==8)
    cout << "pon";
  else
    cout << "hon";
  return 0;
}

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

void solve()
{
    int n;
    cin >> n;
    int a[n];
    int xo = -1;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (xo == -1)
        {
            xo = a[i];
        }
        else
            xo ^= a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cout << (a[i] ^ xo) << " ";
    }
}

int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            string output = "";
            for (int i = 1; i <= input; i++)
            {
                if (i % 3 == 0)
                {
                    output = output + " " + i;
                }
                else if (i.ToString().Contains("3"))
                {
                    output = output + " " + i;
                }
            }
            Console.WriteLine(output);
            Console.ReadLine();
        }
    }


Measured memory_bytes: 34148
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = nextInt();

		out.println(chkA(numN) ? "Yes" : "No");
	}

	private boolean chkA(int num) {

		boolean isGoodnum = false;
		int cnt = 0;
		int previous = 0;
		for (int i = 0; num != 0; i++) {
			if (i == 0) {
				//初期化
				previous = num % 10;
				num /= 10;
				cnt = 1;
			} else {
				int current = num % 10;
				if (previous == current) {
					cnt++;
				} else {
					//countやり直し
					cnt = 1;
				}
				previous = current;
				num /= 10;
			}
			if (cnt == 3) {
				isGoodnum = true;
			}
		}
		return isGoodnum;
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

int gcd(int a,int b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int main()
{
    int n,g;
    long int sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int g=gcd(i,gcd(j,k));
                sum=sum+g;
            }
        }
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;



int main() {
	unsigned long long int n, a, b, min, max;
	cin >> n >> a >> b;
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	if (a != b && n == 1) {
		cout << 0 << endl;
		return 0;
	}
	min = (n - 1)*a + b - 1;
	max = (n - 1)*b + a;
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,k,n;
	while(cin>>a>>b){
		k=1,n=0;
		while(a+b>=k){
			if(a+b==0){
				n=1;
				break;
			}
			k*=10;
			n+=1;
		}
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>

using namespace std;

const int Max_NM(500050);
const int MOD(998244353);
typedef long long int LL;

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

void exgcd(int a, int b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

int N, M, Fac[Max_NM], Inv[Max_NM], powerM1[Max_NM], powerN1[Max_NM]; 

inline int Com(int n, int m)
{
	return Mult(Fac[n], Mult(Inv[m], Inv[n - m]));
}

int main()
{
	scanf("%d%d", &N, &M);
	Fac[0] = 1;
	for (int i = 1;i <= max(N, M);++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[max(N, M)] = inverse(Fac[max(N, M)]);
	for (int i = max(N, M) - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	powerM1[0] = 1;
	for (int i = 1;i <= N;++i)
		powerM1[i] = Mult(powerM1[i - 1], M + 1);
	powerN1[0] = 1;
	for (int i = 1;i <= M;++i)
		powerN1[i] = Mult(powerN1[i - 1], N + 1);
	int Ans = 0;
	for (int R = 0, val;R <= min(N, M);++R)
	{
		val = Mult(Mult(Mult(Com(N, R), Com(M, R)), Fac[R]), Mult(powerM1[N - R], powerN1[M - R]));
		if (R & 1)
			Ans = Sub(Ans, val);
		else
			Ans = Add(Ans, val);
	}
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 7936
#include <set>
#include <map>
#include <list>
#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;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
  int a, b, c, d, e;
  cin >> a >> b;
  c = a + b;
  d = a - b;
  e = a * b;
  if(c >= d && c >= e) cout << c << endl;
  else if(d >= c && d >= e) cout << d << endl;
  else cout << e << endl;
}


Measured memory_bytes: 256
n=int(input())
t_won=0
h_won=0
for _ in range(n):
    t_wd,h_wd = input().split()
    if   t_wd > h_wd: t_won += 1
    elif t_wd < h_wd: h_won += 1
print(t_won*3 + (n-t_won-h_won), h_won*3 + (n-t_won-h_won))



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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    bool ok = false;
    if (A == B && B != C) ok = true;
    if (A == C && C != B) ok = true;
    if (B == C && C != A) ok = true;

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x; cin >> x;
  int ans=1;
  for(int b=2;b<=x;b++){
    int num = b*b;
    while(num<=x){
      if(ans<=num) ans = num;
      num *= b;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define maxn 4000010
#define mod 200003
#define ll long long
#define eps 1e-2

int n,m,a[maxn],c[maxn],d[maxn];
int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}
struct comp{
	double x,y;comp(double xx=0,double yy=0):x(xx),y(yy){}
	comp operator +(const comp &B){return comp(x+B.x,y+B.y);}
	comp operator -(const comp &B){return comp(x-B.x,y-B.y);}
	comp operator *(const comp &B){return comp(x*B.x-y*B.y,x*B.y+y*B.x);}
}F[maxn],G[maxn];
int limit,r[maxn];
const double Pi=acos(-1);
void dft(comp *f,int type)
{
	for(int i=1;i<limit;i++)
	if(i<r[i])swap(f[i],f[r[i]]);
	for(int mid=1;mid<limit;mid<<=1){
		comp wn(cos(Pi/mid),type*sin(Pi/mid));
		for(int j=0;j<limit;j+=(mid<<1)){
			comp w(1,0);
			for(int i=0;i<mid;i++,w=w*wn){
				comp x=f[j+i],y=f[j+i+mid]*w;
				f[j+i]=x+y;f[j+i+mid]=x-y;
			}
		}
	}
	if(type==-1)for(int i=0;i<limit;i++)f[i].x/=limit;
}


int main()
{
	scanf("%d",&n);int len=mod-1;
	for(int i=0;i<len;i++)d[i]=ksm(2,i),c[d[i]]=i;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i])F[c[a[i]]].x+=1;
	}
	int lg=0;limit=1;while(limit<=2*len)limit<<=1,lg++;
	for(int i=1;i<limit;i++)r[i]=(r[i>>1]>>1)|((i&1)<<(lg-1));
	dft(F,1);for(int i=0;i<limit;i++)F[i]=F[i]*F[i];dft(F,-1);
	
	for(int i=1;i<=n;i++)if(a[i])F[c[a[i]]+c[a[i]]].x-=1;
	ll ans=0;
	for(int i=0;i<limit;i++)ans+=(ll)(F[i].x/2+1e-1)*d[i%len];
	printf("%lld",ans);
}

Measured memory_bytes: 131924
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 300000;
int mod = 1e9 + 7;
int a[N], f[N];
string s;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= m; i++){
        for (int j = 20; j <= d; j++){
            int x = j / 10;
            int y = j % 10;
            if (x * y == i && y >= 2) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 100005
#define True 1
#define False 0

typedef struct queue{
  char n[100];
  int s;
} Queue;

int head, tail, n;
Queue  Q[MAX];

int isFull(){
  if(head==(tail+1)%MAX)return True;
  else return False;
}
void enqueue(Queue x){
  if(isFull()==True){
    fprintf(stderr,"Enqueue Error!\n");
    exit(1);
  }
  Q[tail]=x;
  tail=(tail+1)%MAX;
}
Queue dequeue(){
  Queue x=Q[head];

   head=(head+1)%MAX;
   return x;
}
int min(int x, int y){
  if(x<y)return x;
  else return y;
}

int main(){
  int e=0, mint, i, q;
  Queue queue;

  scanf("%d%d",&n,&q);
  for(i=1 ; i<=n ; i++){
    scanf("%s",Q[i].n);
    scanf("%d",&Q[i].s);
  }
  head=1;
  tail=n+1;
  while(head!=tail){
    queue=dequeue();
    mint=min(q, queue.s);
    queue.s-=mint;
    e+=mint;
    if(queue.s>0)enqueue(queue);
    else{
      printf("%s %d\n",queue.n, e);
    }
  }
  return 0;
}


Measured memory_bytes: 11892
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
  int n;
  cin >> n;
  int ret = INT_MAX;
  for(int i = 0; i < n; ++i){
    int a;
    cin >> a;
    int count = 0;
    while(a % 2 == 0){
      a/=2;
      ++count;
    }
    ret = min(ret, count);
  }
  cout << ret << endl;
  return 0;
}

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

int32_t main() {
  int n;
  cin >> n;
  vector<pair<double,double>> v;
  for (int i = 0; i < n; i++) {
    double x, y;
    cin >> x >> y;
    v.emplace_back(x, y);
  }

  int dd = 2;
  int den = 1;
  for (int i = 1; i <= n; i++) {
    if (i != 1)
      dd *= i - 1;
    den *= i;
  }

  int val = pow(2, n-1);
  double res = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      double dst = sqrt(pow(v[i].first - v[j].first, 2) + pow(v[i].second - v[j].second, 2));
      res += dd * dst;
    }
  }

  cout << fixed << setprecision(10);
  cout << res/den;
}

Measured memory_bytes: 256
A=open(0).read().split()
print('YNeos'[all(t-set(map(A.index,A[10:])) for t in({0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}))::2])

Measured memory_bytes: 3064
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

int main(){
  ll N,K;
  cin >> N >> K;
  ll A[N+10];
  ll pre=1,curr=1;
  ll grade[N+10];
  
  rep(i,1,N+1){
    cin >> A[i];
  }

  int j=1;
  for(int i=K+1;i<=N;i++){
    //curr = ;
    if(A[i-K]<A[i]) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    //pre = curr;
    j++;
  }
  
  return 0;
}


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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 1e3 + 5;

int n, m;
char mat[N][N];
ll dp[N][N];

ll add(ll a, ll b) {
    ll ret = a + b;
    if(ret >= MOD)
        ret -= MOD;

    return ret;
}

void load() {
    scanf("%d%d", &n, &m);

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
            scanf(" %c", &mat[i][j]);
}

void solve() {
    dp[1][1] = 1;

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if((i == 1 && j == 1) || mat[i - 1][j - 1] == '#')
                continue;

            dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    printf("%lld\n", dp[n][m]);
}

int main() {
    load();
    solve();

    return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); 
    string s;
    cin >> s;
    int n = s.size();
    map <char, int> c;
    for (auto to : s) {
        c[to] = true;
    }
    if ((c['W'] ^ c['E']) == 1|| (c['N'] ^ c['S']) == 1) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=998244353;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

ll int n,a,b,k;
ll int inv[310000];
void calc(){
    for (long long i = 1; i < n; i++) {
        inv[i] = (i == 1) ? 1 : (MOD - (MOD / i) * inv[MOD % i] % MOD);
        assert(inv[i] * i % MOD == 1);
    }
}


main(){
   
    cin>>n>>a>>b>>k;
 calc();
    int g;
    int c=a,d=b;
    while(1){
        if(c>d){
            c%=d;
        }
        else{
            d%=c;
        }
        if(c==0||d==0) break;
    }
    g=max(c,d);
    if(k%g!=0) { cout<<0; return 0;}
    a/=g; b/=g; k/=g;
    ll int mina=0,maxb=0;
    rep(i,b){
        if((k-a*i)%b==0){
            mina=i; break;
        }
    }
    if(mina==0&&k%b!=0){
        if(k%a==0){
            mina=k/a;
        }
    }
    maxb=(k-mina*a)/b;
    while(maxb>n){
        maxb-=a;
        mina+=b;
    }
    ll int ans=0;
    ll int pre=1;
    ll int comb[3100000];
    ll int temp=1;
    rep2(i,1,n){

        temp=(temp*(n+1-i))%MOD;

        temp=(temp*inv[i])%MOD;

        comb[i]=temp;
    }
comb[0]=1,comb[n]=1;
    while(mina<=n&&maxb>=0){
        ans+=(comb[mina]*comb[maxb])%MOD;

        ans%=MOD;
        mina+=b;
        maxb-=a;
    }
    cout<<ans;
    return 0;

}   


Measured memory_bytes: 6912
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999

#define MAX_S 2000
#define MAX_T 2000

template<typename T> int lcs(T s,T t){
    int lens=s.size();
    int lent=t.size();
    int dp[MAX_S+1][MAX_T+1]={};

    rep(i,lens){
        rep(j,lent){
            if(s[i]==t[j])  dp[i+1][j+1] = dp[i][j]+1;
            else            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
        }
    }
    return dp[lens][lent];
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s,t;
        cin>>s>>t;
        cout<<lcs(s,t)<<endl;
    }
}

Measured memory_bytes: 18860
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline);

line.shift();

tree = {};

function make_node(n) {
  var node;
  if (tree.hasOwnProperty(n)) return tree[n];
  node = {'parent': -1, 'depth': null, 'type': null, 'children': null};
  tree[n] = node;
  return node;
}

for (i in line) {
  ary = line[i].split(' ');
  node_id = ary.shift();
  node = make_node(node_id);
  ary.shift();
  node.children = ary;
  if (ary.length === 0) node.type = 'leaf';
  else node.type = 'internal node';
  for (j in ary) {
    child = make_node(ary[j]);
    child.parent = node_id;
  }
}

for (i in tree)
  if (tree[i].parent === -1) root_id = i;
root = tree[root_id];
root.type = 'root';

function set_depth(node, depth) {
  var children;
  node.depth = depth;
  children = node.children;
  for (i in children)
    set_depth(tree[children[i]], depth + 1);
}

set_depth(root, 0);

keys = Object.keys(tree);
keys.sort(function (a, b) { return a - b; });

for (i in keys) {
  console.log('node %s: parent = %s, depth = %d, %s, [%s]',
    i, tree[i].parent, tree[i].depth, tree[i].type,
    tree[i].children.join(', '));
}

Measured memory_bytes: 85552
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] arr = {a+b,a-b,a*b};
        Arrays.sort(arr);
        System.out.println(arr[2]);
    }
}


Measured memory_bytes: 35752
S = input()
n = len(S)
templ1 = ""
templ2 = ""
if n&1:
    templ1 = "10" * (n//2) + "1"
    templ2 = "01" * (n//2) + "0"
else:
    templ1 = "10" * (n//2)
    templ2 = "01" * (n//2)

diff1 = 0
diff2 = 0
for s,t1,t2 in zip(S,templ1,templ2):
    if s != t1:
        diff1 += 1
    if s != t2:
        diff2 += 1
print(min(diff1,diff2))

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

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

  long long ans = (x / 11) * 2;

  if(x % 11 != 0){
    if(x % 11 <= 6){
      ans++;
    }else{
      ans += 2;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
<>;
$x=$==1,s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$=*=$&**(-$a%3)/ge,++$h{$x},$t{$x}=$=for`factor`;
$\=!!$h{1};
$h{1}=0;
$\+=$h{$h{$_}>$h{$t{$_}}?$_:$t{$_}},$h{$_}=$h{$t{$_}}=0for keys%h;
print


Measured memory_bytes: 51420
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = i_list()
    a.append(0)
    b = i_list()
    b.append(0)

    m = 0
    for i in range(n):
        trial = sum(a[:i+1]) + sum(b[i:])
        m = max(m, trial)
    print(m)






if __name__=="__main__":
    main()


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 1e6 + 10;
char str[maxn];
int n, A[maxn], B[maxn], tmp[maxn];

void solve() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  int mx = 0, pos = 0;
  rep(i, 1, n) {
    A[i] = A[i - 1] + (str[i] == '1' ? 1 : -1);
    if (mx <= A[i]) mx = A[i], pos = i;
  }
  memcpy(tmp, A, sizeof A);
  B[n] = A[n];
  per(i, n - 1, 1) B[i] = max(B[i + 1], A[i]);
  int s = 0;
  rep(i, pos, n) {
    if (str[i] == '?' && B[i] + s <= mx - 2) s += 2;
    A[i] += s;
  }
  int mn = 0;
  rep(i, 1, n) chkmin(mn, A[i]);
  int res1 = mx - mn;
  memcpy(A, tmp, sizeof A);
  s = 0;
  rep(i, pos, n) {
    if (str[i] == '?' && B[i] + s <= mx - 1) s += 2;
    A[i] += s;
  }
  mn = 0;
  rep(i, 1, n) chkmin(mn, A[i]);
  int res2 = mx - mn + 1;
  cout << min(res1, res2) << endl;
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 16468
#include<stdio.h>

int main()
{
    int A,B,C;
    int x,y,z;
    int ans;

    scanf("%d %d %d\n",&A,&B,&C);

    if(A>=B){
        if(B>=C){
            x=A;
            y=B;
            z=C;
        }
        else{
            if(A>=C){
                x=A;
                y=C;
                z=B;
            }
            else{
                x=C;
                y=A;
                z=B;
            }
        }
    }
    else if(B>A){
        if(A>=C){
            x=B;
            y=A;
            z=C;
        }
        else{
            if(B>=C){
                x=B;
                y=C;
                z=A;
            }
            else{
                x=C;
                y=B;
                z=A;
            }
        }
    }
    ans=x*10+y+z;

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

    return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int h,w; cin >> h >> w;
    string s[h];
    rep(i,0,h){
        cin >> s[i];
    }
    rep(i,0,w+2) cout << "#";
    cout << "\n";
    
    rep(i,0,h){
        cout << "#";
        cout << s[i] <<"#\n";
    }
    rep(i,0,w+2) cout << "#";
    cout << "\n";
}

Measured memory_bytes: 3616
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


N=int(input())
l=[]
for i in range(N):
	l.append(int(input()))
	
l_sort=sorted(l)

max=l_sort[-1]
sub_max=l_sort[-2]

for i in l:
	if i == max:
		print(sub_max)
	else:
		print(max)




Measured memory_bytes: 14112
#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 NUM 100005

int N;
int boss[NUM],height[NUM];
bool is_prime[NUM],check[NUM];
int FINAL_POS[NUM],table[NUM];
stack<int> S[NUM];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

int is_same_group(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	//既に同じグループなら何もしない
	if(boss_x == boss_y)return;

	//高さが高い方に吸収する
	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}


int main(){

	//素数を列挙
	for(int i = 0; i < NUM;i++){
		is_prime[i] = true;
		check[i] = false;
	}
	is_prime[0] = false;
	is_prime[1] = false;

	vector<int> PRIME;
	PRIME.push_back(2);

	for(int i = 3; i < NUM; i += 2){
		if(!is_prime[i])continue;

		for(int k = 2*i; k < NUM; k += i){
			is_prime[k] = false;
		}
	}

	int count = 0;

	for(int i = 3; i < NUM; i += 2){

		if(is_prime[i]){
			count++;
			PRIME.push_back(i);
		}
	}

	for(int i = 0; i < NUM; i++){
		boss[i] = i;
		height[i] = 0;
	}

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d",&table[i]);
		FINAL_POS[i] = table[i];
		check[table[i]] = true;
	}

	for(int num = 2; num <= 100000; num++){
		if(!check[num])continue; //★登場しない数なら飛ばす★
		for(int i = 0; i < PRIME.size(); i++){
			if(PRIME[i] >= num)break;

			if(num%PRIME[i] == 0){
				//printf("%dと%dをunite\n",PRIME[i],num);
				unite(PRIME[i],num);
			}
		}
	}


	sort(FINAL_POS,FINAL_POS+N);

	for(int i = 0; i < N; i++){
		S[FINAL_POS[i]].push(i); //本来その数字があるべき場所(複数あり得る)
	}

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

		if(!is_same_group(table[i],table[S[table[i]].top()])){
			printf("0\n");
			return 0;
		}
		S[table[i]].pop();
	}

	printf("1\n");

	return 0;
}



Measured memory_bytes: 72368
char s[4001];u[4001],m,j,c,d;main(n){for(;m=d=~scanf("%s ",s);printf("%d\n",m))for(n=strlen(s);d-10;d=getchar())for(j=n;j--;m<c?m=c:0)u[j+1]=c=s[j]-d?0:u[j]+1;}

Measured memory_bytes: 432
N=int(input())
A=list(map(int,input().split()))

ans=[0]*N
for i in range(N):
  if i%2==0:
    ans[0]+=A[i]
  else:
    ans[0]-=A[i]
for i in range(N-1):
  ans[i+1]=2*(A[i]-ans[i]//2)
print(*ans)

Measured memory_bytes: 14092