akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <unistd.h>
#include <random>
using namespace std;

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define Hardmode usleep(1.5 * 1000000);
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        if(s.at(i) == '9')s.at(i) = '1';
        else if(s.at(i) == '1')s.at(i) = '9';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
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(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        if(b>=a) out.println(c);
        else out.println(Math.max(0,c-(a-b)));
        
        
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
   int a,b,c,d;
   cin>>a>>b;
   c=b-a;
   d=0;
   rep(i,c+1){
     d+=i;
   }
  cout<<d-b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N; N %= 10;
  if(N == 3) cout << "bon" << endl;
  else if(N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3624
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n;
    scanf("%d",&n);
    if(n/100 == n%10){printf("Yes\n");}else{printf("No\n");}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  
  if(n%2==0){
    REP(i,n/2){
      if(s.at(2*i)=='L' || s.at(2*i+1)=='R'){
        cout <<"No"<<endl ;
        return 0 ;
      }
    }
  }
  else{
    if(s.at(n-1)=='L'){
      cout <<"No"<<endl ;
      return 0 ;
    }
    else{
    REP(i,n/2){
      if(s.at(2*i)=='L' || s.at(2*i+1)=='R'){
        cout <<"No"<<endl ;
        return 0 ;
      }
    }
    }
  }
  
  cout <<"Yes"<<endl ;


  return 0 ;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

p = s.count('.')
q = 0
r = p

for i in range(n):
    if s[i] == '#':
        q += 1
    else:
        p -= 1
    r = min(r, p + q)
    # r = r if r < p + q else p + q

print(r)

Measured memory_bytes: 61424
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

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


int main()
{
    int n;
    scanf("%d\n",&n);
    double x;
    long long int jp=0;
    double bt=0;
    char u[4];
    REP(i,n){
        scanf("%lf %s\n",&x,u);
        if(*u=='B'){
            bt+=x;
        }
        else{
            jp+=x;
        }
    }
    double sum=jp+bt*380000;
    printf("%lf\n",sum);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    string s;cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)

int main()
{
    int n,d;
    cin >> n >> d ;
    vector<vector<int>> x(n, vector<int>(d));
    REP(i, n){
        REP(j,d){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    REP(i, n - 1)
    {
        for (int j = i + 1; j < n; j++)
        {
            int v = 0;
            REP(k, d)
            {
                v += pow(x[i][k] - x[j][k], 2);
            }
            float v2 = sqrt((float)v);
            float v3 = (int)v2;
            if (v3-0.000000001<=v2 && v2 <= v3+0.000000001)
            {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}

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

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

    ll n,q;
    string s;
    cin >> n >> q >> s;
    vector<ll> l(q);
    vector<ll> r(q);
    for (ll i = 0;i < q;i++){
        cin >> l[i] >> r[i];
    }
    vector<ll> ac(n);
    int c = 0;
    ac[0] = 0;
    for (ll i = 0;i < n-1;i++){
        if (s[i] == 'A' && s[i+1] == 'C'){
            c++;
        }
        ac[i+1] = c;
    }
    /*for (ll i = 0; i < n; i++){
        cout << ac[i] << endl;
    }*/

    for (ll i = 0; i < q; i++){
        if (l[i] == 1){
            cout << ac[r[i]-1] << endl;
        }
        else if (s[l[i]-1] == 'C' && s[l[i]-2] == 'A'){
            cout << ac[r[i]-1] - ac[l[i]-2] -1 << endl;
        }
        else{
            cout << ac[r[i]-1] - ac[l[i]-2] << endl;
        }
    }
    
}

Measured memory_bytes: 5792
#include <iostream>
#include <math.h>
#define MAX 500000
using namespace std;
 
void merge(int[],int,int,int,int);
void mergeSort(int[],int,int,int);
int L[MAX/2+2],R[MAX/2+2];
int cnt;
 
int main(){
  int i,n;
  cnt = 0;
  int A[MAX];
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> A[i];
  }
  mergeSort(A,n,0,n);
  for(i = 0; i < n; i++){
    if(0 < i){
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl; 
  cout << cnt; 
  cout << endl;
  
  return 0;
}
void merge(int A[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i = 0,j = 0;
  for(k = left; k < right; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}
void mergeSort(int A[], int n, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;
const int mod = 1e9 + 7;

using namespace std;

const ll MAX = (ll)(1e18);

int main(void) {
	int N; cin >> N;
	vector<long double> A(N);
	rep(i, N) {
		cin >> A[i];
		if (A[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	long double ans = 1;
	bool flag = false;

	rep(i, N) {
		ans *= A[i];
		if (ans > MAX) {
			flag = true;
			break;
		}
	}

	if (flag)cout << -1 << endl;
	else printf("%lld\n", (ll)ans);

	return 0;
}

Measured memory_bytes: 4840
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		long[][] task = new long[N][2];
		for(int i=0;i<N;i++) {
			task[i][0] = nextLong();
			task[i][1] = nextLong();
		}

		Arrays.sort(task,(a1,a2)->Long.compare(a1[1],a2[1]));

		long cnt = 0;
		boolean f = true;
		for(int i=0;i<N;i++) {
			cnt += task[i][0];
			if(cnt > task[i][1]) {
				f = false;
				break;
			}
		}

		if(f)out.println("Yes");
		else out.println("No");
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 75856
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>

int INF = 1e14;
int mod = 1e9 + 7;

int power(int x, unsigned int y)
{
    int temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2) % mod;
    if (y & 1 == 0)
        return (temp * temp) % mod;
    else
        return x * ((temp * temp) % mod) % mod;
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int sum = 0;
        int fre[100001] = {0};
        rep(i, 0, n)
        {
            int temp;
            cin >> temp;
            fre[temp]++;
            sum += temp;
        }
        int q;
        cin >> q;
        while (q--)
        {
            int b, c;
            cin >> b >> c;
            sum -= b * fre[b];
            sum += c * fre[b];
            fre[c] += fre[b];
            fre[b] = 0;
            cout << sum << endl;
        }
    }

    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if (k <= (n + 1) / 2) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 256
// Last Change: 03/28/2020 21:09:16.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll K, N;
  cin >> K >> N;
  vector<ll> A(N);
  for (auto &&e : A) {
    cin >> e;
  }

  A.push_back(A[0] + K);

  vector<ll> dist(N + 1);
  for (int i = 0; i < N; ++i) {
    dist[i + 1] = A[i + 1] - A[i];
  }

  ll maxVal = 0;
  for (auto &&e : dist) {
    maxVal = max(maxVal, e);
  }

  cout << K - maxVal << endl;
}


Measured memory_bytes: 5084
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b,x;
 	cin >> a;
 	b=a;
 	while(a){
 		x+=a%10;
 		a=a/10;
 	}
 	if(b%x==0){
 		cout << "Yes" << endl;
 	}else{
 		cout << "No" << endl;
 	}
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    int count=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            count+=vec.at(i)*vec.at(j);
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int gcd(int a, int b)
{
    if (a % b == 0) return b;
    return gcd(b, a % b);
} 

int main()
{
    int a, b;
    while (cin >> a >> b) {
        cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;
    }
    return 0;
}

Measured memory_bytes: 3004
import numpy as np
N = int(input())
S = list(input())

Wleft = np.zeros(N, dtype = int)
Eright = np.zeros(N, dtype = int)
Eright[0] = (S.count("E") if S[0] == "W" else S.count("E") - 1)
for i in range(N-1):
    if S[i] == "W":
        Wleft[i+1] = Wleft[i]+1
    else:
        Wleft[i+1] = Wleft[i]
    if S[i+1] == "E":
        Eright[i+1] = Eright[i] - 1
    else:
        Eright[i+1] = Eright[i]
total = Wleft + Eright
print(np.min(total))

Measured memory_bytes: 22176
#include <iostream>
 #include <string> 
 using namespace std;
string s;
    int main(){ 
         int ans;
  
        cin >> s;
         if(s[0]=='1') ans++; 
         if(s[1]=='1') ans++; 
         if(s[2]=='1') ans++; 
         cout << ans << endl;
    }



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

int main() {
	long long a, b, c, d;
	cin>>a>>b>>c>>d;
	long long e, f, g, h;
	e = a*c; f = a*d; g = b*c; h = b*d;
	cout<<max(max(max(e,f), g), h);
	return 0;
}


Measured memory_bytes: 3648
N = int(input())
A = list(map(int,input().split()))

money = 1000
kabu = 0
p = [1]*N

for i in range(N-1):
  if A[i] < A[i+1]:
    p[i] = 0
  elif A[i] > A[i+1]:
    p[i] = 2

for i in range(N-1):
  if A[i] < A[i+1] and p[i] == 0 and kabu == 0:
    kabu = money//A[i]
    money -= (A[i]*kabu)
  elif A[i] > A[i+1] and p[i] == 2:
    money += (kabu*A[i])
    kabu = 0

money += (A[-1]*kabu)
print(money)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(){
    string S;
    cin >> S;
    int N;
    N = S.size();
    
    vector<int> mod10(N + 1); //10のi乗を2019で割ったあまり
    mod10.at(0) = 1;
    for(int i = 1; i < N + 1; i++){
        mod10.at(i) = (mod10.at(i-1) * 10) % 2019;
    }
    
    vector<int> mod(N + 1); //下からi桁目までを2019で割ったあまり
    mod.at(0) = 0;
    int tmp;
    for(int i = 1; i < N + 1; i++){
        tmp = S.at(N-i) - '0';
        mod.at(i) = (mod.at(i-1) + tmp * mod10.at(i-1)) % 2019;
    }
    
    vector<int> count(2019,0); //配列modで中身がiなものの個数
    for(int i = 0; i < N + 1; i++){
        count.at(mod.at(i))++;
    }
    
    ll ans = 0;
    for(int i = 0; i < 2019; i++){
        ans += count.at(i) * (count.at(i) - 1) / 2;
    }
    printf("%lld\n", ans);
    
}

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

int main(){
	int n,i,j;
	int cards[4][13]={0};
	char suit; //?????????
	int num;;
	
	cin>>n;
	
	for(i=0;i<n;i++){
		cin>>suit>>num;
		
		if(suit=='S'){
			cards[0][num-1]++;
		}else if(suit=='H'){
			cards[1][num-1]++;
		}else if(suit=='C'){
			cards[2][num-1]++;
		}else{
			cards[3][num-1]++;
		}
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(cards[i][j]==0){
				if(i==0){
					cout<<'S'<<" "<<j+1<<endl;
				}else if(i==1){
					cout<<'H'<<" "<<j+1<<endl;
				}else if(i==2){
					cout<<'C'<<" "<<j+1<<endl;
				}else{
					cout<<'D'<<" "<<j+1<<endl;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3092
class Tree():
    def __init__(self):
        self.root = None
    def insert(self, key):
        z = Node(key)
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def print(self):
        print('', ' '.join(map(str, self.root.inwalk())))
        print('', ' '.join(map(str, self.root.prewalk())))


class Node():
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None

    def prewalk(self):
        ret = [self.key]
        if self.left:
            ret += self.left.prewalk()
        if self.right:
            ret += self.right.prewalk()
        return ret

    def inwalk(self):
        ret = []
        if self.left:
            ret += self.left.inwalk()
        ret += [self.key]
        if self.right:
            ret += self.right.inwalk()
        return ret


tree = Tree()
n = int(input())
for i in range(n):
    com = input().split()
    if len(com) == 2:
        tree.insert(int(com[1]))
    else:
        tree.print()


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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin >> n >> k;
	ll h[n];
	rep(i,0,n) cin >> h[i];

	vector<ll> dp(n,inf);
	dp[0]=0;
	for(ll i=0; i<n; i++){
		for(ll j=i+1; j<=i+k; j++){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout << dp[n-1];
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int p[n];
  rep(i,n) cin >> p[i];
  int ans=0;
  rep(i,n-2){    
    int a[3];
    rep(j,3) a[j] = p[i+j];
    sort(a,a+3);
    if(a[1] == p[i+1]) ans++;
  }
  cout << ans << endl;

  return 0;
    

}


Measured memory_bytes: 256
//organize and stay in moment
//Abhinav - IIITA
//I love you Disha
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ld long double
int prime[100005] ,arr[100005],pre[100005];
void seive(){
	prime[0]=prime[1]=1;
	for(int i=2;i<100005;++i){
		if(prime[i]==0)
		for(int j=2*i;j<100005;j+=i)
			prime[j]=1;
	}
}
int32_t main(){
	int n; cin>>n;
	int k; cin>>k;
	int arr[n];
	for(int i=0;i<n;++i)
		cin>>arr[i];
	int cost[n];
	for(int i=0;i<n;++i)
		cost[i]=LLONG_MAX;
	cost[0]=0;
	for(int i=1;i<n;++i){
		for(int j=i-1;j>=0 && i-j<=k;--j){
			cost[i]=min(cost[i],cost[j]+abs(arr[i]-arr[j]));
		}
	}
	cout<<cost[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p,f,a;
  while(1){
    cin >> n >> p;
    a = p;
    if(n==0 && p==0) break;
    int set[50]={};
    int i=0;
    while(1){
      if(i==n) i = 0;
      if(p>0){
        set[i]++;
	p--;
      }
      else{
	if(set[i]!=0){
	p=p+set[i];
	set[i]=0;
	}
      }
      if(set[i]==a){
	f = i;
	break;
      }
      i++;
    }
    cout << f << endl;
  }
  return 0;
}



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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n;
    string s,t;

    cin >> n >> s >> t;

    string ans("");
    rep(i,2*n){
        if(i%2==0){
            ans += s[i/2];
        }else{
            ans += t[i/2];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math

def bin1(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=k**mid
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin1(mid+1,r,k,t,b,val,ans)
		else:
			return bin1(l,mid-1,k,t,b,val,ans)
		
def bin2(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=t*(k**mid)+b*(mid)
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin2(l,mid-1,k,t,b,val,ans)
		else:
			return bin2(mid+1,r,k,t,b,val,ans)

def SieveOfEratosthenes(n): 
      
    # Create a boolean array "prime[0..n]" and initialize 
    #  all entries it as true. A value in prime[i] will 
    # finally be false if i is Not a prime, else true. 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
          
        # If prime[p] is not changed, then it is a prime 
        if (prime[p] == True): 
              
            # Update all multiples of p 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    l=[]
    for i in range(2,n+1):
    	if(prime[i]):
    		l.append(i)
    return l
def bin(l,r,ll,val):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		if(val>=ll[mid][0] and val<=ll[mid][1]):
			return mid
		elif(val<ll[mid][0]):
			return bin(l,mid-1,ll,val)
		else:
			return bin(mid+1,r,ll,val)
def deci(n):
	s=""
	while(n!=0):
		if(n%2==0):
			n=n//2
			s="0"+s
		else:
			n=n//2
			s="1"+s
	return s
def diff(s1,s2):
	if(len(s1)<len(s2)):
		v=len(s1)
		while(v!=len(s2)):
			s1="0"+s1
			v=v+1
	else:
		v=len(s2)
		while(v!=len(s1)):
			s2="0"+s2
			v=v+1
	c=0
	for i in range(len(s1)):
		if(s1[i:i+1]!=s2[i:i+1]):
			c=c+1
	return c
from sys import stdin, stdout 
def fac(a,b):
	v=a
	while(a!=b):
		v*=a-1
		a=a-1
	return v
def bino(l,r,n):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		val1=math.log((n/mid)+1,2)
		val2=int(val1)
		if(val1==val2):
			return val1
		elif(val1<1.0):
			return bino(l,mid-1,n)
		else:
			return bino(mid+1,r,n)

def binary(l,r,ll,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		if(val%ll[mid]==0):
			ans=ll[mid]
			return binary(l,mid-1,ll,val,ans)
		else:
			return binary(l,mid-1,ll,val,ans)
def odd(n,ans,s):
	if(n%2!=0 or n in s):
		return ans
	else:
		s.add(n)
		return odd(n//2,ans+1,s)

if __name__ == '__main__':
	s=set()
	n=int(input())
	for i in range(n):
		s1=str(input())
		s.add(s1)
	print(len(s))

Measured memory_bytes: 103924
#include <bits/stdc++.h>
 
using namespace std;
 
using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }
 
template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
constexpr int INF = 1e9;
constexpr int MXB = 20;
using bin = bitset<MXB>;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());
    
    char c;
    while (read(c)) {
        if (c >= 'A' && c <= 'Z') {
            cout << "A" << endl;
        } else {
            cout << "a" << endl;
        }
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e5+10,inf=(1<<30);
ll f[N],p[N];int n,e,t;
int main()
{
    scanf("%d%d%d",&n,&e,&t);
    fo(i,1,n) scanf("%lld",&p[i]);
    memset(f,63,sizeof(f));f[0]=0;
    ll mn=inf;
    for(int i=1,j=0;i<=n;i++) {
        for(;t<=(p[i]-p[j+1])<<1;j++)
            mn=min(mn,f[j]-2*p[j+1]);
            if(j<i) f[i]=min(f[i],f[j]+t);
            f[i]=min(f[i],mn+2*p[i]);
    }
    printf("%lld\n",f[n]+e);
    return 0;
}

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

int main(){
    ld n; //サイコロの面の数
    ld k; //勝負のしきい値
    cin >> n >> k;

    double ans = 0;

    /* 個々の面ごとに確率を求めていく */
    for(int i=1; i<=n; i++){

        int now = i; //今のサイコロの数
        ld pro = 1.0/n; //確率

        while(now < k){
            now *= 2;
            pro /= 2;
        }

        ans += pro;
    }

    printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

    int a, b, c;
    cin >> a >> b >> c;
    int d = abs(a-b);
    int e = abs(b-c);
    int f = abs(c-a);
    int cost = d + e + f -max(d, max(e, f));
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const long long int n=(int)1e6 + 77;
int main()
{
    int x,n,j,f=0,b=0;
    cin>>x>>n;
    int a[n],i,p[101]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        p[a[i]]=1;
    }
    if(n==0)
        cout<<x;
    else
    {
        i=x;j=x;
        while(1)
        {
            if(j<1)
            {
                f=1;
                b=0;
                break;
            }
            if(i>100 && p[j]==1)
            {
                f=1;
                b=1;
                break;
            }
            if(p[j]==0)
            {
                b=2;
                f=0;
                break;
            }
            j--;
            if(p[i]==0)
            {
                b=3;
                f=0;
                break;
            }
            i++;
        }
        if(f==1)
        {
           if(b==1)
                cout<<101;
           else if(b==0)
                cout<<0;
        }
        else if(f==0)
            {
                if(b==2)
                    cout<<j;
                else if(b==3)
                    cout<<i;
            }
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3632
program alice_in_linear_land
  implicit none
  integer :: n, d, x(500000) = 0, q, p(500000) = 0, i
  integer :: a(500001) = 0, b(500001) = 0
  logical :: ok(500000) = .false.
  read(*,*) n, d
  read(*,*) x(1:n)
  read(*,*) q
  read(*,*) p(1:q)
  a(1) = d
  do i = 1, n
    a(i+1) = min(a(i),abs(a(i)-x(i)))
  end do
  b(n+1) = 1
  do i = n, 1, -1
    b(i) = b(i+1)
    if (b(i+1) > x(i)/2) b(i) = b(i+1)+x(i)
    ok(i) = a(i) >= b(i+1)
  end do
  do i = 1, q
    if (ok(p(i))) then
      write(*,'(a)') "YES"
    else
      write(*,'(a)') "NO"
    end if
  end do
end program alice_in_linear_land

Measured memory_bytes: 12288
// AOJ 2039: Space Coconut Crab II
// 2017.11.6 bal4u@uu
//
// a + b + c = T
// a <= b <= c
// a + b > c

#include <stdio.h>
#include <stdlib.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define MAX  15000
char tbl[MAX+1] = {1,1,0,0};		// zero: if prime
int p[1755] = {						// p[29] = 113 <= sqrt(MAX), max sz = 1754
  2,  3,  5,  7, 11, 13, 17, 19, 23, 29, 
 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 
 73, 79, 83, 89, 97,101,103,107,109,113 }; int sz;

void mkprime()
{
	int i, j, k;
	for (i = 0; i <= 29; i++) {
		k = p[i];
		for (j = k<<1; j < MAX; j += k) tbl[j] = 1;
	}
	for (sz = 29, i = 113; i <= MAX; i += 2) if (!tbl[i]) p[sz++] = i;
}

int bsch(int x)
{
	int m, l = 0, r = sz;

    while (l < r) {
        m = (l + r) >> 1;
        if (p[m] <= x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int T, i, j, k, m, ans;
	char buf[10];
#if TM
	clock_t start, end;
	start = clock();
#endif
	mkprime();
	while (fgets(buf, 10, stdin) && *buf != '0') {
		T = atoi(buf);
		if (!(T & 1)) {			// even T
			k = (T>>1)-1;
			if (k > 2 && !(k & 1)) putchar('0');
			else                   putchar('1' - tbl[k]);
			putchar('\n');
		} else {				// odd T
			ans = 0;
			for (i = 0; ; i++) {
				m = bsch((T-p[i]) >> 1);
				if (m < i) break;
				for (j = i; j <= m; j++) {
					k = p[i] + p[j];
					if (T-k < p[j]) break;
					if (k < T && (k<<1) > T && !tbl[T-k]) ans++;
				}
			}
			printf("%d\n", ans);
		}
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

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

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

  if ( a+b > c+d ) {
    cout << "Left" << endl;
  }
  else if ( a+b < c+d ) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

using namespace std;

int main(){
  char a, b; cin >> a >> b;
  if (a=='H') cout << (b=='H' ? 'H': 'D') << endl;
  else cout << (b=='H' ? 'D': 'H') << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s


int main()
{

	int cost[101][101];
	int time_[101][101];

	while (1)
	{
		int n, m;
		cin >> n >> m; if (n == 0 && m == 0) break;
		REP(i, 101)REP(j, 101)
		{
			if (i == j)
			{
				cost[i][j] = 0;
				time_[i][j] = 0;
			}
			else
			{
				cost[i][j] = INF;
				time_[i][j] = INF;
			}
		}

		REP(i, n)
		{
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			a--; b--;
			cost[a][b] = cost[b][a] = c;
			time_[a][b] = time_[b][a] = t;
		}

		REP(k, m)REP(i, m)REP(j, m)
		{
			cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
			time_[i][j] = min(time_[i][j], time_[i][k] + time_[k][j]);
		}
		int k;
		cin >> k;
		REP(i, k)
		{
			int p, q, r;
			cin >> p >> q >> r;
			p--; q--;
			if (r == 0) cout << cost[p][q] << endl;
			else cout << time_[p][q] << endl;
		}
	}
	return 0;
}

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

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

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int X, Y; cin >> X >> Y;
    bool isOK = false;
    rep(i,X+1){
        int j = X - i;
        if((i*2 + j*4) == Y){
            isOK = true;
            break;
        }
    }
    if(isOK) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<queue>
#include<cstdlib>
#include<set>
#include<functional>
#include<algorithm>

using namespace std;

enum triangle{DOWN=0,UP=1};

const int dx = 101;
const int dy = 101;
const int MAX_X = 2*dx;
const int MAX_Y = 2*dy;

const int roll[20][3]={
  {1,4,5},
  {2,0,6},
  {3,1,7},
  {4,2,8},
  {0,3,9},

  {11,0,10},
  {12,1,11},
  {13,2,12},
  {14,3,13},
  {10,4,14},

  {5,9,15},
  {6,5,16},
  {7,6,17},
  {8,7,18},
  {9,8,19},

  {16,10,19},
  {17,11,15},
  {18,12,16},
  {19,13,17},
  {15,14,18},
};

struct State{
  int x,y;
  int face,preface,from;
  int link[3];
  int cost;
};

State nextState(const State &st, int moveType){
  int x = st.x;
  int y = st.y;
  int which = (abs(x)+abs(y)) % 2;
  State next;

  if( which == DOWN ){
    if( moveType == 0 ){ // right
      x += 1;
    }else if( moveType == 1 ){ // left
      x -= 1;
    }else{ // up
      y += 1;
    }
  }else{
    if( moveType == 0 ){ // right
      x += 1;
    }else if( moveType == 1 ){ // down
      y -= 1;
    }else{ // left
      x -= 1;
    }
  }

  next.x = x;
  next.y = y;
  next.preface = st.face;
  next.face = st.link[ moveType ];
  next.from = moveType;
  next.cost = st.cost + 1;

  int diff;
  for(int i = 0; i < 3; ++i){
    if( roll[next.face][i] == st.face ) diff = i;
  }
  for(int i = 0; i < 3; ++i){
    if( which == DOWN ){
      if( moveType == 0 ){
	next.link[(i+2)%3] = roll[next.face][ (diff+i) % 3 ];
      }else if( moveType == 1 ){
	next.link[(i)%3] = roll[next.face][ (diff+i) % 3 ];
      }else{
	next.link[(i+1)%3] = roll[next.face][ (diff+i) % 3 ];
      }
    }else{
      if( moveType == 0 ){
	next.link[(i+1)%3] = roll[next.face][ (diff+i) % 3 ];
      }else if( moveType == 1 ){
	next.link[(i+2)%3] = roll[next.face][ (diff+i) % 3 ];
      }else{
	next.link[(i)%3] = roll[next.face][ (diff+i) % 3 ];
      }
    }
  }

  return next;
};

const int infty = 200;
bool vis[MAX_X][MAX_Y][20][20][3];

int solve(int gx, int gy, int gface)
{
  queue<State> Q;
  State init;
  
  for(int i = 0; i < MAX_X; ++i){ // x
    for(int j = 0; j < MAX_Y; ++j){ // y
      for(int k = 0; k < 20; ++k){ // face
	for(int l = 0; l < 20; ++l){ // preface
	  for(int m = 0; m < 3; ++m){ // from
	    vis[i][j][k][l][m] = false;
	  }
	}
      }
    }
  }

  init.x = dx;
  init.y = dy;
  init.face = 0;
  init.preface = 0;
  init.link[0] = 1;
  init.link[1] = 4;
  init.link[2] = 5;
  init.cost = 0;
  init.from = 0;
  Q.push( init );

  while(!Q.empty()){
    State cur = Q.front(); Q.pop();
    if( cur.cost + abs(cur.x-gx) + abs(cur.y-gy) > 100 ) continue;
    if( cur.x == gx && cur.y == gy && cur.face == gface ){
      return cur.cost;
    }
    for(int i = 0; i < 3; ++i){
      State next = nextState( cur, i );
      if( vis[next.x][next.y][next.face][next.preface][next.from] )
	continue;
      else
	vis[next.x][next.y][next.face][next.preface][next.from] = true;
      
      Q.push( next );
    }
  }
  return -1;
}

int main()
{
  int x,y,face;
  while(cin>>x>>y>>face){
    if( x == 0 && y == 0 && face == 0 ) break ;
    x += dx;
    y += dy;
    cout << solve(x,y,face) << endl;
  }
  return 0;
}

Measured memory_bytes: 48000
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string s; cin >> s;
  set<char> r{s.begin(), s.end()};
  auto ans = r.size() == s.size();
  cout << (ans ? "yes" : "no") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();
		long[] a = new long[n];
		long[] ac = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}

		long answer = Long.MAX_VALUE;
		for (int i = 0; i < 2; i++) {
			long t = 0;
			ac[0] = a[0];

			for (int j = 0; j < n; j++) {
				if ((i + j) % 2 == 0) {
					if (ac[j] >= 0) {
						t += ac[j] + 1;
						ac[j] = -1;
					}
				} else {
					if (ac[j] <= 0) {
						t += Math.abs(ac[j]) + 1;
						ac[j] = 1;
					}
				}
				if (j < n - 1) ac[j + 1] = ac[j] + a[j + 1];
			}

			answer = Math.min(answer, t);
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 60288
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		if (n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 21716
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;
void ex(int x,int y,int con,int ang);

int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
char m[10][10]={0};
main(){
  int i,j,l;
  int n,x,y;
  cin >> n;
  for(l=1;l<=n;l++){
    for(i=1;i<=8;i++){
      for(j=1;j<=8;j++){
	scanf(" %c",&m[j][i]);
      }
    }

    cin >> x >> y;
    ex(x,y,0,0);
    cout <<"Data "<<l<<':'<<endl;
    for(i=1;i<=8;i++){
      for(j=1;j<=8;j++){
	cout << m[j][i];
      }
      puts("");
    }
  }
}

void ex(int x,int y,int con,int ang){
  int i;
  if(m[x][y]=='1'){
    m[x][y]='0';
    for(i=0;i<4;i++){
      if(0 < x+dx[i] && x+dx[i] < 9 && 0 < y+dy[i] && y+dy[i] <9){
	ex(x+dx[i],y+dy[i],3,i);
      }
    }
  }
  else if(con!=1){
    if(0 < x+dx[ang] && x+dx[ang] < 9 && 0 < y+dy[ang] && y+dy[ang] <9){
      ex(x+dx[ang],y+dy[ang],con-1,ang);
    }
  }
}

Measured memory_bytes: 0