akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int i, j, n, H, W, flag1, flag2, flag3;
    while (1) {
        scanf("%d %d",&H, &W);
        if (H==0&&W==0) {
            break;
        }
        for (i=0; i<H; i++) {
            flag1=i%2;
            if (flag1==0) {
                for (j=0; j<W; j++) {
                    flag2=j%2;
                    if (flag2==0) {
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
            }else{
                for (n=0; n<W; n++) {
                    flag3=n%2;
                    if (flag3==0) {
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int A,B,C,n;
set<PP> erased;

bool isTouchSpace(int x,int y,int z){
  if(x<0 || y<0 || z<0 || x>=A || y>=B || z>=C) return 1;
  return erased.count(PP(x,P(y,z)));
}

bool isTouchCube(int x,int y,int z){
  if(x<0 || y<0 || z<0 || x>=A || y>=B || z>=C) return 0;
  return !erased.count(PP(x,P(y,z)));
}


signed main(){
  cin>>A>>B>>C>>n;
  int ans = 2*(A*B + B*C + C*A);

  int dx[] = {1,-1,0,0,0,0};
  int dy[] = {0,0,1,-1,0,0};
  int dz[] = {0,0,0,0,1,-1};
  
  while(n--){
    int x,y,z;
    cin>>x>>y>>z;
    for(int i=0;i<6;i++){
      int nx = x+dx[i],ny = y+dy[i],nz = z+dz[i];
      ans -= isTouchSpace(nx,ny,nz);
      ans += isTouchCube(nx,ny,nz);
    }
    erased.insert(PP(x,P(y,z)));
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3112
import java.util.*;
 
public class Main{
  public static void main (String[] args){
                Scanner sc = new Scanner(System.in);
		// get a integer
		int X = sc.nextInt();
		int t = sc.nextInt();
               int ans = X - t < 0 ? 0 : X - t;
                System.out.println( ans ) ;
 
 }
}

Measured memory_bytes: 22612
# 2019/05/19
# AtCoder Beginner Contest 126 - A

# Input
n, k = map(int,input().split())
s = input()
ans = ""
# Calc
for i in range(n):
    if i == k - 1:
        if s[i] == "A":
            ans += "a"
        elif s[i] == "B":
            ans += "b"
        else:
            ans += "c"
    else:
        ans += s[i]

# Output
print(ans)


Measured memory_bytes: 3060
/* 3 か所それぞれについて'+' が入るか'-' が入るかでbit 全探索。
条件を満たすbit を取り出して、復元して出力。
*/

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

int main(){
    string x;
    cin >> x;
    int a[4];
    for (int i = 0; i < 4; i++){
        a[i] = x[i] - '0';
    }

    int ans;
    for (int bit = 0; bit < 1<<3; bit++){
        int temp = a[0];
        for (int i = 0; i < 3; i++){
            if (bit & 1<<i){
                temp += a[i + 1];
            }else{
                temp -= a[i + 1];
            }
        }

        if (temp == 7){
            ans = bit;
            break;
        }
    }

    cout << a[0];
    for (int i = 0; i < 3; i++){
        if (ans & 1<<i){
            cout << '+';
        }else{
            cout << '-';
        }
        cout << a[i + 1];
    }
    cout << '=' << 7 <<  endl;

    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll n; cin >> n;
    string s;
    while (n) {
        n--;
        s.push_back('a' + (n % 26));
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    map<string, ll> mp;
    rep(i, n) {
        string s; cin >> s;
        mp[s]++;
    }


    ll max_num = 0;
    for (auto elem : mp) {
        max_num = max(max_num, elem.second);
    }

    vector<string> ans;
    for (auto elem : mp) {
        if (elem.second == max_num) {
            ans.push_back(elem.first);
        }
    }
    sort(all(ans));
    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 26868
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
m = A + 1000
for i in range(N):
  d = abs(T - H[i] * 0.006 - A)
  if m > d:
    m = d
    ans = i + 1
print(ans)

Measured memory_bytes: 62608
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			final char[] chs = sc.next().toCharArray();
			for(int i = 0; i < A; i++){
				if(!Character.isDigit(chs[i])){
					System.out.println("No");
					return;
				}
			}
			if(chs[A] != '-'){
				System.out.println("No");
				return;
			}
			
			for(int i = 0; i < B; i++){
				if(!Character.isDigit(chs[(A + 1) + i])){
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
			
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22996
import java.util.Scanner

fun main(args: Array<String>){
  val cin = Scanner(System.`in`)
  val o = cin.next()
  val e = cin.next()

  val m = o.length

  if (o.length == e.length){
    for (i in 0..m - 1){
      print(o.get(i))
      print(e.get(i))
    }
  }
  else {
    for (i in 0..m - 2){
      print(o.get(i))
      print(e.get(i))
    }
    print(o.get(m - 1))
  }

  println()
  cin.close()
}

Measured memory_bytes: 21676
import scala.math._

// longでrangeの作り方

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val l, r = sc.nextLong
//  val list = List.fill(n, d)(sc.nextInt)

//  val sorted = (l to r).map(p => (p, p % 2019)).sortBy(_._2)
//  val ans = (sorted.head._1 * sorted(1)._1) % 2019

//  val ans = (l to r).take(2019).combinations(2).foldLeft(2019L)((acc, f) => {
//    val tmp = (f.head * f.last) % 2019
//    if (tmp <= acc) tmp else acc
//  })

//  val ans = (l to r).take(2019).combinations(2).map(f => f.head * f.last % 2019).min

  val ans = if (r - l >= 2019L) 0L
  else {
    val candidates = for {
      i <- l to (r - 1)
      j <- (i + 1) to r
    } yield (i * j) % 2019L
    candidates.min
  }

  println(ans)


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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 114556
while True:
    n = input()
    if n == 0:
        break
    R = sorted([map(int,raw_input().split()) for _ in xrange(n)],
                key = lambda x:sum(60*m+s for m,s in zip(x[1::2],x[2::2])))
    print "\n".join(map(str,[R[0][0],R[1][0],R[-2][0]]))

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

int main(){
  string S;
  cin >> S;
  int ans = 700;
  for (int i=0;i<3;i++){
    if (S.at(i) == 'o') ans += 100;
    else if (S.at(i) == 'x') continue;
  }
  cout << ans << endl;
}

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

using namespace std;

long long inf=1000000007;


int main(){
	long long a,b;
	cin>>a>>b;
	a--;

	if(a%2==0){
		if((a/2)%2==0) a^=0;
		else a^=1;
	}else{
		if(((a+1)/2)%2==0) a=0;
		else a=1;
	}

	if(b%2==0){
		if((b/2)%2==0) b^=0;
		else b^=1;
	}else{
		if(((b+1)/2)%2==0) b=0;
		else b=1;
	}

	cout<<(a^b)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;

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

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  map<string, int> counts;

  string str;
  int maxLen=0;
  while(cin >> str){
    counts[str]++;
    maxLen = max((int)str.size(), maxLen);
  }

  string maxLenStr="";
  string maxCountStr = "";
  int maxCount=0;
  map<string, int>::iterator it = counts.begin();
  for(it=counts.begin(); it!=counts.end(); it++){
    if(it->first.size() == maxLen)
      maxLenStr = it->first;
    int m = max(maxCount, it->second);
    if(m!=maxCount){
      maxCountStr = it->first;
      maxCount = m;
    }
  }

  cout << maxCountStr << " " <<  maxLenStr << endl;
}

Measured memory_bytes: 1200
import re

s = input()

flag = 0
for i in range(2, len(s)-1):
    if s[i] == 'C':
        flag += 1

if s[0] == 'A' and flag == 1 and len(re.findall('[A-Z]', s)) == 2:
    print('AC')
else:
    print('WA')


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

using ll = long long;
int main() {
    string A;
    cin >> A;
    set<string> S;
    ll cnt[26] = {};
    rep(i, A.size()) cnt[A[i] - 'a']++;
    // cout << "size = " << A.size() << endl;
    ll ans = 1;
    rep(i, A.size()) ans += i;
    // cout << ans << endl;
    rep(i, 26) if (cnt[i]) ans -= 1LL * (cnt[i] - 1) * (cnt[i]) / 2;
    cout << ans << endl;
    return 0;

    rep(i, A.size()) rep(j, A.size() + 1) if (i <= j) {
        string s1 = A.substr(0, i);
        string s2 = A.substr(i, j - i);
        string s3 = A.substr(j, A.size() - j);
        reverse(all(s2));
        // cout << s1 << ", " << s2 << ", " << s3 << endl;
        S.insert(s1 + s2 + s3);
    }
    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 640
while True:

    a,b = map(int,input().split())

    if a==0 and b == 0: 
        break
    for i in range(a):
        for j in range(b):
            if (i + j) % 2 == 0: 
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()




Measured memory_bytes: 7000
#include <iostream>
#include <vector>
using namespace std; using P=pair<int,int>; using ll=long long;
const ll m = 1e9+7;

int main2() {
	string s; cin>>s;
  if (s[0] == '7' || s[1]=='7' || s[2]=='7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

int main() {
  int n; cin>>n;
  ll an=0;
  for(int i=1;i<=n;i++) {
    if (i%3!=0 && i%5!=0) an+=i;
  }
  cout<<an<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long arr[200000];
int main(){
	long long n, k;
	cin >> k >> n;
	for(long long i=0;i<n;i++) cin >> arr[i];
	long long mn = min(arr[n-1]-arr[0], k-arr[n-1]+arr[n-2]);
	for(long long i=1;i<n-1;i++){
		mn = min(mn, arr[i]+k-arr[i+1]);
		mn = min(mn, k-arr[i]+arr[i-1]);
	}
	cout << mn << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
using namespace std;
const int N=2e5+5;
int n,lastpos,lastlen,ans,Ans;
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	lastpos=1;
	lastlen=1;
	ans=1;
	while (lastpos<n)
	{
		if (lastlen==2) lastpos++,lastlen=1,ans++;
		else if (s[lastpos]!=s[lastpos+1]) lastpos++,lastlen=1,ans++;
		else if (s[lastpos]==s[lastpos+1]&&lastpos<n-1) lastpos+=2,lastlen=2,ans++;
		else lastpos=n;
	}
	Ans=max(Ans,ans);
	if (n>1)
	{
		lastpos=2;
		lastlen=2;
		ans=1;
		while (lastpos<n)
		{
			if (lastlen==2) lastpos++,lastlen=1,ans++;
			else if (s[lastpos]!=s[lastpos+1]) lastpos++,lastlen=1,ans++;
			else if (s[lastpos]==s[lastpos+1]&&lastpos<n-1) lastpos+=2,lastlen=2,ans++;
			else lastpos=n;
		}
		Ans=max(Ans,ans);
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main (void)
{
int a, b, c;
	
	scanf("%d""%d""%d",&a,&b,&c);
	
	if(a<b&&a<c&&b<c){
		printf("Yes\n");
	}
			else{
				printf("No\n");
	}

return 0;
}

Measured memory_bytes: 580
N, M = map(int, input().split())
a = []
b = []
c = []
d = []

temp = []
for n in range(N):
    temp = list(map(int, input().split())) 
    a.append(temp[0])
    b.append(temp[1])

temp = []
for m in range(M):
    temp = list(map(int, input().split())) 
    c.append(temp[0])
    d.append(temp[1])

ans = []
st = []
i = 0
while i < N:
    st.append(abs(a[i] - c[0]) + abs(b[i] - d[0]))
    ans.append(1)
    k = 1
    while k < M:
        temp = abs(a[i] - c[k]) + abs(b[i] - d[k])
        if temp < st[i]:
            st[i] = temp
            ans[i] = k + 1
        k += 1
    i += 1

for i in ans:
    print(i)




Measured memory_bytes: 3064
S=input()

if(len(S)!=26):
 for i in range(ord("a"),ord("z")+1):
  CHARA=chr(i)
  if CHARA not in S:
   print(S+CHARA)
   exit()

S=list(S)
T=[]
while(S):
    for c in T:
        if(c > S[-1]):
            print(''.join(S[:-1]) + c)
            exit()
    T.append(S.pop())
print(-1)

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=1e5+5;
int dist[N];
bool vis[N];
vi adj[N];

int dfs(int u){
	if(vis[u]==true)
		return dist[u];
	vis[u]=1;
	for(auto v: adj[u]){
		dist[u]=max(dist[u],1+dfs(v));
	}
	return dist[u];
}

void solve(){
	int n,m;
	cin>>n>>m;
	int x,y;
	fr(i,0,m){
		cin>>x>>y;
		adj[x].pb(y);
	}
	int ans=0;
	fr(i,1,n+1){
		if(!vis[i]){
			ans=max(ans,dfs(i));
		}
	}
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 11640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    bool ok = S[2]==S[3] && S[4]==S[5];
    cout << (ok? "Yes\n":"No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++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 (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};




int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N, K;
    cin >> N >> K;
    vector<ll> h(N+100000);
    rep(i,N) cin >> h[i];
    vector<ll> dp(N+100000, LLINF);
    dp[0] = 0;
    rep(i,N){
      rep(j,K) chmin(dp[i + j + 1], dp[i] + abs(h[i + j + 1] - h[i]));
    }
    print(dp[N-1]);
}

Measured memory_bytes: 3456
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int count;

void merge(int [],int,int,int);
void mergeSort(int [],int,int);


int main() {
    int a[MAX],n,i;
    
    scanf("%d",&n);
    for(i=0; i<n; i++) scanf("%d",&a[i]);
    
    mergeSort(a,0,n);
    
    for(i=0; i<n; i++){
        printf("%d",a[i]);
        if(i<n-1) printf(" ");
    }
    
    printf("\n");
    printf("%d\n",count);
    
    return 0;
}


void merge(int a[],int left,int mid,int right) {
    int n1,n2,i,j,k;
    
    n1 = mid-left;
    n2 = right-mid;
    
    for(i=0; i<n1; i++) L[i] = a[left+i];
    for(i=0; i<n2; i++) R[i] = a[mid+i];
    
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    
    for(k=left; k<right; k++){
        count++;
        if(L[i]<=R[j]){
            a[k] = L[i++];
        }
        else a[k] = R[j++];
    }
}


void mergeSort(int a[],int left,int right) {
    int mid;
    
    if(left+1<right){
        mid = (left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

Measured memory_bytes: 4508
using System;
    using System.Linq;
    class ans4A
    {
        static void Main()
        {
            var nums = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine((nums[0] / nums[1]) + " " + (nums[0] % nums[1]) + " " + (Convert.ToDouble(nums[0]) / Convert.ToDouble(nums[1])).ToString("f5"));
        }
    }


Measured memory_bytes: 18420
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . reverse . foldl f ""

f s '0' = '0' : s
f s '1' = '1' : s
f "" _ =  ""
f s _ = drop 1 s


Measured memory_bytes: 380
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	StringBuilder sb = new StringBuilder();
	sb.append(S);
	if ( S.length() == 2 ) {
	    System.out.println(S);
	} else if ( S.length() == 3 ) {
	    sb.reverse();
	    String s = sb.toString();
	    System.out.println(s);
	}
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::vector<std::vector<int>> edg(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v; std::cin >> u >> v;
        u--; v--;
        edg[u].push_back(v);
        edg[v].push_back(u);
    }
    std::vector<int> dp(n + 2, 1e9 + 2), ans(n);
    dp[0] = 0;
    auto dfs = [&](auto &self, int pos = 0, int prev = -1) -> void {
        auto iter = std::lower_bound(dp.begin(), dp.end(), a[pos]);
        const int p = *iter;
        *iter = a[pos];
        ans[pos] = std::lower_bound(dp.begin(), dp.end(), 1e9 + 2)
            - dp.begin() - 1;
        for (int c : edg[pos]) {
            if (c == prev) continue;
            self(self, c, pos);
        }
        *iter = p;
    };
    dfs(dfs);
    for (int i = 0; i < n; i++) std::cout << ans[i] << std::endl;
    return 0;
}


Measured memory_bytes: 30804
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}



signed main() {
    i64 n;
    cin>>n;

    i64 minkei = 1LL<<60;

    for(int a=1;a<=sqrt(n);a++){
        if(n % a != 0) continue;

        minkei = min( a+ (n/a) - 2, minkei);
    }
    cout<<minkei<<endl;

    // cout << ans << endl;
    return 0;
}

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

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int cnt = 0;
	bool flag = true;
	while (1) {
		for (int i = 0; i < n; i++)
		{
			if (a[i] % 2 == 0)
				a[i] = a[i] / 2;
			else {
				flag = false;
				break;
			}

		}
		if (flag == true)
			cnt++;
		else
			break;

	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_130
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] xa = ReadInts();
            int x = xa[0];
            int a = xa[1];
            if (x < a) WriteLine(0);
            else WriteLine(10);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;
int arr[4];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int d;
    cin>>d;
    
    if(d==1)
        cout<<"Hello World";
    else
    {
        int a,b;
        cin>>a>>b;
        
        cout<<a+b;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<pair<string, int>> S(N);
    rep(i, N) {
        string s;
        int t;
        cin >> s >> t;
        S.at(i) = make_pair(s, t);
    }
    string X;
    cin >> X;

    bool flg = false;
    int sum = 0;
    rep(i, N) {
        if(flg) {
            sum += S.at(i).second;
        }
        if(S.at(i).first == X) {
            flg = true;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ABC140D
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var S = cin.ReadLine.ToArray();

            int RLCount = 0;
            for(int i = 0; i < N - 1; i++)
            {
                if(S[i] != S[i + 1])
                {
                    RLCount++;
                }
            }

            Console.WriteLine(N - 1 - Max(0, RLCount - 2 * K));
            return;
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

typedef long long int ll;
typedef pair<ll,ll> P;
//cout<<fixed<<setprecision(15)
vector<ll> a,b;

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll tmp=0;
    
    a.push_back(0);
    b.push_back(0);
    for(int i=0;i<n;i++){
        ll atmp;
        cin>>atmp;
        tmp+=atmp;
        a.push_back(tmp);
    }
    tmp=0;
    for(int i=0;i<m;i++){
        ll atmp;
        cin>>atmp;
        tmp+=atmp;
        b.push_back(tmp);
    }
    n++;m++;
    ll mmax=0;
    int now=0;
    while(a[now]<=k&&now<n){
        tmp=(now+1)+upper_bound(b.begin(),b.end(),k-a[now])-b.begin();
        mmax=max(mmax,tmp);
        //cout<<now<<":"<<mmax<<endl;
        now++;
    }
    cout<<mmax-2<<endl;
    return 0;
}

Measured memory_bytes: 7964
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
2
100 1 1
1 100
'''


def MAIN():
  # T_IN()
  A()


def A():
  n = IN_I()
  al = IN_L_I()
  bl = IN_L_I()

  killed = 0
  for i, b in enumerate(bl):
    a1 = al[i] - b
    if a1 >= 0:
      killed += b
      continue

    killed += al[i]

    b = b - al[i]
    a2 = al[i + 1] - b
    if a2 < 0:
      killed += al[i + 1]
      al[i + 1] = 0
    else:
      killed += b
      al[i + 1] -= b

  print(killed)
  return None


def B():
  return None


def C():
  return None


MAIN()


Measured memory_bytes: 19004
import numpy as np


def main():
    N = int(input())
    red = np.zeros([N, 2])
    blue = np.zeros([N, 2])

    for i in range(N):
        red[i, 0:2] = list(map(int, input().split()))

    for i in range(N):
        blue[i, 0:2] = list(map(int, input().split()))

    blue = blue[np.argsort(blue[:, 0])]
    red = red[np.argsort(red[:, 1])[::-1]]

    d = np.zeros([N, 2])
    cnt = 0

    for i in range(N):
        d[0:N, 0:2] = blue[i, 0:2] - red[0:N, 0:2]

        if np.any((d[:, 0] > 0) & (d[:, 1] > 0)):
            dd = d[(d[:, 0] > 0) & (d[:, 1] > 0)]
            dd = dd[np.argsort(dd[:, 1])]
            ind = list(zip(*np.where(d == dd[0])))
            row = ind[0][0]
            red[row, :] = 10**9
            cnt += 1

    print(cnt)


main()


Measured memory_bytes: 12740
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll P, Q, R;
    cin >> P >> Q >> R;
    ll ans = 333;
    ans = min(ans, P + Q);
    ans = min(ans, R + Q);
    ans = min(ans, P + R);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 1000000007;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
vector<ll> a(N),b(N);
ll n;
ll power(ll a,ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res*a)%M;
        a = (a*a)%M;
        b = b >> 1;
    }
    return res;
}
ll modinv(ll a)
{
   return power(a,M - 2); 
}  
void reduce(ll x,ll y,ll index)
{
  if(y == 0)
  {
    a[index] = 1;
    return;
  }
  if(x == 0)
  {
    b[index] = 1;
    return;
  }
  if(x < 0 && y < 0)
    a[index] = abs(x),b[index] = abs(y);
  if(x > 0 && y < 0)
    a[index] = -x,b[index] = -y;
  ll g = __gcd(abs(x),abs(y));
  a[index] /= g,b[index] /= g;
  return;
}
int main()
{
    fast;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll i,j,t,cnt = 0,ans = 1;
    cin >> n;
    for(i = 1; i <= n; i++)
      cin >> a[i] >> b[i];
    map<pair<ll,ll>,ll> sum;
    for(i = 1; i <= n; i++)
    {
      if(a[i] == 0 && b[i] == 0)
        cnt++;
      else
      {
        reduce(a[i],b[i],i);
        sum[{a[i],b[i]}]++;
      }
    }
    map<pair<ll,ll>,bool> visited;
    ll temp = (power(2,sum[{0,1}]) + power(2,sum[{1,0}]))%M;
    temp = (temp - 1 + M)%M;
    ans = temp;
    visited[{0,1}] = visited[{1,0}] = true;
    for(i = 1; i <= n; i++)
    {
      if((a[i] != 0 && b[i] != 0) && !visited[{a[i],b[i]}])
      {
        ll s1 = 0,s2 = 0;
        s1 = sum[{a[i],b[i]}];
        if(a[i] > 0)
        {
          s2 = sum[{-b[i],a[i]}];
          visited[{-b[i],a[i]}] = true;
        }
        else
        {
          s2 = sum[{b[i],-a[i]}];
          visited[{b[i],-a[i]}] = true;
        }
        ll c = (power(2,s1) + power(2,s2))%M;
        c = (c - 1 + M)%M;
        ans = (ans*c)%M;
        visited[{a[i],b[i]}] = true;
      }
    }
    ans = (ans + cnt)%M;
    ans = (ans - 1 + M)%M;
    cout<<ans<<endl;
    return 0;
}    

Measured memory_bytes: 56172
#include <stdio.h>
  
int walk(int i, int time, int w[101][101], int *d, int *f)
{
  int *p;
  
  d[i] = ++time;
  for (p = w[i]; *p != 0; p++)
    if (!d[*p])
      time = walk(*p, time, w, d, f);
  f[i] = ++time;

  return time;
}
  
int main(void)
{
  int num;
  int i,j;
  int u,k;
  int tm=0;
  int d[101]={};
  int f[101]={};
  int w[101][101]={};
  
  scanf("%d", &num);
  for (i=0;i<num;i++)
    {
      scanf("%d %d",&u,&k);
      for (j=0;j<k;j++)
	scanf("%d",&w[u][j]);
    }
  
  for (i=1;i<=num;i++)
    if (d[i]==0)
      tm=walk(i,tm,w,d,f);
  
  for (i=1;i<=num;i++)
    printf("%d %d %d\n",i,d[i],f[i]);
  
  return 0;
}

Measured memory_bytes: 648
#include<stdio.h>

int main(){
  int t_hp,t_a,a_hp,a_a;
  int t_c,a_c;
  if(scanf("%d%d%d%d",&t_hp,&t_a,&a_hp,&a_a)!=4) return -1;
  t_c=t_hp/a_a; 
  a_c=a_hp/t_a; 
  if(t_hp%a_a!=0) {
  	t_c++; 
  }
  if(a_hp%t_a!=0) {
  	a_c++; 
  }
  if(t_c>=a_c) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int sgn(int x){
    if(x > 0) return 1;
    else return -1;
}

int k, x, y;
pair<int, int> solve(pair<int, int> cur={0, 0}){
    int cx, cy;
    tie(cx, cy) = cur;
    int vx = x-cx, vy = y-cy;
    int d = abs(vx) + abs(vy);
    int dx = 0, dy = 0;

    if(d % k == 0){
        for(int i=0;i<d/k;++i){
            dx += k;
            if(cx*sgn(vx) + dx > x*sgn(vx)){
                dy += cx*sgn(vx) + dx - x*sgn(vx);
                dx = (x - cx) * sgn(vx);
            }
            cout << cx + dx*sgn(vx) << " " << cy + dy*sgn(vy) << endl;
        }
        return {x, y};
    }
    if(d < 2*k && d % 2 == 0){
        int u = k - d/2;
        dx = k-u; dy = -u;
        if(cx*sgn(vx) + dx > x*sgn(vx)){
            dy += u;
            dy += cx*sgn(vx) + dx - x*sgn(vx);
            dx = (x - cx) * sgn(vx) + u;
        }
        cout << cx + dx*sgn(vx) << " " << cy + dy*sgn(vy) << endl;
        cout << x << " " << y << endl;
        return {x, y};
    }else{
        dx += k;
        if(cx*sgn(vx) + dx > x*sgn(vx)){
            dy += cx*sgn(vx) + dx - x*sgn(vx);
            dx = (x - cx) * sgn(vx);
        }
        cout << cx + dx*sgn(vx) << " " << cy + dy*sgn(vy) << endl;
        return {cx + dx*sgn(vx), cy + dy*sgn(vy)};
    }
}

int main(){
    cin >> k >> x >> y;
    int d = abs(x)+abs(y);
    if(k%2 == 0){
        if(d%2 == 1){
            cout << -1 << endl;
            return 0;
        }
        else if(d % k == 0) cout << d/k << endl;
        else if(d < 2*k) cout << 2 << endl;
        else cout << (d+k-1)/k << endl;
    }else{
        if(d % k == 0) cout << d/k << endl;
        else if(d < k) cout << 2 + d%2 << endl;
        else if(d%2 == d/k%2) cout << (d+k-1)/k + 1 << endl;
        else cout << (d+k-1)/k << endl;
    }
    pair<int, int> pos{0, 0};
    while(pos != pair<int,int>{x, y}) pos = solve(pos);
    
    return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589
int main() {double corn=0.00,x=0.00,y=0.00;int i,j;while (1) {scanf("%d,%d",&i,&j);if (!i && !j) break;x+=i*sin(corn);y+=i*cos(corn);corn+=(j*PI)/180.00;}printf("%d\n%d\n",(int)(x),(int)(y));return 0;}

Measured memory_bytes: 0
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int n,a,b;cin>>n>>a>>b;

  int m = 0;
  if (a+b>n) m = (a+b)-n;
  else m = 0;

  cout << min(a,b) << " " << m << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)



#ifndef CF
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(vector<T> v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#endif


const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n+1);
    for(int i=1; i<=n; i++){
        cin >> v[i];
    }
    int last = -1;
    for(int i=k; i<=n; i++){
        if(i!=k){
//            debug(v[i] , last);
            if(v[i] > last){
                cout <<"Yes\n";
            }
            else{
                cout <<"No\n";
            }
        }
        last = v[i-k+1];
    }
}


signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
//        cout << "Case #" << t << ": ";
        solve();
    }
}


Measured memory_bytes: 4780
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,d,a = map(int, input().split())
    xh = [list(map(int, input().split())) for _ in range(n)]
    xh.sort(key=lambda a: a[0])
    x = []
    for i in range(n):
        x.append(xh[i][0])
    res = 0
    hp = [0]*n
    for i in range(n):
        if i != 0:
            hp[i] += hp[i-1]
        if hp[i]>=xh[i][1]:
            continue
        res += (xh[i][1]-hp[i]-1) // a + 1
        attack = ((xh[i][1]-hp[i]-1) // a + 1) * a
        hp[i] += attack
        genkai = x[i] + 2 * d
        migi = bisect_right(x, genkai)
        if migi <= n - 1:
            hp[migi] -= attack

    print(res)

if __name__ == '__main__':
    main()

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

int main() 
{
    int n,k;
    cin >> n >> k;
    
    int a[n];
    int dp[k+1];
    
    memset(dp,0,sizeof dp);
    
    for(int i=0;i<n;i++) cin >> a[i];
    
    dp[0] = 0;
    
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=a[j] && dp[i-a[j]]==0) {
                dp[i] = 1;
            }
        }
    }
    
    if(dp[k]) cout<<"First\n";
    else cout<<"Second\n";
    
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

int N,M;
int table[NUM];
vector<int> PLUS,MINUS;

int main(){

	ll ans = 0;

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){

		scanf("%d",&table[i]);
		ans += abs(i-table[i]);

		PLUS.push_back(min(i,table[i]));
		MINUS.push_back(max(i,table[i]));
	}

	sort(PLUS.begin(),PLUS.end());
	sort(MINUS.begin(),MINUS.end());

	reverse(PLUS.begin(),PLUS.end());

	for(int i = 0; i < M; i++){

		ans += 2*max(0,PLUS[i]-MINUS[i]);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 4272
n,k = map(int, input().split())
g = [[0]*(k+1) for _ in range(k+1)]
ans,b = 0,0
for _ in range(n):
  x,y,c = input().split()
  x,y = int(x), int(y)
  d = x//k + y//k
  x %= k; y %= k
  if (c == 'W') ^ (d%2):
    g[x+1][y+1] += 1
  else:
    g[x+1][y+1] -= 1
    b += 1
for i in range(k):
  for j in range(k):
    g[i+1][j+1] += g[i][j+1] + g[i+1][j] - g[i][j]
for i in range(k):
  for j in range(k):
    cur = g[k][k] - g[k][j] - g[i][k] + g[i][j]*2 + b
    if cur > ans: ans = cur
    if n-cur > ans: ans = n-cur
print(ans)

Measured memory_bytes: 34720
use std::io::{stdin, Read};

use std::cmp::Ordering;
use std::cmp::Ordering::*;
use std::cmp::PartialOrd;

#[derive(PartialEq, Eq)]
struct Rev<T>(T);

impl<T: Ord> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(match self.0.cmp(&other.0) {
            Less => Greater,
            Equal => Equal,
            Greater => Less,
        })
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Self) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, m: usize, s: usize, t: usize);
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        parse!(it, u: usize, v: usize, a: usize, b: usize);
        g[u - 1].push((v - 1, a, b));
        g[v - 1].push((u - 1, a, b));
    }
    let mut q = std::collections::BinaryHeap::new();
    let mut froms = vec![None; n];
    q.push(Rev((0, s - 1)));
    while let Some(Rev((l, u))) = q.pop() {
        if froms[u] != None {
            continue;
        }
        froms[u] = Some(l);
        for &(v, a, _) in g[u].iter() {
            if froms[v] != None {
                continue;
            }
            q.push(Rev((l + a, v)));
        }
    }

    let mut q = std::collections::BinaryHeap::new();
    let mut fromt = vec![None; n];
    q.push(Rev((0, t - 1)));
    while let Some(Rev((l, u))) = q.pop() {
        if fromt[u] != None {
            continue;
        }
        fromt[u] = Some(l);
        for &(v, _, b) in g[u].iter() {
            if fromt[v] != None {
                continue;
            }
            q.push(Rev((l + b, v)));
        }
    }

    let mut costs = (0..n)
        .map(|i| Rev((froms[i].unwrap() + fromt[i].unwrap(), i)))
        .collect::<std::collections::BinaryHeap<_>>();
    let money = 1_000_000_000_000_000usize;
    for i in 0..n {
        loop {
            let &Rev((cost, u)) = costs.peek().unwrap();
            if u < i {
                costs.pop();
                continue;
            }
            println!("{}", money - cost);
            break;
        }
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        4 3 2 3
1 4 1 100
1 2 1 10
1 3 20 1
        ";
        solve(s);
    }
}


Measured memory_bytes: 32500