akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a, b, c, d, m1, m2, i, cnt=0;
    cin >> a >> b >> c >> d;
    m1 = min(a, b);
    m2 = min(c, d);
    cout << m1+m2;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
cur = 1
ans = 0
for i in a:
  num = (i - 1) // cur
  ans += num
  i -= cur * num
  if cur != i or i == 1 or num == 0:
  	cur = max(cur,i+1)
  #print(i,num,cur)
print(ans)

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

int main() {
	int n;
  	cin>>n;
  	vector<int> x(n);
    int min=10000000;
    int sum=0;
  	
  	for(int i=0;i<n;i++){
     	cin>>x.at(i); 
    }
  
  	for(int i=1;i<=100;i++){
     	for(int j=0;j<n;j++){
          sum+=(x.at(j)-i)*(x.at(j)-i);
        }
      	if(min>sum){
         	min=sum; 
        }
      	sum=0;
    }
  	
  	
  cout<<min<<endl;
  	
}

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

using namespace std;
using ll = long long;

using P = pair<int, int>;

int main() {
    int w, h;
    cin >> w >> h;
    multiset<P> s;
    for (int i = 0; i < w; i++) {
        int x;
        cin >> x;
        s.insert(P(x, 0));
    }
    for (int j = 0; j < h; j++) {
        int x;
        cin >> x;
        s.insert(P(x, 1));
    }
    ll sm = 0;
    int xc = 0, yc = 0;
    for (auto p: s) {
        int us;
        if (p.second == 0) {
            sm += ll(p.first)*(h+1);
            w--;
        } else {
            sm += ll(p.first)*(w+1);
            h--;
        }
        //cout << us << " " << p.first << " " << p.second << endl;;
    }
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 9728
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class SegTree:
    def __init__(self,aa):
        n=1<<(len(aa)-1).bit_length()
        tree=[0]*(2*n-1)
        tree[n-1:n-1+len(aa)]=aa
        for i in range(n-2,-1,-1):tree[i]=tree[2*i+1]|tree[2*i+2]
        self.tree=tree
        self.n=n

    def update(self,i,a):
        i=self.n-1+i
        self.tree[i]=a
        while i:
            i=(i-1)//2
            self.tree[i]=self.tree[2*i+1]|self.tree[2*i+2]

    def SegOr(self,l,r,i=0,segl=0,segr=-1):
        if segr==-1:segr=self.n
        if r<=segl or segr<=l:return 0
        if l<=segl and segr<=r:return self.tree[i]
        m=(segl+segr)//2
        return self.SegOr(l,r,2*i+1,segl,m)|self.SegOr(l,r,2*i+2,m,segr)

def main():
    code=lambda c:ord(c)-ord("a")
    popcnt=lambda x:bin(x).count("1")
    n=II()
    s=SI()
    aa=[1<<code(c) for c in s]
    st=SegTree(aa)
    q=II()
    for _ in range(q):
        op,x,y=SI().split()
        if op=="1":
            i=int(x)-1
            st.update(i,1<<code(y))
        else:
            l,r=int(x)-1,int(y)
            print(popcnt(st.SegOr(l,r)))

main()

Measured memory_bytes: 48412
N = int(input())
S = input()

dp = [[None for j in range(N)] for i in range(N)]
vlen = 0
for i in range(N-1):
    for j in range(i + 1, N):
        if S[i] != S[j]:
            dp[i][j] = 0
        elif i - 1 >= 0 and j - 1 >= 0:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = 1
        if i + dp[i][j] <= j:
            vlen = max(vlen, dp[i][j])
print(vlen)


Measured memory_bytes: 429832
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n,k;
    cin >> n >> k;
    double ans=0;
    for(int i=1;i<=n;i++){
        int num=0;
        while(i*pow(2,num)<k) num++;
        ans+=(1.0/n)*(pow(0.5,num));
    }
    printf("%.12f\n",ans);
}

Measured memory_bytes: 4220
#include<iostream>

using namespace std;
long long a[1005];
int n = 0, f = 1,num=0;
int b[1005];
long long tdl(int i) {
	if ((i - f) % 2 == 1)return a[i];
	else return 0;
}
void dl(int i) {
    b[++num] = i;
	if (i == n) {
		n--;
		return;
	}
	if (i == 1) {
		n--;
		for (int j = 1; j <= n; j++)
			a[j] = a[j + 1];
		return;
	}
	n -= 2;
	a[i - 1] += a[i + 1];
	for (int j = i; j <= n; j++)
		a[j] = a[j + 2];
	return;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);


	while (n != 1) {
		long long o = 0, e = 0,m = -9999999999; int  im = 0;

		for (int i = 1; i <= n; i++) {
			if (a[i] >= m) {
				m = a[i];
				im = i;
			}
		}

		if (m <= 0) {
			a[1] = m; num = n - 1;
			for (int i = 1; i <= im - 1; i++)b[i] = 1;
			for (int i = im; i < n; i++)b[i] = n + 1 - i;
			break;
		}

		for (int i = 1; i <= n; i = i + 2)if (a[i] >= 0)o += a[i];
		for (int i = 2; i <= n; i = i + 2)if (a[i] >= 0)e += a[i];
		if (o > e)f = 0;
		else f = 1;

		m = 1; im = 0;
		for (int i = 1; i <= n; i++) {
			if (tdl(i) < m) {
				im = i; m = tdl(i);
			}
		}
		dl(im);
	}

	printf("%lld\n", a[1]);
	cout << num;
	for (int i = 1; i <= num; i++) {
		printf("\n%d", b[i]);
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
ma = sum(As)
o = dict()
INF = 10**19
from itertools import accumulate
aa = [0] + list(accumulate(As))

for i in range(N):
    for j in range(N-i):
        span = i*N+j
        # 長さi+1, 開始位置jの合成コスト+構成要素の和
        if i == 0:
            o[span] = As[j]
            continue
        C = INF
#        print(i,j,o)
        for k in range(i):
            # 長さk+1とi+1-(k+1)=i-kに分割
#            print(i,j,k*N+j, (i-k-1)*N+j+k, o)
            C = min(C, o[k*N+j]+o[(i-k-1)*N+j+k+1])
#        o[span] = C + sum(As[j:j+i+1])
        o[span] = C + aa[j+i+1] - aa[j]

print(o[span]-ma)


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

pair<ll,ll> ans[1 << 20];
ll ret[1 << 20];

pair<ll,ll> seica(pair<ll,ll> &A,pair<ll,ll> &B){
	ll fir = max(A.FI,B.FI);
	ll sec = max(min(A.FI,B.FI),max(A.SE,B.SE));
	return MP(fir,sec);
}	

int main(){
	
	int n;cin >> n;
	vector<ll> v(1>>n);
	
	REP(i,1<<n){
		ll tmp;cin >> tmp;
		ans[i].FI = tmp;
	}
	
	REP(i,n){
		for(int j = 0;j < (1<<n);j++){
			if(j & (1 << i)){
				ans[j] = seica(ans[j],ans[j^(1<<i)]);
			}
		}
	}
	
	REP(i,1<<n){
		ret[i] = ans[i].FI + ans[i].SE;
	}
	
	REP(i,1<<n){
		ret[i+1] = max(ret[i+1],ret[i]);
	}
	
	for(int i = 1;i < (1<<n);i++){
		cout << ret[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 120000;
typedef long long ll;
ll n,a,b;
int main(){
    cin>>a>>b;
  int ans=-1;
  	fo(i,1,100000){
      if(i*8/100==a && i/10==b){
        ans=i;
        break;
      }
    }
  cout<<ans<<endl;
    return 0;
}

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


int main() {
  int N, M;
  cin >> N >> M;
  if (0 < N && N < 10 && 0 < M && M < 10) {
    cout << N*M << endl;
  } else {
    cout << "-1" << endl;  
  }
  return 0;
}
  

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

struct triple {
	ll b, r, l;
} tt[MAXN];

ll x;

ll eval(const triple &tr) {
	return x * tr.r - tr.b * (tr.r - tr.l);
}

bool operator < (const triple &t1,const triple &t2) {
	return eval(t1) > eval(t2);
}

ll get_val(ll dif, const triple &tr) {
	ll val = INF;
	if (tr.b * tr.l >= dif) {
		val = (dif + tr.l - 1) / tr.l;
	} else if (eval(tr) >= dif) {
		ll tmp = dif + tr.b * (tr.r - tr.l);
		val = (tmp + tr.r - 1) / tr.r;
	}
	return val;
}

void solve(){
	int n;
	scanf("%d%lld", &n, &x);
	REP(i, 0, n) {
		scanf("%lld%lld%lld", &tt[i].b, &tt[i].l, &tt[i].r);
	}
	sort(tt, tt + n);
	ll cur = 0ll;
	REP(i, 0, n) {
		cur -= tt[i].b * tt[i].l;
	}
	ll ans = 0ll;
	int ind = 0;
	for(; ind < n; ind++) {
		ll dif = eval(tt[ind]);
		if (cur + dif >= 0) {
			break;
		}
		cur += dif;
		ans += x;
	}
	ll mn = INF;
	REP(i, ind, n) {
		ll dif = -cur;
		ll val = get_val(dif, tt[i]);
		mn = min(mn, val);
	}
	ans += mn;
	
	cur += eval(tt[ind]);
	ll ans2 = (ind + 1) * x;
	REP(i, 0, ind) {
		ll cur2 = cur - eval(tt[i]);
		ll dif = -cur2;
		ll val = get_val(dif, tt[i]);
		ans2 = min(ans2, ind * x + val);
	}
	ans = min(ans, ans2);
	
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 4352
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	lp(i,1,n)
		cin>>a[i];
	for(ll i=1; i<=n-k; i++){
		if(a[i]<a[i+k])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;	
}


Measured memory_bytes: 5200
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main()
{
    string s1;
    cin>>s1;
    string s2="2019/04/30";
    int j=s1.compare(s2);
    if(j>0)
        printf("TBD\n");
    else
        printf("Heisei\n");
    return 0;
}


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

int main(void){
    int a, b; cin >> a >> b;
  	int n = b - a;
  	int ans = ((n + 1) * n / 2) - n - a;
  	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

int main() {
	
	long long n, x;
	long long a[100050] = {};
	long long b[100050] = {};
	cin >> n >> x;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	a[n] = x;
	sort(a, a + n + 1);
	

	for (int i = 1; i <= n; i++)
	{
		b[i - 1] = a[i] - a[i - 1];
	}

	long long r;
	long long ans = 1000000005;
	for (int i = 1; i <= n; i++)
	{
		r = b[i] % b[i - 1];
		while (r != 0) {
			b[i] = b[i - 1];
			b[i - 1] = r;
			r = b[i] % b[i - 1];
		}
		if(ans > b[i - 1])
		ans = b[i - 1];
		
	}

	cout << ans;




		
				
}

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

int N;
ll X;
vector<ll> nAll;
vector<ll> nP;

ll f(int l, ll x) {
  if(x == 0) return 0;
  if(l == 0) return x;

  if(x == nAll[l]) return nP[l];
  if(x < nAll[l-1] + 2) return f(l-1, x-1);
  return 1 + nP[l-1] + f(l-1, x - nAll[l-1] - 2);
}

int main () {
  cin >> N >> X;

  nAll = vector<ll>(N+1, 1);
  nP = vector<ll>(N+1, 1);
  rep(i,N) {
    nAll[i+1] = 2*nAll[i] + 3;
    nP[i+1] = 2*nP[i] + 1;
  }

  cout << f(N, X) << endl;
  return 0;
}


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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int r,c;
    cin>>r>>c;
    
    int a[r][c];
    
    int t=0;
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            cin>>a[i][j];
            t += a[i][j];
        }
    }
    
    int d[c];
    for(int i=0; i<c; i++) d[i]=0;
    for(int i=0; i<c; i++){
        for(int j=0; j<r; j++){
            d[i] += a[j][i];
        }
    }
    
    for(int i=0; i<r; i++){
        int sum = 0;
        for(int j=0; j<c; j++){
            cout<<a[i][j]<<" ";
            sum += a[i][j];
        }
        cout<<sum<<endl;
    }
    
    for(int i=0; i<c; i++){
        cout<<d[i]<<" ";
    }
    cout<<t<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3212
fun main(args: Array<String>) {
    val inputs = readInputLine().split(" ").map { it.toInt() }
    val a = inputs[0]
    val b = inputs[1]
    val c = inputs[2]
    val d = inputs[3]
    val e = inputs[4]
    val f = inputs[5]
    
    var maxDensity = 0.0
    
    var water = 0
    var sugar = 0
    
    for (i in 0..(f / 100 / a)) {
        for (j in 0..((f / 100 - i) / b)) {
            if (i == 0 && j == 0) {
                continue
            }
            for (k in 0..(f / c)) {
                for (l in 0..((f - c * k) / d)) {
                    if (i * a * 100 + j * b * 100 + k * c + l * d <= f && k * c + l * d <= e * (i * a + j * b)) {
                        val density = (100 * (k * c + l * d)).toDouble() / (i * a * 100 + j * b * 100 + k * c + l * d)
                        if (density > maxDensity) {
                            maxDensity = density
                            water = i * a * 100 + j * b * 100
                            sugar = k * c + l * d
                        }
                    }
                }
            }
        }
    }
    
    if (water == 0) {
        println("${100 * a} 0")
    } else {
        println("${water + sugar} $sugar")
    }
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36072
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,s1,s2,s3,s4;
  	cin >> N;
  	s4 = N % 1000;
  	s3 = s4 % 100;
  	s2 = s3 / 10;
  	s1 = s3 % 10;
  	s3 = s4 / 100;
  	s4 = N / 1000;
  	if(s4 == s3&&s4 == s2){
      	cout << "Yes" << endl;
    }
  	else if(s3 == s2&&s3 == s1){
      	cout << "Yes" << endl;
    }
  	else{
      	cout << "No" << endl;
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

#define x first
#define y second
#define pb push_back
#define MX 100007

int fx[4]={1,-1,0,0};
int fy[4]={0,0,1,-1};
int n,m;


int main()
{
	int n;
	cin >>n;
	string s;cin >>s;
	int k;cin >>k;
	k--;
	char c=s[k];

	for(int i=0;i<n;i++){
		if(s[i]!=c){
			s[i]='*';
		}
	}
	cout << s<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> p(N);
  string S;
  int P;
  for (int i = 0; i < N; i++) {
    cin >> S >> P;
    p.at(i) = make_tuple(S, -P, i + 1);
  }
  sort(p.begin(), p.end());
  for (auto elem : p) {
    cout << get<2>(elem) << endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

    public static final int FIRST_NUMBER = 0;
    public static final int SECOND_NUMBER = 1;

    public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);
	int arrayLength = Integer.parseInt(sc.nextLine());
	int loopCount = Integer.parseInt(sc.nextLine());

	int[] outputArray = new int[arrayLength + 1];
	for (int i = 0; i < outputArray.length; i++) {
	    outputArray[i] = i;
	}

	List<int[]> inputArrays = new ArrayList<>();

	for (int i = 0; i < loopCount; i++) {
	    String[] queryStr = sc.nextLine().split(",");
	    int[] query = new int[2];
	    query[FIRST_NUMBER] = Integer.parseInt(queryStr[FIRST_NUMBER]);
	    query[SECOND_NUMBER] = Integer.parseInt(queryStr[SECOND_NUMBER]);
	    inputArrays.add(query);
	}

	exchangeLine(inputArrays, outputArray);

	for (int i = 1; i < outputArray.length; i++) {
	    System.out.println(outputArray[i]);
	}

    }

    private static void exchangeLine(List<int[]> inputArrays, int[] outputArray) {

	for (int[] query : inputArrays) {
	    int mediator = 0;

	    mediator = outputArray[query[FIRST_NUMBER]];
	    outputArray[query[FIRST_NUMBER]] = outputArray[query[SECOND_NUMBER]];
	    outputArray[query[SECOND_NUMBER]] = mediator;

	}

    }
}

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

int main() {
  int n;
  ll mod = 1e9+7,ans = 1;
  string s1,s2;
  cin >> n >> s1 >> s2;
  vector<int>data;
  rep(i,0,n){
    if(s1[i] == s2[i]) data.push_back(0);
    else{data.push_back(1);i++;}
  }
  int s = data.size();
  rep(i,0,s){
    if(i == 0){
      if(data[i] == 0) ans *= 3;
      else ans *= 6;
    }
    else{
      if(data[i] == 0){
        if(data[i-1] == 0) ans *= 2;
        else ans *= 1;
      }
      else{
        if(data[i-1] == 0) ans *= 2;
        else ans *= 3;
      }
    }
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool Month_Check(int a){
  if(0<a&&a<13) {
    return true;
  }else{
    return false;
  }
}
bool Year_Check(int a){
  if(0<a&&a<100) {
    return true;
  }else{
    false;
  }
}

int main(){
  int S,S_s,S_e;
  scanf("%d",&S);
  S_s=S/100;
  S_e=S%100;
  if((Year_Check(S_s) && Month_Check(S_e))&&(Year_Check(S_e) && Month_Check(S_s))){
    printf("AMBIGUOUS");
  }else if((Year_Check(S_s) && Month_Check(S_e))&&!(Year_Check(S_e) && Month_Check(S_s))){
  	printf("YYMM");
  }else if(!(Year_Check(S_s) && Month_Check(S_e))&&(Year_Check(S_e) && Month_Check(S_s))){
    printf("MMYY");
  }else{
    printf("NA");
  }
  
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int sum_rep {};
  rep(i, N) {
    sum_rep += A[i];
  }
  double k = sum_rep / (double)(4*M);
  int cnt {};
  rep(i, N) {
    if (k <= A[i]) ++cnt;
  }
  if (cnt >= M) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
  
ll n,h;
cin>>h>>n;
ll a[n];
ll sum=0;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    sum=sum+a[i];
}

if(sum>=h)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int a,b,c,n,i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);


    if((((a*a)+(b*b)==(c*c))||((a*a)+(c*c)==(b*b))||((c*c)+(b*b)==(a*a)))&&(a>0&&b>0&&c>0)){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  
  return 0;  
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

void solve(){
    int N;
    cin >> N;

    double mean=0;
    vi a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        mean += a[i];
    }
    mean /= N;
    // sort(all(a));

    int flame = 0;
    double mindiff=100000;
    for (int i = 0; i < N; i++) {
        if (mindiff > abs(mean - a[i])) {
            mindiff = abs(mean - a[i]);
            flame = i;
        }
    }

    cout << flame << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////



int main() {
	
	ll N;

	cin >> N;

	ll r[3] = {};

	ll ans = 1;

	repn(i, N) {

		ll a;
		cin >> a;

		int cnt=0;

		rep(i, 3) {
			if (a == r[i]) { cnt++; }
		}

		ans = ans * cnt%MOD;

		rep(i, 3) {
			if (a == r[i]) {
				r[i]++;
				break;
			}
		}

	}

	cout << ans;
	

	system("PAUSE");
}

Measured memory_bytes: 504
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto L = RDR.split.to!(long[]);
	L.sort();
	auto ans = L[$-1] < L[0..$-1].sum;

	writeln(ans ? "Yes" : "No");
	stdout.flush();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int F[111][11];
    for (int i = 0; i < n;i++){
        for (int j = 0; j < 10;j++){
            cin >> F[i][j];
        }
    }
    int P[111][11];
    for (int i = 0; i < n;i++){
        for (int j = 0; j < 11;j++){
            cin >> P[i][j];
        }
    }
    int res = -mod;
    for (int bit = 1; bit < (1 << 10);bit++){
        int sum = 0;
        for (int i = 0; i < n; i++)
        {
            int cnt = 0;
            for (int b = 0; b < 10; b++){
                if(((bit>>b)&1)&&F[i][b])
                    cnt++;
            }
            sum += P[i][cnt];
        }
        res = max(res, sum);
    }
    cout << res << endl;
}

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

int main() {
  ll n,a[10005],ans=0;
  cin>>n;
  for(ll i=0; i<n; i++) cin>>a[i];
  for(int i=0; i<n; i++){
    while(a[i]%2==0) {
      a[i] /= 2;
      ans++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 384
// Last Change: 08/18/2019 22:06:22.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  if (a == 0 and b == 0)
    return 0;
  a = abs(a);
  b = abs(b);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  ll g = gcd(a, b);
  return (a / g) * b;
}

int main() {
  ll N;
  cin >> N;

  ll productAll = 1;
  vector<ll> A(N);
  for (auto &&e : A) {
    cin >> e;
    productAll = lcm(productAll, e);
  }

  ll sumProA = 0;
  for (auto &&e : A) {
    sumProA += productAll / e;
  }

  cout << fixed << setprecision(10) << double(productAll) / sumProA << endl;
}



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

void Main()
{
    int n, q;
    cin >> n >> q;
    atcoder::dsu g(n);
    for (int i = 0; i < q; i++)
    {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) g.merge(u, v);
        if (t == 1) cout << (g.same(u, v) ? 1 : 0) << endl;
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <vector>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

#define MOD 1000000007

#include <iostream>
#include <sstream>
#include <vector>

template<typename T_bit_data>
class BIT
{
private:
    int cnt; // 実際の要素数
    std::vector<T_bit_data>* data; // データ本体
public:
    BIT(int n)
    {
        cnt = n;
        data = new std::vector<T_bit_data>(cnt + 1);
    }

    virtual ~BIT() { delete data; }

    T_bit_data Sum(int k)
    {
        if(k <= 0 || cnt < k) {
            std::ostringstream s;
            s << "k = " << k;
            throw std::out_of_range(s.str());
        }
        T_bit_data s = 0;
        while(k > 0) {
            s += (*data)[k];
            // 1 であるビットのうち一番下のビットを 0 に
            k -= k & -k; // 目的の 1 であるビットは k & -k で取り出せる
        }
        return s;
    }

    void Add(int k, T_bit_data a)
    {
        if(k <= 0 || cnt < k) {
            std::ostringstream s;
            s << k << " -> " << a;
            throw std::out_of_range(s.str());
        }
        while(k <= cnt) {
            (*data)[k] += a;
            k += k & -k;
        }
    }

    void Show()
    {
        for(int i = 1; i <= cnt; i++) {
            std::cout << (*data)[i] << " ";
        }
        std::cout << std::endl;
    }
};

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

    vector<int> A(N);
    rep(n, N) {
        cin >> A[n];
    }

    BIT<int> bit(2001);
    ll ans = 0;
    rep(i, N) {
        ans += i - bit.Sum(A[i]);
        bit.Add(A[i], 1);
    }
    ans = (ans * (ll)K) % MOD;

    ll m = ((ll)K * (ll)(K - 1) / 2) % MOD;
    rep(i, N) {
        ans = (ans + (ll)(N - bit.Sum(A[i])) * m % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}


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

const int MX = 26;
int f[MX];

int main() {
	string S;
	int n;
	
	cin >> S;
	n = S.size();
	
	for(int i = 0; i < n; f[S[i] - 'a']++, i++);
	bool ok = true;
	for(int i = 0; i < MX; ok &= (f[i] % 2 == 0), i++);
	
	ok ? cout << "Yes" << endl : cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N, M, Q = map(int, input().split())
D = [[0]*N for i in range(N)]
E = [[-1]*N for i in range(N)]

for i in range(M):
    l, r = map(int, input().split())
    D[l-1][r-1] += 1

def dfs(l, r):
    if not l <= r:
        return 0
    if l == r:
        return D[l][r]
    if E[l][r] != -1:
        return E[l][r]
    E[l][r] = res = D[l][r] + dfs(l+1, r) + dfs(l, r-1) - dfs(l+1, r-1)
    return res

ans = []
for i in range(Q):
    p, q = map(int, input().split())
    ans.append(dfs(p-1, q-1))
print(*ans, sep='\n')

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
ll a[300010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < 3 * N; i++) {
    cin >> a[i];
  }

  ll L[100010], R[100010];
  priority_queue<ll, vector<ll>, greater<ll>> queL;
  priority_queue<ll> queR;
  ll sumL = 0, sumR = 0;
  for (int i = 0; i < N; i++) {
    sumL += a[i];
    queL.emplace(a[i]);
  }
  L[0] = sumL;
  for (int i = 2 * N; i < 3 * N; i++) {
    sumR += a[i];
    queR.emplace(a[i]);
  }
  R[0] = sumR;
  for (int i = N; i < 2 * N; i++) {
    queL.emplace(a[i]);
    sumL += a[i];
    ll p = queL.top(); queL.pop();
    sumL -= p;
    L[i - N + 1] = sumL;
  }
  for (int i = 2 * N - 1; i >= N; i--) {
    queR.emplace(a[i]);
    sumR += a[i];
    ll p = queR.top(); queR.pop();
    sumR -= p;
    R[2 * N - i] = sumR;
  }
  
  ll ans = -(1LL << 60);
  for (int i = 0; i <= N; i++) {
    ans = max(ans, L[i] - R[N - i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5876
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	int k, i, h, w, n, num = 1;
	cin >> h >> w;
	cin >> n;
	vector<int> a(n);
	vector2d(out, int, h, w, 0);
	for (i = 0; i < n; i++) cin >> a[i];
	for (k = 0; k < h; k++) {
		if (k % 2 == 0) {
			for (i = 0; i < w; i++) {
				out[k][i] = num;
				a[num - 1]--;
				if (a[num - 1] == 0) num++;
			}
		}
		else {
			for (i = w - 1; i >= 0; i--) {
				out[k][i] = num;
				a[num - 1]--;
				if (a[num - 1] == 0) num++;
			}
		}
	}
	for (k = 0; k < h; k++) {
		for (i = 0; i < w; i++) {
			if (i > 0) cout << " ";
			cout << out[k][i];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main () {
	int data[30] , w , n , i , a , b , tmp;
	scanf("%d %d",&w,&n);
	for ( i = 0; i < w; i++ )
		data[i] = i+1;
	for ( i = 0; i < n; i++ ) {
		scanf("%d,%d",&a,&b);
		a--; b--;
		tmp = data[a];
		data[a] = data[b];
		data[b] = tmp;
	}
	for ( i = 0; i < w; i++ )
		printf("%d\n",data[i]);
	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    v = list(map(int, input().split()))

    counter = 0
    for ia in range(len(v) - 2):
        a = v[ia]
        for ib in range(ia + 1, len(v) - 1):
            b = v[ib]
            for ic in range(ib + 1, len(v)):
                c = v[ic]
                if (abs(a - b) < c) and (c < (a + b)):
                    if (a != b) and (b != c) and (c != a):
                        counter += 1
    print(counter)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73660
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


int x[110];
int y[110];

int main(){
  int N,M;
  int X,Y;
  cin >> N >> M >> X >> Y;
  rep(i,N) cin >> x[i];sort(x,x+N);
  rep(i,M) cin >> y[i];sort(y,y+M);
  for(int i = -100; i <= 100; i++){
    if(X < i && i <= Y && x[N-1] < i && y[0] >= i){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  
}



Measured memory_bytes: 256
//ΔARC100F
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 25555;
const int K = 444;
const int MO = 1e9+7;
int mul(int x,int y){
	return (LL)x*y%MO;
}
int fpow(int x,int y=MO-2){
	if(!y)
		return 1;
	int z=fpow(x,y>>1);
	z=mul(z,z);
	if(y&1)
		return mul(z,x);
	return z;
}
int n,k,f[N][K],g[N][K];
int m,a[N];
int s[K];
int main()
{
	int i,j,x;
	scanf("%d%d%d",&n,&k,&m);
	for(i=1;i<=m;i=i+1)
		scanf("%d",a+i);
	x=0;
	for(i=1;i<=m&&i<=k;i=i+1){
		if(!s[a[i]])
			x++;
		s[a[i]]++;
	}
	for(;i<=m;i=i+1){
		if(x==k)
			break;
		if(!s[a[i]])
			x++;
		s[a[i]]++;
		s[a[i-k]]--;
		if(!s[a[i-k]])
			x--;
		if(x==k)
			break;
	}
	if(x==k){
		cout<<mul(n-m+1,fpow(k,n-m));
		return 0;
	}
	for(i=1;i<=k;i=i+1)
		s[i]=0;
	for(i=1;i<=m;i=i+1)
		s[a[i]]++;
	for(i=1;i<=k;i=i+1)
		if(s[i]>1)
			break;
	if(i>k){
		f[0][0]=1;
		for(i=1;i<=n;i=i+1){
			x=0;
			for(j=k-1;j;j=j-1){
				x=(x+f[i-1][j])%MO;
				f[i][j]=(x+mul(k-j+1,f[i-1][j-1]))%MO;
			}
			x=0;
			for(j=k-1;j;j=j-1){
				x=(x+g[i-1][j])%MO;
				g[i][j]=(x+mul(k-j+1,g[i-1][j-1]))%MO;
			}
			for(j=m;j<k;j=j+1)
				g[i][j]=(g[i][j]+f[i][j])%MO;
		}
		x=0;
		for(j=1;j<k;j=j+1)
			x=(x+g[n][j])%MO;
		for(i=k;i>k-m;i=i-1)
			x=mul(x,fpow(i));
		x=mul(n-m+1,fpow(k,n-m))-x+MO;
		cout<<x%MO;
		return 0;
	}
	for(i=1;i<=k;i=i+1)
		s[i]=0;
	for(i=1;i<=m;i=i+1){
		if(s[a[i]])
			break;
		s[a[i]]++;
	}
	f[0][i-1]=1;
	for(i=1;i<=n;i=i+1){
		x=0;
		for(j=k-1;j;j=j-1){
			x=(x+f[i-1][j])%MO;
			f[i][j]=(x+mul(k-j+1,f[i-1][j-1]))%MO;
		}
	}
	for(i=1;i<=k;i=i+1)
		s[i]=0;
	for(i=m;i;i=i-1){
		if(s[a[i]])
			break;
		s[a[i]]++;
	}
	g[0][m-i]=1;
	for(i=1;i<=n;i=i+1){
		x=0;
		for(j=k-1;j;j=j-1){
			x=(x+g[i-1][j])%MO;
			g[i][j]=(x+mul(k-j+1,g[i-1][j-1]))%MO;
		}
	}
	for(i=0;i<=n;i=i+1)
		for(j=k;j;j=j-1)
			f[i][j-1]=(f[i][j-1]+f[i][j])%MO,g[i][j-1]=(g[i][j-1]+g[i][j])%MO;
	x=0;
	for(i=1,j=m;j<=n;i=i+1,j=j+1)
		x=(x+mul(f[i-1][0],g[n-j][0]))%MO;
	x=mul(n-m+1,fpow(k,n-m))-x+MO;
	cout<<x%MO;
	return 0;
}


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int N = (int) 1e9;

int main(int argc, char *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int a[n];
	int b[n];
	int c[n];
	ll d[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);

	ll ans = 0;
	memset(d, 0, sizeof(d));
	for (int i = 0; i < n; ++i) {
		int l = 0, r = n - 1;
		ll foo = n;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (c[mid] > b[i]) {
				r = mid - 1;
				foo = mid;
			}
			else {
				l = mid + 1;
			}
		}
		d[i] = n - foo;
	}
	for (int i = n - 2; i >= 0; --i) {
		d[i] += d[i + 1];
	}
	for (int i = 0; i < n; ++i) {
		int l = 0, r = n - 1;
		ll foo = -1;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (b[mid] > a[i]) {
				r = mid - 1;
				foo = mid;
			}
			else {
				l = mid + 1;
			}
		}
		if (foo != -1) {
			ans += d[foo];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2176
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let s = util::chars();

    let z = s.iter().filter(|&&c| c == '0').count();
    let o = s.iter().filter(|&&c| c == '1').count();

    println!("{}", min(z, o) * 2);
}


Measured memory_bytes: 8572
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g
def main():
  n = int(input())
  ans = 1
  for i in range(n):
    t = int(input())
    ans = lcm(ans,t)
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	string S;
	cin >> S;
	if(S == "Sunny")cout << "Cloudy" << endl;
	if(S == "Cloudy")cout << "Rainy" << endl;
	if(S == "Rainy")cout << "Sunny" << endl;

	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

template<class T = int>
vector<T> BFS(const Graph &G,int source = 0){
	vector<T> dist(G.size(),-1);
	queue<int> que;
	dist[source] = 0;
	que.push(source);
	for(T d = 0;;d++){
		int siz = que.size();
		if(siz == 0) break;
		for(int i = 0;i < siz;i++){
			int v = que.front();que.pop();
			for(int to : G[v]){
				if(dist[to] == -1){
					dist[to] = d + 1;
					que.push(to);
				}
			}
		}
	}
	return dist;
}

int n,color[210];
Graph G;
bool isBibartite = true;

void dfs(int v){
	for(int to : G[v]){
		if(color[to] == -1){
			color[to] = !color[v];
			dfs(to);
		}else if(color[to] == color[v]) isBibartite = false;
	}
}

signed main(){
	cin >> n;
	G.resize(n);
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		for(int j = 0;j < n;j++){
			if(s[j] == '1') G[i].push_back(j);
		}
		color[i] = -1;
	}
	dfs(0);
	if(!isBibartite){
		cout << -1 << endl;
		return 0;
	}
	int ans = 0;
	for(int i = 0;i < n;i++){
		auto dist = BFS(G,i);
		int ma = 0;
		for(int j = 0;j < n;j++) chmax(ma,dist[j]);
		chmax(ans,ma + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    int N;
    cin >> N;

    vector<ll> L;
    L.push_back(2);
    L.push_back(1);
    for (int i = 2; i < N+1; i++)
    {
        L.push_back(L[i-2] + L[i-1]);
    }

    cout << L[N] << endl;
}

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

#define f first
#define s second

bool okay(int k, pair<int, int> sc[], int m)
{
    int  c = k ;
    vector<int> v ;
    if(k == 0)
        v.push_back(0) ;
    while(c > 0)
    {
        v.push_back(c % 10) ;
        c /= 10 ;
    }
    reverse(v.begin(), v.end()) ;
    for(int i = 0 ; i < m ; i++)
    {
        if(v[sc[i].f] != sc[i].s)
        {
            return false ;
        }
    }
    return true ;
}
 
int main()
{
  int n, m ;
  cin >> n >> m ;
  pair<int, int> sc[m] ;
  for(int i = 0 ; i < m ; i++)
  {
      int x, y ;
      cin >> x >> y ;
      x-- ;
      sc[i] = {x, y} ;
  }
  int a = pow(10, n-1), ans = -1 ;
  if(n == 1)
    a = 0 ;
  for(int i = a ; i <= 999 ; i++)
  {
      if(okay(i, sc, m))
      {
          ans = i ;
          break ;
      }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] s = S.toCharArray();
        String ans = "";
      
         for(int i = 0; i < s.length; i++){
           char temp = (char)(65+(s[i]+N+65)%26);
           ans += temp;
         }
       
         System.out.println(ans);
      
	}

}

Measured memory_bytes: 56624
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, K, A, one;
    cin>>N>>K;
    rep1(i,N){
        cin>>A;
        if(A==1) one=i;
    }
    cout<<(((N-K)%(K-1)==0) ? ((N-K)/(K-1)+1) : ((N-K)/(K-1)+2))<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static long mod(long x, long y){
    return x%y<0?x%y+(y<0?-y:y):x%y;
    }
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		long [] in = new long [a+1]; 
        in[0]=1;
		long b = 1000000007;
      
        for(int i=3;i<=a;i++){
          for(int j=0;j<=i-3;j++){in[i]+=in[j];
                                                     in[i]=mod(in[i],b);
                                 }
                             }        
		System.out.println(in[a]);
	}
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    if ((n - 1) % (k - 1) != 0) {
        cout << ((n - 1) / (k - 1)) + 1 << endl;
    } else {
        cout << ((n - 1) / (k - 1)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3792