akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

int32_t main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n), sum(n+2, 0);
	for(int &i : v)
		cin >> i;
	sum[1] = v[0];
	
	for(int i = 2; i <= n; i++) 
		sum[i] = v[i-1] + sum[i-1];
	
	
	int at = 0, s = 0, e = k;	
	
	for(int i = 1; i + k - 1 <= n; i++) 
		if(sum[i+k-1] - sum[i-1] > at) {
			at = sum[i+k-1] - sum[i-1];
			s = i-1;
			e = i+k-2;
		}
	
	
	vector<double> prob(1005, 0.0);
	for(int i = s; i <= e; i++)
		for(int j = 1; j <= v[i]; j++)
			prob[j] += (double) 1.0/v[i];
	
	double ans = 0;
	for(int i = 1; i <= 1000; i++) {
		
		ans += (double) prob[i]*i;
	}
		
	cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int max_arr(int arr[],int len){
  int ans=arr[0];
  for(int i=1;i<len;i++){
    ans=max(ans,arr[i]);
  }
  return ans;
}
int main(){
  int n,i,j;
  cin>>n;
  int p[n][3];
  for(i=0;i<n;i++){
    cin>>p[i][0]>>p[i][1]>>p[i][2];
  }
  int dp[n][3];
  dp[0][0]=p[0][0];
  dp[0][1]=p[0][1];
  dp[0][2]=p[0][2];
  for(i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+p[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+p[i][1];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+p[i][2];
  }
  cout<<max_arr(dp[n-1],3);
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int x[5];
    rep(i,5) cin>>x[i];

    rep(i,5){
        if(x[i]!=i+1){
            cout<<i+1<<endl;
            return 0;
        }
    }   
}


Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;
typedef long long ll;

int main()
{
	int n;
	int c[500], s[500], f[500];
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 0; i < n; i++) {
		int t = 0;
		for (int j = i; j < n - 1; j++) {
			if (t < s[j]) t = s[j];
			else if (t % f[j] == 0);
			else t = t + f[j] - t % f[j];
			t += c[j];
		}
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = [None for i in range(n)]
for i in range(n):
    lst[i] = input()

count = [0,0,0,0]
for i in lst:
    if i=="AC":
        count[0]+=1
    elif i=="WA":
        count[1]+=1
    elif i=="TLE":
        count[2]+=1
    else:
        count[3]+=1

print("AC x",count[0])
print("WA x",count[1])
print("TLE x",count[2])
print("RE x",count[3])


Measured memory_bytes: 16164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int k,a,b;
    cin >> k ;
    cin >> a >> b;
    int count=0;

    for(int i=a;i<=b;i++){

        if(i%k==0){
            count+=1;
            break;
        }
        
    }

    if(count==1)cout<<"OK"<<endl;
    else cout <<"NG"<<endl;


    return 0;
}


Measured memory_bytes: 3636
n,m = map(int,input().split(" "))
ar = [[0,1] for i in range(n)]
ar[0] = [1,1]
r = 0
for i in range(m):
    a,b = map(int,input().split(" "))
    a -= 1
    b -= 1
    if ar[a][0] == 1 and ar[a][1] >= 1:
        ar[b][0] = 1
    ar[b][1] += 1
    ar[a][1] -= 1
    if ar[a][1] == 0:
        ar[a][0] = 0
count = 0
for r in ar:
    if r[0] == 1:
        count += 1
print(count)

Measured memory_bytes: 13172
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ans=0
ab.sort()
m=bin(k)
# print(m)
klst=[m]
for i in range(2,len(m)):
    if m[i]=="1":
        klst.append(m[:i]+"0"+"1"*(len(m)-i-1))

# print(klst)
for i in klst:
    tmp=0
    for j in range(n):
        a,b=ab[j]
        if a|int(i,0)==int(i,0):
            tmp+=b
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 88996
package main

import "fmt"

func main() {
	var N, D, X int
	fmt.Scan(&N, &D, &X)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	sum := 0
	for _, v := range a {
		for i := 1; i <= D; i += v {
			sum++
		}
	}

	ans := sum + X
	fmt.Println(ans)
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl


//----------------------------------------------------------------

int main(void) {
  ll n, k;
  cin >> n >> k;

  vector<ll> p(n);
  rep(i,n){
    cin >> p[i];
  }

  vector<ll> sum(n+1);

  sum[0] = 0;
  rep(i,n){
    sum[i+1] = sum[i]+p[i];
  }

  ll ans=-1;
  rep(i,n-k+1){
    if(ans < sum[i+k]-sum[i]){
      ans = sum[i+k]-sum[i];
    }
  }

  prtd(2, double(ans+k)/2.);

}


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

bool comp1(const char& a, const char& b){
    return a < b;
}

bool comp2(const char& a, const char& b){
    return a > b;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 using v = vector<int>;
 const int INF = 2147483647;
    //int nax = max_element(p.begin(),p.end())-p.begin();
    //int nin = max_element(p.begin(),p.end())-p.begin();
     //sort(l.begin(),l.end(),greater<int>());
     //stringは",charは'
     //ちょっとあやしかったら立ち止まって考える
     //例外処理はreturn忘れずに
     //文字列連結 文字+="aa" でできる

 int main(){
     int a,b,m;
     cin >> a >> b >> m;
     v va(a);
     v vb(b);
     rep(i,a) cin >> va[i];
     rep(i,b) cin >> vb[i];
     v x(m);
     v y(m);
     v c(m);
     rep(i,m) {
         cin >> x[i] >> y[i] >> c[i];
     }
     int nin = INF;
     rep(i,m){
        //  nin = min(nin,va[x[i]-1]+vb[y[i]-1]-c[i]);
         nin = min(nin,va[x[i]-1]+vb[y[i]-1]-c[i]);

     }
     sort(va.begin(),va.end());
     sort(vb.begin(),vb.end());
    nin = min(nin,va[0]+vb[0]);
     cout << nin << endl;
     return 0;
 }

Measured memory_bytes: 2304
#include<stdio.h>
#include<string.h>
main(){
  int n;
  int out=0,hit=0,total_out=0;
  int point=0;
  char ibe[10];
  scanf("%d",&n);
  while(total_out!=3*n){
    scanf("%s",ibe);
    if(strcmp(ibe,"HIT")==0){
      hit++;
    }
    if(hit==4){
      point++;
      hit=3;
    }
    if(strcmp(ibe,"OUT")==0){
      out++;
      total_out++;
    }
    if(strcmp(ibe,"HOMERUN")==0){
      point+=hit+1;
      hit=0;
    }
    if(out==3){
      out=0;
      hit=0;
      printf("%d\n",point);
      point=0;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
import math
a, b, x = map(int, input().split())
h = x / (a ** 2)
s = x / a
if h > b / 2:
    ans = math.atan((b - h) * 2 / a)
    print(math.degrees(ans))
else:
    ans = math.atan(b ** 2 / (2 * s))
    print(math.degrees(ans))


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		int su = 1;
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		int answer=0;
		for(int i=0;n>i;i++) {
			if(list.get(i)==su)
				su++;
			else
				answer++;
		}
		if(answer==n)
			System.out.println(-1);
		else
			System.out.println(answer);
	}
}

Measured memory_bytes: 92000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        if (i % 2 == 0 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	ll n; cin >> n;
	Rep(i, 100000){
		if((i * (i + 1) / 2) >= n){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b;
  string s;
  cin>>N;
  vector<tuple<string,int,int>> t;
  for(int i=0;i<N;i++){
    cin>>s>>a;
    t.push_back(make_tuple(s,(-1)*a,i+1));
  }
  sort(t.begin(),t.end());
  for(int i=0;i<N;i++){
    tie(s,a,b)=t[i];
    cout<<b<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	int fx = 0;
	int x = n;
	while(x > 0){
		fx += x%10;
		x /= 10;
	}
	
	if(n >= fx && n % fx == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
  int h,w,i,j,k,l;
  scanf("%d %d",&h,&w);
  char s[h][w+1];
  for(i=0;i<h;i++){
    scanf("%s",s[i]);
  }
  for(i=0;i<w+2;i++){
    printf("#");
  }
  printf("\n");
  for(i=0;i<h;i++){
    printf("#");
    printf("%s",s[i]);
    printf("#\n");
  }
  for(i=0;i<w+2;i++){
    printf("#");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
 public static void main(String args[]){
  long max,min,n,g,i,j;
  max=-1000001;min=1000001;g=0;i=0;
  Scanner sc = new Scanner(System.in);
  n=sc.nextInt();
  while(i<n){
   j=sc.nextInt();
   if(max<j)
    max=j;
   if(min>j)
    min=j;
   g+=j;
   i++;}
  System.out.println(min+" "+max+" "+g);
 }
}


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

//?´??????°????§£?????????????????°??????
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.nextLine());
		System.out.print(n + ":");
		List<Long> pf = new ArrayList<>();
		while (true) {
			if (n == 1) {
				break;
			}
			for (long i = 2; i <= Math.ceil(Math.sqrt(n)); i++) {
				if (n % i == 0) {
					n = n / i;
					pf.add(i);
					break;
				}
				if (i == Math.ceil(Math.sqrt(n))) {
					pf.add(n);
					n = 1;
					break;
				}
			}
		}
		for (long i : pf) {
			System.out.print(" " + i);
		}
		System.out.print("\n");
	}

}

Measured memory_bytes: 26256
#include <stdio.h>

int main(){
   int d,c[26],s[365][26],last[26],i,j,ms,mi,t;
   long sum;

   scanf("%d",&d);
   for (i=0;i<26;i++) {
      scanf("%d",&c[i]);
      last[i]=-1;
   }
   for (j=0;j<d;j++)
      for (i=0;i<26;i++) scanf("%d",&s[j][i]);
   for (i=0;i<d;i++) {
      mi=0;
      ms=s[i][0]-c[0]*(i-last[0]);
      for (j=1;j<26;j++) {
         t=s[i][j]-c[j]*(i-last[j]);
         if (t>ms) {
            ms=t;
            mi=j;
         }
      }
      printf("%d\n",mi+1);
      last[mi]=i;
   }
   return 0;
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand rng
using namespace std; void solve();
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;

struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
  int main(){solve_dbg();}
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>;
constexpr int MOD = 998244853;
mt19937_64 rng(58);
/////////

void solve(){
  ins(S , T);
  int ans = 0;
  rep(i , sz(S)) ans += S[i] == T[i];
  out(ans);
}


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

struct PAIR{
public:
    int x,y;
};

int main(void){
    // Your code here!
    int h,w;
    cin >> h>> w;
    string maze[h+2];
    int distance[h+2][w+2];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            maze[i]+='#';
            distance[i][j]=0;
        }
    }
    for(int i=1;i<=h;i++){
        string tmp;
        cin >> tmp;
        maze[i]='#'+tmp+'#';
    }
    
    int black=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(maze[i][j]=='#')
            black++;
        }
    }
    
    std::vector<PAIR> que;
    que.push_back(PAIR{1,1});
    int cnt=0;
    bool flag=false;
    while(que.size()!=0){
        PAIR id = que.front();
        que.erase(que.begin());
        int x=id.x,y=id.y;
        if(x==h and y==w){
            flag=true;
            break;
        }else{
            int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
            for(int i=0;i<4;i++){
                if (maze[x+dx[i]][y+dy[i]]=='.'){
                    maze[x+dx[i]][y+dy[i]]='o';
                    que.push_back(PAIR{x+dx[i],y+dy[i]});
                    distance[x+dx[i]][y+dy[i]]=distance[x][y]+1;
                }
            }
        }
        // for(int i=0;i<h+2;i++){
        //     for(int j=0;j<w+2;j++){
        //         cout << maze[i][j];
        //     }
        //     cout << endl;
        // }
    }
    if(flag == false){
        cout << -1;
    }else{
        cout << (h*w)-black-distance[h][w]-1;        
    }
    // cout << h << ' '<< w << ' '<<black<<' '<<distance[h][w]<<endl;


}


Measured memory_bytes: 256
unittest
{
	assert( [ "4 3", "1 3 2", "2 4 3", "1 4 6" ].parse.expand.solve == 5 );
	assert( [ "4 2", "1 2 1", "3 4 2" ].parse.expand.solve == -1 );
	assert( [ "10 7", "1 5 18", "3 4 8", "1 3 5", "4 7 10", "5 9 8", "6 10 5", "8 10 3" ].parse.expand.solve == 28 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto lrcs = new long[ 3 ][ nm[ 1 ] ];
	foreach( ref lrc; lrcs )
	{
		input.popFront;
		lrc = input.front.split.to!( long[] );
		lrc[ 0 .. 2 ] -= 1;
	}
	return tuple( nm[ 0 ], lrcs );
}

auto solve( long n, long[ 3 ][] lrcs )
{
	lrcs.sort();
	
	// 頂点Lから頂点Rへ距離Cの有向辺を張る
	auto nss = new Tuple!( long, long )[][ n ];
	auto ec = 0L;
	foreach( lrc; lrcs )
	{
		nss[ lrc[ 0 ] ] ~= tuple( lrc[ 1 ], lrc[ 2 ] );
		ec++;
	}
	
	// 頂点Rから頂点Lまでの全頂点間へ距離0の有向辺を張る
	foreach( lrc; lrcs )
	{
		foreach_reverse( i; lrc[ 0 ] .. lrc[ 1 ] )
		{
			if( !nss[ i + 1 ].empty && nss[ i + 1 ][ $ - 1 ][ 0 ] == i ) break;
			nss[ i + 1 ] ~= tuple( i, 0L );
			ec++;
		}
	}
	
	// 最短距離を探索
	auto ds = dijkstra( nss, ec, 0 );
	return ( ds[ $ - 1 ] == long.max ) ? -1 : ds[ $ - 1 ];
}

// 正の重み付きグラフの始点指定最短経路探索（ダイクストラ法）
auto dijkstra( Tuple!( long, long )[][] nss, long ec, long s )
{
	import std.container.binaryheap;
	
	auto ds = new long[ nss.length ];
	ds[] = long.max;
	ds[ s ] = 0;
	auto us = new bool[ nss.length ];
	auto uc = 0L;
	
	auto queue = heapify!( ( a, b ) => b[ 1 ] < a[ 1 ] )( new Tuple!( long, long )[ ec ], 0 );
	queue.insert( tuple( s, 0L ) );
	while( !queue.empty )
	{
		auto fi = queue.front[ 0 ];
		auto fd = queue.front[ 1 ];
		queue.popFront();
		
		if( us[ fi ] ) continue;
		us[ fi ] = true;
		uc++;
		if( uc == us.length ) break;
		
		foreach( t; nss[ fi ] )
		{
			auto ti = t[ 0 ];
			auto td = fd + t[ 1 ];
			
			if( ds[ ti ] <= td ) continue;
			
			ds[ ti ] = td;
			queue.insert( tuple( ti, td ) );
		}
	}
	return ds;
}


Measured memory_bytes: 17788
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int X,Y,Z;
	int n,Q,W;
    scanf(" %d%d%d",&X,&Y,&Z);
	Q=X-2*Z;
	W=Y+Z;
	n=Q/W;
	if(Q%W>=Y)
		{n=n+1;}
		printf("%d",n);
		
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
#include<cstring>
#include<cstdio>
int f[1500][1500];
int a[1500][1500];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int maxn = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]==1)
				f[i][j]=0;
			else
			f[i][j] = min(f[i-1][j],min(f[i][j-1],f[i-1][j-1]))+1;
			maxn = max(f[i][j],maxn);
		}
	}
	printf("%d\n",maxn*maxn);
	return 0;
}


Measured memory_bytes: 19564
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)




main(){
int t,tc = 0;

ll n;
cin>>n;
ll ans = 1;
for(ll i = 0; i<3; i++)
    ans*=n;
cout<<ans<<endl;


return 0;
}



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int N = scan.nextInt();
    int A[] = new int[N];
    int maxA[] = new int[N];

    int max = 0;

    for(int i = 0; i < N; i++) {
      A[i] = scan.nextInt();
      if(A[i] > max){
        max = A[i];
      }
      maxA[i] = max;
    }

    long ans = 0;

    for(int i = 0; i < N; i++) {
      ans += maxA[i] - A[i];
    }

    os.println(ans);
  }
}


Measured memory_bytes: 51888
#include<stdio.h>

int main(){
	int n, x;
	scanf("%d", &n);
	scanf("%d", &x);
	int l[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &l[i]);
	}
	int cnt = 0;
	int y = 0;
	for(int j = 0; cnt <= x; j++){
		cnt = cnt + l[j];
		y++;
	}

	printf("%d\n", y);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
 
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
 
#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)
 
typedef long long ll;
typedef pair<int, int> pii;

#define INF (1<<10)

string str;

int strpos;
void init() { strpos = 0; }
char get() { return str[strpos++]; }
void unget() { strpos--; }

vector<int> nums;
vector<char> ops;
vector<int> priorities;

int num();
void expr();

void initialize()
{
	nums.clear();
	ops.clear();
	priorities.clear();
	init();
	expr();
}

int num()
{
	int n = 0;
	for (;;) {
		char ch = get();
		if (!isdigit(ch))
			break;
		n = (10*n) + (ch-'0');
	}
	unget();
	return n;
}

void expr()
{
	int depth = 0;
	while (strpos < str.size()) {
		char ch = get();
		if (ch == '(') {
			depth++;
		} else if (ch == ')') {
			depth--;
		} else if (isdigit(ch)) {
			unget();
			int n = num();
			nums.push_back(n);
		} else {
			char op = ch;
			ops.push_back(op);
			priorities.push_back(depth);
		}
	}
}

int main()
{
	while (cin >> str, str != "#") {
		initialize();
/*
		rep(i, ops.size())
			cout << ops[i] << (i==ops.size()-1?"\n":", ");
		rep(i, priorities.size())
			cout << priorities[i] << (i==priorities.size()-1?"\n":", ");
		rep(i, nums.size())
			cout << nums[i] << (i==nums.size()-1?"\n":", ");
		cout << "----" << endl;
*/

		set<int> ans;
		int sz = priorities.size();
		vector<int> pri;
		rep(i, sz) pri.push_back(i);
		do {
			vector<int> buf(nums);
			int mi = INF;
			bool used[11] = {};

			rep(i, sz) {
				if (mi < priorities[pri[i]])
					goto NEXT;
				mi = min(mi, priorities[pri[i]]);
			}

			rep(i, sz) {
				int idx = pri[i];
				char op = ops[idx];
				int a = buf[idx];
				int b = buf[idx+1];
				int ret;
				switch(op) {
				case '+': ret = a+b; break;
				case '-': ret = a-b; break;
				case '*': ret = a*b; break;
				case '/':
					{
						if (b == 0)
							goto NEXT;
						ret = a/b;
						break;
					}
				}
				for (int j = idx+1;; j++) {
					buf[j] = ret;
					if (j == sz || !used[j]) break;
				}
				for (int j = idx;; j--) {
					buf[j] = ret;
					if (j == 0 || !used[j-1]) break;
				}
				used[idx] = true;
			}
			/*
			rep(i, pri.size())
				cout << pri[i] << (i==pri.size()-1?"\n":", ");
			rep(i, buf.size())
				cout << buf[i] << (i==buf.size()-1?"\n":", ");
			cout << "----" << endl;
			*/
			ans.insert(buf[0]);
NEXT:;
		} while(next_permutation(ALL(pri)));
		cout << ans.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
//struct cmp {bool operator()(const pair<int, char> &a, const pair<int, char> &b) {if (a.first == b.first) {return a.second > b.second;} else {return a.first > b.first;}}};
#include<bits/stdc++.h>
#define endl "\n"
#define _  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define min_heap priority_queue <int, vector<int>, greater<int> >
#define max_heap priority_queue <int>
#define ll long long
//#define int long long
#define MOD 1000000007#define deb3(x,y,z) cout << #x << "=" << x << "\t"<<#y<<"="<<y<< "\t"<<#z<<"="<<z<<endl;
#define DEBUG cout<<"Hello1\n";
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << "=" << x << "\t\t"<<#y<<"="<<y<<endl;
#define deb3(x,y,z) cout << #x << "=" << x << "\t"<<#y<<"="<<y<< "\t"<<#z<<"="<<z<<endl;
#define all(v) (v).begin(),(v).end()
using namespace std;

void solve() {
	int n, l;
	cin >> n >> l;
	vector<string> v;
	while (n--) {
		string s;
		cin >> s;
		v.pb(s);
	}

	sort(all(v));

	for (auto x : v)cout << x;
}

int32_t main() {
	_


	solve();
}



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


int main()
{
    char a[4];
    scanf("%s",a);
    int f=1,cnt=0,ans=0;
    for(int i=0;i<=3;++i) {
        if(a[i]=='R') {
            if(f) cnt++;
            else f=1,cnt=1;
        }
        else f=0,ans=max(ans,cnt);
    }
    cout<<ans;
}

Measured memory_bytes: 3760
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int n,m;
cin>>n>>m;
int k[n];
pair<int,int> a[n][m];
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        a[i][j].first=j;
        a[i][j].second=0;
    }
}

for(int i=0;i<n;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
        int x;
        cin>>x;
        a[i][x-1].second=1;
    }
}

int ans=0;
for(int j=0;j<m;j++){
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i][j].second==1){
            cnt+=1;
        }
    }
    if(cnt==n)ans+=1;
}

cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define maxn 105
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
using namespace std;

int a[maxn];
int b[maxn];
int n;

int main(){
    scanf("%d", &n);
    rep(i, 1, n) scanf("%d", &a[i]), a[i] += a[i - 1];
    rep(i, 1, n) scanf("%d", &b[i]);
    per(i, n, 1) b[i] += b[i + 1];
    int ans = 0;
    rep(i, 1, n) ans = max(ans, a[i] + b[i]); 
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
    l *= i // gcd(l, i)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(ceil((m // l) / 2))

Measured memory_bytes: 20140
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
//0の場合のアレンジに注意
template<class T>
T gcd(T a,T b){
    if(a == 0)return b;
    else if(b == 0)return a;
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

template<class T = ll>
T in(){T x;cin >> x;return x;}
int main(){
    ios::sync_with_stdio(true);
    cin.tie(0);cout.tie(0);
    ll N = in(),K = in();
    vector<dou> vec(N);
    vecin(vec);
    dou le = 0,ri = 1000000000;
    while(ri - le > 1){
        dou mid = (le + ri) / 2;
        mid = ceil(mid);
        ll cnt = 0;
        rep(i,N){
            cnt += ceil(vec[i] / mid) - 1;
        }
        if(cnt <= K)ri = mid;
        else le = mid;
    }
    ll ans = ri;
    cout << ans << "\n";
}

Measured memory_bytes: 28232
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*


fun main(args: Array<String>) {
    val inputReader = InputReaderd(System.`in`)

    val n = inputReader.nextInt()
    val s = inputReader.nextLine().split(" ").map { i -> i.toInt() }

    var count = 1
    for(i in 0 until n) {
        if (count == s[i])
            count++
    }

    if (count == 1)
        print(-1)
    else
        print(n - --count)
}

class InputReaderd(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream))
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = reader.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


Measured memory_bytes: 63896
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

i64 N, K;
vector<i64> a;

int main() {
  cin >> N >> K;
  a.resize(N + 1);
  for(int i = 1;i <= N;i++) cin >> a[i];

  vector<vector<i64>> dp(N + 1, vector<i64>(K + 1, 0));
  dp[0][0] = 1;

  const i64 mod = 1e9 + 7;

  for(int i = 1;i <= N;i++){
    i64 sum = 0;
    for(int k = 0;k <= K;k++) {
      sum += dp[i - 1][k];
      sum %= mod;
      dp[i][k] = sum;
      if(k - a[i] >= 0) {
        sum -= dp[i - 1][k - a[i]];
        sum %= mod;
        sum += mod;
        sum %= mod;
      }
    }
  }
  cout << dp[N][K] << endl;
}


Measured memory_bytes: 80256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=1000+19;

struct Circle{
	int x,y,r;
} C[N];
db dis[N];
int vis[N];
int n;

db calc(int i,int j){
	db dis=sqrt(1.0*(C[i].x-C[j].x)*(C[i].x-C[j].x)+1.0*(C[i].y-C[j].y)*(C[i].y-C[j].y));
	return max(dis-C[i].r-C[j].r,0.0);
}

int main(){
	C[1]=(Circle){IN(),IN(),0};
	C[2]=(Circle){IN(),IN(),0};
	n=IN();
	For(i,1,n+1) C[i+2]=(Circle){IN(),IN(),IN()};
	For(i,0,n+3) dis[i]=1e60;
	dis[1]=0;
	For(i,1,n+3){
		int x=0;
		For(j,1,n+3){
			if (!vis[j]&&dis[j]<dis[x]) x=j;
		}
		vis[x]=1;
		For(j,1,n+3){
			if (!vis[j]&&dis[x]+calc(x,j)<dis[j]) dis[j]=dis[x]+calc(x,j);
		}
	}
	printf("%.20lf\n",dis[2]);
}

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

int main() {
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);
    (A[0] + A[1] == A[2]) ? cout << "Yes\n": cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string Longest_Common_Subsequence(string &s1,string &s2)
{
    int maxValue;
    int length1 = (int)s1.length(), length2 = (int)s2.length();
    vector< vector< int > > DP(length1+1,vector< int > ((length2+1),0));
    for(int i=1;i<=length1;i++){
        for(int j=1;j<=length2;j++){
            if(s1[i-1] == s2[j-1]){
                DP[i][j] = 1 + DP[i-1][j-1];
            }
            else{
                DP[i][j]= max(DP[i-1][j],DP[i][j-1]);
            }
        }
    }
    string ans = "";
    int i = length1,j=length2;
    while(i>0 && j>0){
        if(DP[i][j] == DP[i][j-1]){
            j--;
        }
        else if(DP[i][j] == DP[i-1][j]){
            i--;
        }
        else{
            ans += s1[i-1];
            i--,j--;
        }
    }
//    for(int i=0,j=ans.length()-1;i<j;i++,j--)
//        swap(ans[i],ans[j]);
    reverse(ans.begin(),ans.end());
    return ans;
}
int main()
{
    //freopen("in.txt","r",stdin);
    string s1,s2;
    cin >> s1 >> s2;
    string ans = Longest_Common_Subsequence(s1,s2);
    cout << ans << endl;
}


Measured memory_bytes: 35584
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    d = LI()
    ans = 0
    q = [1]
    for i in range(n):
        q_ = []
        while q:
            p = q.pop()
            if not (1 << d[i]) & p:
                q_.append((1 << d[i]) | p)
            if not (1 << (24 - d[i])) & p:
                q_.append((1 << (24 - d[i])) | p)
        q = q_
    for qi in q:
        tmp = 25
        for i in range(25):
            for j in range(i + 1, 25):
                x = (1 << i) | (1 << j)
                if (qi & x) == x:
                    tmp = min(tmp, min(j - i, 24 - (j - i)))
        ans = max(ans, tmp)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

int main(void)
{
	int n;
	int arr[10010];
	int cnt=0;

	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		scanf("%d", arr+i);
		while(arr[i]%2==0&&arr[i]!=0)
		{
			cnt++;
			arr[i]/=2;
		}
	}

	printf("%d", cnt);

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    string s,t;
    cin  >> s >> t;
    int i = 0;
    while(i!=s.size()){
        if(s!=t){
            t = t.back() + t;
            t.erase(t.size()-1);
            ++i;
        }
        else{
            Yes
        }
    }
    No
    return 0;
}


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

using namespace std;


int main()
{
	int n,flag=1,flag2=1,flag3=1;
	
	cin >> n;
	
	vector<long long int> v(n);
	
	for(int i=0;i<n;i++){
		cin >> v[i];
		if(v[i] != 0) flag3 = 0;
	}
	
	
	if(flag3 == 1){
		cout << "Yes" << endl;
		return 0;
	}
	
	if(n%3 != 0) {
		cout << "No" << endl;
		return 0;
	}
	
	sort(v.begin(),v.end());
	
	
	long long int b,c,d;
		
	b = v[0];
	c = v[n/3];
	d = v[2*n/3];
	
	for(int i=0;i<40;i++){
		int cnt=0;
		
		if(b%2 == 1){
			cnt++;
		}
		b = b/2;
		if(c%2 == 1){
			cnt++;
		}
		c = c/2;
		if(d%2 == 1){
			cnt++;
		}
		d = d/2;
		
		if(cnt != 2 && cnt != 0){
			flag2 = 0;
			break;
		}
		if(d == 0)break;
	}
	
	if(flag2 == 0){
		cout << "No" << endl;
		return 0;
	}
	
	for(int i=0;i<n;i++){
		if(n/3 > i){
			if(v[0] != v[i]){
				flag = 0;
				break;
			}
		}else if(2*n/3 > i){
			if(v[n/3] != v[i]){
				flag = 0;
				break;
			}
		}else{
			if(v[2*n/3] != v[i]){
				flag = 0;
				break;
			}
		}
	}
	
	if(flag == 1)cout << "Yes" << endl;
	else cout << "No" << endl;

		
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int L = scn.nextInt();
		if(L >= 0) {
			System.out.println(N*(N-1)/2 + (N-1)*L);
		}else {
			if(N > -L) {
				int ans = 0;
				for(int i = 0;i < N;i++) {
					ans += L+i;
				}
				System.out.println(ans);
			}else {
				int ans = 0;
				for(int i = 0;i < N-1;i++) {
					ans += L+i;
				}
				System.out.println(ans);
			}
		}
	}

}

Measured memory_bytes: 22604
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

int main(void){
  int N, q;
  cin >> N >> q;
  queue<pair<string, int> > que;
  for(int i=0;i<N;i++){
    int a; string s;
    cin >> s >> a;
    que.push(make_pair<string, int>(s, a));
  }

  int sum = 0;
  while(!que.empty()){
    pair<string, int> qu = que.front();
    que.pop();
    if(qu.second <= q){
      sum += qu.second;
      cout << qu.first << " " << sum << endl;
      continue;
    }
    qu.second -= q;
    sum += q;
    que.push(qu);
  }
  return 0;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define se second
#define fi first
#define pb push_back
#define mp make_pair
using namespace std;

const int N = 30010;
const int MX = 1000000;

int x , y;

int main() {
	cin >> x >> y;
	if(x%y == 0){
		puts("-1");
		return 0;
	}
	printf("%d\n", x);
	return 0;
}


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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

ll A,B,K;
int main(){
    cin >> A >> B >> K;
    if(A>=K){
        cout << A-K <<" " << B << endl;
    }else if(K>=A && B>=(K-A)){
        cout << 0 << " " << B-(K-A) << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }

    return 0;
}

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

H = list(map(int, input().split()))

h = [0]*(N - 1)
for i in range(N - 1):
    h[i] = H[i+1] - H[i]

s = 0
count = [0]*(N)
prev = 0
for i in range(N-1):
    if i == 0:
        if h[0] <= 0:
            count[0] = 1
        continue
    elif h[i] <= 0:
        count[i] = count[i - 1] + 1
    else:
        count[i] = 0


print(max(count))


Measured memory_bytes: 14992
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int before = 0;
		int cnt = 0;

		for (int i = 0; i < N; i++) {
			int H = scan.nextInt();

			if (before <= H) {
				cnt++;
			}
			if (H > before) {
				before = H;
			}
		}

		System.out.println(cnt);
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
    cout<<setprecision(10);

    ll n,m,d;
    cin>>n>>m>>d;
    double base=(double)(d==0?n-d:2*(n-d))/(n*n);
    double ans=base*(m-1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

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

    string s = "";

    int count = N;
    int amari = 0;
    while (1) {
        amari = count % 26;
        count /= 26;

        s.push_back('`');
        s[SIZE(s) - 1] += amari;
        if (amari == 0) {
            s[SIZE(s) - 1] += 26;
            count--;
        }

        if (count <= 0) {
            break;
        }
    }

    REP(i, SIZE(s)) {
        cout << s[SIZE(s) - i - 1];
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3628
//
// Created by yuu on 2019-08-18.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;

double V[60];
int main(void){
    int N;
    cin>>N;


    for (int i = 0; i < N; ++i) {
        cin>>V[i];
    }



    for (int i = 0; i < N-1; ++i) {
        sort(V, V+N);
        V[i+1] = (V[i] + V[i+1])/2.0;
        V[i] = - 1;
    }

//    for (int i = 0; i < N; ++i) {
//        cout<<V[i]<<endl;
//    }

    cout<<V[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[120];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<int>());
    int alice = 0;
    int bob = 0;
    
    for(int i = 0; i < n; i++){
        if(i == 0) alice += a[i];
        else if(i%2 == 1) bob += a[i];
        else alice += a[i];
    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 256