akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

int N, D;
vector<int> C;
vector<vector<int>> S;

vector<int> ans;

void Read(bool local = false) {
  N = 26;
  if (local) {
    D = 365;
  } else {
    cin >> D;
  }
  C.resize(N);
  for (int i = 0; i < N; i++) {
    if (local) {
      C[i] = rnd() % 100;
    } else {
      cin >> C[i];
    }
  }
  S.resize(D);
  for (int i = 0; i < D; i++) {
    S[i].resize(N);
    for (int j = 0; j < N; j++) {
      if (local) {
        S[i][j] = rnd() % 20000;
      } else {
        cin >> S[i][j];
      }
    }
  }
  ans.assign(D, 0);
}

void Write() {
  for (auto i : ans) {
    cout << i + 1 << "\n";
  }
}

int Arithmetic(int n) {
  return n * (n - 1) / 2;
}

vector<set<int>> Build(vector<int> a) {
  vector<set<int>> occ(N);
  for (int i = 0; i < D; i++) {
    occ[a[i]].insert(i);
  }
  for (int i = 0; i < N; i++) {
    occ[i].insert(-1);
    occ[i].insert(D);
  }
  return occ;
}

int Evaluate(vector<int> a) {
  vector<int> last(N, -1);
  int score = 0;
  for (int i = 0; i < D; i++) {
    score += S[i][a[i]];
    last[a[i]] = i;
    for (int j = 0; j < 26; j++) {
      score -= C[j] * (i - last[j]);
    }
  }
  return score;
}

int Evaluate(int init_score, const vector<int> &a, const vector<set<int>> &occ, int d, int q) {
  if (a[d] == q) return init_score;
  const set<int> &cur = occ[a[d]];
  auto pos = cur.lower_bound(d);
  int lst = *prev(pos);
  int nxt = *next(pos);

  int score = init_score;
  score += C[a[d]] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  pos = occ[q].upper_bound(d);
  lst = *prev(pos);
  nxt = *pos;
  score -= C[q] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  score -= S[d][a[d]];
  score += S[d][q];

  return score;
}

void Change(int &init_score, vector<int> &a, vector<set<int>> &occ, int d, int q) {
  int new_score = Evaluate(init_score, a, occ, d, q);
  init_score = new_score;
  occ[a[d]].erase(d);
  a[d] = q;
  occ[a[d]].insert(d);
}

void Solve() {
  vector<int> a(D);
  for (int i = 0; i < D; i++) {
    a[i] = i % N;
  }
  int score = Evaluate(a);
  vector<set<int>> occ = Build(a);

  double temp = 10000;
  double cooling_rate = 0.9999;
  double absolute_zero = 0.001;

  while (temp > absolute_zero) {
    int d = rnd() % D;
    int q = rnd() % N;
    int delta = Evaluate(score, a, occ, d, q) - score;
    if (delta > 0 || exp(delta / temp)) {
      Change(score, a, occ, d, q);
    }
    temp *= cooling_rate;
  }
  if (Evaluate(ans) < Evaluate(a)) {
    ans = a;
  }
}

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

  Read(1);
  for (int rep = 0; rep < 10; rep++) {
    Solve();
  }
  Write();
  cerr << Evaluate(ans) << "\n";
  return 0;
}


Measured memory_bytes: 4336
import java.util.Scanner;

public class Main {
	static long[] memo; 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		memo = new long[n+1];
		memo[0] = 1;
		memo[1] = 1;
		
		for (int i = 2; i <= n; i++) {
			memo[i] = memo[i-1] + memo[i-2];
		}
		
		System.out.println(memo[n]);
	}
	
}

Measured memory_bytes: 17232
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

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

#define EPS 1e-6

using namespace std;


int main(){

vector<int>v;
int a;
rep(i,5){

cin >> a;
v.push_back(a);

}

sort(v.begin(),v.end(),greater<int>());

cout << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << " " << v[4] << endl;

return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int h,w,k; cin >> h >> w >> k;
    vector<string> cho(h);
    rep(i,h) cin >> cho[i];
    int tans=INF; 

    rep(i,1<<(h-1)){
        vector<int> now(h,0);
        vector<int> group(h,-1);
        int g=0;
        rep(j,h){
            group[j]=g;
            if(i>>j&1) g++;
        }
        g++;
        int ans=g-1;
        int check=-1;
        int p=0;
        while(p<w){
            check++;
            int c=0;
            rep(j,g){
                while(group[c]==j && c<h){
                    if(cho[c][p]=='1') now[j]++;
                    c++;
                }
            }
            bool wr=true; bool nest=true;
            rep(j,g){
            if(now[j]>k){
                if(!check){
                    wr=false;
                    break;
                }
                nest=false;
                break;
            }
            }
            if(nest==false){
                ans++;
                rep(j,g) now[j]=0;
                check=-1;
                p--;
            }
            if(wr==false){
                rep(j,g) now[j]=0;
                ans=INF;
                break;
            }
            p++;
        }
    tans=min(tans,ans);
    }
    cout << tans << endl;
    return 0;
}


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

using namespace std;

int main(){
  for(int N;cin>>N,N;){
    const int C=55440;
    int a[C]={};
    int eq[25][24]={};
    while(N--){
      int d,t;
      cin>>d>>t;
      int q[24];
      for(int i=0;i<d;i++){
	cin>>q[i];
	eq[d][(i-t+d)%d]+=q[i];
      }
      if(C%d==0){
	for(int i=0;i<C;i++){
	  a[i]+=q[(i+t)%d];
	}
      }
    }
    for(int i=1;i<=24;i++){
      if(C%i){
	int m=*max_element(eq[i],eq[i]+i);
	for(auto &e:a){
	  e+=m;
	}
      }
    }
    cout<<*max_element(begin(a),end(a))<<endl;
  }
}

Measured memory_bytes: 1388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String[] a = new String[2];
		int[] b = new int[2];

		for (int i = 0; i < 2; i++) {
			a[i] = sc.next();

			if (a[i].equals("A")) {
				b[i] = 10;
			} else if (a[i].equals("B")) {
				b[i] = 11;
			} else if (a[i].equals("C")) {
				b[i] = 12;
			} else if (a[i].equals("D")) {
				b[i] = 13;
			} else if (a[i].equals("E")) {
				b[i] = 14;
			} else if (a[i].equals("F")) {
				b[i] = 15;
			}
		}

		if (b[0] < b[1]) {
			System.out.println("<");
		} else if (b[0] > b[1]) {
			System.out.println(">");
		} else {
			System.out.println("=");
		}

	}
}

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

using namespace std;

int m,n;

void solve(){
    int i,j;
    string str;
    cin >> n >> m;
    vector<int> a(n);
    for(i = 0;i < n;i++) cin >> a[i];
    int s = 0;
    for(i = 0;i < n;i++) s += a[i];
    long long ans = 0;
    for(i = 0;i < n;i++) if(a[i]*4*m >= s) ans++;
    if(ans < m) cout << "No" << endl;
    else cout << "Yes" << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
//#include <iostream>
//#include <vector>
//#include <set>
//#include <map>
//#include <algorithm>

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll len = 2 * (int) 1e5 + 1;


int main() {
//    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        int ptr = 1;
        for (int j = i + 1; j < n ; j++) {
            while (ptr < n && a[ptr] < a[i] + a[j]) {
                ptr++;
            }
            ans += max(0, ptr - j - 1);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int player[100005],q,a,n,st_v;
int main()
{
    cin>>n>>st_v>>a;
    for(int i=0;i<a;i++)
    {
       cin>>q;
       player[q]++;
    }
    for(int i=1;i<=n;i++)
    {
      //  cout<<player[i]<<" "<< player[i]-a+st_v;
        if(player[i]-a+st_v > 0)
            cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 S              PIC X(100).
01 ans            PIC X(100).

PROCEDURE DIVISION.
  ACCEPT S.
  PERFORM FUNCTION STORED-CHAR-LENGTH(S) TIMES
      STRING ans(1:FUNCTION STORED-CHAR-LENGTH(ans)) "x" INTO ans
  END-PERFORM.
  DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
  STOP RUN.


Measured memory_bytes: 636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<set>
#include<queue>

using namespace std;

typedef pair<int,int> PII;
typedef long long ll;

int main(){

	int n,m;

	while(true){
		cin>>n>>m;
		
		if(!n&&!m)break;

		vector<int> peoples(n);

		int j = 0,i = 0,c = 0;
		while(c<n-1){
			while(peoples[j] == 1){
				j++;
				j%=n;
			}
			if(i%m == m-1){
				c++;
				peoples[j] = 1;
			}
			i++;
			j++;
			j%=n;
		}

		for(int i=0;i<n;i++){
			if(peoples[i] == 0){
				printf("%d\n",i+1);
				break;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 908
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
print(-(-(n-1)//(k-1)))

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

int main(){
    unsigned long L, A, B, M;
    cin >> L >> A >> B >> M;
    cout << [impl = [&M](auto f, auto L, auto A, auto B) -> pair<unsigned long, unsigned long> {
        if(to_string(A).size() < to_string(A + B * (L - 1)).size()){
            auto a = f(f, L / 2, A, B), b = f(f, (L + 1) / 2, A + B * (L / 2), B);
            return {a.first * b.first % M, (a.second * b.first + b.second) % M};
        }
        unsigned long ret = 0, len = to_string(A).size(), N = L,  R = 1, K = 1, p = 10;
        A %= M;
        B %= M;
        while(len){
            if(len & 1)(R *= p) %= M;
            (p *= p) %= M;
            len >>= 1;
        }
        p = R;
        while(L){
            if(L & 1)(K *= p) %= M;
            (p *= p) %= M;
            L >>= 1;
        }
        while(N){
            if(N & 1){
                ((ret *= R) += A) %= M;
                (A += B) %= M;
            }
            ((A *= R + 1) += B) %= M;
            (B *= 2 * (R + 1)) %= M;
            (R *= R) %= M;
            N >>= 1;
        }
        return {K, ret};
    }](auto L, auto A, auto B){return impl(impl, L, A, B).second;}(L, A, B) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
  int i, j, k, n, f = 0, now = 0;
  scanf("%d", &n);
  char s[n + 10];
  scanf("%s", s);
  for(i = 0; i < n; ++i) {
    if(s[i] == '(') now++;
    else {
      if(now) now--;
      else f++;
    }
  }
  for(i = 0; i < f; ++i) printf("(");
  printf("%s", s);
  for(i = 0; i < now; ++i) printf(")");
  return 0;
}


Measured memory_bytes: 128
#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 ;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
	ll n ;
    cin >> n ;
    vector<pair< pair<string,ll> , ll> > v ;
    rep( i , 0 , n ){
        string s ;
        ll x ;
        cin >> s >> x ;
        v.pb({{s,-x},i+1});
    }
    sort(all(v));
    
    rep( i , 0 , n )
        cout << v[i].s << '\n' ; 
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


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

ll mod = 1e9 + 7;

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W, 0)), B(H, vector<int>(W, 0)); 
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> B[i][j];
        }
    }
    vector<vector<vector<bool>>> dp(H, vector<vector<bool>>(W, vector<bool>(20000, false)));
    dp[0][0][10000+A[0][0]-B[0][0]] = true;
    dp[0][0][10000+B[0][0]-A[0][0]] = true;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int t = abs(A[i][j]-B[i][j]);
            for (int k = 0; k < 20000; k++) {
                if (i > 0) {
                    if (k-t >= 0 && dp[i-1][j][k-t]) dp[i][j][k] = true;
                    if (k+t <= 19999 && dp[i-1][j][k+t]) dp[i][j][k] = true;
                }
                if (j > 0) {
                    if (k-t >= 0 && dp[i][j-1][k-t]) dp[i][j][k] = true;
                    if (k+t <= 19999 && dp[i][j-1][k+t]) dp[i][j][k] = true;
                }
            }
        }
    }
    int ans = 10000;
    for (int i = 0; i < 20000; i++) {
        if (dp[H-1][W-1][i] && abs(10000-i) < ans) ans = abs(10000-i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

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

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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='1'){
            s[i]='9';
        }else{
            s[i]='1';
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
import Text.Printf

main = interact $ show' . solve . read'
  where
    show' = unlines . map (printf "%.9f")
    solve xs = [minkovsky 1 xs, minkovsky 2 xs, minkovsky 3 xs, minkovsky (-1) xs]
    minkovsky p [a, b] = (g $ zipWith f a b) ** (1 / p')
      where
        f x y = (abs (x - y)) ** p'
        g | p == -1 = foldr1 max
          | otherwise = sum
        p' | p == -1 = 1
           | otherwise = p
    read' = map (map read . words) . tail . lines :: String -> [[Double]]



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}

template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


int main() {
	ll a = -150;
	int A = 0, B = 0;
	ll ans = 0;
	vector<ll> num;
	while (ans < pow(10, 9) * 2) {
		ans = (a * a * a * a * a);
		//cout <<"a = "<<a << " : " <<  ans << endl;
		num.push_back(ans);
		a++;
	}
	//cout << num.size();
	ll X;
	cin >> X;
	for (int i = 0; i < ll(num.size()); i++) {
		for (int j = 0; j < ll(num.size()); j++) {
			if (num[i] - num[j] == X) {
				A = i - 150;
				B = j - 150;
				break;
			}
		}
	}
	cout << A << " " << B << endl;
	return 0;
}


Measured memory_bytes: 3552
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  vec b = a;

  sort(b.rbegin(),b.rend());

  REP(i,n){
    if(a[i] != b[0]) cout << b[0] << endl;
    else cout << b[1] << endl;
  }

  return 0;
}

Measured memory_bytes: 4736
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def f(c):
    if c == 'A': return 'T'
    if c == 'T': return 'A'
    if c == 'C': return 'G'
    if c == 'G': return 'C'

print(''.join(map(f, input())))




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

int main(){
    int a[5];
    int k;
    for(int i = 0; i < 5; ++i) cin >> a[i];
    cin >> k;
    if((a[4] - a[0]) <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
# 153716888
MOD = (10**9) + 7
s = gets.chomp
l = s.size
m = 13
dma = {10=>1, 9=>10, 12=>9, 3=>12, 4=>3, 1=>4}
b = [1, 10, 9, 12, 3, 4][l%6]
before = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
curr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
l.times do |i|
  curr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  b = dma[b]
  if s[i] == '?'
    m.times do |j|
      csp = 0
      10.times { |k| csp = (csp + before[(j+k*b)%m])%MOD }
      curr[j] = csp%MOD
    end
  else
    k = s[i].to_i
    m.times do |j|
      curr[j] = before[(j+k*b)%m]%MOD
    end
  end
  before = curr
end
p curr[8]


Measured memory_bytes: 2172
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      double  x = sc.nextFloat();
      double h = sc.nextFloat();

      if(x == 0 && h == 0) {
        break;
      }

      double S = x * x;
      double y = Math.sqrt((x/2.0)*(x/2.0)+h*h);
      S += 4.0 * (x * y / 2.0);

      String s = String.format("%.5f", S);
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 27912
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V == W:
    if A == B:
        print('YES')
    else:
        print('NO')
else:
    if 0 <= abs(A-B)/(V-W) <= T:
        print('YES')
    else:
        print('NO')


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

int main(){
  long n,m;
  cin >> n >> m;
  vector<long> x(m);
  for(int i = 0;i < m;i++){
    cin >> x.at(i);
  }
  vector<long> d(m-1);
  sort(x.begin(),x.end());
  for(int i = 0;i < m-1;i++){
    d.at(i) = abs(x.at(i+1) - x.at(i));
  }
  sort(d.begin(),d.end());
  long kekka = 0;
  for(int i = 0;i < m-n;i++){
    kekka += d.at(i);
  }
  cout << kekka << endl;
}

Measured memory_bytes: 1792
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
p = list(map(int, input().split()))
p_ = []

r = 0
for i in range(k):
    r += p[i]
p_.append(r)

for i in range(k, n):
    r += p[i] - p[i-k]
    p_.append(r)

print((max(p_)+k)/2)

Measured memory_bytes: 25060
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int answer = 0;
		for(int i = 0; i < s.Length; i++)
    {
      if(s[i] == 'x') answer++;
    }

		Console.WriteLine((answer >= 8)?"NO":"YES");
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,a[105],s;
P m=P(INF,INF);
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    s+=a[i];
	}
	for(int i=0;i<n;i++){
	    m=min(m,P(abs(a[i]*n-s),i));
	}
	cout<<m.S<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k){
    cout << s << endl;
  }else{
    rep(i, k){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3052
import java.util.*;

public class Main {
    static long mod = 1000000007;


    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis = new long[n];
        long[] lis_l = new long[n];
        long[] lis_r = new long[n];

        for (int i = 0; i < n; ++i) {
            long l = sc.nextLong();
            lis[i] = l;
        }
        for (int i = 0; i < n; ++i) {
            if (i == 0) {
                lis_l[i] = gcd(0, lis[i]);
                lis_r[n-i-1] = gcd(0, lis[n-i-1]);
            } else {
                lis_l[i] = gcd(lis_l[i-1], lis[i]);
                lis_r[n-i-1] = gcd(lis_r[n-i], lis[n-i-1]);
            }
        }

        long r = lis_r[1];
        for (int i = 1; i < n - 1; ++i) {
            r = Math.max(r, gcd(lis_l[i-1], lis_r[i+1]));
        }
        r = Math.max(r, lis_l[n-2]);
        System.out.println(r);
    }
}


Measured memory_bytes: 62956
N = int(input())
S = list(input() for i in range(N))
ans = 0
for A in range(N):
    flag = 1
    for i in range(N):
        for j in range(N):
            if S[i][(j+A)%N] != S[j][(i+A)%N]:
                flag = 0
    ans += flag*N
print(ans)

Measured memory_bytes: 43648
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
L = []
R = []

for _ in range(N):
  (l, r) = reads()
  L.append(l)
  R.append(-r)

L.sort(); L.reverse()
R.sort(); R.reverse()

psumL = [0] * (N+1)
psumR = [0] * (N+1)

for i in range(N):
  psumL[i+1] = psumL[i] + L[i]
  psumR[i+1] = psumR[i] + R[i]

ans = 0

for i in range(N+1):
  ans = max(ans, psumL[i] + psumR[i])

for i in range(N):
  ans = max(ans, psumL[i] + psumR[i+1])
  ans = max(ans, psumL[i+1] + psumR[i])

print(ans * 2)


Measured memory_bytes: 21564
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
    using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int x, y;
    cin >> x >> y;

    int num[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    if(num[x] == num[y]) p("Yes")
    else p("No");
}

Measured memory_bytes: 256
import java.util.*;

class Main{
 public static void main(String[] args){
  Scanner scan = new Scanner(System.in).useDelimiter("\\s\\n*");

  int a=scan.nextInt(),b=scan.nextInt(),c=scan.nextInt();

  int d;

  for(int e=0;e<3;e++){
   if(a>b){d=a;a=b;b=d;}
   if(b>c){d=b;b=c;c=d;}
  }
  System.out.println(a+" "+b+" "+c);  
 }
}

Measured memory_bytes: 26364
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 int main()
 {
   string str;
   while(cin>>str)
   {
     int hash[26]={0};
     int res=-1;
     for(int i=0;i<str.length();i++) hash[str[i]-'a']++;
     for(int i=0;i<26;i++)
     {
       if(0==hash[i])
       { 
         res=i;
         break;
       }         
     }         
     char ca='a'+res;
     if(-1==res) cout<<"None"<<endl;
     else cout<<ca<<endl;     
   }
   //while(1);
   return 0;
 }
 
 

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

int main() {
  int n;
  cin >> n;
  if(n / 1000 == n / 100 % 10 && n / 100 % 10 == n / 10 % 10 ) {
    cout << "Yes" << endl;
  } else if(n / 100 % 10 == n / 10 % 10 && n / 10 % 10 == n % 10) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
def prime(n):
    for i in range(2,int((n)**0.5)+1):
        if n % i == 0:
            return False
    return True

def main(n):
    ans = 0
    for i in range(n+1,2*n+1):
        if prime(i):
            ans += 1
    print(ans)
while 1:
    n = int(input())
    if n == 0:
        break
    main(n)


Measured memory_bytes: 5696
#include <cstdio>

int main(void)
{
    int totalValue=0;
    int commonPart,Apart,Bpart;
    int priceA,priceB,priceMix;

    scanf("%d%d%d",&priceA,&priceB,&priceMix);
    scanf("%d%d",&Apart,&Bpart);

    commonPart=(Apart<Bpart?Apart:Bpart);
    if(2*priceMix<priceA+priceB)
    {
        totalValue=priceMix*2*commonPart;
    }
    else
    {
        totalValue=commonPart*(priceA+priceB);
    }
    if( (Apart-commonPart)*priceA+(Bpart-commonPart)*priceB
            < (Apart-commonPart+Bpart-commonPart)*priceMix*2 )
    {
        totalValue+=(Apart-commonPart)*priceA+(Bpart-commonPart)*priceB;
    }
    else
    {
        totalValue+=(Apart-commonPart+Bpart-commonPart)*priceMix*2;
    }
    printf("%d\n",totalValue);
    return 0;
    

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if( a == b || ( a == 1 && b == 1)){
        System.out.println("Draw");
    }else if( a == 1){
        System.out.println("Alice");
    }else if( b == 1){
        System.out.println("Bob");
    }else if( a > b ){
        System.out.println("Alice");
    }else{
        System.out.println("Bob");
    }


    


    
    


    
	}
}

Measured memory_bytes: 21716
import Control.Monad
import Control.Applicative

solve :: [Int] -> String
solve [h,w] = 
    unlines . replicate h $ replicate w '#'

main =
    mapM_ putStrLn =<< map solve . takeInputs . lines <$> getContents
    where
    takeInputs :: [String] -> [[Int]]
    takeInputs = takeWhile (not . all (== 0)) . map (map read . words)

Measured memory_bytes: 4556
// Problem : E - Simple String Queries
// Contest : AtCoder - AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359;
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 500001; //check the limits, dummy

    vi v[26];
 
    ll rsq(int b,int index) { // sum of freq. of pos 1 to pos b
        ll sum = 0;
        while (b > 0) {
            sum += v[index][b];
            b -= b & (-b);
        }
        return sum;
    }
    
    ll rsq(int a, int b,int index) {  // sum of freq. of pos a to pos b
        return rsq(b,index) - (a == 1 ? 0 : rsq(a - 1,index));
    }
    
    void add(int k, int V,int index) { // add freq. v to pos k
        while (k < v[index].size()) {
            v[index][k] += V;
            k += k & (-k);
        }
    }

int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    // int T; cin >> T;
    // while(T--) 
 	// {
//   	
  	// }
  	// FenwickTree v[26];
	int N,Q;
	cin>>N;
	string str;
	cin>>str>>Q;
	N=sz(str);
  	F0R(x,26)
  	{
  		v[x].assign(N+1,0);
  	}
	F0R(x,N)
	{
		add(x+1,1,str[x]-'a');
	}
	F0R(x,Q)
	{
		int chc;
		cin>>chc;
		if(chc==1)
		{
			int index;
			char ch;
			cin>>index>>ch;
			add(index,-1,str[index-1]-'a');
			add(index,1,ch-'a');
			str[index-1]=ch;
		}
		else
		{
			int l,r;
			cin>>l>>r;
			int ans=0;
			F0R(y,26)
			{
				int val=rsq(l,r,y);
				if(val>0)ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343
 



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

int main()
{
	string s;
	int c=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
    {
        if(s[i]=='+')
        {
            c++;
        }
        else {c--;}
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	vector<ll>l(2 * n); REP(i, 2 * n)l[i] = in(); sort(ALL(l));
	ll ans = 0;
	REP(i, 2 * n) {
		if (i % 2 == 0)ans += l[i];
	}
	cout << ans << endl;
}

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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            long N = long.Parse(line[0]);
            long A = long.Parse(line[1]);
            long B = long.Parse(line[2]);

            if ((B - A) % 2 == 0)
            {
                Console.WriteLine((B - A) / 2);
            }
            else
            {
                if (A - 1 > N - B)
                {
                    Console.WriteLine((N - B) + 1 + (B - A - 1) / 2);
                }
                else
                {
                    Console.WriteLine(A + (B - A - 1) / 2);
                }
            }

        }
    }
}

Measured memory_bytes: 11092
S = str(input())
slist = []
for i in range(len(S)):
    slist.append(S[i])
ans = 0

for i in range(len(slist)-1):
    if slist[i]==slist[i+1] and slist[i+1]=='0':
        slist[i+1] = '1'
        ans += 1
    elif slist[i]==slist[i+1] and slist[i+1]=='1':
        slist[i+1] = '0'
        ans += 1
    else:
        pass
print(ans)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  vl x(m);
  rep(i,m){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  vl dp(m-1);
  ll sum=x[m-1]-x[0];
  rep(i,m-1){
    dp[i]=x[i+1]-x[i];
  }
  sort(dp.begin(),dp.end());
  ll ans=sum;
  if(n>m){
    cout << 0 << endl;
  }
  else{
    ll i=0;
    while(i<n){
      ans-=dp[m-1-i];
      i++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	
	bool flg = true;
	
	if(x - r < 0 || x + r > W){
		flg = false;
	}
	if(y - r < 0 || y + r > H){
		flg = false;
	}
	
	const char* ans = flg ? "Yes" : "No";
	
	cout << ans << endl;
	
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second

int main() {
	int n; scanf("%d", &n);
	vector<int> v;
	int r =0;
	for( int i = 0, x ; i < n ; ++i ) scanf("%d", &x), v.push_back(x);
	for( int i = 0, x ; i < n ; ++i ) scanf("%d", &x), v[i] -= x;
	sort(v.rbegin(), v.rend());
	for( int i = 0 ; i < n ; ++i ) {
		if(v[i] > 0) r += v[i];
		else break;
	}
	printf("%d\n", r);
	return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

#define MAX_SLEN 100000
#define MOD 1000000000 + 7

ll ans = 0;
int s_len = 0;
int dp[MAX_SLEN][9];

void update_ans(const ll add) {
    ans += add;
    ans %= MOD;
}

int main() {
    string s;
    cin >> s;
    vi ans(s.length(), 0);
    int low_lim = 0, up_lim = -1;
    REP(i, s.length() - 1) {
        if(s[i] == 'R' && s[i + 1] == 'L') {
            ans[i]++;
            ans[i + 1]++;
            up_lim = i + 1;
            while(up_lim < s.length() && s[up_lim + 1] == 'L') up_lim++;
            FOR(j, low_lim, i) {
                if((i - j) % 2 == 1) ans[i + 1]++;
                else ans[i]++;
            }
            FOR(j, i + 2, up_lim + 1) {
                if((j - i - 2) % 2 == 1) ans[i + 1]++;
                else ans[i]++;
            }
            low_lim = up_lim + 1;
            i = up_lim;
        }
    }

    REP(i, s.length()) {
        if(i < s.length() - 1) cout << ans[i] << " ";
        else cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 1104
n , m , x, y = map(int,input().split())
xlist = list(map(int,input().split()))
ylist = list(map(int,input().split()))
X = max(xlist)
Y = min(ylist)
for i in range(x+1, y+1):
     if X < i <=Y:
           print('No War')
           exit()
print('War')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long int fact(long long int x);
int main()

{

    int i;

        long long int k,s,m,f;
    long long int n;
scanf("%lld",&n);
m=1000000007;
f=1;
for(i=1;i<=n;i++)
{
    f=(f*i)%m;
}


printf("%lld",f);
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<map>
using namespace std;
string s;
map<char,long>lim;
map<pair<char,long>,long>S;
long ok(string t)
{
	if(t[0]>='0'&&t[0]<='9')
	{
		long ret=0;
		for(int i=0;i<t.size();i++)ret=ret*10+t[i]-'0';
		return ret;
	}
	long now=ok(t.substr(2,t.size()-3));
	if(now<0)return now;
	char name=t[0];
	if(S.find(make_pair(name,now))!=S.end())return S[make_pair(name,now)];
	else return-1;
}
main()
{
	while(cin>>s,s!=".")
	{
		lim.clear();S.clear();
		int ans=0,nowline=0;
		do{
			nowline++;
			int id=-1;
			for(int i=0;i<s.size();i++)if(s[i]=='=')id=i;
			if(id<0)
			{
				char name=s[0];
				long now=ok(s.substr(2,s.size()-3));
				if(now<0)
				{
					if(ans==0)ans=nowline;
				}
				lim[name]=now;
			}
			else
			{
				char name=s[0];
				long idx=ok(s.substr(2,id-3));
				long now=ok(s.substr(id+1,s.size()-id-1));
				if(idx<0||now<0||lim.find(name)==lim.end()||lim[name]<=idx)
				{
					if(ans==0)ans=nowline;
				}
				else S[make_pair(name,idx)]=now;
			}
		}while(cin>>s,s!=".");
		cout<<ans<<endl;
	}
}



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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n, x;
int main()
{
	std::cin >> n >> x;

	if (n == 2) {
		if (x == 2) {
			std::cout << "Yes" << std::endl;
			for (int i = 1; i <= 3; ++i) {
				std::cout << i << std::endl;
			}
		}
		else {
			std::cout << "No" << std::endl;
		}
		return 0;
	}

	if (x == 1 || x == 2 * n - 1) {
		std::cout << "No" << std::endl;
		return 0;
	}

	std::vector<int> v(2 * n - 1);
	for (size_t i = 0; i < 2 * n - 1; ++i) {
		v[i] = i + 1;
	}

	std::swap(v[n - 1], v[x - 1]);
	if (x < n) {
		std::swap(v[x - 2], v[n]);
	}
	else if (x > n) {
		std::swap(v[n - 2], v[x]);
	}

	std::cout << "Yes" << std::endl;
	for (int i : v) {
		std::cout << i << std::endl;
	}

	return 0;
}


Measured memory_bytes: 2304
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
var arr = (0..<N).map{_ in 0}
 
for _ in 0..<M {
  let input = readLine()!.characters.split(" ").map{Int(String($0))!}
  let (a, b) = (input[0], input[1])
  if a == 1 {
    arr[b] += 1
  }
  if b == N {
    arr[a] += 1
  }
}
print((arr.contains(2) ? "" : "IM") + "POSSIBLE")

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

int main() {
  
  int N,K;
  cin >> N >> K;
  
  int X = N - K;
  int count = 1;
  
  while ( X > 0 ){
    X = X + 1 - K;
    count++;
  }
  
  cout << count << endl;

}


Measured memory_bytes: 256
#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 main(){
	int n,x;
	cin >> n >> x;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());
	int sum = x;
	int counts = 0;
	rep(i,n){
		if(sum < a[i]) {
			cout << counts << endl;
			return 0;;
		}
		sum -= a[i];
		counts++;
	}
	if(sum == 0) cout << counts << endl;
	else if(counts == 0) cout << 0 << endl;
	else cout << counts -1 << endl;
}

Measured memory_bytes: 3532
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    String s = br.readLine();
    int min = 987654321;
    for (char i=0; i<26; i++) {
      int val = count(s,(char)('a'+i));
      if (val<min) {
        min = val;
      }
    }
    System.out.println(min);

  }
  public static int count(String s, char target) {
    StringBuilder sb = new StringBuilder();
    for (int i=0; i<s.length(); i++) {
      sb.append(target);
    }
    int count = 0;
    StringBuilder sb2 = new StringBuilder(s);
    while (!s.equals(sb.toString())) {
      sb2 = new StringBuilder();
      for (int i=0; i<sb.length()-1; i++) {
        if (s.charAt(i)==target || (s.charAt(i+1)==target)) {
          sb2.append(target);
        } else {
          sb2.append(s.charAt(i));
        }
      }
      count++;
      sb.delete(sb.length()-1, sb.length());
      s = sb2.toString();
    }
    return count;
  }
}


Measured memory_bytes: 26068
#include <iostream>

using namespace std;

int main()
{
    int N, X;

    cin >> N >> X;

    int L[N];

    for ( int i = 0; i < N; i ++ ) cin >> L[i];

    int D = 0;
    int count = 1;
    for ( int i = 0; i < N; i ++ ) {
        D += L[i];
        if ( D > X ) break;
        count ++;
    }

    cout << count << endl;

    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+9;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

std::vector<bool> IsPrime;

LL my_pow(int x, int y){
	LL a=1;
	REP(i,y){
		a *= x;
		a %= MOD;
	}
	return a % MOD;
}


void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

void Main()
{
	int x; cin>>x;

	sieve(x*2);

	FOR(i,x,x*2){
		if(IsPrime[i]){
			cout << i << endl;
			return;

		}
	}
	



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;

using namespace std;

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

  int n, k;
  cin >> n >> k;
  vector<int> v(n + 1);
  rep1(i, n) cin >> v[i];
  int maxsum = -INF;
  multiset<int> got_l;
  rep(i, n + 1) {
    if (i > k) break;
    if (i != 0) got_l.insert(v[i]);
    multiset<int> got_all = got_l;
    rep(j, n - i + 1) {
      if (i + j > k) break;
      if (j != 0) got_all.insert(v[n - j + 1]);
      int first_posi_pos = distance(got_all.begin(), got_all.lower_bound(0));
      int sum = 0;
      auto itr = got_all.begin();
      rep(x, got_all.size()) {
        if (x >= min(first_posi_pos, k - i - j)) sum += *itr;
        ++itr;
      }
      maxsum = max(maxsum, sum);
    }
  }
  cout << maxsum << endl;
  return 0;
}

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

vector<pair<long, long>> prime_factorize(long n) {
  vector<pair<long, long>> v;
  for (long p = 2; p * p <= n; ++p) {
    if (n % p != 0) {
      continue;
    }
    long num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    v.push_back(make_pair(p, num));
  }

  if (n != 1) {
    v.push_back(make_pair(n, 1));
  }

  return v;
}

const int MOD = 1000000007;
const int MAX = 200001;
long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long comb(int n, int k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long N, M;
  cin >> N >> M;
  comb_init();
  vector<pair<long, long>> primes = prime_factorize(M);

  long res = 1;
  for (auto &p : primes) {
    long num = p.second;
    res = (res * comb(num + N - 1, num)) % MOD;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4992