akhauriyash/Code-Regression huggingface dataset:
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args){
        FastReader scan=new FastReader();
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            long a=scan.nextInt();
            long b=scan.nextLong();
            long n=scan.nextLong();
            out.println((a*Math.min(b-1,n))/b);
        }
        out.flush();
        out.close();
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}


Measured memory_bytes: 32668
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

signed main() {
	int a; cin >> a;
	if (a == 1)puts("Hello World");
	else {
		int b, c; cin >> b >> c;
		cout << b + c << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)



int main(){
  ll n; cin >> n;
  vll re(100010,0);
  ll sum = 0;
  rep(i, n){ll a; cin >> a; re[a]++; sum += a;}

  ll q; cin >> q;
  rep(i, q){
    ll b, c;
    cin >> b >> c;
    sum += c * re[b];
    sum -= b * re[b];
    re[c] += re[b];
    re[b] = 0;
    cout << sum << endl;
  }




}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int k = fs.nextInt();
		
		int[] aArr = fs.nextIntArr(n);
		for(int i = k; i < n; i++) {
			
			int leftIndex = i - k;
			if(aArr[leftIndex] < aArr[i]) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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


typedef long long ll;

const int maxn=2e5+10;

int a[maxn];

int main()
{
	int n;
	cin>>n;
	for( int i=1;i<=n;i++ ) cin>>a[i];
	int ans=0;
	sort(a+1,a+1+n);
//	n=unique(a+1,a+1+n)-(a+1);
	
	for( int i=1;i<=n;i++ )
	{
		for( int j=i+1;j<=n;j++ )
		{
			for( int k=j+1;k<=n;k++ )
			{
				if( a[i]==a[j] || a[i]==a[k] || a[j]==a[k] ) continue;
				if( a[i]+a[j]>a[k] ) ans++;
			}
		}
	}
	cout<<ans<<endl;
} 

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

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

const int MAX_N = 100;
int G[MAX_N][MAX_N];

int main() {
    REP(i,MAX_N) REP(j,MAX_N) G[i][j] = 0;
    int N; cin >> N;
    for(int i = 0; i < N; i++) {
        int u, k; cin >> u >> k; u--;
        while(k--) {
            int v; cin >> v; v--;
            G[u][v] = 1;
        }
    }
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            cout << G[i][j] << " \n"[j == N - 1];
}

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (a > 0 || b > 0)
    cout << n / (a + b) * a + min(n % (a + b), a) << endl;
  else
    cout << "0" << endl;
}

Measured memory_bytes: 256
$d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
      [ [-1, 0], [0, -1],  [1, 0], [1, 1], [0, 1], [-1, 1]]]
     
def bfs(fld, w, h)
  prt = (h+2).times.map{ [false]*(w+2) }
  arr = []
  arr << [0, 0]
  prt[0][0] = true
  until arr.empty?
    y, x = arr.pop
    $d[y%2].each do |dy, dx|
      u = y + dy; v = x + dx
      next if u < 0 || u > h+1 || v < 0 || v > w+1
      if !fld[u][v] && !prt[u][v]
        prt[u][v] = true
        arr << [u, v]
      end
    end
  end
  (1..h).each do |k|
    (1..w).each do |m|
      fld[k][m] = true unless prt[k][m]
    end
  end
  fld
end

w, h = gets.split.map(&:to_i)
fld = Array.new(h+2)
(1..h).each{ |i| fld[i] = gets.split(" ") }
(1..h).map{ |i| (0...w).map{ |j| fld[i][j] = fld[i][j] == "1" ? true : false } }
fld[1,h].each{ |arr| arr.unshift(false); arr << false }
fld[0] = [false]*(w+2); fld[h+1] = [false]*(w+2)
fld = bfs(fld, w, h)
sum = 0
(1..h).each do |i|
  (1..w).each do |j|
    if fld[i][j]
      $d[i%2].each do |y, x|
        sum += 1 if !fld[i+y][j+x]
      end
    end
  end
end
p sum

Measured memory_bytes: 9008
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  n,m = map(int,input().split())
  
  AB = [map(int,input().split()) for _ in range(n)]
  CD = [list(map(int,input().split())) for _ in range(m)]
  idx = 1

  for i in range(n):
    a,b = AB[i]
    man = float("inf")
    for j in range(m-1,-1,-1):
      c,d = CD[j]
      if abs(a-c) + abs(b-d) <= man:
        man = abs(a-c) + abs(b-d)
        idx = j
    print(idx+1)
      
  
if __name__ == '__main__':
  main()

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int main(){
    int n;
    cin>>n;
    vector<string> str(n);
    bool flag=true;
    rep(i,n)cin>>str[i];
    rep(i,n-1){
        if(str[i][str[i].size()-1]!=str[i+1][0]){
            cout<<"No"<<endl;
            return 0;
        }
        reps(j,i+1,n){
            if(str[i]==str[j]){
                cout<<"No"<<endl;
                return 0;              
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#解説の方針にしたがった
import fractions

N = int(input())
X = list(map(int, input().split()))
   
M = 1  
L = [0 for i in range(100004)] #L(0)=0
R = [0 for i in range(100004)]  #R(N+1) = 0

for i in range(N):
  L[i] = (fractions.gcd(L[i-1],X[i]))

for i in reversed(range(N)):
  #print(i)
  R[i] = (fractions.gcd(R[i+1],X[i]))
    
ans = 1

#print(L)
#print(R)
for i in range(N):
  ans = max(ans, fractions.gcd(L[i-1],R[i+1]))

print(ans)

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

int main()
{
    int N;
    scanf("%d", &N);
    bool vis[N];
    int A[N];
    fill(vis, vis + N, false);
    for(int i = 0; i < N; ++i) { scanf("%d", &A[i]); --A[i]; }
    vis[0] = true;
    int to = A[0];
    int cnt = 1;
    while(!vis[to]) {
        if(to == 1) { cout << cnt << endl; return 0; }
        vis[to] = true; to = A[to]; ++cnt;
    }
    cout << -1 << endl;
    return 0;
}

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

#define FOR(a,b,c) for(int a=(b),a##_end__=(c);a<a##_end__;a++)
#define ll long long
#define M 50

ll ans;
ll C[M][M];
int a,b,n,p;

void Rd(int &res){
    char c;res=0;
    while(c=getchar(),c<48);
    do res=(res<<3)+(res<<1)+(c^48);
    while(c=getchar(),c>47);
}

void Wt(ll x){
    static int stk[24];int p=0;
    do stk[++p]=x%10^48;
    while(x/=10);
    while(p) putchar(stk[p--]);
}

void init(){
    C[0][0]=C[1][0]=C[1][1]=1LL;
    FOR(i,1,M){
        C[i][0]=C[i][i]=1LL;
        FOR(j,1,i) C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
}

int main(){
    Rd(n);Rd(p);
    FOR(i,0,n){
        int x;Rd(x);
        if(x&1) a++;
        else b++;
    }
    init();
    ans=0;
    //printf("%d\n",a);
    for(int i=p;i<=a;i+=2){
        ans+=C[a][i];
    }
    Wt(ans*(1LL<<b));
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt() + sc.nextInt();
		int r = sc.nextInt() + sc.nextInt();

		if(l == r) {
			System.out.println("Balanced");
		}else {
			System.out.println(l > r ? "Left" : "Right");
		}

		sc.close();
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string s;
int32_t main(){
CODE_START;
cin>>s;
n=s.size();
for(ll i=0;i<n;i++)
if(i%2==0){
    cout<<s[i];
}
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int i=-1,flag=0;
  char a[100]={};
  scanf("%s",a);
  do{
   i++;
  }while(a[i]);
  i--;
    for(int j=0;j<=(i+1)/2;j++){
     if (a[j]!=a[i-j]){
      printf("No");
       return 0;
     }
    }
   
  for(int j=0;j<=(i-1)/2;j++){
     if (a[j]!=a[(i-1)/2-j]){
      printf("No");
       return 0;
     }
  }
    
    for(int j=0;j<=(i-1)/2;j++){
     if (a[(i+3)/2+j]!=a[i-j]){
      printf("No");
       return 0;
     }
    
    }
  
  
  printf("Yes");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int k,n,a[1024];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	int tot=0;
	for(int i=1;i<=k;i++) tot+=a[i];
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int N;
  cin >> N;
  for(int ii=9; ii>0; ii--){
    if(N%ii!=0) continue;
    if(N/ii<=9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll X; cin >> X;
    ll i = 1;
    for (; i < X; i++) {
        ll sum = i * (i + 1) / 2;
        if (sum == X) {
            cout << i << endl;
            return 0;
        } else if (sum > X) {
            break;
        }
    }
    cout << i << endl;
}


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

using namespace std;

const int MX = 20;

int cnt[20][20];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		static char s[20];
		ignore = scanf("%s", s);
		
		long long a = 0, k = 0;
		for (int j = 0, f = 0; s[j] != 0; j++) {
			if (s[j] == '.') f = 1;
			else {
				a *= 10;
				a += s[j] - '0';
				
				k += f;
			}
		}
		
		while (k != 9) {
			a *= 10;
			k++;
		}
		
		int p2 = 0, p5 = 0;
		while (a % 2 == 0) {
			a /= 2;
			p2++;
		}
		
		while (a % 5 == 0) {
			a /= 5;
			p5++;
		}
		
		p2 = min(p2, 18);
		p5 = min(p5, 18);
		
		cnt[p2][p5]++;
	}
	
	long long ans = 0;
	for (int p2 = 0; p2 < MX; p2++)
		for (int p5 = 0; p5 < MX; p5++)
			for (int q2 = 0; q2 < MX; q2++)
				for (int q5 = 0; q5 < MX; q5++) {
					if (p2 + q2 < 18 || p5 + q5 < 18) continue;
					
					if (p2 == q2 && p5 == q5) {
						ans += cnt[p2][p5] * (cnt[p2][p5] - 1LL);
					}
					else {
						ans += cnt[p2][p5] * 1LL * cnt[q2][q5];
					}
				}
	
	printf("%lld\n", ans / 2);
	
	return 0;
}


Measured memory_bytes: 3820
#include <stdio.h>
#include <algorithm>
#define MN 300000
#define MA 300000

int n,k,ans=0;

int T[MA*4+5]={0};

void modify(int k,int l,int r,int p,int w){
	if(l==r){
		T[k] = w;
		return;
	}
	int mid=(l+r)>>1;
	if(p<=mid) modify(k<<1,l,mid,p,w);
	else modify(k<<1|1,mid+1,r,p,w);
	T[k] = std::max(T[k<<1],T[k<<1|1]);
}

int query(int k,int l,int r,int L,int R){
	if(l==L&&r==R) return T[k];
	int mid=(l+r)>>1;
	if(R<=mid) return query(k<<1,l,mid,L,R);
	if(L>mid) return query(k<<1|1,mid+1,r,L,R);
	return std::max(query(k<<1,l,mid,L,mid),query(k<<1|1,mid+1,r,mid+1,R));
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1,a;i<=n;i++){
		scanf("%d",&a);
		int t = query(1,0,MA,std::max(0,a-k),std::min(MA,a+k))+1;
		ans = std::max(ans,t);
		modify(1,0,MA,a,t);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 7328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int n;
	cin >> n;
	int d;
	cin >> d;

	int did = 2 * d + 1;
	int ans = n / did;
	if (n%did != 0) ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        final int N = scan.nextInt();
        int M = scan.nextInt();
        long result = 0;
        long temp = 0;
        PriorityQueue<Long> a = new PriorityQueue<Long>(N, Collections.reverseOrder());
        for(int i = 0;i < N; i++){
            a.add(scan.nextLong());
        }
        scan.close();
        while(M > 0){
            // 最大値を取得して割る2
            temp = a.poll();
            a.add(temp / 2);
            M--;
        }
        Long[] arrayA = a.toArray(new Long[0]);
        for(int i = 0; i < N; i++){
            result += arrayA[i];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 61508
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

char a[9][9];
int main()
{
    ios_base::sync_with_stdio(0);
     map<int,int>mp;
    int s;
    cin >> s;
    for (int i= 1; ;i++)
    {
        // cout << s << endl;
        if (mp.count(s)!=0)
        {
            cout <<i<<endl;
            return 0;
        }
        mp[s]=i;
        if (s%2==0)
        {
            s/=2;
        }
        else
        {
            s=3*s+1;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2

int n,t;
int co[N], d[N], f[N], M[N][N];

void dfs1(int);
void dfs2();

int main(){
  int i,j,k,u,v;

  scanf("%d", &n);
  for(i = 0 ; i < n; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = 0;
    }
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      M[u-1][v-1] = G;
    }
  }
  dfs2();

  return 0;
}

void dfs1(int u){
  int i;

  co[u] = G;
  d[u] = ++t;

  for(i = 0 ; i < n; i++){
    if(M[u][i] == 0){
       continue;
    }
    if(co[i] == 0){
       dfs1(i);
    }
  }

  co[u] = B;
  f[u] = ++t;
}

void dfs2(){
  int i;

  for(i = 0; i < n; i++){
    co[i] = 0;
  }

  t = W;

  for(i = 0 ; i < n; i++){
    if(co[i] == 0){
      dfs1(i);
    }
  }

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



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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,xdata[ohara],ydata[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s>>x>>y;
      //コーナーケースさん
      if(x==0&&y==0){
        ll cntx=0,cnty=0,F=0;
        rep(i,Size(s)){
          if(s[i]=='T'){
            if(cnt%2==0) cntx+=F;
            else cnty+=F;
            cnt++;
          }
          else F++;
        }
         if(cnt%2==0) cntx+=F;
         else cnty+=F;
        if(cntx%2==0&&cnty%2==0)Cout("Yes");
        else Cout("No");
      }
      else{
      bitset<8000*2+1000> dpx;
      bitset<8000*2+1000> dpy;
      dpx[8000]=true;
      dpy[8000]=true;
      ll cntx=0,cnty=0;
      ll F=0;
      rep(i,Size(s)){
        if(s[i]=='T'){
          if(cnt%2==0){
            xdata[cntx++]=F;
          }
          else{
            ydata[cnty++]=F;
          }
          cnt++;
          F=0;
        }
        else{
          F++;
        }
      }
      if(F!=0){
       if(cnt%2==0){
            xdata[cntx++]=F;
          }
          else{
            ydata[cnty++]=F;
          }
          cnt++;
          F=0;
        }
      x+=8000;y+=8000;
      rep(i,cntx){
        if(i==0) dpx=(dpx<<xdata[i]);
        else dpx=(dpx<<xdata[i])|(dpx>>xdata[i]);
      }
       rep(i,cnty){
        dpy=(dpy<<ydata[i])|(dpy>>ydata[i]);
      }
     if(dpx[x]&&dpy[y])Cout("Yes");
     else Cout("No");
      }


     

       
return 0;
}


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

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

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

  int n; cin >> n;
  vector<ll> a(3*n);
  rep(i, 3*n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  ll ans = 0;
  for(int i = 1; i < 2*n; i += 2) ans += a[i];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include  <iostream>
#include  <cstdio>
#include  <algorithm>
#include  <string>
using namespace std;
long long int a[1100000];
typedef struct
{
    long long int t,b;
} fhs;
fhs odd[110000],even[110000];
long long int o,e;
long long int m,n,l,r,vm,ans=1e9+10,mv=1e9;
bool cmp(fhs a1,fhs b1)
{
    return a1.b>b1.b;
}
int main()
{
    cin>>m;
    ans=m;
    for(int x=0; x<m; x++)
    {
        cin>>a[x];
    }
    for(int x=0; x<m; x++)
    {
        vm=max(vm,a[x]);
        mv=min(mv,a[x]);
        if(x%2==0)
        {
            odd[a[x]].b++;
            odd[a[x]].t=a[x];
            o++;
        }
        else
        {
            e++;
            even[a[x]].b++;
            even[a[x]].t=a[x];
        }
    }
    long long omax=0,emax=0,lp=0;
    sort(even,even+100001,cmp);
    sort(odd,odd+100001,cmp);
   if(odd[0].t==even[0].t)
   {
       cout<<ans-max(odd[0].b+even[1].b,even[0].b+odd[1].b)<<endl;
   }
   else{
       cout<<ans-odd[0].b-even[0].b<<endl;;
   }
   }


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> S(N,0);
  for(int i = 0; i < M; ++i){
    int k;
    cin >> k;
    for(int j = 0; j < k; ++j){
      int t;
      cin >> t;
      --t;
      S[t] |= (1<<i);
    }
  }
  int bit = 0;
  for(int i = 0; i < M; ++i){
    int p;
    cin >> p;
    bit |= p<<i;
  }
  int ans = 0;
  for(int i = 0; i < (1<<N); ++i){
    int t = bit;
    for(int j = 0; j < N; ++j){
      if(not ((i>>j)&1)) continue;
      t ^= S[j];
    }
    if(not t) ++ans;
  }
  cout << ans << endl;
}


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

int main() {
    int N, T, c, t, ans = 1e9;
    cin >> N >> T;
    rep(i, N) {
        cin >> c >> t;
        if (t <= T) ans = min(ans, c);
    }
    if (ans == 1e9) cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    vector<vector<ll>> v(n,vector<ll>(n,0));
    auto v2 = v;
    rep(i,n){
      rep(j,n){
        cin >> v[i][j];
      }
    }
    rep(i,n){
      rep(j,n){
        v2[j][i] = v[i][j];
      }
    }
    map<pll,ll> m;
    rep(i,n){
      int mi = *min_element(all(v[i]));
      rep(j,n){
        if(v[i][j] == mi){
          m[mp(i,j)]++;
        }
      }
    }
    rep(i,n){
      int Ma = *max_element(all(v2[i]));
      rep(j,n){
        if(v2[i][j] == Ma){
          m[mp(j,i)]++;
        }
      }
    }
    bool f = false;
    for(auto e: m){
      if(e.se == 2){
        f = true;
        cout << v[e.fi.fi][e.fi.se] << endl;
        break;
      }
    }
    if(!f) cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n,ans[N];
vector<int>e[N];
bool vis[N];

vector<int>v[3];
inline void dfs(int u,int fa,int dep){
	v[dep&1].pb(u);
	for (auto v:e[u]) if (v!=fa) dfs(v,u,dep+1);
}

inline int tot(int k){
	return n/3+(n%3>=k);
}

int main(){
	n=read();
	FOR(i,1,n){
		int x=read(),y=read();
		e[x].pb(y),e[y].pb(x);
	}
	dfs(1,0,0);
	if (siz(v[0])>siz(v[1])) swap(v[0],v[1]);
	if (siz(v[0])<tot(2)){
		int tot=3;
		for (auto i:v[0]) ans[i]=tot,tot+=3,vis[tot-3]=1;
		int now=1;
		for (auto i:v[1]){
			while (vis[now]) ++now;
			ans[i]=now,vis[now]=1;
		}
	} else {
		int now=2;
		for (auto i:v[0]) ans[i]=now,now+=3;
		now=1;
		for (auto i:v[1]) ans[i]=now,now+=3;
		now=3;
		For(i,1,siz(v[0])-tot(2)) ans[v[0][siz(v[0])-i]]=now,now+=3;
		For(i,1,siz(v[1])-tot(1)) ans[v[1][siz(v[1])-i]]=now,now+=3;
	}
	For(i,1,n) printf("%d ",ans[i]);
}

Measured memory_bytes: 23448
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

struct Peace{
	int minx;
	int maxx;
	double weightPlace;
	set<int> link;
};


// ツピツーツスツづ個湘ョツ陛ア
int peaceCnt=0;
Peace G[200];
int w,h;

vector<double> blockList;

bool passed[100][100];
char field[100][100];
int place[100][100];

int minx;
int maxx;

bool no = false;
int rootNode;

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

void dfs(int x,int y,char num){
	place[y][x]=peaceCnt;
	passed[y][x]=true;
	blockList.push_back(x+0.5);

	// ツ地ツ姪環づ可づつつ「ツづつ「ツつスツづァツδ仰ーツトツノツーツド
	if(y==h-1){
		rootNode=peaceCnt;
	}

	for(int i = 0; i < 4; i++){
		int ny = y+dy[i];
		int nx = x+dx[i];
		if(ny>=0&&nx>=0&&ny<h&&nx<w&&!passed[ny][nx]&&field[ny][nx]==num){
			dfs(nx,ny,num);
		}
	}
}

// ツ渉ーツづーツ仰づ淞、ツδ環δ督クツづーツ催ャツづゥ
void dfs2(int x,int y,int num){
	passed[y][x]=true;
	//minx=min(minx,x);
	//maxx=max(maxx,x+1);

	for(int i = 0; i < 4; i++){
		int ny = y+dy[i];
		int nx = x+dx[i];
		if(ny>=0&&nx>=0&&ny<h&&nx<w&&!passed[ny][nx]&&place[ny][nx]==num){
			dfs2(nx,ny,num);
		}
		else if(ny<h&&ny>=0&&nx>=0&&nx<w&&((dy[i]==1&&place[ny][nx]!=num&&place[ny][nx]!=-1))){
			// ツ可コツづ可暗。ツつ、ツ氾板債づ個ノツーツド
			G[place[ny][nx]].link.insert(num);
			minx=min(minx,nx);
			maxx=max(maxx,nx+1);
		}
		// ツ地ツ姪環づ可静堋つオツづつ「ツつスツづァ
		if(ny == h){
			minx=min(minx,nx);
			maxx=max(maxx,nx+1);
		}
	}

}

// ツ姪淞づィツ値ツづ債重ツ心ツづ個暗環置ツづブツδ債ッツクツづ個重ツつウ
pair<double,int> calc(int nodeNum){
	if(no)
		return make_pair(0.0,0);
	double weip=G[nodeNum].weightPlace;
	int cnt=0;
	int wei=4;
	for(set<int>::iterator it = G[nodeNum].link.begin(); it!=G[nodeNum].link.end(); it++){
		int v=*it;
		pair<double,int>tmp = calc(v);

		weip=(tmp.second*tmp.first + weip*wei)/(wei+tmp.second);
		wei = wei+tmp.second;
	}
	// ツ重ツ心ツ計ツ算
	if(weip > G[nodeNum].minx && weip < G[nodeNum].maxx){
		return make_pair(weip,wei);
	}
	else{
		no=true;
		return make_pair(0,0.0);
	}
}

int main(){

	while(cin >> w >> h && !(w == 0 && h == 0)){
		no=false;
		peaceCnt=0;

		for(int i = 0; i < h; i++){
			fill(passed[i],passed[i]+w,false);
		}
		for(int i = 0; i < 100; i++){
			fill(place[i],place[i]+w,-1);
		}
		for(int i = 0; i < 200; i++){
			G[i].link.clear();
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> field[i][j];
			}
		}
		// ツブツδ債ッツクツづーツづ慊づづ淞、ツ重ツ心ツづーツ仰づ淞づゥ
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(field[i][j] != '.' && !passed[i][j]){
					dfs(j,i,field[i][j]);
					double wa=0;
					for(int k = 0; k < blockList.size(); k++){
						wa+=blockList[k];
					}
					G[peaceCnt].weightPlace=wa/blockList.size();
					blockList.clear();
					peaceCnt++;
				}
			}
		}
		for(int i = 0; i < h; i++)
			fill(passed[i],passed[i]+w,false);
		// ツδ環δ督クツづーツづつづ按つーツづゥ
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				minx = 100000000;
				maxx = -1;
				if(field[i][j] != '.' && !passed[i][j]){
					dfs2(j,i,place[i][j]);
					G[place[i][j]].maxx=maxx;
					G[place[i][j]].minx=minx;
				}
			}
		}
		// ツ催帰ツ的ツづ可重ツ心ツづーツ計ツ算
		calc(rootNode);
		if(no)
			cout << "UNSTABLE" << endl;
		else
			cout << "STABLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int t=(n+1)/2;
    cout<<fixed<<setprecision(7)<<1.0*t/n<<endl;;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n; cin >> n;
  vector<int> arr(3);
  rep(i,3) cin >> arr[i];
  vector<P> q(n);
  rep(i,n){
    string s; cin >> s;
    if(s == "AB") q[i] = P(0,1);
    else if(s == "AC") q[i] = P(0,2);
    else q[i] = P(1,2);
  }
  vector<char> s(3);
  rep(i,3) s[i] = 'A' + i;
  string ans = "";
  q.push_back(P(0,1));
  rep(i,n){
    int a = q[i].first;
    int b = q[i].second;
    if(!arr[a] && !arr[b]){
      cout << "No" << endl;
      return 0;
    }
    if(!arr[a]){
      arr[a]++;
      arr[b]--;
      ans += s[a];
    }else if(!arr[b]){
      arr[a]--;
      arr[b]++;
      ans += s[b];
    }else{
      int na = q[i+1].first;
      int nb = q[i+1].second;
      if(a == na || a == nb){
        arr[a]++;
        arr[b]--;
        ans += s[a];
      }else{
        arr[a]--;
        arr[b]++;
        ans += s[b];
      }
    }
  }
  cout << "Yes" << endl;
  rep(i,n) cout << ans[i] << endl;
  return 0;
}

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

const int MAX = 2000;
const int mod = 1e9+7;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; ++i){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
ll Combination(int n, int k){
    if (n < k){
        return 0;
    }
    if (n < 0 || k < 0){
        return 0;
    } 
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {

    int n, k;
    cin >> n >> k;

    COMinit();

    for(int i=1; i<=k; ++i){
        if(i == 1){
            cout << n-k+1 << endl;
        }
        else if(i == k){
            cout << Combination(n-k+1, k) << endl;
        }
        else{
            cout << Combination(k-1, i-1) * Combination(n-k+1, i) % mod << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    char O[50],E[50],a[100];
    scanf("%s%s",O,E);
    for(n=0;n<=50;n++){
        a[2*n+1]=E[n];
        a[2*n]=O[n];
    }
    printf("%s\n",a);
    return 0;
}


Measured memory_bytes: 128
N,K = map(int,input().split())
p = list(map(int,input().split()))
max_l = 0
point = sum(p[:K])
index = 0

for i in range(1,N-K+1):
  point -= (p[i-1] - p[i+K-1])
  if point > max_l:
    max_l = point
    index = i
print(sum([(n+1)/2 for n in p[index:index+K]]))

Measured memory_bytes: 25060
#include <stdio.h>

int total(int n, int k, int x, int y) {
  int total;
  if (n >= k)
    total = (n - k) * y + k * x;
  else
    total = n * x;
  return total;
}

int main(void) {
  int n, k, x, y;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  scanf("%d", &y);
  printf("%d\n", total(n, k, x, y));
  return 0;
}

Measured memory_bytes: 128
a,b,m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
for i in range(m):
    x.append(list(map(int, input().split())))

min_a = min(a)
min_b = min(b)
money = min_a + min_b

for i in range(m):
    kingaku = a[x[i][0]-1] + b[x[i][1]-1] - x[i][2]
    if kingaku < money:
        money = kingaku

print(money)

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

using namespace std;

int main() {
	int N, M, X;
	int A[101], B[101];
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	for (int i = 0; i <= N; i++) {
		B[i] = 0;
	}
	for (int i = 0; i < M; i++) {
		B[A[i]] = 1;
	}

	int c = 0, d = 0;
	for (int i = X; i <= N; i++) {
		c += B[i];
	}
	for (int i = 0; i <= X; i++) {
		d += B[i];
	}
	cout << min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#define mil 200001

using namespace std;


int main()
{
    int n,m;
    cin>>n>>m;
    int count = 0,result = 0;

    while(count != 2)
    {
        if(m>=n)
        {
            result+=m;
            m--;
            count++;
        }
        else
        {
            result+=n;
            n--;
            count++;
        }
    }
    cout<<result;

}


Measured memory_bytes: 256
from itertools import combinations
from fractions import gcd
import math


n = int(input())
mx = 55555
ans = []
primes = [2]
for i in range(3, mx + 1, 2):
    if all(i % p != 0 for p in primes):
        primes.append(i)
        if i % 5 == 1:
            ans.append(i)
        if len(ans) == n:
            break
print(*ans)

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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N, M, p, res[100010], num_ac=0, num_wa[100010], res_num_wa=0;
string S;

int main() {
    for (int i = 0; i < N; ++i) {
        res[i] = 0; num_wa[i] = 0;
    }
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        cin >> p >> S;
        if (S == "AC") {
            if (res[p-1] == 0) {
                num_ac++;
                res[p-1] = 1;
            }
        } else {
            if (res[p-1] == 0) {
                num_wa[p-1]++;
            }
        }
    }

    for (int i = 0; i < N; ++i) {
        if (res[i] == 1) {
            res_num_wa += num_wa[i];
        }
    }
    cout << num_ac << " " << res_num_wa << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
int N,D,X;

int main(){
    cin >> N;
    cin >> D >> X;
    int ans = 0;
    rep(i,0,N - 1){
        int a;
        cin >> a;

        //D = T * A + 1
        //(D - 1) / A >= T
        ans += (D - 1) / a + 1;
    }

    cout << ans + X << endl;

}



Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

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


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt(),k=nxt();
    vc<ll> v(n);
    generate(all(v),nxt);
    rep(a,k,n)
    {
        if(v[a]>v[a-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
	printclock;
	return 0;
}

Measured memory_bytes: 4812
"""
    一行目の左端からi番目と二行目のi番目から右端までの和
    sum_iの最大値
"""
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
# 最初のsumだけ求めておく
sum = a1[0]+sum(a2)
max_sum = sum
for i in range(n-1):
    sum = sum-a2[i]+a1[i+1]
    if sum > max_sum:
        max_sum = sum

print(max_sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{    
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
    ll N;
    ll W;
    cin>>N>>W;
    ll a,b,s=0;
    ll w[N],v[N];
    for(ll i=0;i<N;i++){
        cin>>a>>b;
        w[i]=a;
        v[i]=b;
        s+=v[i];
    }
    ll dp[s+1];
    for(ll i=0;i<=s;i++)
        dp[i]=10000000098;
    dp[0]=0;
    s=0;
    for(ll i=0;i<N;i++) {
        s+=v[i];
        for(ll j=s;j>=v[i];j--) 
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
    for (ll i=s;i>=0;i--)
        if (dp[i]<=W){
            cout<<i;
            break;
        }
}


Measured memory_bytes: 1024
#include<stdio.h>
int main() {
	int n, m, d[111] = { 0 }, t, i, k, ss;
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		ss = 0;
		for (k = 0; k < m; k++) {
			scanf("%d", &t);
			printf("%d ", t);
			ss += t;
			d[k] += t;
		}
		printf("%d\n", ss);
		d[m] += ss;
	}
	for (i = 0; i <=m; i++) {
		if(i==m)
			printf("%d\n", d[i]);
		else
			printf("%d ", d[i]);
	}
	return 0;
}

Measured memory_bytes: 600
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i).sort
b = gets.chomp.split.map(&:to_i).sort
c = gets.chomp.split.map(&:to_i).sort
 
res = b.inject(0) do |r, bi|
  ai = a.bsearch_index{ |x| x >= bi }
  ci = c.bsearch_index{ |x| x > bi }
  
  if ci
    r + (ai || n)*(n-ci)
  else
    r
  end
end
 
puts res

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,K; cin>>N>>K;
  //n-1 c 2 + n-2 = n-2 n+1 / 2
  if(K > (N-1)*N/2 - (N-1)){
    cout<<-1<<endl;
    return 0;
  }
  int k = (N-1)*(N-2)/2;//必要なペア数
  vector<pair<int,int>> res;
  rep1(i,N)res.push_back(make_pair(1,i+1));
  for(int i = 2; i < N; i++){
    if(K==k)break;
    for(int j = i+1; j <= N; j++){
      k--;
      res.push_back(make_pair(i,j));
      if(K==k)break;
    }
  }
  cout<<res.size()<<endl;
  for(auto p: res){
    cout<<p.first<<" "<<p.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=10010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
string x;
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	cin>>x;
	int m=(x[5]-'0')*10+(x[6]-'0');
	int d=(x[8]-'0')*10+(x[9]-'0');
	if(m>4)
	{
		printf("TBD\n");
	}else if(m==4)
	{
		if(d>=31)
		{
			printf("TBD\n");
		}else
		{
			printf("Heisei\n");
		}
	}else
	{
		printf("Heisei\n");
	}
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	vector<int> v;
	int temp;
	while (1)
	{
		cin >> temp;
		if (temp == 0)break;
		v.push_back(temp);
	}
	temp = 1;
	for (int i : v)
	{
		
		cout << "Case " << temp << ": " << i << endl;
		temp++;
	}
}


Measured memory_bytes: 3196
S=list(input())
S.sort()
c=[]
m=["a","b","c","d","e","f","g","h","i","j"
   ,"k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(m)):
  if S.count(m[i])==0:
    print(m[i])
    break
  else:
    c.append(m[i])
if c==m:
  print("None")
    

Measured memory_bytes: 4336
#                         author:  kagemeka 
#                         created: 2019-11-07 11:52:43(JST)
import sys
# import collections
# import math
# import string
import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    n, m, x, *a = (int(i) for i in sys.stdin.read().split())
    th_x  = bisect.bisect_left(a, x)
    cost = min(th_x, m - th_x)
    print(cost)
    


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int gcd(int,int);

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%d\n",gcd(a,b));
  return 0;
}

int gcd(int a,int b){
  return (b > 0 ? gcd(b,a%b) : a);
}

Measured memory_bytes: 592
def test():
    nums = list(map(int, list(input())))
    end = False
    for i in range(2 ** 3):
        ans = nums[0]
        res = '{}'.format(nums[0])
        for j in range(3):
            if (i >> j) & 1:
                ans += nums[j+1]
                res += '+{}'.format(nums[j+1])
            else:
                ans -= nums[j+1]
                res += '-{}'.format(nums[j+1])
        if ans == 7:
            end = True
            break
    print('{}=7'.format(res))

if __name__ == '__main__':
    test()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#define REP(i, n) for(int i = 0; i < n; i++)
//using ll = long long;
using namespace std;


int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  double PI=3.14159265358979323846;

  int n;
  double ans=0;
  cin >> n;
  
  ans = 2 * n * PI;

  cout << ans << endl;
      
}


Measured memory_bytes: 3792
S = input()
SR = S[::-1]
temp =['dream','dreamer','erase','eraser']
T=""
j=0
count=0
while j<=10**5//5:
    j +=1
    for i in temp:
        if i[::-1] == SR[count:len(i)+count]:
            count+=len(i)
            T+=i[::-1]
            if SR==T:
                print('YES')
                exit()
print('NO')

Measured memory_bytes: 3316