akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;


public class  Main{
    public static void main(String[] args) throws Exception{
    	MScanner sc = new MScanner(System.in);
        //MScanner sc = new MScanner("reduce.in");
        PrintWriter pw=new PrintWriter(System.out);
        //int n=sc.nextInt();
        //Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=sc.nextInt();
        int n=sc.nextInt();
        pair[]in=new pair[n];
        for(int i=0;i<n;i++) {
        	in[i]=new pair(sc.nextInt(),sc.nextInt());
        }
        Arrays.sort(in);
        int time=0;
        for(int i=0;i<n;i++) {
        	time+=in[i].t;
        	if(time>in[i].d) {
        		pw.println("No");pw.flush();return;
        	}
        }
        pw.println("Yes");
        pw.flush();
    }
    static class pair implements Comparable<pair>{
    	int t;int d;
    	pair(int x,int y){
    		t=x;d=y;
    	}
    	@Override
    	public int compareTo(pair o) {
    		if(d!=o.d) {
    			return d-o.d;
    		}
    		return t-o.t;
    	}
    	 
    	public boolean equals(pair o) {
    		if(this.compareTo(o)==0)return true;
    		return false;
    	}
    	public String toString() {
    		return "("+t+" "+d+")";
    	}
    }
    static StringBuilder tosb(int[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    static StringBuilder tosb(long[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 49636
#include<cstdio>
using namespace std;
int main(){

    int a,b,n;
    while(scanf("%d%d%d",&a,&b,&n) != EOF){

        int ans = 0;


        for(int i = 0; i < n; i++){
            a = (a % b)*10;
            ans += a / b;
        }

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

    }

    return 0;
}

Measured memory_bytes: 1024
s = str(input())

s = "".join(list(reversed(s)))

y = 0

for _ in range(100000):
    if y == len(s):
        print("YES")
        break
    elif s[y:y+7] == "remaerd":
        y += 7
        #print(y)
    elif s[y:y+6] == "resare":
        y += 6
        #print(y)
    elif s[y:y+5] == "esare":
        y += 5
        #print(y)
    elif s[y:y+5] == "maerd":
        y += 5
    else:
        print("NO")
        break

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

int main(int argc, const char * argv[]) {
    int N, x;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> x;
        v[i] = x;
    }
    
    int a_p = 0, b_p = 0;
    bool flag = true;
    sort(v.begin(), v.end());
    for (int i = N-1; i >= 0; i--) {
        if (flag) {
            a_p += v[i];
            flag = false;
        }else{
            b_p += v[i];
            flag = true;
        }
    }
    cout << a_p - b_p << endl;
}


Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
Max_d = 0
mi = 0
d = 0
for i in range(N-1):
    if Max_d < A[i+1]-A[i]:
        mi = i
        Max_d = A[i+1]-A[i]
    d += A[i+1]-A[i]    
if Max_d < K-A[N-1]+A[0]:
    print(d)
else:
    d = 0
    for i in range(mi):
        d += A[i+1]-A[i]
    for i in range(mi+1, N-1):
        d += A[i+1]-A[i]
    d += K-A[N-1]+A[0]
    print(d)

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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  
  if ((a == b) && (a == c)){
    cout << 1 << endl;
  }
  else if ((a != b) && (a != c) && (b != c)) {
    cout << 3 << endl;
  }
  else {
    cout << 2 << endl;
  }
}

Measured memory_bytes: 256
N,M,Q=map(int, input().split())

#C[i][j]= i==LかつR<=jなる列車の総数(1-indexed)
C=[[0 for _ in range(N+1)] for __ in range(N+1)]

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

for _ in range(Q):
    p,q=map(int, input().split())
    ans=0
    for i in range(p,q+1):
        ans+=C[i][q]-C[i][i-1]
    print(ans)


Measured memory_bytes: 57176
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#define INF 100000000
#define ll long long int
using namespace std;

/*
vector <int> dx = {1,0,-1,0};
vector <int> dy = {0,1,0,-1};

*/


struct Node {
  ll parent;
  ll size;
};

vector < Node > UnionFind(100098);






int find(Node a);

void connect(Node a,Node b);

 int main(){
   ll N,M; cin>>N>>M;
   ll A[M],B[M];
   for(int i=0;i<M;i++) cin>>A[i]>>B[i];
   ll ans [100008] = {};
   ans [M-1] = N*(N-1)/2;

   
   for(int i=1;i<=N;i++) {UnionFind[i].parent=-i; UnionFind[i].size = 1 ;}
 

  for(int i=M-2;i>=0;i--){


    int a = A[i+1]; int b = B[i+1];

    int roota = find(UnionFind[a]);
    int rootb = find(UnionFind[b]);

    ll delta = UnionFind[roota].size * UnionFind[rootb].size;

    bool flag = roota == rootb;

    connect(UnionFind[a],UnionFind[b]);


    if(not flag){

      ans[i] = ans[i+1] - delta;

      continue;

    } else {

      ans[i] = ans[i+1] ;//- UnionFind[-UnionFind[a].parent].size * UnionFind[-UnionFind[b].parent].size;

      

      continue;

    }
  }

for(int i=0;i<M;i++){
  cout<<ans[i]<<endl;
}

return 0;
 }


 int find(Node a){
   if(a.parent < 0) return -a.parent;

   int par = find(UnionFind[a.parent]);

   UnionFind[par].size += a.size;
   a.size = 0;
   a.parent = par;

   return par;

 }

void connect(Node a,Node b){

int apar = find(a);
int bpar = find(b);

if(apar == bpar) return ;

if(UnionFind[apar].size >= UnionFind[bpar].size){


UnionFind[bpar].parent = apar;
UnionFind[apar].size += UnionFind[bpar].size;
UnionFind[bpar].size = 0;

} else{

UnionFind[apar].parent = bpar;
UnionFind[bpar].size += UnionFind[apar].size;
UnionFind[apar].size = 0;
}

return ;



}

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

using namespace std;
typedef long long ll;

ll n,arr[405],mem[405][405];

ll dp(int l, int r){
    if(l==r)return arr[l]-arr[l-1];
    if(mem[l][r]!=-1)return mem[l][r];
    ll res=10000000000000;
    for(int i=l;i<r;i++)
        res=min(res,arr[r]-arr[l-1]+dp(l,i)+dp(i+1,r));
    return mem[l][r]=res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>arr[i];
        arr[i]+=arr[i-1];
    }
    memset(mem,-1,sizeof(mem));
    cout<<dp(1,n)-arr[n];
}

Measured memory_bytes: 1536
use std::io::{stdout, Write, BufWriter};

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<i64>();
    let (n, k, q) = (input[0], input[1], input[2]);
    let mut points = vec![0; n as usize];

    let need = q - k;

    for _ in 0..q {
        let a = read::<usize>() - 1;
        points[a] += 1;
    }

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    for point in points {
        if point > need {
            out.write(b"Yes\n").unwrap();
        } else {
            out.write(b"No\n").unwrap();
        }
    }
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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 COM(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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll H=in<ll>();
    ll a=2;
    ll ans=1;
    REP(i,40){
        if(H==1){
            break;
        }
        
        H/=2;        

        ans=ans*2+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
maze = [list("#" * (w + 2))]
white = 0
for _ in [0] * h:
    line = "#" + input().strip() + "#"
    maze.append(list(line))
    white += line.count(".")
maze += [list("#" * (w + 2))]
maze[1][1] = 0
maze[-2][-2] = "goal"

q = set([(1,1)])
dir = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dis = 0
while q:
    next_q = set()
    dis += 1
    for x, y in q:
        #print("x,y:", x, y)
        maze[y][x] = dis

        for dx, dy in dir:
            next_x, next_y = x + dx, y + dy
            if maze[next_y][next_x] == ".":
                #print(next_y,next_x)
                next_q.add((next_x, next_y))

            if maze[next_y][next_x] == "goal":
                print(white - dis - 1)
                exit()
    q = next_q
print(-1)


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

int main(){
  int n,a,min=64,temp;
  cin >> n;
  for (int i=0;i<n;i++){
    cin >> a;
    temp=0;
    while (a!=0) {
      if (a%2==0) temp++,a/=2;
      else break;
    }
    if (min > temp)min=temp;
  }
  cout << min << endl;
}

Measured memory_bytes: 384
#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;

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

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() 
{
    string stones;
    int size;
    cin>>size;
    cin>>stones;
    int countw = 0;
    int countr = 0;
    for(int i = 0; i<size; i++)
    {
        if(stones[i]=='W')
            countw++;
        else
            countr++;
    }
    // cout<<countc<<" "<<countr<<endl;
    if(countw == 0 || countr == 0)
    {
        cout<<0;
        return;
    }
    int front = countr;
    for(int i = 0; i<countr; i++)
    {
        if(stones[i] == 'R')
            front--;
    }
    cout<<front;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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


Measured memory_bytes: 3772
while True:
  n = int(input())
  if n == 0:
    break
  w = [input() for _ in range(n)]
  w = reversed(w)

  eles = [[] for _ in range(9)]

  for item in w:
    d,c = len(item) - 1,item[-1]

    if c == "+":
        eles[d].append(sum(eles[d+1]))
        eles[d+1] = []
    elif c == "*":
        tmp = 1
        for i in eles[d+1]:
            tmp *= i
        eles[d].append(tmp)
        eles[d+1] = []
    else:
        eles[d].append(int(c))


    

  print(eles[0][0])





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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

vvl dp(2001,vl(2001,-1));
vll a(2000);
ll happy(ll l,ll r,int n){
    //cout<<l<<" "<<r<<endl;
    if(dp[l][r]!=-1)
        return dp[l][r];
    if(l==r){
        return dp[l][r]=a[n].first*abs(a[n].second-l);
    }
    dp[l][r]=happy(l+1,r,n+1)+a[n].first*abs(a[n].second-l);
    dp[l][r]=max(dp[l][r],happy(l,r-1,n+1)+a[n].first*abs(a[n].second-r));
    return dp[l][r];
}
int main(){
    fastio;
    //clock_t tm = clock();
    ll n;
    cin>>n;
    f(i,0,n){
        cin>>a[i].first;
        a[i].second=i+1;
    }
    sort(all(a),greater<pll>());
    cout<<happy(1,n,0)<<endl;
//    f(i,1,n+1){
//        f(j,i,n+1)
//            cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
//    }
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}


Measured memory_bytes: 35168
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long 
map<ll,ll> factorise(ll k){
  map<ll,ll>res;
  for(ll i=2;i*i<=k;i++){
    while(k%i==0){
      k=k/i;
      res[i]++;
    }
  }
  if(k!=1)
    res[k]++;
  return res;
}
int main(){
  ll n,p;
  cin>>n>>p;
  ll z=sqrt(p);
  ll ans=1;
  auto m=factorise(p);
  for(auto x:m){
    ll k=x.second/n;
    for(ll i=0;i<k;i++)
      ans=ans*(x.first);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
const ll INF = (1ll << 60);

int main() {
  ll N,A,B; cin>>N>>A>>B;
  cout<<min(B,A*N)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793


int main(){
    int w, a, b;
    cin >> w >> a >> b;

    int ab = abs(a-b);
    if(ab > w)
        cout << ab - w << endl;
    else
        cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ll sum = 0;
        ll n = i;
        while(n >= 10){
        sum += n%10;
        n = n / 10;
        }
        sum += n;
        if (sum >= A && sum <= B) ans += i;
    }
    cout << ans;
    return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	return 0; 
}


Measured memory_bytes: 256
import sys

ans=0
A, B, C, K = (int(x) for x in input().split())

if A>K:
  print(K)
  sys.exit(0)
else:
  K-=A
  ans+=A
  
if B>K:
  print(ans)
  sys.exit(0)
else:K-=B

if C>K:
  print(ans-K)
  sys.exit()
else:
  ans-=C
  print(ans)

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

/* 大文字を小文字に変換 */
char tolower(char c) {
  return (c + 0x20);
}

/* 小文字を大文字に変換 */
char toupr(char c) {
  return (c - 0x20);
}

int main()
{
    string s;
    getline(cin, s);
    for(int i=0; i<s.size(); i++){
        char moji = (char)s[i];
        if('a' <= moji && moji <= 'z') moji = toupr(moji);
        else if('A' <= moji && moji <= 'Z') moji = tolower(moji);
        else moji = moji;
        cout << moji;
    }
    cout << endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (i + 1 < s.size() && s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0; 
        } else if (i + 2 < s.size() && s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0; 
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
using namespace std;
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    rrep(i, K) {
        if ((i + i) % K)continue;
        if (i > N)break;
        ll a = (N - i) / K + 1;
        ans += a * a * a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int S, h, m, s;
    scanf("%d", &S);
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
        printf("%d:%d:%d\n", h, m, s);
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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 DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n,a;
	cin >> n >> a;
	cout << n * n - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

int kk[2019];
int pp[200003];
int fact[2019];
int ncr(int n, int r) {
    return fact[n] / fact[r] / fact[n-r];
}
signed main() {
    string s;
    cin>> s;
    int n = s.size();
    pp[0] = 1;
    rep(i,n+1) {
        pp[i+1] = (pp[i] * 10) % 2019;
    }
    fact[0] = 1;
    rep(i, 2020) {
        fact[i+1] = fact[i] * (i+1);
    }
    vi a(n+1);
    rep(i, n) {
        a[i+1] = a[i]*10 + (s[i] - '0');
        a[i+1] %= 2019;
    }
    rep(i,n+1) {
        // cerr<<i<<' '<<a[i]<<' '<<pp[n-i]<<endl;
        kk[(a[i]*pp[n-i])%2019]++;
    }
    // cout << b.size();
    // return 0;
    ll ans = 0;//n+1;
    // rep(i,2019) if(kk[i]>=1) ans--;
    rep(i,2019) {
        if(kk[i] >= 2)
        ans += (kk[i]*(kk[i]-1)/ 2);
    }
    cout<< ans<<endl;

    // cout<<n+1 - b.size()<<endl;
    // rep(i,n+1) cout<<a[i]<<' ';
    // ll ans = 0;
    // rep(i, n+1) {
    //     ll p = 10;
    //     FOR(j, i+1, n+1) {
    //         if(ll(a[j] - a[i]* p) %2019==0) ans++;
    //         p *= 10;
    //     }
    // }
    // cout<<ans<<endl;
    return 0;
}

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

int main(void) {
    int sx,sy,tx,ty;
    int cntx = 0; 
    int cnty = 0; 
    cin >> sx >> sy >> tx >> ty;

    // 1周目
    for(int y=sy;y<ty;y++) {
        cout << "U";
        cnty++;
    }
    for(int x=sx;x<tx;x++) {
        cout << "R";
        cntx++;
    }
    for(int y=0;y<cnty;y++) {
        cout << "D";
    }
    for(int x=0;x<cntx;x++) {
        cout << "L";
    }

    // 2周目
    cout << "L";
    for(int y=0;y<cnty+1;y++){
        cout << "U";
    }
    for(int x=0;x<cntx+1;x++){
        cout << "R";
    }
    cout << "DR";
    for(int y=0;y<cnty+1;y++){
        cout << "D";
    }
    for(int x=0;x<cntx+1;x++){
        cout << "L";
    }
    cout << "U\n";

    return 0;
}


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

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

    ll a[n];
    ll sum[n + 1];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum[i] = 0;
    }
    sum[n] = 0;

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

    sort(sum, sum + n + 1);

    ll ans = 0;
    ll cou = 0;
    for(int i = 0; i < n; i++){
        if(sum[i] == sum[i + 1]){
            cou++;
        }else{
            if(cou != 0){
                cou++;
                ans += cou * (cou - 1) / 2;
                cou = 0;
            }
        }
    }

    if(cou != 0){
        cou++;
        ans += cou * (cou - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
from collections import defaultdict, deque
import copy
N, M = map(int, input().split())
cnt_in = defaultdict(int)
G = defaultdict(list)
G_rev = defaultdict(list)
for _ in range(N-1+M):
    a, b = map(int, input().split())
    G[a].append(b)
    G_rev[b].append(a)
    cnt_in[b] += 1
cnt = copy.deepcopy(cnt_in)
q = deque(v for v in range(1, N+1) if cnt_in[v] == 0)
res = []
while q:
    v = q.popleft()
    res.append(v)
    for nv in G[v]:
        cnt_in[nv] -= 1
        if cnt_in[nv] == 0:
            q.append(nv)
point2order = defaultdict(int)
dp = [0] * N
ans = [0] * N
for i in range(N):
    point2order[res[i]] = i
    for v in G_rev[res[i]]:
        if dp[point2order[v]]+1 >= dp[i]:
            dp[i] = dp[point2order[v]]+1
            ans[res[i]-1] = v
for elem in ans:
    print(elem)


Measured memory_bytes: 76576
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	mm := map[int]int{}
	xm := map[int]int{}
	erase := map[int]int{}
	for i := 0; i < n; i++ {
		x := getNextInt(scanner)
		xm[x] = xm[x] + 1
		mm[x%m] = mm[x%m] + 1
	}
	ans := 0
	for v, c := range mm {
		if v == 0 || v == m-v {
			ans += c >> 1
			continue
		}
		if c <= mm[m-v] {
			ans += c
			mm[m-v] -= c
			mm[v] -= c
			continue
		}
		erase[v] = c - mm[m-v]
	}
	for x, c := range xm {
		p := minint(erase[x%m], c) >> 1
		ans += p
		erase[x%m] -= p << 1
	}

	fmt.Fprintln(writer, ans)
}

func minint(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n, 0);
  REP(i, n) cin >> a[i];
  k = min(k, 100);
  REP(j, k)
  {
    vector<int> b(n, 0);
    REP(i, n)
    {
      int l,r;
      l = max(0, i - a[i]);
      r = min(n - 1, i + a[i]);
      b[l]++;
      if(r + 1 < n) b[r+1]--;
    }
    REP(i, n-1)
    {
      b[i+1] += b[i];
    }
    REP(i, n)
    {
      a[i] = b[i];
    }
  }
  REP(i, n)
    cout << a[i] << " ";
  
  return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
string s[100];
int x[100];
map<string,vector<P>> m;
signed main(){
	int n;
	cin>>n;
	f(i,n){
		cin>>s[i]>>x[i];
		m[s[i]].push_back(P(x[i],i+1));
	}
	for(pair<string,vector<P>> p:m){
		vector<P> v=p.S;
		sort(v.begin(),v.end());
		for(int i=v.size()-1;i>=0;i--){
			cout<<v[i].S<<endl;
		}
	}
}


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

int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    string res = "Yes";
    if(x-r < 0 || x+r > w) res = "No";
    if(y-r < 0 || y+r > h) res = "No";
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3216
N = int(input())
W = list(map(int,input().split()))
S1= 0
S2 = 0
ls = []
for i in range(N):
    S1 += W[i]
for j in range(N):
    ls.append(abs(S1-S2))
    S2 += W[j]
    S1 = S1 - W[j]
print(min(ls))

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

constexpr long long MAX = 200000 + 1;

long long fact[MAX], fact_inv[MAX];

long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long long comb(long long n, long long k)
{
  long long ans = (fact[n] * fact_inv[k]) % MOD;
  return (ans * fact_inv[n - k]) % MOD;
}

int main()
{
  long long n, k;
  std::cin >> n >> k;

  fact[0] = 1;
  for (int i = 0; i < n; ++i)
    fact[i + 1] = fact[i] * (i + 1) % MOD;
  fact_inv[n] = power(fact[n], MOD - 2);

  for (int i = n - 1; 0 <= i; --i)
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;

  long long ans = 1;
  auto limit = std::min(n - 1, k);
  for(long long i = 1; i <= limit; ++i)
  {
    long long tmp = (comb(n, i) * fact[n - 1]) % MOD;
    tmp = (tmp * fact_inv[i]) % MOD;
    tmp = (tmp * fact_inv[n - i - 1]) % MOD;
    ans = (ans + tmp) % MOD;
  }
  std::cout << ans << std::endl;

  return 0;
}



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

using namespace std;
using ll = long long int;

struct Work
{
    ll time, deadline;
};

int main()
{
    int n;
    cin >> n;
    vector<Work> W;
    for (int i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        W.push_back({ a, b });
    }

    sort(W.begin(), W.end(), [](auto &a, auto &b)
    {
        return a.deadline < b.deadline;
    });

    ll time = 0;
    for (auto &w : W)
    {
        time += w.time;
        if (time > w.deadline)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 6384
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,C=get_i
a=A
seen=Hash.new(false)
until a==C or seen[a]
    seen[a]=true
    a+=A
    a%=B
end
if seen[a]
    puts "NO"
else
    puts "YES"
end

Measured memory_bytes: 14236
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n,k,total=0;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<k;i++){
        total+=arr[i];
    }
    cout<<total<<endl;

    return 0;

}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    int mx[2],my[2];
    my[0] = y - r;
    my[1] = y + r;
    mx[0] = x - r;
    mx[1] = x + r;
    string ans = "Yes";
    rep(i,2) if(mx[i] < 0 || mx[i] > w || my[i] < 0 || my[i] > h) ans = "No";
    cout << ans << endl;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int a[10];
int x;
int main(){
    char c;
    while(cin>>c&&c!='\0'){
        if(c=='0') a[++x]=0;
        else if(c=='1') a[++x]=1;
        else if(x) x--;
    }
    if(x){
        for(int i=1;i<=x;i++) cout<<a[i];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int n = 5;
	  int[] dishes = new int[n];
	  int[] res = {Integer.MAX_VALUE, 0 };
	  
	  for (int i = 0; i < n; i++) {
		  dishes[i] = sc.nextInt();
	  }
	  
	  permutation(dishes, 0, n, res);
	  
	  System.out.println(res[0]);
  }
  
  private static void permutation(int[] nums, int begin, int end, int[] res) {
	  if (begin == end) {
		  int total = 0;
		  for (int i = 0; i < nums.length - 1; i++) {
			  total += (int)(Math.ceil(nums[i]/10.0) * 10.0);
		  }
		  res[0] = Math.min(res[0], total + nums[nums.length - 1]);
	  } else {
		  for (int i = begin; i < end; i++) {
			  swap(nums, i, begin);
			  permutation(nums, begin + 1, end, res);
			  swap(nums, i, begin);
		  }
	  }
  }
  
  private static void swap(int[] nums, int i, int j) {
	  int tmp = nums[i];
	  nums[i] = nums[j];
	  nums[j] = tmp;
  }
  
  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: 21300
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    vector<int> a;
    int p[3] = { 3, 5, 7 };
    for (int k = 3; k <= 9; k++) {
        int l = (int)pow(3, k);
        for (int i = 0; i < l; i++) {
            int t = 0;
            int s = i;
            int q[3] = {};
            for (int j = 0; j < k; j++) {
                t *= 10;
                t += p[s % 3];
                q[s % 3] = 1;
                s /= 3;
            }
            if (q[0] && q[1] && q[2]) a.push_back(t);
        }
    }

    int r = 0;
    for (auto& i : a) {
        if (i <= n) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, x = 0, mx = 0;
    string s;
    cin >> n >> s;
    fore(i,0,n) {
        x += (s[i]=='I'?1:-1);
        mx = max(mx, x);
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
a = []

gets.to_i.times do
  a << gets.to_i
end

prev_n = 0
os = false
res = 0

a.sort.each do |n|
  if n != prev_n
    if os
      res += 1
    end

    os = true
  else
    os = !os
  end

  prev_n = n
end

if os
  res += 1
end

puts res


Measured memory_bytes: 4528
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n, m, r, s = 0;
  cin >> n >> m;
  for(int i = 0; i < m; i++)
  {
    cin >> r;
    s += r;
  }
  if((n - s) >= 0)
    cout << (n - s);
  else
    cout << -1;
  return 0;
}

Measured memory_bytes: 3624
N=int(input())
s=[]
for i in range(N):
    s.append(int(input()))
s.sort()

if sum(s)%10!=0:
    ans=sum(s)
else:
    f=False
    for si in s:
        if si%10!=0:
            ans=sum(s)-si
            f=True
            break
    if not f:
        ans=0

print(ans)

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

bool comp(pii lhs, pii rhs) {
  return lhs.first > rhs.first;
}

/*
aとbを降順にソート
aの頭とbの頭を見て大きい方を行えばいい？？？
基本的にaの頭は投げない方がいい
つまり、bの方が大きい場合はずっとbを行って
9 2 2 2
10 9 9 9 9

a
46 62
40 43
35 44
31 79
28 83

b
28 83
31 79
46 62
35 44
40 43

*/
int n,h;
vector<int> a;
vector<int> b;

int main(){
  scanf("%d %d",&n,&h);
  REP(i,n){
    int k;
    scanf("%d",&k);
    a.push_back(k);
    scanf("%d",&k);
    b.push_back(k);
  }
  sort(a.begin(), a.end(),greater<int>());
  sort(b.begin(), b.end(),greater<int>());
  int cnt = 0;
  while(h > 0){
    if(b.size() == 0 || a[0] >= b[0]){
      cnt += h / a[0];
      if(h%a[0]) cnt++;
      break;
    }else{
      h -= b[0];
      b.erase(b.begin());
    }
    cnt++;
  }
  printf("%d\n",cnt);
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
ll a[200005];


int32_t main(){
    IOS;
    ll i,j,k,n,m;
    cin >> n >> k;
    fori(n){
        cin >> a[i];
    }
    for(i=k;i<n;i++){
        if(a[i] > a[i-k]) cout <<"Yes\n";
        else cout <<"No\n";
    }
} 

Measured memory_bytes: 5232
#include <iostream>
#include <cmath>
#include <string>
#include <stack>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

typedef long long llong;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	cout << a*b/2 << endl;

	return 0;
}



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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string N;
	int ans[2] = {0, 1};
	
	cin>>N;

	for(int i = 0; i < N.size(); i++){
		int a0 = min(ans[0] + N[i] - '0',  ans[1] + 10 - (N[i] - '0'));
		int a1 = min(ans[0] + N[i] - '0' + 1, ans[1] + 10 - (N[i] - '0' + 1));
		
		ans[0] = a0;
		ans[1] = a1;
	}
	
	
	cout<<ans[0]<<endl;
	
	return 0;
}

Measured memory_bytes: 1948
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int Y;
    int M;
    int D;
    cin >> Y >> M >> D;

    int ans = 0;
    int cur_Y = 1000;
    while(cur_Y > Y + 1){
      cur_Y --;
      if(cur_Y % 3 == 0){
        ans += 10 * 20;
      } else {
        ans += 5 * 20 + 5 * 19;
      }
    }

    int cur_M = 11;
    while(cur_M > M + 1){
      cur_M --;
      if(Y % 3 == 0){
        ans += 20;
      } else {
        if(cur_M % 2 == 0){
          ans += 19;
        } else {
          ans += 20;
        }
      }
    }

    int cur_D;
    if(M % 2 == 0 && Y % 3 != 0){
      ans += 20 - D;
    } else {
      ans += 21 - D; 
    }

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



Measured memory_bytes: 3072
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {
       
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] a = ReadLine().Split().Select(int.Parse).OrderBy(x=>x).ToArray();
            for (long i = 0; i < n-1;i++)
            {
                if(a[i] == a[i+1]){
                    WriteLine("NO");
                    return;
                }



            }

            WriteLine("YES");
        }

        
    }


    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }

        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }



		
    }
}



Measured memory_bytes: 34524
#include<stdio.h>
int main()
{
  int h,a;
  scanf("%d%d",&h,&a);
  int sum=0;
  int count=0;
  for(int i=0;i<h;i++)
  {
    sum+=a;
    count++;
    if(sum>=h)
    {
      printf("%d\n",count);
      break;
    }
  }
}

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

int main(){
  int N;
  string S;
  cin>>N;
  cin>>S;
  int x=0;
  int maxx=0;
  
  for (int i=0;i<N;i++){
    if(S.at(i)=='I'){
      x=x+1;
      maxx=max(maxx,x);
    }
    if(S.at(i)=='D'){
      x=x-1;
    }
  }
  cout<<maxx<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1000000000
int n,k,h[100005],f[100005];
int main()
{
    cin >> n >> k;
    for (int i=1;i<=n;i++)
    {
        cin >> h[i];
        f[i]=INF;
    }
    f[1]=0;
    for (int i=1;i<n;i++)
        for (int j=i+1;j<=min(n,i+k);j++)
            f[j]=min(f[j],f[i]+abs(h[i]-h[j]));
    cout << f[n];
    return 0;
}

Measured memory_bytes: 4388
# -*- coding: utf-8 -*-
# B - Narrow Rectangles Easy
# 標準入力の取得
W,a,b = list(map(int, input().split()))

# すでに連結しているかどうかで場合分け
is_connected = (a <= b + W) and (b <= a + W)
if is_connected:
    print(0)
else:
    print(min(abs(b-(a+W)), abs(a-(b+W))))

Measured memory_bytes: 2940
function Main(arg)
{
  var a = arg.split("\n")[0].split(" ")[0]-0;
  var b = arg.split("\n")[0].split(" ")[1]-0;
 
  if (a < b) {
    console.log(a.toString().repeat(b));
  }
  else {
    console.log(b.toString().repeat(a));
  }

  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        int D = Integer.parseInt(sl[0]);

        out.println(D == 25 ? "Christmas"
                    : D == 24 ? "Christmas Eve"
                    : D == 23 ? "Christmas Eve Eve"
                    : "Christmas Eve Eve Eve");

        out.flush();
    }
}


Measured memory_bytes: 21332
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {

	static char[] xx = new char[] {'S','H','C','D'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		}

	}
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
#define rp(i, n) for(int i = 0; i < n; i++)
#define rp2(i, a, n) for(int i = a; i < n; i++)

using namespace std;
using ll = long long;

const int INF = 1001000000;

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n);
    rp(sv, n){
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d){
            if(dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while (!q.empty())
        {
            int v = q.front(); q.pop();
            int d = dist[v];
            if(v-1 >= 0) push(v-1, d+1);
            if(v+1 < n) push(v+1, d+1);
            if(v == x) push(y, d+1);
            if(v == y) push(x, d+1);
        }
        rp(i, n) ans[dist[i]]++;
    }
    rp(i,n) ans[i] /= 2;
    for(int i = 1; i <= n-1; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_AtCoder
{

    
    class Program
    {      

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());

            int num = 1;
            for(int i = 0; i < N; i++)
            {
                if (num * 2 < num + K) num *= 2;
                else num += K;
            }

            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 13140