akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k,t,u,v,l,d[210]={0};
  cin>>n>>k>>t>>u>>v>>l;
  for(int i=1;i<=n;i++)cin>>d[i];
  d[n+1]=l;
  long long a=0,p=0;
  for(int i=1;i<=n+1;i++){
    if(a>d[i]-d[i-1]){
      a-=d[i]-d[i-1];
      if(a/(v*t)<k)a+=v*t;
      else a=v*t*(k+1);
    }
    else p+=d[i]-d[i-1]-a,a=v*t;
  }
  printf("%.10f\n",1.0*p/u+1.0*(l-p)/v);
  return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

#define MAX 100

int main(){
  int i,j;
  int n;
  int a[MAX];
  int minj;
  int key;
  int dif=0;

  scanf("%d",&n);//要素数
  for(i=0; i<n; i++){//要素読み
    scanf("%d",&a[i]);
  }

  for(i=0; i<n-1; i++){
    minj=i;
    for(j=i; j<=n-1; j++){
      if(a[j]<a[minj]){
	minj = j;
      }
    }
    key=a[i];
    a[i]=a[minj];
    a[minj]=key;
    if(i!=minj)dif++;
  }
  for(i=0; i<n; i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",dif);

  return 0;
}



Measured memory_bytes: 2124
n, k = map(int, input().split())
pp = list(map(int, input().split()))
p = [pp[i]-1 for i in range(n)]
c = list(map(int, input().split()))

ans = -(10**9+1)
for i in range(n):
  s = 0
  x = i
  for j in range(k):
    x = p[x]
    s += c[x]
    ans = max(ans,s)
    if i == x:
      break
  a = int(k/(j+1))
  m = k%(j+1)
  if m == 0 and a > 1:
    m = j+1
    a -= 1
  s *= a
  ans = max(ans,s)
  for l in range(m):
    x = p[x]
    s += c[x]
    ans = max(ans, s)
print (ans)


Measured memory_bytes: 74640
#include <stdio.h>

#include <string.h>

int main()

{

    int x;

    double a,b,c,sum;

    scanf("%d",&x);

    a=x/3.00;

    b=x/3.00;

    c=x/3.00;

    sum=a*b*c;

    printf("%.12lf\n",sum);

    return 0;

}

Measured memory_bytes: 128
import java.util.*;

public class Main{

    final static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        System.out.println(B());
    }

    public static String A() {
        int input = sc.nextInt();
        if(input >= 30){
            return "Yes";
        }
        else{
            return "No";
        }
    }

    public static int B(){
        int N = sc.nextInt();
        int D = sc.nextInt();
        int cnt = 0;

        for ( var i = 0; i< N; i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            double num = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
            if(num<=D){
                cnt++;
            }
        }

        return cnt;
    }
}


Measured memory_bytes: 58992
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(b+a);
    }else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(b*a);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n", pop());
  return 0;
}

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

const int m=1000000007;

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  ll sum=0;
  rep(i,n) sum+=a[i];
  int m=(n-1)/2;
  for(int i=1;i<n;i+=2){
    sum-=a[i]*2;
  }
  sum/=2;
  cout << sum*2 << "\n";
  for(int i=0;i<n-1;i++){
    sum=(a[i]-sum);
    cout << sum*2 << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 3776
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		switch(x % 7) {
		case 0:
			System.out.println("thu");
			break;
		case 1:
			System.out.println("fri");
			break;
		case 2:
			System.out.println("sat");
			break;
		case 3:
			System.out.println("sun");
			break;
		case 4:
			System.out.println("mon");
			break;
		case 5:
			System.out.println("tue");
			break;
		case 6:
			System.out.println("wed");
			break;
		}
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}



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

int main(){
    int a;
    cin >> a;
    int top = 0;
    int key = 0;
    vint A(a);
    rep(i,a){
        int b;
        cin >> b;
        A[i] = b;
        if(top < b){
            top = max(top,b);
            key = i;
        }
    }
    sort(A.begin(),A.end());
    rep(i,a){
        if(i != key)cout << A[a-1] << endl;
        else cout << A[a-2] << endl;
    }

}


Measured memory_bytes: 2432
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
max_count = c.most_common()[0][1]
max_k_list = [kv[0] for kv in c.items() if kv[1] == max_count]
max_k_list.sort()
for max_k in max_k_list:
    print(max_k)


Measured memory_bytes: 45040
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
if n % 2 == 0:
    n -= 1
ans = []
left_range = n//2
right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

while True:
    if left1 >= right1:
        break
    ans.append([left1, right1])
    left1 += 1
    right1 -= 1

while True:
    if left2 >= right2:
        break
    ans.append([left2, right2])
    left2 += 1
    right2 -= 1
    
for i in range(m):
    print(*ans[i])    




Measured memory_bytes: 84364
#include <iostream>
#include <cmath>
#include <set>
using namespace std;
int main()
{
	string s;
	int k;
	cin>>s>>k;
	set<string> q;
	char c='a';
	while(q.size()<=k){
		for(int i=0;i<s.length();i++)
		{
			if(s[i]==c){
				for(int j=0;j<=10;j++){
					string t=s.substr(i,j);
					q.insert(t);
					//cout<<t<<endl;
				}
			}
		}
		c++;
	}
	int i;
	set<string>::iterator it;
	for(i=0,it=q.begin();i<k&&it!=q.end();it++,i++);
	cout<<(*it)<<endl;
	return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int m(int x) {
    return (int)ceil(sqrt(2.0*x+0.25) - 0.5);
}
void solve(int N) {
    vi a;
    while (N) {
        int r = m(N);
        a.pb(r);
        N -= r;
    }
    for (int i=a.size()-1; i>=0; --i) {
        cout << a[i] << endl;
    }
}

int main() {
    int N; cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[30][30][30][30];
char str[30][30];
int calc(int a,int b,int c,int d){
    if(a>=b||c>=d)return 0;
    if(dp[a][b][c][d]!=-1)return dp[a][b][c][d];
    int val[64];
    for(int i=0;i<64;i++)val[i]=0;
    for(int i=a;i<b;i++)for(int j=c;j<d;j++){
        if(str[i][j]=='X')continue;
        int tmp=0;
        tmp^=calc(a,i,c,j);
        tmp^=calc(i+1,b,c,j);
        tmp^=calc(a,i,j+1,d);
        tmp^=calc(i+1,b,j+1,d);
        val[tmp]=1;
    }
    for(int i=0;i<64;i++)if(!val[i])return dp[a][b][c][d]=i;
}
int main(){
    int a,b;scanf("%d%d",&a,&b);
    for(int i=0;i<a;i++)scanf("%s",str[i]);
    for(int i=0;i<30;i++)for(int j=0;j<30;j++)for(int k=0;k<30;k++)for(int l=0;l<30;l++)
        dp[i][j][k][l]=-1;
    int ret=calc(0,a,0,b);
    if(ret)printf("First\n");
    else printf("Second\n");
}

Measured memory_bytes: 5848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3],i,c=1;
    for(i=0;i<3;i++) cin>>a[i];
    sort(a,a+3);
    for(i=0;i<2;i++)
    {
        if(a[i]==a[i+1]) continue;
        else c++;
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3604
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=list(set([int(input()) for _ in range(n)]))
l=[]
for i in range(len(b)):
  for j in range(3):
    for k in range(3):
      if b[i]==a[j][k]:
        l.append([j+1,k+1])
if len(l)>=7:
  print('Yes')
elif len(l)<=2:
  print('No')
else:
  if l.count([1,1])==l.count([2,2])==l.count([3,3])==1 or l.count([1,3])==l.count([2,2])==l.count([3,1])==1:
    print('Yes')
  else:
    count1,count2=1,1
    l=sorted(l, key=lambda x: (x[0]))
    ll=sorted(l, key=lambda x: (x[1]))
    for i in range(len(l)-1):
      if l[i][0]==l[i+1][0]:
        count1+=1
      elif count1!=3:
        count1=1
      if ll[i][1]==ll[i+1][1]:
        count2+=1
      elif count2!=3:
        count2=1
    if count1==3 or count2==3:
      print('Yes')
    else:
      print('No')

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    vector<vector<ll>> cnt(M);
    rep(i, N) {
        cnt[X[i] % M].push_back(X[i]);
    }
    ll ans = 0;
    ans += cnt[0].size() / 2;
    if (M % 2 == 0) ans += cnt[M / 2].size() / 2;
    rep(i, (M-1) / 2) {
        ll idx = i + 1;
        ll jdx = M - i - 1;
        if (cnt[idx].size() > cnt[jdx].size()) swap(idx, jdx);
        vector<ll> T = cnt[jdx];
        vector<ll> S = cnt[idx];
        ll over = T.size() - S.size();
        ans += S.size();

        map<ll, ll> C;
        for (ll t : T) {
            C[t]++;
        }
        ll tmp = 0;
        for (P c : C) {
            tmp += c.second / 2;
        }
        ans += min(over / 2, tmp);
    }
    cout << ans << '\n';
}


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


Measured memory_bytes: 6528
use std::io::*;

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines();
  let n = lines.next().unwrap().unwrap().parse::<u64>().unwrap();

  let mut data = [[[0; 10]; 3]; 4];

  for _ in 0..n {
    let line = lines.next().unwrap().unwrap();
    let mut args = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let b = args.next().unwrap() as usize;
    let f = args.next().unwrap() as usize;
    let r = args.next().unwrap() as usize;
    let v = args.next().unwrap();

    data[b - 1][f - 1][r - 1] += v;
  }

  let stdout = stdout();
  let mut stdout = BufWriter::new(stdout.lock());

  for b in 0..4 {
    if b != 0 { writeln!(stdout, "####################").unwrap() }

    for floor in &data[b] {
      for room in floor {
        write!(stdout, " {}", room).unwrap();
      }

      writeln!(stdout).unwrap();
    }
  }
}



Measured memory_bytes: 5040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine(), " ");
    int a = Integer.parseInt(st.nextToken());
    int b = Integer.parseInt(st.nextToken());
    int c = Integer.parseInt(st.nextToken());
    if (b-a == c-b) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 20564
#include <stdio.h>
#define N 36
#define exch(a, b) {card x = a; a = b; b = x;}
#define less(a, b) (a.num < b.num)
#define compexch(a, b) {if(less(a, b))exch(a, b);}

typedef struct{
  char mark, num;
}card;

void printarr(card *a, int n){
  int i;
  for(i = 0; i < n; i++){
    printf("%c%c", a[i].mark, a[i].num);
    printf((i == n - 1) ? "" : " ");
  }
  printf("\n");
}

void selectionSort(card *a, int n){
  int i, j, min, count = 0;
  for(i = 0; i < n - 1; i++){
    min = i;
    for(j = i + 1; j < n; j++)
      if(less(a[j], a[min])) min = j;
    if(min != i) exch(a[i], a[min]);
  }
}

void bubblesort(card *a, int n){
  int i, j;
  for(i = 0; i < n - 1; i++)
    for(j = n - 1; j >= i; j--)
      compexch(a[j], a[j - 1]);
}

int comparr(card *a, card *b, int n){
  int i;
  for(i = 0; i < n; i++)
    if(a[i].mark != b[i].mark) return 0;
  return 1;
}

int main(void){
  int n, i;
  char ch;
  card bubble[N], select[N];
  scanf("%d%c", &n, &ch);
  for(i = 0; i < n; i++){
    scanf("%c%c%c", &bubble[i].mark, &bubble[i].num, &ch);
    select[i] = bubble[i];
  }
  bubblesort(bubble, n);
  printarr(bubble, n);
  printf("Stable\n");
  selectionSort(select, n);
  printarr(select, n);
  printf(comparr(bubble, select, n) ? "Stable\n" : "Not stable\n");
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
int N;
vector<ll> A,B;

int main(void)
{
  cin >> N;
  for (int i = 0; i < N; ++i)
    {
      ll a;
      cin >> a;
      A.push_back(a);
    }
  for (int i = 0; i < N; ++i)
    {
      ll b;
      cin >> b;
      B.push_back(b);
    }
  ll res=0;
  for(int digit=29;digit>=0;digit--)
    {
      ll high=1LL<<(digit+1);
      ll low=1LL<<(digit);
      for (int i = 0; i < N; ++i)
	{
	  A[i]%=high;
	  B[i]%=high;
	}
      sort(B.begin(),B.end());
      ll num=0;
      for (int i = 0; i < N; ++i)
	{
	  ll add=0;
	  if(low-A[i]>=0)
	    {
	      add+=lower_bound(B.begin(),B.end(),high-A[i])-lower_bound(B.begin(),B.end(),low-A[i]);
	    }
	  else
	    {
	      add+=lower_bound(B.begin(),B.end(),high-A[i])-B.begin();
	      add+=lower_bound(B.begin(),B.end(),high)-lower_bound(B.begin(),B.end(),high+low-A[i]);
	    }
	  num+=add;
	}
      if(num&1) res+=low;
    }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

bool odd(int n) {
    int d = 0;
    while (n > 0) {
        d++;
        n /= 10;
    }
    return d % 2 == 1;
}

int main() {
    int N, cnt = 0;
    cin >> N;
    FOR(i, 1, N + 1) {
        if (odd(i)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  	char S[50];
  	int N, K = 0;
  	scanf("%d %d",&N, &K);
  	scanf("%s",S);
  	if(S[K-1] == 'A'){
    	S[K-1] = 'a';
    }else if(S[K-1] == 'B'){
    	S[K-1] = 'b';
    }else if(S[K-1] == 'C'){
    	S[K-1] = 'c';
    }
  
  	printf("%s\n", S);
	return 0;
}

Measured memory_bytes: 128
//*********Abhay is awesome *************\

#include<bits/stdc++.h>


#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define piii pair<int,pii>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repc(i,a,n) for(int i=a;i<n;++i)
#define  repd(i,a,n) for(int i=a;i>n;--i)

using namespace std;
using ll = long long;
const ll N = 3*1e5 +5 ;
const ll mod = 1e9+7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;

typedef vector<ll> vi;


void solve(){
	ll n,x,y;
	cin>>n>>x>>y;
	x--;
	y--;
	ll dif= y-x;
	vi v(n+1) ;
	rep(i,n+1)v[i]=0;
	//v[0] = n;

	//int dis[n][n];
	ll min;
	rep(i,n-1){
		repc(j,i+1,n){
			min=((j-i)< (abs(x-i)+abs(y-j)+1))?(j-i):(abs(x-i)+abs(y-j)+1);
			v[min]++;
			// if((i<=x&&j<=x)||(i>=y&&j>y))v[j-i]++;
			// if(i<=x&&j>=y)v[j-i-dif+1]++;
			// if(j>x&&j<=y){
			// 	min= (j-i)< (abs(x-i)+y-j+1)?(j-i):(abs(x-i)+y-j+1);
			// }

		}
	}
	repc(i,1,n)cout<<v[i]<<"\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output1.txt", "w", stdout);
	//#endif
	solve(); 
	return  0;
}



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

// Hello, this is a snippet.

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

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] A = new int[N];
		for(int i = 0;i < N;i++) {
			A[i] = scn.nextInt();
		}

		Arrays.sort(A);
		int ans = 0;
		int count_a = 0,count_b = 0,count = 0;
		int buf = -1;
		for(int i = 0;i < N;i++) {
			if(buf == A[i]) {
				count++;
			}else if(buf == A[i]-1){
				count_a = count_b;
				count_b = count;
				count = 1;
			}else if(buf == A[i] - 2) {
				count_a = count;
				count_b = 0;
				count = 1;
			}else {
				count_a = 0;
				count_b = 0;
				count = 1;
			}
			buf = A[i];
			ans = Math.max(ans, count_a + count_b + count);
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 51500
#include<stdio.h>

int main(void){
  int n,i,j;
  double x[4],y[4],t;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    for(j=0;j<4;j++)
      scanf("%lf%lf",&x[j],&y[j]);

    for(j=0;j<4;j+=2){
      if(x[j]<x[j+1]){
        t=x[j];
        x[j]=x[j+1];
        x[j+1]=t;
        t=y[j];
        y[j]=y[j+1];
        y[j+1]=t;
      }
    }

    if((x[0]-x[1])/(y[0]-y[1])==(x[2]-x[3])/(y[2]-y[3]))printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n;
lint K, a[MAX];

bool check(lint mid){
    if(mid == 0) return false;
    lint sum = 0;
    rep(i, n){
        sum += div_ceil(a[i], mid) - 1;
    }
    return sum <= K;
}

int main(){
    scanf("%d%lld", &n, &K);
    rep(i, n) scanf("%lld", &a[i]);
    lint low = 0, high = mod;
    while(high - low > 1){
        lint mid = (high + low) / 2;
        (check(mid) ? high : low) = mid;
    }
    printf("%lld\n", high);
}

Measured memory_bytes: 5368
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
int n,m,sum=0;
cin>>n>>m;
int a[m];
for(int i=0;i<m;i++){
cin>>a[i];
sum=sum+a[i];
}
if(sum<=n)
cout<<n-sum<<endl;

else
cout<<"-1"<<endl;

return 0;

}

Measured memory_bytes: 3660
S = list(input())
ki = ["R","U","D"]
gu = ["L","U","D"]
for i in range(len(S)):
    tmp = S[i]
    if (i+1) % 2 == 1:
        if "R" == tmp or "U" == tmp or "D" == tmp:
            continue
        print("No")
        exit()
    else:
        if "L" == tmp or "U" == tmp or "D" == tmp:
            continue
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <algorithm>
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 rev(v) reverse(v.begin(), v.end())
#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; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
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 gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);

	int D; cin >> D;
	vi c(26); vin(c);
	vvi s(D, vi(26));
	rep(i, D){
		rep(j, 26){
			cin >> s.at(i).at(j);
		}
	}
	long long int satisfaction = 0;

	vi last_day(26, 0);
	rep(i, D){
		vi temp_satisfaction(26, 0);
		rep(j, 26){
			auto temp_last_day = last_day;
			temp_satisfaction.at(j) += s.at(i).at(j);
			temp_last_day.at(j) = (i + 1);
			rep(k, 26){
				satisfaction -= c.at(k) * ((i+1) - temp_last_day.at(j));
			}
		}
		int max_index = max_element(temp_satisfaction.begin(),temp_satisfaction.end()) - temp_satisfaction.begin();
		satisfaction += temp_satisfaction.at(max_index);
		last_day.at(max_index) = (i + 1);
		cout << max_index + 1 << endl;
		//cout << "t " << t.at(i) << " s " <<  s.at(i).at(t.at(i) - 1)<< " i " << (i + 1) << endl;
		//last_day.at(j) = (i + 1);
	}
}

Measured memory_bytes: 3712
x=input()
lst=x.split(" ")
lstr=[]
for a in lst:
    lstr.append(int(a))
X=lstr[0]
Y=lstr[1]
if(Y%2==1):
    print('No')
else:
    if(Y/X<=4 and Y/X>=2):
        print('Yes')
    else:
        print("No")
    

Measured memory_bytes: 9140
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, M;
  cin >> N >> M;
  ll fact[100001];
  fact[0] = 1ll;
  REP(i, 100000) {
    fact[i + 1] = fact[i] * (i + 1);
    fact[i + 1] %= MOD;
  }
  ll ans = 0;
  if (N == M) {
    ans = 2 * fact[N] % MOD * fact[M] % MOD;
  } else if (abs(N - M) == 1) {
    ans = fact[N] * fact[M] % MOD;
  }
  cout << ans << endl;
  return 0;
}

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

long long n;
int m = 0;

int sft(long long k) {
	if (k > n)
		return 0;
	else {
		bool f3 = 0, f5 = 0, f7 = 0;
		long long j = k;
		while (j > 0) {
			if (j % 10 == 3)
				f3 = 1;
			else if (j % 10 == 5)
				f5 = 1;
			else if (j % 10 == 7)
				f7 = 1;
			j /= 10;
		}
		if (f3 && f5 && f7)
			m++;

		sft(10 * k + 3);
		sft(10 * k + 5);
		sft(10 * k + 7);
	}
	return 0;
}

int main()
{
	cin >> n;

	sft(0);

	cout << m << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int gcd(int a, int b) {
        if (a % b != 0) {
            return gcd(b, a % b);
        } else {
            return b;
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int max = Integer.MAX_VALUE;
        int n = sc.nextInt();
        int t = sc.nextInt();
        int[] nl = new int[n];
        int[] tl = new int[n];
        int index = 0;
        for (int i = 0; i < n; i++) {
            nl[i] = sc.nextInt();
            tl[i] = sc.nextInt();
            if (tl[i] <= t && nl[i] < max) {
                max = nl[i];
            }
        }

        if (max == Integer.MAX_VALUE) {
            System.out.println("TLE");
        } else {
            System.out.println(max);
        }

    }
}

Measured memory_bytes: 21716
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)
#define Sort(a) sort(a.begin(),a.end())

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int a,b,c;cin>>a>>b>>c;
	if(a+b+c>=22)cout<<"bust";
	else cout<<"win";
	return 0;
}


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

long long N;


void func(long long cur, int use, long long &counter){


    if(cur > N)return;
    if(use == 0b111) ++counter;
    
    
    func(cur*10+7, use | 0b001, counter);
    
    func(cur*10+5, use | 0b010, counter);
    
    func(cur*10+3, use | 0b100, counter);
    
    
}

int main(void){
    cin >> N;
    long long res = 0;
    func(0,0,res);
    cout << res << endl;
    
}


Measured memory_bytes: 256
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1100000000000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int main(){
    int N;
    cin>>N;
    map<ll,int> D;
    for(int i=0;i<N;i++){
        ll d;
        cin>>d;
        D[d]++;
    }
    int M; cin>>M;

    for(int i=0;i<M;i++){
        ll T;
        cin>>T;
        if(D.find(T)==D.end() || D[T]==0){
            cout<<"NO"<<endl;
            return 0;
        }
        D[T]--;
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      int[] seqS = new int[n];
      LineToInt(seqS, in.readLine(), ' ');
      int q = Integer.parseInt(in.readLine());
      int[] seqT = new int[q];
      LineToInt(seqT, in.readLine(), ' ');

      int cnt=0;
      for (int key : seqT) {
        if(linerSerach(seqS, key))
          cnt++;
      }

      System.out.println(cnt);
      
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private boolean linerSerach(int[] arr, int key) {

    for(int i: arr)
      if(i == key) return true;

    return false;
  }

  void LineToInt(int[] arr, String line, char regex) {
    int offset=0,next=0;
    boolean isEnd = false;
    for(int i=0; !isEnd; i++) {
      if((next = line.indexOf(regex,offset)) == -1) {
        next = line.length();
        isEnd = true;
      }
      arr[i] = Integer.parseInt(line.substring(offset, next));
      offset = ++next;
    }

  }
}


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

map<array<int,26>,int> mp;//sの部分文字列を保管する

int main()
{
	string s;
	string t;
	int ans=0;
	cin>>s>>t;
	//すべての文字列の長さについて調べる
	int len=min(s.size(),t.size());
	for(int a=1;a<len+1;a++)
	{
		//cerr<<a<<endl;
		mp.clear();
		//sの長さaの連続部分文字列をすべて列挙する
		int r=0;
		array<int,26> cnt;
		fill(cnt.begin(),cnt.end(),0);
		for(r=0;r<a;r++)
			cnt[s[r]-'a']++;
		mp[cnt]+=1;
		for(int i=1;i<s.size()-a+1;i++)
		{
			cnt[s[i-1]-'a']--;
			cnt[s[i+a-1]-'a']++;
			mp[cnt]+=1;
		}
		//tの長さaの連続部分文字列をすべて列挙する
		fill(cnt.begin(),cnt.end(),0);
		for(r=0;r<a;r++)
			cnt[t[r]-'a']++;
		if(mp[cnt]>0)
		{
			ans=max(ans,a);
		}else{
			//探す
			for(int i=1;i<t.size()-a+1;i++)
			{
				cnt[t[i-1]-'a']--;
				cnt[t[i+a-1]-'a']++;
				if(mp[cnt]>0)
				{
					ans=max(ans,a);
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4212
N,Q = map(int,input().split())
AB = [[] for _ in range(N-1)]
for n in range(N-1):
    AB[n] = list(map(int,input().split()))
PX = [[] for _ in range(Q)]
for q in range(Q):
    PX[q] = list(map(int,input().split()))
graph = [[] for _ in range(N+1)]
for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
val = [0] * (N+1)
for px in PX:
    val[px[0]] += px[1]
parent = [0] * (N+1)
Q  = [1]
while Q:
    q = Q.pop()
    for c in graph[q]:
        if c == parent[q]:
            continue
        parent[c] = q
        Q.append(c)
        val[c] += val[q]
print(*val[1:])


Measured memory_bytes: 132940
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

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

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N,M;
    cin >> N >> M;
    VI flag;
    VI wacount;
    REP(i,N){
        flag.PB(0);
        wacount.PB(0);
    }

    REP(i,M){
        int p;
        string S;
        cin >> p >> S;
        --p;
        //AC
        if(S=="AC"){
            flag[p]=1;
        }
        //WA
        else{
            if(flag[p]==0){
                ++wacount[p];
            }
        }

    }
    int acsum=0;
    int wasum=0;
    REP(i,N){
        acsum += flag[i];
        wasum += wacount[i]*flag[i];
    }
    cout << acsum << " " << wasum << endl;
    
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

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

using namespace std;

int main(){
 int N,L;
 cin>>N>>L;
 string s[110];
 for(int i=0;i<N;i++)cin>>s[i];
 sort(s,s+N);
 for(int i=0;i<N;i++)cout<<s[i];
 cout<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val H = scn.nextInt()
    val W = scn.nextInt()

    if(W==1 || H == 1){
        println(1)
        return
    }

    var ans = 0L
    for(i in 1..W){
        if(i%2==1){
            ans += (H+1)/2
        }else{
            ans += H/2
        }
    }
    println(ans)
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n), p(n);
  for(int i = 0; i < n; i++)
  {
    cin >> p[i];
    p[i]--;
    a[p[i]]++;
  }
  long long ans = 0;
  for(int i = 0; i < n; i++)
  {
    ans += a[i] * (a[i] - 1) / 2;
  }
  for(int i = 0; i < n; i++)
  {
    long long nans = ans - max((long long) 0, (a[p[i]] - 1));
    cout << nans << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<string> res;
    function<void(string)> rec = [&] (string s) {
        if (s.size()==n) {
            res.push_back(s); 
            return;
        }
        int mx='a';
        for(auto x:s) {
            chmax(mx, int(x));
        }
        int nxt = 'a';
        while(nxt<=mx+1) {
            rec(s + string(1,nxt));
            nxt++;
        }
        return;
    };
    rec("a");
    sort(begin(res), end(res));
    for(auto x:res) {
        cout << x << endl;
    }
    return 0;

}


Measured memory_bytes: 7796
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int x, y;
int deg[maxn];

template<typename T>
inline void read(T &k)
{
	int f = 1; k = 0; char c = getchar();
	while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
	while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
	k *= f;
}

int main()
{
	for (int i = 1; i <= 3; i++) read(x), read(y), deg[x]++, deg[y]++;

	sort(deg + 1, deg + 5);

	if (deg[1] == 1 && deg[2] == 1 && deg[3] == 2 && deg[4] == 2) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inn()
b = inn()
c = inn()
d = inn()
e = inn()
m = min([a,b,c,d,e])
print(5+(n-1)//m)


Measured memory_bytes: 38384
a, b = list(map(int, input().split()))

tmp = int((a*12.5) // 1)
cnt = tmp
'''
while (cnt*0.08)//1 == a:
  cnt += 1
  
if cnt == tmp:
  if (cnt * 0.1)//1 == b:
    print(cnt)
    exit()
'''
for i in range(tmp, 10001):
  ans = (i * 0.08)//1
  bans = (i*0.1)//1
  #print(i ,ans)
  if (bans==b) and ans==a:
    print(i)
    exit()
  elif ans > a:
    break
print(-1)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <queue>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
typedef long long LL;
typedef long double db;
const int maxN = 5e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;

struct pt {
	LL x; db y;
	pt(LL _x = 0, db _y = 0) {x = _x, y = _y;}
	inline pt operator - (const pt &v) const {return pt(x - v.x, y - v.y);}
	inline pt operator + (const pt &v) const {return pt(x + v.x, y + v.y);}
	inline void operator += (const pt &v) {x += v.x, y += v.y;}
	inline void operator -= (const pt &v) {x -= v.x, y -= v.y;}
};
typedef pt vec;

inline db slope(const vec &u) {return (db)u.y / (db)u.x;}

inline bool cmp(const vec &u, const vec &v) { return slope(u) < slope(v); }

deque<vec> q;

int main() {

	n = ri(), m = ri();

	pt tot;
	rep (i, 1, n) {
		LL t = ri(), v = ri();	
		vec nw = vec(v, v * t);

		q.push_front(nw); tot += nw;
		while (!q.empty() && tot.x > m) {
			vec tp = q.back(); tot -= tp;
			q.pop_back();
			if (tot.x < m) {
				tp = vec(m - tot.x, (m - tot.x) * slope(tp));
				q.push_back(tp); tot += tp;
			}
		}
		printf("%.7Lf\n", (db)(tot.y - (tot.x - m) * slope(q.back())) / (db)m);
		q.pop_front(); 

		while (!q.empty() && cmp(nw, q.front())) {
			nw = nw + q.front();
			q.pop_front();
		}
		q.push_front(nw); 
	}

	return 0;
}

Measured memory_bytes: 25404
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 1e11
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli A, B, Q;
    cin >> A >> B >> Q;
    vector<lli> S;
    vector<lli> T;
    vector<lli> x(Q);

    S.push_back(-INF);
    REP(i, A)
    {
        lli p;
        cin >> p;
        S.push_back(p);
    }
    S.push_back(INF);

    T.push_back(-INF);
    REP(i, B)
    {
        lli p;
        cin >> p;
        T.push_back(p);
    }
    T.push_back(INF);

    REP(i, Q)
    {
        cin >> x[i];
    }
    //find nearest temple
    vector<lli> nearT(A + 2);
    vector<lli> nearS(B + 2);

    REPS(i, A)
    {
        auto t0 = lower_bound(ALL(T), S[i]);
        lli val0 = *t0;
        lli val1 = *(--t0);
        lli ans = min(val0 - S[i], S[i] - val1);
        nearT[i] = ans;
    } //300 300

    REPS(i, B)
    {
        auto s0 = lower_bound(ALL(S), T[i]);
        lli val0 = *s0;
        lli val1 = *(--s0);
        lli ans = min(val0 - T[i], T[i] - val1);
        nearS[i] = ans;
    } //300 300

    REP(i, Q)
    {
        auto t0 = lower_bound(ALL(T), x[i]);
        auto s0 = lower_bound(ALL(S), x[i]);
        lli val0 = -x[i] + *t0 + nearS[t0 - T.begin()];
        lli val1 = x[i] - *(--t0) + nearS[t0 - T.begin()];
        lli val2 = -x[i] + *s0 + nearT[s0 - S.begin()];
        lli val3 = x[i] - *(--s0) + nearT[s0 - S.begin()];

        lli ans = min({val0, val1,
                       val2, val3});
        cout << ans << "\n";
    }
}

Measured memory_bytes: 5364
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int d;
    int n;
    int num=0;
    int ans=1;
    int tmp_d;
    int tmp_n=0;
    int tmp_ans;
    cin >> d >> n;
    while(true){
        tmp_d=0;
        tmp_ans=ans;
        while(tmp_ans%100==0){
            tmp_d++;
            tmp_ans/=100;
        }
        if(tmp_d==d){
            tmp_n++;
        }
        if(tmp_n==n){
            break;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = []
N.times do |i|
  S[i] = gets.chomp
end

hash = Hash.new(0)
max = 0

S.each do |s|
  hash[s] += 1
  max = hash[s] if hash[s] > max
end

list = []
hash.each do |key, value|
  list.push(key) if value == max
end

list.sort.each do |str|
  puts str
end


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

int main()
{
	int n, a[1000][3];
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		int x = a[i][0] * a[i][0], y = a[i][1] * a[i][1], z = a[i][2] * a[i][2];
		if (x == y + z || y == z + x || z == x + y) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
    return 0;
}



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

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    bool ok = false;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            ok = true;
            break;
        }
    }
    if (ok)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3644
main :: IO ()
main = getLine >> solve <$> getLine >>= print

solve :: String -> Int
solve s = minimum $ zipWith (+) ws es
  where
    ws = init $ scanl (\n x -> if x == 'W' then n + 1 else n) 0 s
    es = tail $ scanr (\x n -> if x == 'E' then n + 1 else n) 0 s

Measured memory_bytes: 62332
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

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

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

vector< vector<int> > memo;

int gcd(int a, int b, int c) {
	int min_num = (a > b) ? b : a;
	if (min_num > c) min_num = c;
	while (min_num != 1) {
		if (a % min_num == 0 && b % min_num == 0 && c % min_num == 0) break;
		min_num--;
	}
	return min_num;
}

int gcd(int a, int b) {
	int m = (a < b) ? a : b;
	while (m != 1) {
		if (a % m == 0 && b % m == 0)break;
		m--;
	}
	return m;
}



int main() {
	int n, k;
	cin >> n >> k;
	vector<int> ans(n);
	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int tmp;
			cin >> tmp;
			ans[tmp - 1]++;
		}
	}
	int count = 0;
	rep(i, n)if (ans[i] == 0)count++;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3632
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N; cin >> N;
	if (N % 2 == 0)cout << N << endl;
	else cout << 2 * N << endl;
}

Measured memory_bytes: 256