akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt","r",stdin);
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
void read(int &val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int INF = 0x3f3f3f3f;
const int maxn=1e6+7;
const int mod=1e9+7;
typedef long long LL;
struct node{
    int l,r,sum;
}T[maxn*40];
int n,q,a[maxn],cnt,root[maxn],pos[1000005];
void update(int &now,int pre,int val,int l,int r,int pos){
    T[++cnt]=T[pre],T[cnt].sum+=val,now=cnt;
    if(l==r) return;
    int mid=l+r>>1;
    if(pos<=mid) update(T[now].l,T[pre].l,val,l,mid,pos);
    else update(T[now].r,T[pre].r,val,mid+1,r,pos);
}
int query(int L,int R,int l,int r,int rt){
    if(L<=l&&R>=r) return T[rt].sum;
    int ans=0,mid=l+r>>1;
    if(L<=mid) ans+=query(L,R,l,mid,T[rt].l);
    if(R>mid) ans+=query(L,R,mid+1,r,T[rt].r);
    return ans;
}
int main(){
    scanf("%d",&n); scanf("%d",&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        if(pos[a[i]]){
            update(root[i],root[i-1],-1,1,n,pos[a[i]]);
            update(root[i],root[i],1,1,n,i);
        }else update(root[i],root[i-1],1,1,n,i);
        pos[a[i]]=i;
    }

    while(q--){
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",query(l,r,1,n,root[r]));
    }
    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  int sum = 0;
  vector<int> taste(N);
  for (int i=0; i<N ; i++){
    taste.at(i) = L + i;
  }
  
  if(L > 0){
    for (int i=0; i<N; i++){
      if(i == 0){
        continue;
      }
      else sum += taste.at(i);
    }
  }
  else {
    if (L * (-1) < N){
      for(int i=0; i<N ; i++){
        sum += taste.at(i);
      }
    }
    else {
      for(int i=0; i<N; i++){
        if ( i == N-1){
          break;
        }
        sum += taste.at(i);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        Map<String, Long> map = new HashMap<>();
        map.put("M",0L);
        map.put("A",0L);
        map.put("R",0L);
        map.put("C",0L);
        map.put("H",0L);

        for (int i = 0; i < n; i++){
            String s = String.valueOf(sc.next().charAt(0));
            if (map.containsKey(s)) {
                map.put(s, map.get(s) + 1);
            }
        }
        long sum = 0;

        sum += map.get("M")*map.get("A")*map.get("R");
        sum += map.get("M")*map.get("A")*map.get("C");
        sum += map.get("M")*map.get("A")*map.get("H");
        sum += map.get("M")*map.get("R")*map.get("C");
        sum += map.get("M")*map.get("R")*map.get("H");
        sum += map.get("M")*map.get("C")*map.get("H");
        sum += map.get("A")*map.get("R")*map.get("C");
        sum += map.get("A")*map.get("R")*map.get("H");
        sum += map.get("A")*map.get("C")*map.get("H");
        sum += map.get("R")*map.get("C")*map.get("H");

        System.out.println(sum);
    }
}

Measured memory_bytes: 49132
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  // 次のmapには，言った数字とその登場回数をメモ
  map<int, int> memo;
  for (int i=0; i<N; i++) {
    if (memo.count(A[i])) memo[A[i]]++;
    else memo[A[i]] = 1;
  }
  int ans = 0;
  for (auto p: memo) {
    auto k = p.first;
    auto v = p.second;
    if (v%2!=0) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

void solve() {
    long long n,m, ans = 0;
    cin >> n >> m;
    ans = min(n, m/2);
    n = n - ans;
    m = m - ans*2;
    if (n == 0) {
        ans += m / 4;
        cout << ans;
        return;
    } else {
        cout << ans;
        return;
    }


}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 3132
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    String[] s = scanner.next().split("");
    ArrayList<String> result = new ArrayList<>();
    
    for(int i = 0; i < s.length; i++) {
      if(s[i].equals("0") || s[i].equals("1")) {
        result.add(s[i]);
      } else if(result.size() >= 1) {
        result.remove(result.size() - 1);
      }
    }
    
    for(String r: result) {
      System.out.print(r);
    }
  }
}

Measured memory_bytes: 35564
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50, vector<int>(4, 0));

int N, Y;
int mode = 0;

//tuple<int, int, int> calc(int A, int B, int C) {}



int main() {
	cin >> N >> Y;
	rep(i, 0, N + 1) {
		rep(j, 0, N - i + 1) {
			int tot = (Y - (i * 10000 + j * 5000))/1000;
			if (tot == N - (i + j)) {
				cout << i << " " << j << " " << tot << '\n';
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << '\n';
	return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */

int main() {
	string S;
	cin >> S;
	string A = S.substr(0,2);
	string B = S.substr(2,2);

	int a = stoi(A);
	int b = stoi(B);
	if ((a == 0) or (b == 0)){
		if ((0 < b) and (b <= 12)){
			puts("YYMM");
		}else if (((0 < a) and (a <= 12))){
			puts("MMYY");
		}else{
			puts("NA");
		}

		return 0;
	}

	if ((a <= 12) and (b <= 12)){
		puts("AMBIGUOUS");
	}else if (a<=12) {
		puts("MMYY");
	}else if (b<=12){
		puts("YYMM");
	}else{
		puts("NA");
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int n,m,t,d;
int ba[9][30];

bool go() {
  int p = m;
  REP(i,d) {
    if (p>0&&ba[p-1][i]) p--;
    else if (p<n-1&&ba[p][i]) p++;
  }
  return (p==t);
}
int main() {
  while(cin>>n,n) {
    cin>>m>>t>>d;
    m--;
    t--;
    REP(i,d) {
      REP(j,n-1) {
        char c;
        cin >> c;
        ba[j][i] = c-'0';
      }
    }
    if (go()) {
      cout << 0 << endl;
      continue;
    }
    int f = 0;
    REP(i,d) {
      REP(j,n-1) {
        if (ba[j][i]) continue;
        if (j>0&&ba[j-1][i] || j<n-2&&ba[j+1][i]) continue;
        ba[j][i] = 1;
        if (go()) {
          printf("%d %d\n",i+1,j+1);
          f = 1;
          break;
        }
        ba[j][i] = 0;
      }
      if (f) break;
    }
    if (f==0)
      cout << 1 << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count = 0;
  string S;
  cin >> S;
  char c;
  for(int i = 0; i < 4; i++){
    c = S.at(i);
    if (c == '+'){
      count += 1;
    }
    else{
      count -= 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/**
 *   Author: praveen_ojha
 *   Created: 16 January 2019
 *   Time: 19:02:07
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define MAX 100005
int a[MAX][3];
int dp[100005][4];
int n;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
    	cin>>a[i][0]>>a[i][1]>>a[i][2];
    
    function<int(int,int)> solve =[&](int day,int act){
	if(day==n){
		//cnt0=cnt1=cnt2=0;
		return 0;
	}	if(dp[day][act]!=-1)
		return dp[day][act];

		int ans0=0,ans1=0,ans2=0;
		if(act!=0){
		//cnt0++;
		dp[day+1][0]=solve(day+1,0);
		ans0=a[day][0]+dp[day+1][0];
		//cnt0=0;
		}
		if(act!=1){
		//cnt1++;
		dp[day+1][1]=solve(day+1,1);
		ans1=a[day][1]+dp[day+1][1];
		//cnt1=0;
		}
		if(act!=2){
		//cnt2++;
		dp[day+1][2]=solve(day+1,2);
		ans2=a[day][2]+dp[day+1][2];
		//cnt2=0;
		}
		//cout<<"Max at end of day "<<day<<" "<<max(ans0,max(ans1,ans2))<<"\n";
		return max(ans0,max(ans1,ans2));
	
};
    cout<<solve(0,3);
    // for(int i=0;i<n;i++)
    // 	cout<<a[i][0]<<" "<<a[i][1]<<" "<<a[i][2]<<"\n";

return 0;
}

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

int main() {
  int n;
  int x;
  int array[n];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    array[i] = x;
  }
  int max;
  max = array[0];
  for (int i = 1; i < n; i++) {
    if (array[i] > max) {
      max = array[i];
    }
  }
  // cout << max << endl;

  int minimum;
  minimum = array[0];
  for (int i = 1; i < n; i++) {
    if (array[i] < minimum) {
      minimum = array[i];
    }
  }
  cout << max - minimum << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
for i in range(Q):
    B[i], C[i] = map(int,input().split())
    
num = [0]*100000
for i in range(len(A)):
    num[A[i]-1] += 1
    
S =[sum(A)]
for i in range(Q):
    S.append(S[i]+(C[i]-B[i])*num[B[i]-1])
    num[C[i]-1] += num[B[i]-1]
    num[B[i]-1] = 0
 
S.pop(0)    
for i in range(Q):
    print(S[i])

Measured memory_bytes: 27408
s = list(input())
s.sort()
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'r', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in a:
    if i not in s:
        print(i)
        exit()
print('None')

Measured memory_bytes: 10104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  ll ans = 1;
  ll X = 0, Y = 0, Z = 0;
  for (ll i = 0; i < N; i++)
  {
    ll tmp = 0;
    if (A.at(i) == X)
      tmp++;
    if (A.at(i) == Y)
      tmp++;
    if (A.at(i) == Z)
      tmp++;
    
    if (A.at(i) == X)
      X++;
    else if (A.at(i) == Y)
      Y++;
    else if (A.at(i) == Z)
      Z++;

    ans *= tmp;
    ans %= MOD;

    //cerr << tmp << endl;
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  list<int> b;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i%2 == 0) {
      b.push_back(a);
    }
    else {
      b.push_front(a);
    }
  }
  if (n%2 == 1) {
    b.reverse();
  }
  auto i = b.begin();
  int x = *i;
  cout << x;
  i++;
  while (i != b.end()) {
    x = *i;
    cout << " " << x;
    i++;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 8448
def main():
    n = int(input())
    n_f = n
    f = 0
    for i in range(8):
        if n >= 10: 
            f += n % 10
            n  = n // 10
        else:
            f += n % 10
            break
    if n_f % f == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()
    


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if ((a[i] + a[j] > a[k])  && (a[i] + a[k] > a[j]) && (a[k] + a[j] > a[i]) && (a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
def main():                                                                     
  n = int(raw_input())                                                          
  data = {}                                                                     
                                                                                
  for a in xrange(1,n):                                                         
      b = n-a                                                                   
      if a == b:                                                                
          continue                                                              
      data[(min(a,b), max(a, b))] = 1                                           
                                                                                
  print(len(data.keys()))                                                       
                                                                                
main()

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	cin >>n;
	VI h(n);
	rep(i,n) cin >>h[i];
	int nw=0;
	rep(i, n){
		if(h[i] >=nw) ans++;
		nw = max(nw, h[i]);
	}
	
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

long solve(long N, long X) {
    long ans = N;
    long nX = N - X;
    long big = max(X, nX);
    long small = min(X, nX);
    X = big;
    nX = small;
    
    while(X % nX) {
        ans += nX * (X / nX * 2);
        long temp = X % nX;
        X = nX;
        nX = temp;
    }
    return ans + nX * (X / nX * 2 - 1);
}

int main() {
    long N;
    long X;
    cin >> N >> X;
    
    long ans = solve(N, X);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);
    int ans=0,id;
    int N,M;
    int a[52],b[520],c[52],d[52];

int main(){
    ios_base::sync_with_stdio(false);
    REP(i,3)cin>>a[i];
    ans++;
    a[0]!=a[1]?ans++:ans=ans;
    a[2]!=a[1]&&a[2]!=a[0]?ans++:ans=ans;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
    long long n, m, k;
    cin >> n >> m >> k;
    vector<long long> a(n), b(m);
    for (auto &i : a) cin >> i;
    for (auto &i : b) cin >> i;

    vector<long long> prefa(n), prefb(m);
    prefa[0] = a[0], prefb[0] = b[0];
    for (int i = 1; i < n; i++) prefa[i] = a[i] + prefa[i - 1];
    for (int i = 1; i < m; i++) prefb[i] = b[i] + prefb[i - 1];

    int ans = distance(prefb.begin(), upper_bound(prefb.begin(), prefb.end(), k)); 
    for (int i = 0; i < n; i++)
    {
        if (prefa[i] <= k) {ans = max(ans, i + 1 + (int)distance(prefb.begin(), upper_bound(prefb.begin(), prefb.end(), k - prefa[i])));}
    }
    cout << ans << endl;
    return 0; 
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, 0, n){
        cin >> l[i];
    }
    sort(all(l));
    int ans = 0;
    rep(i, 0, n){
        rep(j, i + 1, n){
            auto s = lower_bound(all(l), l[j] + l[i]);
            ans += s - l.begin() - j - 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
XYI = [tuple(map(int,input().split() + [i])) for i in range(N)]
sx = sorted(XYI, key=lambda x:x[0])
sy = sorted(XYI, key=lambda x:x[1])

es = []
for (x0,_,i0),(x1,_,i1) in zip(sx,sx[1:]):
    es.append((x1-x0, i0, i1))
for (_,y0,i0),(_,y1,i1) in zip(sy,sy[1:]):
    es.append((y1-y0, i0, i1))
es.sort(key=lambda x:x[0])

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]
uf = UnionFind(N)

ans = 0
for d,a,b in es:
    if uf.is_same(a,b): continue
    uf.unite(a,b)
    ans += d
print(ans)

Measured memory_bytes: 53224
using System;


public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ss = new int[n];
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++) ss[i] = int.Parse(line[i]);

        var n2 = int.Parse(Console.ReadLine().Trim());
        var tt = new int[n2];
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n2; i++) tt[i] = int.Parse(line2[i]);
        var count = 0;
        foreach (var x in tt)
            if (BS(ss,x)) count++;
        Console.WriteLine(count);

    }
    public static  bool  BS (int[] a  , int b)
    {
        var left = 0;
        var right = a.Length;
        while (left < right)
        {
            var mid = (left + right) / 2;
            if (a[mid] == b) return true;
            else if (b < a[mid]) right = mid;
            else left = mid + 1;
        }
        return false;
    }
}

Measured memory_bytes: 22144
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a = int(input())
b = int(input())
c = int(input())
x = int(input())
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<cstring>
using namespace std;
const int N = 20;
int a[N];
int x[N][N];
bool y[N][N];
int check[N];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		for(int j=1;j<=a[i];j++){
			cin>>x[i][j]>>y[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		memset(check,0,sizeof(check));
		bool ok=true;
		for(int l=1;l<=n;l++){
			for(int j=1;j<=n;j++){
				if((i&(1<<(j-1)) && check[j]==1) || (!i&(1<<(j-1)) && check[j]==2)){
					ok=false;
					break;
				}
				if(i&(1<<(j-1)) || check[j]==2){
					for(int k=1;k<=a[j];k++){
						if(y[j][k]){
							if(check[x[j][k]]==1){
								ok=false;
							}
							else{
								check[x[j][k]]=2;
							}
						}
						else{
							if(check[x[j][k]]==2){
								ok=false;
							}
							else{
								check[x[j][k]]=1;
							}
						}
					}
				}
			}
		}
		if(ok){
			int cnt=0;
			for(int j=1;j<=n;j++){
				if(i&(1<<(j-1))){
					cnt++;
				}
			}
			ans=max(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, a, b, c = [int(i) for i in input().split()]

l = []
for i in range(n):
    l.append(int(input()))


def calc(q):
    score = 0
    x = y = z = 0
    xflag = yflag = zflag = False
    for i in range(n):
        if q[i] == 0:
            x += l[i]
            if xflag:
                score += 10
            xflag = True
        elif q[i] == 1:
            y += l[i]
            if yflag:
                score += 10
            yflag = True
        elif q[i] == 2:
            z += l[i]
            if zflag:
                score += 10
            zflag = True
    if xflag and yflag and zflag:
        return abs(a-x) + abs(b-y) + abs(c-z) +score
    else:
        return 100000000000000


ans = 100000000000000
def dfs(q):
    global ans
    if len(q) >= n:
        res = calc(q)
        ans = min(ans,res)
        return
    else:
        for i in range(4):
            q.append(i)
            dfs(q)
            q.pop(-1)
    return ans


dfs([])

print(dfs([]))



Measured memory_bytes: 3064
n, p = map(int, input().split())
A = list(map(int, input().split()))
A = [a%2 for a in A]
if sum(A) == 0:
    print(pow(2, n) if p==0 else 0)
elif n>=2:
    print(pow(2, n)//2)
else:
    print(1 if A[0]==p else 0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	ll N,K; cin>>N>>K;
	vi vec(0);
	map<ll,ll> mp;
	rep(i,0,N){
		ll a,b; cin>>a>>b;
		mp[a]+=b;
	}
	ll ans=0;
	for(auto p:mp){
		K-=p.second;
		if(K<=0){
			ans=p.first;
			break;
		}
	}
	//sort(all(vec));
	cout<<ans;
	
	
}

Measured memory_bytes: 7544
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int a, b, c;

signed main() {

	cin >> a >> b >> c;

	cout << max(0LL, c - (a - b)) << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        ArrayList<Long> F = new ArrayList<>();
        ArrayList<Long> L = new ArrayList<>();
        StringBuilder opt = new StringBuilder();
        for(int i=0;i<q;i++){
            int cmd = sc.nextInt();
            int cmd1 = sc.nextInt();
            if(cmd==0){
                if(cmd1==0)F.add(sc.nextLong());
                else L.add(sc.nextLong());
            }
            else if(cmd==2){
                if(cmd1==0){
                    if(F.size()!=0)F.remove(F.size()-1);
                    else L.remove(0);
                }
                else{
                    if(L.size()!=0)L.remove(L.size()-1);
                    else F.remove(0);
                }
            }
            else{
                if(cmd1>F.size()-1)opt.append(L.get(cmd1-F.size())+"\n");
                else opt.append(F.get(F.size()-1-cmd1)+"\n");
            }
        }
        System.out.print(opt);
    }
}


Measured memory_bytes: 304552
r,g,b,n = map(int,input().split())
ans = 0
for i in range((n//r)+1):
         for j in range(((n-(r*i))//g)+1):
                  if (n-(r*i+g*j))%b == 0 or (n-(r*i+g*j)) == 0:
                           ans += 1
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
    int h,i,j,w;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(j=0;j<w;j++){
            printf("#");
        }
        printf("\n");
        for(i=1;i<h-1;i++){
            printf("#");
            for(j=1;j<w-1;j++){
                printf(".");
            }
            printf("#\n");
        }
        for(j=0;j<w;j++){
            printf("#");
        }
        printf("\n\n");
    }
    return 0;
}


Measured memory_bytes: 2576
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    ll res = 0;
    for(int i = 0; i < n; i++){
        res = res ^ a[i];
    }
    for(int i = 0; i < n; i++){
        cout << (res ^ a[i]) << " ";
    }
    cout << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4768
import std.algorithm, std.conv, std.range, std.stdio, std.string;

alias graph = Graph!(long, size_t, 10L ^^ 18);
alias edge = graph.Edge;

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];

  auto g = new edge[][](n);
  foreach (_; 0..m){
    auto rd2 = readln.split, a = rd2[0].to!size_t-1, b = rd2[1].to!size_t-1, c = rd2[2].to!long;
    g[a] ~= edge(a, b, -c);
  }

  auto dist = graph.bellmanFord(g, 0), d = dist[n-1];
  if (d <= -graph.inf)
    writeln("inf");
  else
    writeln(-d);
}

template Graph(Wt, Node, Wt _inf = 10 ^^ 9, Node _sent = Node.max)
{
  const inf = _inf, sent = _sent;

  struct Edge
  {
    Node src, dst;
    Wt wt;
  }

  Wt[] bellmanFord(Edge[][] g, Node s)
  {
    Wt[] dist;
    Node[] prev;
    bellmanFord(g, s, dist, prev);
    return dist;
  }

  void bellmanFord(Edge[][] g, Node s, out Wt[] dist, out Node[] prev)
  {
    auto n = g.length;

    dist = new Wt[](n);
    dist[] = inf + inf;
    dist[s] = 0;

    prev = new Node[](n);
    prev[] = sent;

    foreach (k; 0..n)
      foreach (i; 0..n)
        foreach (e; g[i])
          if (dist[e.dst] > dist[e.src] + e.wt) {
            dist[e.dst] = dist[e.src] + e.wt;
            prev[e.dst] = e.src;
            if (k == n-1) dist[e.dst] = -inf;
          }
  }
}


Measured memory_bytes: 2428
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//メモ化：n^2なので間に合わない

struct Factorial{
	long long N,mod;
	vector<long long> fact,inv;
	long long mod_pow(long long x,long long n){
		long long res=1;
		while(n){
			if(n&1) (res*=x)%=mod;
			(x*=x)%=mod;
			n>>=1;
		}
		return res;
	}
	long long Inverse(long long n){
		return mod_pow(n,mod-2);
	}
	Factorial(){}
	Factorial(long long sn,long long smod){
		N=sn; mod=smod;
		fact.reserve(sn+1); inv.reserve(sn+1);
		//初期化
		fact[0]=1;
		for(int i=1;i<=sn;i++){
			fact[i]=(fact[i-1]*i) % mod;
		}
		inv[sn]=Inverse(fact[sn]);
		for(int i=sn;i>0;i--){
			inv[i-1]=(inv[i]*i) % mod;
		}
	}
	long long Fact(long long n){
		if(n<0)return 0;
		return fact[n];
	}
	long long Inv(long long n){
		if(n<0)return 0;
		return inv[n];
	}
	long long Combination(long long n,long long r){
		if(n<r)return 0;
		if(r<0)return 0;
		if(r==0)return 1;
		long long ans=1;
		ans = (ans*Fact(n)) % mod;
		ans = (ans*Inv(r)) % mod;
		ans = (ans*Inv(n-r)) % mod;
		return ans;
	}
	long long plus(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a+b)%mod;
	}
	long long minus(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a+mod-b)%mod;
	}
	long long mul(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a*b)%mod;
	}
	long long div(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a*Inverse(b))%mod;
	}
};

int main(void){
	ll n,a[100010],sum[100010],ans=0;
	Factorial f(100010,1e9+7);
	sum[0]=0;
	cin>>n;
	reg(i,1,n){
		cin>>a[i];
		sum[i]=f.div(1,i)+sum[i-1];
	}
	reg(i,1,n)ans=f.plus(ans,f.mul(f.plus(sum[abs(i-1+1)],sum[abs(n-i+1)])-1,a[i]));
	ans=f.mul(ans,f.Fact(n));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(){
	int a;
  	cin>>a;
  	int square_a{};
  	int cube_a{};
  	square_a=a*a;
  	cube_a=a*a*a;
  	cout<<a+square_a+cube_a<<endl;
 	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int x, y;
  cin >> x >> y;
  int ans = x + (y/2);
  cout << ans << endl;
}

Measured memory_bytes: 3624
#Circle in a Rectangle
w, h, x, y, r= gets.split.map(&:to_i)
cs = r * r * 3.14
rs = w * h
xmax = x + r
ymax = y + r

if rs < cs
  puts "No"
elsif x < 0 || y < 0
  puts "No"
elsif w < xmax  || h < ymax
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 8664
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int n, k, x, y, anser;
  cin >> n >> k >> x >> y;
  if (n <= k) {
    anser = n * x;
  } else {
    anser = k * x + (n - k) * y;
  }
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
l = []
for i in range(N):
    a,b = map(int,input().split())
    l.append([a,b])
add = 0
for i in range(N-1,-1,-1):
    if (l[i][0] + add) % l[i][1] == 0:
        continue
    add += l[i][1] - (l[i][0] + add) % l[i][1]
print(add)

Measured memory_bytes: 19616
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main () {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  
  if (a==0) cout << 1 << endl;
  if (b==0) cout << 2 << endl;
  if (c==0) cout << 3 << endl;
  if (d==0) cout << 4 << endl;
  if (e==0) cout << 5 << endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>

using namespace std;

//5 3
//8
//1
//7
//3
//9
int check(int N[], int n, int k, int w) {
	int i = 0;
	for (int j = 0; j < k; ++j) {
		int s = 0;
		while (s + N[i] <= w) {
			s += N[i];
			++i;
			if (i == n)
				return n;
		}
	}
	return i;
}

int main() {

	int MAX_W = 1000000000;

	int n, k;
	scanf("%d %d", &n, &k);

	int N[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &N[i]);
	}

	int left = 0;
	int right = MAX_W;
	while (left < right) {
		int mid = (left + right) / 2;
		if (check(N, n, k, mid) == n) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	cout << right << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> L = {2, 1};
  if (N==0)
    cout << 2 << endl;
  else if (N==1)
    cout << 1 << endl;
  else {
    for (int i=0; i<N-1; i++) {
      L.push_back(L.at(i)+L.at(i+1));
    }
    cout << L.at(N) << endl;
  }
}


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

int main(){
	int A, B;
	scanf("%d%d", &A, &B);
	printf("%d\n", (B-1) / (A-1) + (bool)((B-1) % (A-1)));
	return 0;
}

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

int main(void){
	char taro[N],hana[N];
	int i,n,hik,taroP=0;
	int hanaP=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",taro,hana);
		hik=strcmp(taro,hana);
		if(hik>0)taroP=taroP+3;
		else if(hik<0)hanaP=hanaP+3;
		else{
			taroP++;
			hanaP++;
		}
	}
	printf("%d %d\n",taroP,hanaP);
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define ll long long
#define Mod 1000000007
#define N 2004

using namespace std;

int n, m;
ll f[N][N];
int s[N], t[N];

int main(){
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		scanf("%d", s + i),f[i][0] = 1;
	for (int i = 1; i <= m; ++i)
		scanf("%d", t + i),f[0][i] = 1;
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			(f[i][j] += (f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1]) % Mod) %= Mod;
			if (s[i] == t[j])
				(f[i][j] += f[i - 1][j - 1]) %= Mod;
		}
	}

	cout << (f[n][m] % Mod + Mod) % Mod << endl;
	return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;

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

  if(n < 10){
    cout << 100 * (10 -n) + r << endl;
  }
  else if(n >= 10){
    cout << r;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char str[10005];
int main()
{
	int N;
	scanf("%d",&N);
	scanf("%s",str);
	for(int i=0;i<strlen(str);i++)
	 {
	 	str[i]=str[i]+N;
	 	if(str[i]>'Z')
	 	str[i]=str[i]-'Z'+'A'-1;
	 }
	printf("%s\n",str);
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 220000
inline char gc(){
	static char now[1<<16],*S,*T;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
#define S 1<<19
inline int read(){
	int x=0,f=1;char ch=gc();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=gc();}
	while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
	return x*f;
}
int f1[S],f2[S],n,num,bin[20],st[N],a[N],right[N][20],left[N][20],v;
int main(){
//	freopen("agc.in","r",stdin);
	n=read();v=read();int Log=0;
	for (int i=1;i<=n;++i) a[i]=read();
	while ((1<<Log)<=v) Log++;Log++;
	for (int i=0;i<=Log+1;++i) bin[i]=1<<i;
	num=1;for (int i=2;i<=n;++i) if (a[i]-a[i-1]>v) num++;
	for (int j=0;j<Log;++j){
		left[1][j]=1;right[n][j]=n;
		for (int i=2;i<=n;++i) if (a[i]-a[i-1]>(v>>j)) left[i][j]=i;else left[i][j]=left[i-1][j];
		for (int i=n-1;i>=1;--i) if (a[i+1]-a[i]>(v>>j)) right[i][j]=i;else right[i][j]=right[i+1][j];
	}	
	/*for (int j=0;j<Log;++j){
		for (int i=1;i<=n;++i) printf("%d ",right[i][j]);printf("\n");
		for (int i=n;i>=1;--i) printf("%d ",left[i][j]);printf("\n");
	}*/
	if (num>Log){
		for (int i=1;i<=n;++i) printf("Impossible\n");return 0;
	}
	for (int s=0;s<=bin[Log]-1;++s) {f1[s]=0,f2[s]=n+1;}
	for (int s=0;s<=bin[Log]-1;++s){
		for (int i=0;i<Log;++i){
			if (s&bin[i])continue;
			if (f1[s]==n) f1[s|bin[i]]=n;else f1[s|bin[i]]=max(f1[s|bin[i]],right[f1[s]+1][Log-i-1]);
			if (f2[s]==1) f2[s|bin[i]]=1;else f2[s|bin[i]]=min(f2[s|bin[i]],left[f2[s]-1][Log-i-1]);
		}
	}for (int i=0;i<=n;++i) st[i]=n+2;
	for (int s=0;s<=bin[Log-1]-1;++s){
		int s1=(bin[Log-1]-1)^s;
		st[f1[s]]=min(st[f1[s]],f2[s1]);
	} for (int i=n-1;i>=0;--i) st[i]=min(st[i],st[i+1]);
	//for (int i=0;i<=n;++i) printf("%d ",st[i]);printf("\n");
	for (int i=1;i<=n;++i){
		int l=left[i][0],r=right[i][0];
		if (st[l-1]<=r+1) printf("Possible\n");else printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 42496
N = int(input())
A = list(map(int,input().split()))
M = 1000001
cnt = [0]*M
ans = 0
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x,M,x):
        cnt[i] += 1
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)

    


Measured memory_bytes: 32024
_n, m = gets.split.map(&:to_i)

data = m.times.map.with_index do |i|
  p, y = gets.split.map(&:to_i)
  [p, i, y]
end

data
  .group_by(&:first)
  .each_value do |cities|
    cities
      .sort_by(&:last)
      .each.with_index(1) {|(_p, data_index, _y), order| data[data_index][2] = order }
  end

data.each {|p, _i, y| puts "%06d%06d" % [p, y] }


Measured memory_bytes: 24444
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a;
  if(a%10==a/100) cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e15+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;
    int n,k;
    cin>>n>>k;
    int arr[n];
    rep(i,n) in arr[i];
    for(int i=1;i<n-k+1;i++){
        if(arr[i-1]<arr[k+i-1])
            out "Yes";
        else out "No";
        out endl;
    }
return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 5220
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()){
				String str = sc.nextLine();
				String[] s = str.split(" ");
				Stack<Integer> stk = new Stack<Integer>();
				if(s.length > 2){
					for(int i=0;i<s.length;i++){
						if(s[i].toString().equals("*"))
							stk.push((stk.pop()*stk.pop()));
						else if(s[i].toString().equals("/")){
							int a=stk.pop(),b=stk.pop();
							stk.push(b/a);
						}
						else if(s[i].toString().equals("+"))
							stk.push((stk.pop()+stk.pop()));
						else if(s[i].toString().equals("-")){
							int a=stk.pop(),b=stk.pop();
							stk.push(b-a);
						}
						else{
							stk.push(Integer.valueOf(s[i].toString()));
						}
					}
					System.out.printf("%d\r\n",stk.pop());
				}
			}
	}
}


Measured memory_bytes: 26364
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] vals = in.nextIntArr(n);
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(vals[0] - vals[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(vals[i] - vals[i - 1]), dp[i - 2] + Math.abs(vals[i] - vals[i - 2]));
        }
        out.println(dp[n - 1]);
        out.close();

    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public String nextLine() throws IOException {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
                return nextLine();
            }

            String ret = "";
            while (st.hasMoreTokens()) {
                ret += st.nextToken();
            }
            return ret;
        }
        public int[] nextIntArr(int size) throws IOException {
            int[] arr = new int[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        public long[] nextLongArr(int size) throws IOException {
            long[] arr = new long[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        public double[] nextDoubleArr(int size) throws IOException {
            double[] arr = new double[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 43232
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  string s;
  cin >> s;
  bool ok = true;
  for (int i = 0; i < s.size(); i += 2) {
    if (s[i] != 'h' || s[i + 1] != 'i') {
      ok = false;
      break;
    }
  }
  print(ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int n,max_num = -1000001,min_num = 1000001,tmp;
    long long int sum = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&tmp);
        sum += tmp;
        max_num = max(max_num,tmp);
        min_num = min(min_num,tmp);
    }
    printf("%d %d %lld\n",min_num,max_num,sum);
}


Measured memory_bytes: 2744
#include <stdio.h>

int main() {
    int a,b,c;
    int temp;
    scanf("%d %d %d",&a,&b,&c);
    temp = a;
    a = b;
    b = temp;

    temp = a;
    a = c;
    c = temp;
    printf("%d %d %d", a,b,c);
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;

int X, Y, Z, K;
ll A[1100], B[1100], C[1100];
std::vector<ll> D;
std::priority_queue<ll, std::vector<ll>, std::greater<ll>> pq;
std::stack<ll> st;

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

    std::cin >> X >> Y >> Z >> K;

    for(int i=0;i<X;++i){
        std::cin >> A[i];
    }

    for(int i=0;i<Y;++i){
        std::cin >> B[i];
    }

    for(int i=0;i<Z;++i){
        std::cin >> C[i];
    }

    std::sort(A, A + X);
    std::reverse(A, A + X);

    D.resize(Y * Z);

    for(int i=0;i<Y;++i){
        for(int j=0;j<Z;++j){
            D[i * Z + j] = B[i] + C[j];
        }
    }

    std::sort(D.rbegin(), D.rend());

    for(int i=0;i<std::min(X, K);++i){
        for(int j=0;j<Y*Z&&i+j<K;++j){
            if(pq.size() < K){
                pq.emplace(A[i] + D[j]);
            }else if(pq.top() < A[i] + D[j]){
                pq.emplace(A[i] + D[j]);
                pq.pop();
            }
        }
    }
    
    until(pq.empty()){
        st.emplace(pq.top());
        pq.pop();
    }

    until(st.empty()){
        std::cout << st.top() << std::endl;
        st.pop();
    }
}


Measured memory_bytes: 8192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> k;
	vector<ll>	aa(n);
	for(i=0;i<n;i++) cin >> aa[i];
	vector<ll>	dp(n+1),an(n+1);
	for(i=0;i<n;i++) dp[i+1] = dp[i] + aa[i];
	for(i=k;i<=n;i++) {
		an[i] = dp[i] - dp[i-k];
	}
	for(i=k+1;i<=n;i++) {
		if (an[i-1] < an[i]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
//	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8008
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#define ff first
#define ss second
#define M 1000000007
typedef long long int ll;
using namespace std;
ll power(ll a,ll b){
    ll ans = 1;
    while(b>0){
        if(b%2!=0){
            ans = ((ans)*(a));
        }
        a = ((a)*(a));
        b=b/2;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector <ll> w(n);
    vector <ll> v(n);
    ll s = 0;
    for(ll i=0;i<n;i++){
        cin>>w[i]>>v[i];
        s+=v[i];
    }
    vector <ll> dp(s+1,1000000008);
    dp[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=s;j>=v[i];j--){
            dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
        }
    }
    ll ans = 0;
    for(ll i=0;i<=s;i++){
        if(dp[i]<=k)ans=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024