akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define int long long int
#define MOD 1000000007
#define MAX INT_MAX
using namespace std;

int add(int a, int b) {
    int z = (a%MOD + b%MOD) % MOD;
    return z;
}

int mul(int a, int b) {
    int z = (a%MOD * b%MOD) % MOD;
    return z;
}

int myXOR(int x, int y) {
     return (x | y) & (~x | ~y);
}

void solve() {
    int n;
    cin >> n;
    vector <int> v;
    vector <int> ans;
    int max = 0, secmax = 0;
    vector <int> copy;
    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        v.push_back(x);
        copy.push_back(x);
        if(x > max)
            max = x;
    }
    sort(copy.begin(), copy.end(), greater<int>());
    for(int i=0;i<n;i++) {
        if(v[i] < max)
            ans.push_back(max);
        else
            ans.push_back(copy[1]);
    }
    for(int x : ans)
        cout << x << '\n';
    return ;
}              

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 4076
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll imos[33][100100] = {0};
int main(void){
    int n, c;
    cin >> n >> c;
    vector<pair<pair<int,int>,int>> d(n);
    int maxt = 0;
    for(int i = 0; i < n; i++){
        cin >> d[i].first.first >> d[i].first.second >> d[i].second;
        maxt = max(maxt, d[i].first.second);
    }

    

    for(int i = 0; i < n; i++){
        int s = d[i].first.first;
        int t = d[i].first.second;
        int c = d[i].second;
        imos[c][s]++;
        imos[c][++t]--;
    }

    for(int i = 1; i <= c; i++){
        for(int j = 0; j <= maxt; j++){
            if(j > 0) imos[i][j] += imos[i][j - 1];
        }
    }
    int ans = 0;
    for(int i = 0; i <= maxt; i++){
        int tmp = 0;
        for(int j = 1; j <= c; j++){
            //cout << i << " " << j << " " << imos[j][i] << endl;
            if(imos[j][i]){
                tmp++;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

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

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

        int[] dis = new int[3];

        for(int i=0; i<3; i++) {
            dis[i] = scan.nextInt();
        }



        int[] sum = {0, 0, 0};


        sum[0] = dis[0] + dis[1];
        sum[1] = dis[0] + dis[2];
        sum[2] = dis[1] + dis[2];

        Arrays.sort(sum);

        System.out.println(sum[0]);
    }
}


Measured memory_bytes: 22740
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
#define ll long long

using namespace std;

int main()
{
	int n;
	string s;
	cin>>n>>s;
	int l = 0,r = n-1;
	int ans = 0;
	while(l < r)
	{
		while(s[l] == 'R' && l < r) l++;
		while(s[r] == 'W' && l < r) r--;
		if(l < r) swap(s[l], s[r]),ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World"
         << "\n";
  } else if (N == 2) {
    int A, B;
    cin >> A >> B;
    cout << A + B << "\n";
  }
}

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

int main(){
    int a,b,c,n,m;
    int s=0;
    cin>>a>>b>>c>>n;
    for (int i = 0; a*i <= n; i++){
        for (int j = 0; a*i+b*j <= n; j++){
            int k = n-a*i-b*j;
            if (k%c == 0) s++;
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int o=sc.nextInt();
        for (int i = 0; i < o; i++) {
            int gx=sc.nextInt();
            int gy=sc.nextInt();
            int[][][] road=new int[gx+1][gy+1][2];
            int p=sc.nextInt();
            for (int j = 0; j < p; j++) {
                int x1=sc.nextInt();
                int y1=sc.nextInt();
                int x2=sc.nextInt();
                int y2=sc.nextInt();
                if(x1==x2){
                    road[x1][max(y1,y2)][1]=1;
                }else{
                    road[max(x1,x2)][y1][0]=1;
                }
            }
            long[][] step=new long[gx+1][gy+1];
            step[0][0]=1;
            for (int x = 1; x <= gx; x++) {
                if(road[x][0][0]==1)break;
                step[x][0]=1;
            }
            for (int y = 1; y <= gy; y++) {
                if(road[0][y][1]==1)break;
                step[0][y]=1;
            }
            int[] dx={-1,0};
            int[] dy={0,-1};
            for (int y = 1; y <= gy; y++) {
                for (int x = 1; x <= gx; x++) {
                    for (int j = 0; j < 2; j++) {
                        int X=x+dx[j];
                        int Y=y+dy[j];
                        if(road[x][y][j]==0){
                            step[x][y]+=step[X][Y];
                        }
                    }
                }
            }
            out.println(step[gx][gy]==0?"Miserable Hokusai!":step[gx][gy]);
        }
    }
}


Measured memory_bytes: 33180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  double p=3.14159;
  double n;
  cin >> n;
  cout << fixed << setprecision(5);
  cout << 2*p*n << endl;
}


Measured memory_bytes: 3788
n,k = list(map(int, input().split()))
org = list(map(int, input().split()))
h = [10**10 for _ in range(n+k+1)]
for i in range(n):
  h[i] = org[i] 
dp = [10**10 for _ in range(n+k+1)]

dp[0] = 0
for i in range(n):
  for j in range(1, k+1):
    dp[i+j] = min([dp[i+j], dp[i] + abs(h[i] - h[i+j])])
print(dp[n-1])

Measured memory_bytes: 57568
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


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

string S; cin >> S;
int64_t sum = 0ll;
int Slen = S.size();

rep(bit, 0, (1<<(Slen-1))) { // bit全探索, 0 ≦ bit < 0b1000... （0がSlen-1個ならぶ)
    int64_t sub = 0;
    rep(i, 0, Slen){ // Sの位置 
        sub = 10 * sub + (S[i] - '0');
        if (bit & (1<<i)){
            sum += sub;
            sub = 0;
        } 
    }
    sum += sub;
}

cout << sum << "\n";

return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int mod = (int)1e9 + 7;
const int max_size = 2*(int)1e5+1;

long long sum[max_size] = {};
long long dp[max_size] = {};
int n;

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin >> n;
    for(int i = 1,a; i <= n  ;++i){
        cin >> a;
        sum[i] = sum[i-1]+a;
        sum[i] %= mod;
        dp[i] = dp[i-1] + sum[i-1]*a;
        dp[i] %= mod;
    }
    cout << dp[n];
    
    return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define int long long

using namespace std;
using P = pair<int, int>;
using ll = long long;
const ll INF = LLONG_MAX/3;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

bool isprime(int x){
	rep(i,1,sqrt(x)+1)if(gcd(i,x)!=1)return false;
	return true;
}

signed main(){
    int a,b,k;
	cin>>a>>b>>k;
	if(a<=k)cout<<0<<" "<<max(0ll,b-(k-a))<<endl;
	else cout<<a-k<<" "<<b<<endl;

}


Measured memory_bytes: 256
from sys import stdin
H, W, K = (int(i) for i in input().split())
S = [input() for i in range(H)] 
ans = [[0] * W for i in range(H)]
current = 1
firstfounded = False
same = False
copyraw = []
for i in range(H):
    if '#' not in S[i]:
        copyraw.append(i)
        continue
    for j in range(W):
        #print(S[i][j])
        if S[i][j] == '.':
            ans[i][j] = current
        elif S[i][j] == '#' and firstfounded:
            current += 1
            ans[i][j] = current
        else:
            ans[i][j] = current
            firstfounded = True
    current += 1
    firstfounded = False

for i in copyraw:
    for j in range(i+1, H):
        if j not in copyraw:
            for k in range(W):
                ans[i][k] = ans[j][k]
            break
    if j == H-1:
        for k in range(W):
                ans[i][k] = ans[i-1][k]
      
    if i == H-1:
        for k in range(W):
                ans[i][k] = ans[i-1][k]

for i in range(H):
    for j in range(W):
        print(ans[i][j], end=' ')
    print("")


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

int main(){

    string s;
    cin >> s;

    int a=0,b=0;

    rep(i,s.size()){
        if(i%2==0&&s[i]!='0'){
            a++;
        }else if(i%2==1&&s[i]!='1'){
            a++;
        }
    }
    rep(i,s.size()){
        if(i%2==0&&s[i]!='1'){
            b++;
        }else if(i%2==1&&s[i]!='0'){
            b++;
        }
    }

    cout << min(a,b) << endl;

    return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

const FILL: char = '#';
const DX: [i32; 4] = [-1, 0, 1, 0];
const DY: [i32; 4] = [0, -1, 0, 1];

fn main() {
    let h: usize = read();
    let w: usize = read();

    let s: Vec<Vec<char>> = (0..h)
        .map(|_| read::<String>().chars().collect())
        .collect();

    let mut success = true;
    'fullscan: for i in 0..h {
        'nextcell: for j in 0..w {
            if s[i][j] == FILL {
                for k in 0..4 {
                    let x = i as i32 + DX[k];
                    let y = j as i32 + DY[k];

                    if x < 0 || x >= h as i32 { continue 'nextcell; }
                    if y < 0 || y >= w as i32 { continue 'nextcell; }
                    if s[x as usize][y as usize] == FILL { continue 'nextcell; }
                }

                success = false;

                break 'fullscan;
            }
        }
    }

    println!("{}", if success { "Yes" } else { "No" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007


signed main(){

	int K;
	cin >> K;
	vector<int> v(50);

	for (int i = 0; i < 50; i++)
		v[i] = K / 50 + 49;

	for (int n = 0; n < K % 50; n++){
		for (int i = 0; i < 50; i++){
			if (i == n) v[i] += 50;
			else v[i]--;
		}
	}

	cout << 50 << endl;
	for (int i = 0; i < 50; i++)
		cout << v[i] << " ";
	cout << endl;


	return 0;
}


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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;
ll dp[3005][3005];
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}

int main() {
    input;
    int n, s;
    cin >> n >> s;
    int a[n];
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    // dp[i][j] = sum of left endpoints of subsequences with sum j that end at i 
    for(int i = 1; i <= n; i++) {
        dp[i][a[i]] = i;

        for(int j = 0; j <= s; j++) {
            dp[i][j] += dp[i - 1][j];
            dp[i][j] %= mod;
            if(j - a[i] >= 0) {            
                dp[i][j] += dp[i - 1][j - a[i]];
                dp[i][j] %= mod;
            }
        }
        
    }
    for(int i = 1; i <= n; i++) {
        debug(dp[i][s]);
        dp[i][s] += dp[i - 1][s];
        dp[i][s] %= mod;
    }


    cout << dp[n][s];
}


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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
const ll MAX_N=131072;
const ll INF=1000000;
const ll MOD=1000000007;
int main(){
    int N;int a[100];cin>>N;
    int sum=0;
    rep(i,N) {
        cin>>a[i];
        sum+=a[i];
    }
    if (sum<0){
        sum-=N/2;
    }else sum+=N/2;
    sum/=N;
    int ans=0;
    rep(i,N) ans+=pow(a[i]-sum,2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()

fastest = []
latest = []


date = 1

for work_days in range(K):
    while S[date - 1] == 'x':
        date += 1
    fastest.append(date)
    date += C + 1

date = 1

for work_days in range(K):
    while S[- date] == 'x':
        date += 1
    latest.append(N - (date - 1))
    date += C + 1
    
for i in range(K):
    if fastest[i] == latest[- (i + 1)]:
        print(fastest[i])

Measured memory_bytes: 20648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;

#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){\
cout << it.fi << " " << it.se << endl;}


#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
//#define endl "\n"
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n;
    n=s.size();
    vec v(n);
    vec v1(n);
    for (int i = n - 1; i >= 0;i--){
        int val = power(10, n - 1 - i, 2019);
        v[i] = val * (s[i] - '0');
        v[i] %= 2019;
        v1[i] = (s[i] - '0') % 3;
    }
    for (int i = n - 2; i >= 0;i--){
        v[i] += v[i + 1];
        v[i] %= 2019;
         v1[i] += v1[i + 1];
         v1[i] %= 3;
    }
    map<int, int> m;
    int ans = 0;
    fo(i,n){
        if(v[i]==0){
            ans++;
        }
        ans += m[v[i]];
        m[v[i]]++;

    }
    cout << ans;
}

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

int main() {
    ll H, W;
    cin >> H >> W;
    vector<string> a(H);
    for (ll i = 0; i < H; i++) {
        cin >> a[i];
    }

    constexpr ll MOD = 1e9 + 7;

    vector<vector<ll>> dp(H, vector<ll>(W, 0));
    dp[0][0] = 1;
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            if (a[i][j] == '#') {
                continue;
            }
            if (i < H - 1 && a[i + 1][j] != '#') {
                (dp[i + 1][j] += dp[i][j]) %= MOD;
            }
            if (j < W - 1 && a[i][j + 1] != '#') {
                (dp[i][j + 1] += dp[i][j]) %= MOD;
            }
        }
    }

    cout << dp[H - 1][W - 1] << endl;
}

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

int main()
{
    int N;
    string S;
    int x = 0;
    int ans = 0;
    cin >> N >> S;

    for(int i=0;i<N;i++){
        if(S[i] == 'I'){
            x++;
        }

        else {
            x--;
        }
        ans = max(x,ans);
    }

    cout << ans << endl;

    return 0;
}

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


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    string S;
    cin>>S;
    ll s = 0,g=S.size();
    rep(i,0,S.size()){
        if(S[i] == 'A'){
            s = i;
            break;
            }
    }
    for(ll i = S.size()-1;i >=0;i--){
        if(S[i] == 'Z'){
            g = i;
            break;
        }
    }
    cout<<g-s+1;
    return 0;
}

Measured memory_bytes: 640
import copy
def main():
    n = int(input())
    act3 = [0]*3
    for i in range(n):
        if i==0:
            act1 = list(map(int, input().split()))
        else:
            act2 = list(map(int, input().split()))
            for j, act in enumerate(act2):
                act3[j] = max(act1[j-1] + act, act1[j-2] + act)
            act1 = copy.copy(act3)
    print(max(act1))

main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
int const mod = 1e9+9;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            // res = res*a;
            res = (res*a)%m;
        }
        a=(a*a)%m;
        // a%=m;
        b=b/2;
    }
    return res;
}
// ll mul(ll num1,ll num2,ll m){
//     ll x = (num1*num2)%m;
//     return x;
// }

// ll add(ll num1,ll num2,ll m){
//     ll x = ((num1%m)+(num2%m))%m;
//     return x;
// }

// ll sub(ll num1,ll num2,ll m){
//     ll x = (((num1%m)-(num2%m))%m + m)%m;
//     return x;
// }


int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 1e5+5;
int const inf = 2e18;

void solve(){  
    int i,j;
    int n;
    cin >> n;
    int ans[n+1]={0};

    for(int x=1;x<=n;x++){
        if(x*x > n) break;
        for(int y=1;y<=n;y++){
            if(x*x + y*y + x*y > n) break;
            for(int z=1;z<=n;z++){
                if(x*x + y*y + z*z + x*y + y*z + x*z > n) break;
                int p = x*x + y*y + z*z + x*y + y*z + x*z;
                ans[p]++;
            }
        }
    }
    for(i=1;i<=n;i++) cout<<ans[i]<<endl;
}           

int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

*/

Measured memory_bytes: 3644
N = gets.strip.to_i
A = Array.new(N)
B = gets.strip.split(' ').map(&:to_i)
(0..N-2).each do |i|
  B[i-1] < B[i] ? A[i] = B[i-1] : A[i] = B[i]
  A[i] = B[i] if i == 0
  A[i+1] = B[i] if i == N - 2
end
puts A.inject(&:+)

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int ans;
    string S;
    cin >> S;
    bool b = false;
    for (int i = 1; i < S.length(); i++)
    {
        if (S[i] != '9') {
            b = true;
            break;
        }
    }
    ans = S[0] - '0' + 9 * (S.length() - 1);
    if (b && S.length() != 1) ans--;
    cout << ans << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N, M = map(int, input().split())
dis_list = []
my_count = Counter()
for i in range(1, N + 1):
    my_count[i] = 0
for i in range(M):
    a, b = map(int, input().split())
    my_count[a] += 1
    my_count[b] += 1
my_count = sorted(my_count.items())
for i in range(N):
    print(my_count[i][1])

Measured memory_bytes: 9396
n,m=map(int,input().split())

ans=[0 for i in range(n+1)]

list_tonari=[[] for i in range(n+1)]

for i in range(m):
  a,b=map(int,input().split())
  list_tonari[a].append(b)
  list_tonari[b].append(a)
  
const=list()
const.append(1)

const_vary=list()


while 1:
  const_vary=const
  const=[]
  
  while len(const_vary):
    get=const_vary.pop()
    
    for n in list_tonari[get]:
      if ans[n] ==0:
        ans[n]=get
        list_tonari[n].remove(get)
        const.append(n)
        
  if len(const)==0:
    break
    
print("Yes")
for n in ans[2:]:
  print(n)

Measured memory_bytes: 34724
n=int(input())
s1=input()
s2=input()
if s1[0]==s2[0]:
    i=1
else:
    i=0
ans=3

flag=False
while i<n:
    if s1[i]==s2[i]:
        if flag:
            flag=False
            i+=1
        else:
            ans*=2
            i+=1
    else:
        if flag:
            ans*=3
            i+=2
        else:
            ans*=2
            i+=2
            flag=True

print(ans%(10**9+7))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  string s1 = to_string(n), s2 = to_string(n);
  reverse(s2.begin(), s2.end());
  cout << (s1 == s2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
  char trout[2001][2001];
  int range[2001][2001] = {0};
  int h, w;

  scanf("%d %d", &h, &w);

  int x, y;
  for (y = 0; y < h; y++)
  {
    scanf("%s", trout[y]);
  }

  int start, norm;
  for (y = 0; y < h; y++)
  {
    x = 0;
    while (x < w)
    {
      start = x;
      while (trout[y][x] == '.')
        x++;
      norm = x - start;
      while (start < x)
      {
        range[y][start] += norm;
        start++;
      }
      while (trout[y][x] == '#')
        x++;
    }
  }
  for (x = 0; x < w; x++)
  {
   	y = 0;
    while (y < h)
    {
      start = y;
      while (trout[y][x] == '.')
        y++;
      norm = y - start;
      while (start < y)
      {
        range[start][x] += norm;
        start++;
      }
      while (trout[y][x] == '#')
        y++;
    }
  }

  int max;
  for (y = 0; y < h; y++)
  {
    for (x = 0; x < w; x++)
      max = max(range[y][x], max);
  }

  printf("%d\n", max - 1);
  return 0;
}


Measured memory_bytes: 19712
#At coder 2020/2/16 C
import collections

# スペース区切りのサイズNの配列の入力
# スペース区切りのサイズNの配列の入力
N = int(input())
S = [0] * N

for ii in range(N):
    S[ii] = input()
#S=str(S)


c = collections.Counter(S)

maxv=max(c.values())
#print(c)
#c = sorted(c.items())

ans = [k for k, v in c.items() if v == maxv]
#ans = sorted(ans.items())
ans=sorted(ans)


for ii in range(len(ans)):
    print(ans[ii])
#    if v == maxv :
#        print(k)

Measured memory_bytes: 35560
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N, L; cin >> N >> L;
    vector<int> a(N + 1);
    for (int i = 1; i <= N; i++) cin >> a[i];

    for (int i = 1; i <= N - 1; i++) {
        if (a[i] + a[i + 1] >= L) {
            cout << "Possible" << endl;
            for (int j = 1; j < i; j++) cout << j << endl;
            for (int j = N-1; j >= i; j--) cout << j << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 1152
N = int(input())

# 最初の符号
print(0, flush=True)
first = input()

if first == 'Vacant':
    exit()

if first == 'Male':
    first = 1
else:
    first = -1

notHas = 1
has = N - 1

while has - notHas > 1:
    mid = (notHas + has) // 2
    print(mid, flush=True)
    ret = input()

    if ret == 'Vacant':
        exit()

    if ret == 'Male':
        ret = 1
    else:
        ret = -1

    trueValue = first * (-1)**(mid % 2)
    if ret == trueValue:
        notHas = mid
    else:
        has = mid

print(notHas, flush=True)
ret = input()

if ret == 'Vacant':
    exit()

print(has, flush=True)
input()
exit()

Measured memory_bytes: 3660
#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()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int n = S.size();
    vector<char>s(n);
    rep(i,n)s[i] = S[i];
    vector<char>t(n);
    rep(i,n)cin >> t[i];
    
    rep(i,n){
        bool ok = true;
        rep(j,n){
            int x = i+j;
            if(x >= n)x -= n;
            if(s[x] != t[j])ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e15;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

ll pwr (ll a, ll p) {
    if (p == 0) return 1ll;
    if (p == 1) return (a%MOD);
    ll ret = pwr(a, p/2);
    ret *= ret;
    ret %= MOD;
    if (p%2 == 1) ret *= (a%MOD);
    return (ret%MOD);
}

ll n, k;
//ll dp[MAXN];
ll atim[MAXN];

int main() {
	setIO();

    cin >> n >> k;

    ll s = 0;

    for (ll i = k; i > 0; i--) {
        ll a = k/i;
        ll rem = (pwr(a,n)+MOD-(atim[i]%MOD))%MOD;
        s += (i*rem)%MOD;
        s %= MOD;

        //cout << " i=" << i << " addig=" << rem << "  atim=" << atim[i] << endl;

        set<ll> divs;

        for (ll d = 1; d <= 1; d++) {
            ll N = d*i;
            for (ll j = 1; j*j <= N; j++){
                if (N%j > 0) continue;
                //atim[j] += rem;
                //atim[i/j] += rem;
                divs.insert(j);
                divs.insert(N/j);
            }
        }

        for (ll x : divs) atim[x]+=rem;

    }

    cout << s;

	return 0;
}




Measured memory_bytes: 4392
#include <stdio.h>

int main()
{
	int y, m, d, res;
	scanf("%d/%d/%d", &y, &m, &d);

	if(y > 2019){
		res = 1;
	} else if(y == 2019){
		if(m > 4){
			res = 1;
		} else if(m == 4){
			if(d > 30){
				res = 1;
			} else if(d == 30){
				res = -1;
			} else {
				res = -1;
			}
		} else {
			res = -1;
		}
	} else {
		res = -1;
	}

	if(res == 1){
		printf("TBD\n");
	} else {
		printf("Heisei\n");
	}
}


Measured memory_bytes: 128
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int parent[100001];
int size[100001],ans[100001];

int find_set(int v){
	if(parent[v]==v)return v;
	else return parent[v]=find_set(parent[v]);
}

int union_set(int a,int b){
	int pa=find_set(a);
	int pb=find_set(b);
	if(pa!=pb){
		parent[pb]=pa;
		size[pa]+=size[pb];
	}
} 

int make_set(int v){
	parent[v]=v;
	size[v]=1;
}

int solve(){
    int n,m,k;
    cin>>n>>m>>k;
	rep(i,0,n+1)make_set(i);
	while(m--){
		int x,y;
		cin>>x>>y;
		ans[x]++;ans[y]++;
		union_set(x,y);
	}
	while(k--){
		int x,y;
		cin>>x>>y;
		if(find_set(x)==find_set(y)){
			ans[x]++;
			ans[y]++;
		}	
	}
	rep(i,1,n+1){
		cout<<size[find_set(i)]-ans[i]-1<<" ";
	}
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 2688
import sys
import math
from collections import deque
from collections import defaultdict
INF = 10**9

def main():
    h, n = list(map(int,sys.stdin.readline().split()))
    magic = [list(map(int,sys.stdin.readline().split())) for _ in range(n)]
    #print(magic)
    max_a = max(a for a, b in magic)
    dp = [0] * (h + max_a + 1)
    for i in range(1, h + max_a):
        dp[i] = min(dp[i - a] + b for a, b in magic)
        #print(dp)
    print(dp[h])

    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 3964
def main():
    N, W = map(int, input().split())
    dp = [0]*(W+1)

    for _ in range(N):
        w, v = map(int, input().split())
        for j in range(W,-1,-1):# 後ろから更新しないとダメ
            if j - w >= 0:
                dp[j] = max(dp[j], dp[j-w]+v)
    print(dp[W])    

if __name__ == "__main__":
    main()

Measured memory_bytes: 67332
def upper_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m] <= v then l = m
    else r = m
    end
  end
  r
end
 
EPS = 1e-9

n, m, l = gets.split.map(&:to_i)
p, t, v = n.times.map{ gets.split.map(&:to_f) }.transpose
time_set = n.times.map{ [0] * (m + 1) }
prob_set = n.times.map{ [0] * (m + 1) }

factorial = (1..m).each_with_object([1]) { |i, arr| arr << arr[-1] * i }
n.times do |i|
  s = l / v[i]
  (m + 1).times do |j|
    time_set[i][j] = s + t[i] * j
    prob_set[i][j] = (p[i] / 100.0) ** j * (1 - p[i] / 100.0) ** (m - j) * factorial[m] / factorial[m - j] / factorial[j]
  end
end
prob_sum = prob_set.map{ |ps| (0..m).map{ |i| ps[i..-1].reduce(:+) } }
n.times do |i|
  ret = 0
  (m + 1).times do |j|
    prob = prob_set[i][j]
    n.times do |k|
      next if i == k
      idx = upper_bound(time_set[k], time_set[i][j] + EPS)
      if idx == m + 1
        prob = 0
        break
      end
      prob *= prob_sum[k][idx]
    end
    ret += prob
  end
  puts '%.8f' % ret
end

Measured memory_bytes: 9192
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      m: usize,
      ab: [(usize, usize); m]
   }

   let mut to = vec![vec![]; n];
   for (a, b) in ab {
      to[a-1].push(b-1);
      to[b-1].push(a-1);
   }
   let mut ans = false;
   for &v in to[0].iter() {
      for &u in to[v].iter() {
         if u == n-1 {
            ans = true;
            break;
         }
      }
   }
   if ans {
      println!("POSSIBLE");
   } else {
      println!("IMPOSSIBLE");
   }
} 


Measured memory_bytes: 22780
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	ll A=gi(),B=gi();
	if(A==B)return puts("1"),0;
	for(int i=59;~i;--i)
		if(((A>>i)&1)==((B>>i)&1))
			A&=~(1ll<<i),B&=~(1ll<<i);
		else break;
	ll T=1;while((T<<1)<=B)T<<=1;
	ll ans=T-A;
	ll P=-1;
	while(T+(1ll<<P+1)<=B)++P;
	ll OR=T+(1ll<<P+1)-1;
	if(OR<T+A)ans+=OR-T+1+2*T-(T+A);
	else ans+=T;
	printf("%lld\n",ans);
	return 0;
}


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

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

    double l;
    cin >> l;

    l /= 3.0;

    double ans = l * l * l;
    cout << fixed << setprecision(10) << ans  << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[][] graph = new int[N][N];
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      graph[a][b] = graph[b][a] = 1;
    }

    boolean[] visited = new boolean[N];
    visited[0] = true;
    System.out.println(dfs(N, graph, visited, 0));
  }

  private static int dfs(int N, int[][] graph, boolean[] visited, int id) {
    visited[id] = true;
    int numVisited = 0;
    for (int i = 0; i < N; i++) if (visited[i]) numVisited++;
    if (numVisited == N) {
      return 1;
    }
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (graph[id][i] == 1 && !visited[i]) {
        visited[i] = true;
        count += dfs(N, graph, visited, i);
        visited[i] = false;
      }
    }
    return count;
  }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,k,s;
	scanf("%d%d%d",&n,&k,&s);
	if(s<=2) {
		for(int i=1;i<=n;i++) {
			printf("%d%c",i<=k?s:100,i==n?'\n':' ');
		}
	}
	else {
		for(int i=1;i<=n;i++) {
			printf("%d%c",i<=k?s:s-1,i==n?'\n':' ');
		}
	}
	return 0;
}

Measured memory_bytes: 1280
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    if a<=0<=b
        println("Zero")
    elseif b<0 && (b-a)%2==0
        println("Negative")
    else
        println("Positive")
    end
end
main()

Measured memory_bytes: 167384
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,C,D,E,F=get_i
water=array(F/100+1,false)
water[0]=true
A.step(F/100,A) do|i|
  water[i]=true
end
(F/100-B+1).times do|i|
  water[i+B]=true if water[i] 
end
suger=array(F,false)
suger[0]=true
C.step(F,C) do|i|
    suger[i]=true
end
(F-D+1).times do|i|
    suger[i+D]=true if suger[i]
end
ans_s=0
ans_w=100
water.each_with_index do|f,w|
    next if not f or w.zero?
    s=0
    min(F-w*100,E*w).downto(0) do|x|
      if suger[x] and x>s
          s=x
      end 
    end
    if ans_s*w*100<=s*ans_w
      ans_s=s
      ans_w=w*100
    else
      break
    end
end
puts [ans_s+ans_w,ans_s].join(" ")

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

int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> ans(n);
  rep(i,n){
    cin >> a[i];
    b[i]=a[0]^a[i];
  }
  int x=0;
  rep(i,n){
    x^=b[i];
  }
  ans[0]=x^a[0];
  for(int i=1;i<n;i++) ans[i]=b[i]^ans[0];
  
  rep(i,n) cout << ans[i] << "\n";
  return 0;
}

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

using namespace std;

string s, p;

void solve() {
    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < p.size(); j++) {
            if(s[(i+j) % s.size()] != p[j]) break;
            if(j == p.size()-1) {
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

int main() {
    cin >> s >> p;
    solve();
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;

int main(void) {
	cin >> n;
	set<int> se;
	multiset<int> mse;
	rep(i, n){
		int t; cin >> t;
		se.insert(t), mse.insert(t);
	}

	ll ma1 = 0, ma2 = 0;
	for(auto u : se) {
		if(mse.count(u) >= 4) {
			chmax(ma1, u), chmax(ma2, u);
		}else if(mse.count(u) >= 2){
			if(u > ma1) {
				ma2 = ma1, ma1 = u;
			}else if(u > ma2) {
				ma2 = u;
			}
		}
	}
	cout << ma1 * ma2 << endl;
	return 0;
}

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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    char c[4]; cin >> c;
    for(int i = 1; i < 4; i++) if(c[i] == c[i-1]) return cout << "Bad", 0;
    cout << "Good";    
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int x[200], a, b;
int main() {
	while (cin >> a >> b) {
		for (int i = 0; i < 200; i++)x[i] = 0;
		x[a]++; x[b]++; while (true) { cin >> a >> b; if (a == 0) { break; }x[a]++; x[b]++; }
		int F = 0; for (int i = 3; i < 200; i++) { if (x[i] % 2 == 1)F = 1; }
		if (x[1] % 2 == 0 || x[2] % 2 == 0)F = 1; if (F == 1)cout << "NG" << endl; else cout << "OK" << endl;
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, l = 0, x = 0, y = 0;
cin >> n;
int a[n], b[n], s = 0;
vector <int> v, f;
for (int i = 0; i < n; i++)
    cin >> a[i];
for (int i = 0; i < n; i++)
    v.push_back (a[i]);
for (int i = 0; i < n; i++)
    cin >> b[i];
for (int i = 0; i < n; i++)
    f.push_back (a[i]);
for (int i = 0; i < n; i++)
{
    if (a[l] > b[l]){
        x += a[l];
        y += b[l];
    }
    l++;
}
cout << x - y;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        for(int i = M / N; i > 0; i--){
            if((M - (N * i)) % i == 0){
                System.out.println(i);
                break;
            }
        }
        sc.close();
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=5e3+7;
ll val[maxn][maxn];
int b[maxn][205];
int a[maxn];
int st[maxn],ed[maxn];
inline void add(int v,int x1,int y1,int x2,int y2)
{
	val[x1][y1]+=v;
	val[x1][y2+1]-=v;
	val[x2+1][y1]-=v;
	val[x2+1][y2+1]+=v;
}
ll dp[2][maxn];
ll pre[maxn];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<n;i++) 
	{
		cin>>a[i];
		pre[i+1]=pre[i]+a[i];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>b[i][j];
	for(int j=1;j<=m;j++)
	{
		stack<int> s;
		for(int i=1;i<=n;i++)
		{
			while(!s.empty()&&b[s.top()][j]<b[i][j])
			{
				ed[s.top()]=i-1;
				s.pop();
			}
			if(s.empty()) st[i]=1;
			else st[i]=s.top()+1;
			s.push(i);
		}
		while(!s.empty())
		{
			ed[s.top()]=n;
			s.pop();
		}
		for(int i=1;i<=n;i++)
			add(b[i][j],st[i],i,i,ed[i]);
	}
	ll ans=0;
	int cc=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dp[cc][j]=-dp[cc^1][j-1]+val[i][j]+dp[cc^1][j]+dp[cc][j-1];
			if(i<=j) ans=max(ans,dp[cc][j]-(pre[j]-pre[i]));
		}
		cc^=1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 199040
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = deque([])
    for i, a in enumerate(A):
        if i % 2 == N % 2:
            B.append(a)
        else:
            B.appendleft(a)

    print(*B)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 111376
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,ans=1;
    cin>>n;
    for(ll i=1;i*i<=n;i++){
            if(n%i==0) ans=max(i,ans);
    }
    cout<<n/ans+ans-2;
}

Measured memory_bytes: 3620