akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, k; cin >> n >> k;
  vll h(n);
  REP(i, n) cin >> h.at(i);
  vll dp(n, 0);
  rep(i, 1, n) {
    ll dpa = HIGHINF;
    for (ll j=1; j<=min(i, k); j++) {
      dpa = min(dpa, dp.at(i-j) + abs(h.at(i) - h.at(i-j)));
    }
    dp.at(i) = dpa;
  }
  cout << dp.at(n-1) << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 
        PrintWriter pw=new PrintWriter(System.out);
        String s=br.readLine();
        String s1=s.substring(0,s.length()/2);
        String s2=s.substring(s.length()/2+1,s.length());
        for(int i=0;i<s1.length()/2;i++)
        {
            if(s1.charAt(i)!=s1.charAt(s1.length()-1-i))
            {
                pw.println("No");
                pw.flush();
                pw.close();
                return;
            }
        }
        for(int i=0;i<s2.length()/2;i++)
        {
            if(s2.charAt(i)!=s2.charAt(s2.length()-1-i))
            {
                pw.println("No");
                pw.flush();
                pw.close();
                return;
            }
        }
        for(int i=0;i<s.length()/2;i++)
        {
            if(s.charAt(i)!=s.charAt(s.length()-1-i))
            {
                pw.println("No");
                pw.flush();
                pw.close();
                return;
            }
        }
        pw.println("Yes");
        pw.flush();
        pw.close();
    }
}


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

int main() {
  int r;
  cin>>r;
  if(r<1200) cout<<"ABC"<<endl;
  else if(r<2800) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
  return 0;
}


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

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

  int flag = 0;

  for(;;){
    flag = 0;
    for(int i=2;i<x;i++){
      if(x%i == 0){
        flag = 1;
        break;
      }
    }
    if(flag == 0){
      cout << x;
      return 0;
    }
    x++;


  }
}

Measured memory_bytes: 3612
import heapq
N=int(input())
a=list(map(int,input().split()))
#print(a)
b=a[::-1]
A=a[:N]
#print(A)
AR=[A[0]]
for i in range(1,len(A)*2):
    AR.append(a[i]+AR[i-1])
#print("AR",AR)
AL=[]

heapq.heapify(A)
for i in range(N,N*2):
    heapq.heappush(A,a[i])
    AL.append(A[0])
    heapq.heappop(A)
#print(AL)
ALR=[AL[0]]
for i in range(1,len(AL)):
    ALR.append(ALR[i-1]+AL[i])
#print(ALR)
ANSA=[AR[N-1]]
for i in range(len(ALR)):
    ANSA.append(AR[N+i]-ALR[i])
#print(ANSA)

B=b[:N]
for i in range(len(B)):
    B[i]*=-1
#print("B",B)
BR=[B[0]]
for i in range(1,len(B)*2):
    BR.append(-b[i]+BR[i-1])
#print("BR",BR)
BL=[]
#print("B",B)
heapq.heapify(B)
for i in range(N,N*2):
    heapq.heappush(B,-b[i])
    BL.append(-B[0])
    heapq.heappop(B)
#print("BL",BL)
BLR=[BL[0]]
for i in range(1,len(BL)):
    BLR.append(BLR[i-1]+BL[i])
#print("BLR",BLR)
BNSA=[BR[N-1]]
for i in range(len(BLR)):
    BNSA.append(BR[N+i]+BLR[i])
#print(BNSA)
BNSA=BNSA[::-1]
#print(BNSA)
ANS=-10**20
for i in range(len(BNSA)):
    if (ANSA[i]+BNSA[i])>ANS:
        ANS=(ANSA[i]+BNSA[i])
print(ANS)

Measured memory_bytes: 65188
N = int(input())
shiritori = list()

for a in range(N):
	shiritori.append(input())

ans = "Yes"

for i in shiritori:
    if shiritori.count(i) != 1:
        ans = "No"
        break
    
for k in range(N-1):
    first = shiritori[k]
    second = shiritori[k+1]
    if first[-1] != second[0]:
        ans = "No"
        break


    
print(ans)

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

class _C
{
	void _()
	{
		string S = _Ss()[0];
		int a = _Ns()[0];

		var s = new char[S.Length];

		int i;
		for (i=0;i<S.Length-1;i++)
		{
			var cost= (25 + 'b' - S[i]) % 26;

			if (cost <= a)
			{
				a -= cost;
				s[i] = 'a';
			} else
				s[i] = S[i];
		}

		//
		var c = (S[i]-'a');
		c=((c+a) % 26);


		s[S.Length-1] =(char)('a'+c);


		Console.WriteLine(s);
	}

	static void Main(string[] args)
  {
    new _C()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}

Measured memory_bytes: 3800
a,b = gets.chomp.split
ni = 0
nf = 0
digit = 0
b.size.times do |i|
	next if b[i] == "."
	t = (a.to_i * b[i].to_i) / (10 ** digit)
	s = (a.to_i * b[i].to_i) % (10 ** digit)
	ni += t
	nf += s * (10 ** (2 - digit))
	digit += 1
end

puts ni + (nf/100)

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


public class Main {

  public static void main(String[] args) throws Exception {
    int x, a, b;
    FastScanner fs = new FastScanner();
    x = fs.nextInt();
    a = fs.nextInt();
    b = fs.nextInt();
    
    System.out.println(solve(x, a, b));
    return;
  }
  
  static int solve(int x, int a, int b) {
    x -= a;
    x -= (x/b) * b;
    return x;
  }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22996
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

ans=[]
if N%2==0:
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if i+j!=N+1:
                ans.append((i, j))
else:
    for i in range(1, N):
        ans.append((i, N))
    for i in range(1, N):
        for j in range(i+1, N):
            if i+j!=N:
                ans.append((i, j))

print(len(ans))
for edge in ans:
    print(*edge)


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

struct data{
  int t;
  int s;
  int d;
};

int main()
{
  int n,m,tmp,sum;
  struct data tsd[20001];

  for(;;){
    cin>>n>>m;
    if(!(n|m)) break;
    int inf[20001]={0};
    inf[0]=1;
    for(int i=0;i<m;i++)
      cin>>tsd[i].t>>tsd[i].s>>tsd[i].d;
    for(int i=0;i<m-1;i++)
      for(int j=0;j<m-1;j++)
	if(tsd[j].t>tsd[j+1].t){
	  tmp=tsd[j].t; tsd[j].t=tsd[j+1].t; tsd[j+1].t=tmp;
	  tmp=tsd[j].s; tsd[j].s=tsd[j+1].s; tsd[j+1].s=tmp;
	  tmp=tsd[j].d; tsd[j].d=tsd[j+1].d; tsd[j+1].d=tmp;
	}
    sum=1;
    for(int i=0;i<m;i++)
      if(inf[tsd[i].s-1]&&!inf[tsd[i].d-1]){
	inf[tsd[i].d-1]=1; sum++;
      }
    cout<<sum<<endl;
  }
}


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

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int>> minHeap;
#define endl "\n"
#define int long long
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define max(x, y) ((x > y) ? x : y)
#define min(x, y) ((x < y) ? x : y)
#define mid(s, e) ((s + (e - s) / 2))

bool test_cases;

void init(bool k) {
    test_cases = k;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

struct precompute {
    void compute() {
    }
};

struct test_cases {
    void test_case() {
        int n, k;
        cin >> n >> k;
        int a[n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        int dp[n + 1];
        dp[0] = 0;
        dp[1] = 0;
        for (int i = 2; i <= n; i++) {
            int mn = INT_MAX;
            for (int j = i - 1; j >= max(1, i - k); j--) {
                mn = min(dp[j] + abs(a[j - 1] - a[i - 1]), mn);
            }
            dp[i] = mn;
        }

        cout << dp[n] << endl;
    }
};

int32_t main() {
    init(false);
    int tc;
    if (test_cases) {
        cin >> tc;
    } else {
        tc = 1;
    }
    struct precompute l;
    l.compute();
    for (int i = 0; i < tc; i++) {
        struct test_cases o;
        o.test_case();
    }
    return 0;
};

Measured memory_bytes: 5164
A, B = map(int, input().split())
white = [["#"] * 100 for i in range(50)]
black = [["."] * 100 for i in range(50)]
A, B = A-1, B-1

row = 0
line = 0
for i in range(A):
    white[line][row] = "."
    row += 2
    if row >= 100:
        row = 0
        line += 2

row = 0
line = 1
for i in range(B):
    black[line][row] = "#"
    row += 2
    if row >= 100:
        row = 0
        line += 2

ans = white + black
print(100, 100)
for a in ans:
    print("".join(a))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int ans[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;cin>>n;
    cout<<ans[n-1]<<endl;
    return 0;
}


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

using namespace std;
long long f[401][401];
long long a[401];
long long sum[401];
long long rec(long long l,long long r)
{
    if(l==r)return 0;
    if(f[l][r]>=0)return f[l][r];
    long long rez=1e14;
    for(long long i=l;i<r;i++)
    {
        rez=min(rez,sum[r+1]-sum[l]+rec(l,i)+rec(i+1,r));
    }
    f[l][r]=rez;
    return rez;
}
int main()
{
    long long n;
    cin >> n;
    sum[0]=0;
    for(long long i=0;i<n;i++)
    {
        cin >> a[i];
        sum[i+1]=sum[i]+a[i];
    }
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<n;j++)
        {
            f[i][j]=-1;
        }
    }
    cout << rec(0,n-1);
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>

int main(){
	int p,q,r,num;
	scanf("%d%d%d",&p,&q,&r);
	num=p+q;
	if(num>q+r)num=q+r;
	if(num>r+p)num=r+p;

	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  int num[n];
  REP(i,n){
    cin >> num[i];
  }
  
  for(int i = n-1; i >= 0; i -= 2){
    cout << num[i] << " ";
  }
  
  for(int i = n%2; i < n; i += 2){
    cout << num[i] << " ";
  } 

  cout << endl;

 return 0;
}

Measured memory_bytes: 2944
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int abc(int n){
	if(n>=0){
		return n;
	}else{
		return 0-n;
	}
}
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abc(c-a)<=d || (abc(c-b)<=d && abc(b-a)<=d)){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

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

using namespace std;

int N = 0;
long long int K = 0;
vector< pair<int,int> > p;

int main(void){
    int a = 0, b = 0;

    cin >> N >> K;
    p.resize(N);
    for(int i=0; i<N; ++i){
        cin >> p[i].first >> p[i].second;
    }

    sort(p.begin(), p.end());

    int res = 0;
    for(int i=0; i<N; ++i){
        K -= p[i].second;
        if(K <= 0){
            res = p[i].first;
            break;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int[] a=new int[100];
    	int count=0;
    	for(int i=0;i<100;i++){
    		a[i]=0;
    	}
    	int A=sc.nextInt();
    	int B=sc.nextInt();
    	int C=sc.nextInt();
    	int D=sc.nextInt();
    	for(int i=A;i<B;i++){
    		a[i]++;
    	}
    	for(int i=C;i<D;i++){
    		a[i]++;
    	}
    	for(int i=0;i<100;i++){
    		if(a[i]==2){
    			count++;
    		}
    	}
    	System.out.println(count);
    }
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val,typename Number>
//use ll or int for gcd
Val gcd(Val a, Val b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//count vector and return pair (count,vector item)
template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->push_back(make_pair(count,A->at(i)));
        count = 1;
      }
    }else{
      R->push_back(make_pair(count,A->at(i)));
      count = 1;
    }
  }
}

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

int main(){
  string S,ans,C;
  cin>>S;
  ans ="No";
C="coffee";
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5))ans ="Yes";
  cout<<ans<<endl;


}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

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

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

	if(n==m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

typedef pair<long long, long long> data_t;

int main(){
  int a[6];
  for(int i=0;i<6;i++)
    cin>>a[i];
  if(a[4]-a[0]<=a[5])
  	cout<<"Yay!"<<endl;
  else
    cout<<":("<<endl;
}


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

int64_t gcd(int64_t a, int64_t b){
   if (a%b == 0){
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

int64_t lcm(int64_t a, int64_t b) {
   return a * b / gcd(a, b);
}

int main(){
   int64_t A, B;
   cin >> A >> B;
   cout << lcm(A,B) << endl;
   return 0;
}


Measured memory_bytes: 256
import fractions

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

a_c = (a - 1) // c
a_d = (a - 1) // d
a_cd = (a - 1) // (c * d // fractions.gcd(c, d))

b_c = b // c
b_d = b // d
b_cd = b // (c * d // fractions.gcd(c, d))

print((b - b_c - b_d + b_cd) - ((a - 1) - a_c - a_d + a_cd))


Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n), dp(n, INF);
  rep(i, n) cin >> h[i];

  dp[0] = 0;

  rep(i, n) {
    repI(j, 1, k+1) {
      if (i - j >= 0)
        chmin(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
      else break;
    }
  }
  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<=1000;i++)
	{
		if(i*a%b==c)
		{
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int a[6];
void rotation(char c){
    int aoki;
    if(c=='N'){
        aoki=a[0];
        a[0]=a[1];
        a[1]=a[5];
        a[5]=a[4];
        a[4]=aoki;
    }
    else if(c=='S'){
        aoki=a[0];
        a[0]=a[4];
        a[4]=a[5];
        a[5]=a[1];
        a[1]=aoki;
    }
    else if(c=='E'){
        aoki=a[0];
        a[0]=a[3];
        a[3]=a[5];
        a[5]=a[2];
        a[2]=aoki;
    }
    else if(c=='W'){
        aoki=a[0];
        a[0]=a[2];
        a[2]=a[5];
        a[5]=a[3];
        a[3]=aoki;
    }
}
int main(){
    for(int i=0;i<6;++i){
        cin>>a[i];
    }
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int x,y;
        cin>>x>>y;
        while(true){
            if(a[0]==x) break;
            else if(a[1]==x) rotation('N');
            else if(a[2]==x) rotation('W');
            else if(a[3]==x) rotation('E');
            else if(a[4]==x) rotation('S');
            else if(a[5]==x) rotation('S'),rotation('S');
        }
        if(a[1]==y) cout<<a[2]<<endl;
        else if(a[2]==y) cout<<a[4]<<endl;
        else if(a[3]==y) cout<<a[1]<<endl;
        else if(a[4]==y) cout<<a[3]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
n = input()
result = []
# もしnの1桁目が"1"だったら"9"にする
if n[0] == "1":
    result.append("9")
else :
    result.append("1")    
# もしnの2桁目が"1"だったら"9"にする
if n[1] == "1":
    result.append("9")
else :
    result.append("1")    
# もしnの3桁目が"1"だったら"9"にする
if n[2] == "1":
    result.append("9")
else :
    result.append("1") 
print("{}{}{}".format(result[0],result[1],result[2]))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(998244353)
#define INF 1e12
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int pos(int n,int k,vector<int> &v){
	int hi=n,lo=-1;
	while(hi-lo>1){
		int m=(hi+lo)/2;
		if(v[m]<=k) lo=m;
		else hi=m;
	}
	return hi;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> v(n+1,INF);
	int t;
	For(i,0,n-1){
		cin>>t;
		v[pos(n,-t,v)]=-t;
	}
	cout<<pos(n,INF-1,v)<<"\n";
	return 0;
}

















Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool checkValidity(int a, int b, int c) 
{ 
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
} 
int main(){
    int n,i,j,k,t;
    cin>>n;
    vector<int> a;
    int ans = 0;
    map<int,int> mp;
    for(i=0;i<n;++i){
        cin>>t;
        if(mp.find(t) == mp.end())
            a.push_back(t);
        mp[t]++;

    }
    n = a.size();
    for(i=0;i<n;++i){
        for(j=i+1;j<n;++j){
            for(k=j+1;k<n;++k){
                if(a[i] != a[j] && a[j] != a[k] && checkValidity(a[i],a[j],a[k]))
                    ans += mp[a[i]]*mp[a[j]]*mp[a[k]];
            }
        }
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 3632
#include <iostream>

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

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;

		while (a % 2 == 0) {
			a /= 2;
			++ans;
		}
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
use std::io::BufRead;
use std::str::FromStr;

fn main() {
    let stdin = std::io::stdin();
    let mut t = Tokenizer::new(stdin.lock().lines().map(|x| x.unwrap()));

    let n: i32 = t.take();
    println!( "{}", problem( n ));
}

fn problem( n:i32 ) -> f64 {
    if n == 1 {
        return 1.0 as f64;
    }
    if n % 2 == 1 {
        return ((n/2+1) as f64)/(n as f64);
    }
    return 0.5 as f64;
}


#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn test1() {
        let result = problem( 5 );
        assert_eq!(result,vec![3,6,1]);
    }
}


struct Tokenizer<S: Iterator<Item = String>> {
    input: S,
    items: Vec<String>,
}

impl<S: Iterator<Item = String>> Tokenizer<S> {
    pub fn new(input: S) -> Self {
        Tokenizer {
            input: input,
            items: Vec::new(),
        }
    }

    pub fn take<T: FromStr>(&mut self) -> T {
        loop {
            if let Some(r) = self.items.pop() {
                return r.parse().ok().expect("parse failed");
            }
            let mut items = self
                .input
                .next()
                .unwrap()
                .split_whitespace()
                .map(|x| x.to_string())
                .collect::<Vec<String>>();
            items.reverse();
            self.items = items;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		if (int(i * 1.08) == n) {
			printf("%d\n", i);
			return 0;
		}
	}
	printf(":(\n");
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long n = 100;

		int i=0;
		while(n<x) {
			n = n + (long)(0.01 * n);
			i++;
		}
		System.out.println(i);
		sc.close();
	}


}

Measured memory_bytes: 35808
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::*,
    std::{cmp::*, collections::*, convert::*, iter::*, marker::*, mem::*, ops::*},
};
fn main() {
    input! {//
        n:usize,
        m:usize,
        ab:[(Usize1,Usize1);m],
    }
    let mut uf = UnionFind::new(n);
    for &(a, b) in ab.iter() {
        uf.unite(a, b);
    }
    let mut s = BTreeSet::new();
    for i in 0..n {
        s.insert(uf.find(i));
    }
    println!("{}", s.len() - 1);
}
pub struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        let mut vec = vec![0; n];
        for i in 0..n {
            vec[i] = i;
        }
        UnionFind {
            par: vec,
            rank: vec![0; n],
            size: vec![1; n],
        }
    }
    pub fn find(&mut self, x: usize) -> usize {
        if x == self.par[x] {
            x
        } else {
            let par = self.par[x];
            let res = self.find(par);
            self.par[x] = res;
            res
        }
    }
    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }
    pub fn unite(&mut self, a: usize, b: usize) {
        let apar = self.find(a);
        let bpar = self.find(b);
        if apar == bpar {
            return;
        }
        if self.rank[apar] > self.rank[bpar] {
            self.par[bpar] = apar;
            self.size[apar] += self.size[bpar];
        } else {
            self.par[apar] = bpar;
            self.size[bpar] += self.size[apar];
            if self.rank[apar] == self.rank[bpar] {
                self.rank[bpar] += 1;
            }
        }
    }
    pub fn size(&mut self, a: usize) -> usize {
        let p = self.find(a);
        self.size[p]
    }
}


Measured memory_bytes: 7356
def isprime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True

result = 0
for i in range(int(input())):
    result += isprime(int(input()))
print(result)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(c, it) \
    for (auto it = c.begin(); it != c.end(); it++)
#define cpresent(c, e) (find(all(c), e) != c.end())
#define present(c, e) (c.find(e) != c.end())
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll MOD = 1e9 + 7;

ll mincx[15][1 << 15];
ll mincy[15][1 << 15];

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n), y(n), p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> p[i];
    }
    vector<ll> ans(n + 1, 1ll * MOD * MOD);
    for (int mask = 0; mask < (1 << n); mask++)
    {
        for (int j = 0; j < n; j++)
        {
            ll res = 1e18;
            for (int z = 0; z < n; z++)
            {
                if (mask & (1 << z))
                    res = min(res, p[j] * abs(x[j] - x[z]));
            }
            res = min(res, p[j] * abs(x[j]));
            mincx[j][mask] = res;
        }
    }
    for (int mask = 0; mask < (1 << n); mask++)
    {
        for (int j = 0; j < n; j++)
        {
            ll res = 1e18;
            for (int z = 0; z < n; z++)
            {
                if (mask & (1 << z))
                    res = min(res, p[j] * abs(y[j] - y[z]));
            }
            res = min(res, p[j] * abs(y[j]));
            mincy[j][mask] = res;
        }
    }
    for (int mask = 0; mask < (1 << n); mask++)
    {
        int cnt = __builtin_popcount(mask);
        for (int submask = mask;; submask = (submask - 1) & mask)
        {
            int other = mask - submask;
            ll res = 0;
            for (int j = 0; j < n; j++)
            {
                res += min(mincx[j][submask], mincy[j][other]);
            }
            ans[cnt] = min(ans[cnt], res);
            if (submask == 0)
                break;
        }
    }
    for (int i = 0; i < n + 1; i++)
    {
        cout << ans[i] << "\n";
    }
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a / b << " " << a % b << " ";
    double quotient = static_cast<double>(a) / static_cast<double>(b);
    cout << fixed << setprecision(16) << quotient << endl;
}


Measured memory_bytes: 3276
#include <stdio.h>

int main(void)
{
	int a, b1, b2, c;
	int num = 0;
	int i;

	scanf("%d%d", &a, &b1);
	b2 = b1;

	while (b2 != 0)
	{
		b2 /= 10;
		num++;
	}

	if (num == 1)
	{
		a *= 10;
		c = a + b1;
	}
	else if (num == 2)
	{
		a *= 100;
		c = a + b1;
	}
	else if (num == 3)
	{
		a *= 1000;
		c = a + b1;
	}

	for (i = 1;i <= 1000;i++)
	{
		if (c == i * i)
		{
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		if (e-a>k) {
			System.out.println(":(");
		}else {
			System.out.println("Yay!");
		}
	}
}

Measured memory_bytes: 22740
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

int second(string s) {
	for (auto &i : s)i -= '0';
	int ret = s[0];
	ret *= 10;
	ret += s[1];
	ret *= 6;
	ret += s[3];
	ret *= 10;
	ret += s[4];
	return ret;
}

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

	while (cin >> N, N) {
		map<string, vector<int>>mp;
		vector<string>a(N);
		vector<string>b(N);
		vector<char>c(N);
		vector<string>d(N);
		for (int i = 0; i < N; i++) {
			cin >> a[i] >> b[i] >> c[i] >> d[i];
			mp[a[i]].push_back(i);
		}
		map<string, int>score;
		for (auto i : mp) {
			vector<int>v(1441);
			for (auto j : i.second) {
				if (d[j] == "000") {
					if (c[j] == 'I') {
						v[second(b[j])]++;
					}
					else {
						v[second(b[j])]--;
					}
				}
			}
			for (int j = 1; j <= 1440; j++) {
				v[j] += v[j - 1];
			}
			for (auto j : i.second) {
				if (d[j] != "000") {
					if (c[j] == 'I') {
						for (int k = second(b[j]); k <= 1440; k++) {
							score[d[j]] += v[k];
						}
					}
					else {
						for (int k = second(b[j]); k <= 1440; k++) {
							score[d[j]] -= v[k];
						}
					}
				}
			}
		}
		int ans = 0;
		for (auto i : score) {
			ans = max(ans, i.second);
		}
		cout << ans << endl;
	}
}


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

int main()
{
	int N,T,i,c,t,ans=1001;
	cin>>N>>T;
	for(i=0;i<N;i++){
		cin>>c>>t;
		if(t<=T){
			if(ans>c){
				ans=c;
			}
		}
	}
	if(ans==1001){
		cout<<"TLE";
	}else{
		cout<<ans;
	}
}


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

int main()
{
    int a, b;
    while(cin >> a >> b) {
        int sum = a + b;
        cout << (sum == 0 ? 1 : (int) log10(sum) + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
N, M = map(int,input().split())
S = set()
T = set()
for i in range(M):
    a, b = map(int,input().split())
    if a == 1:
        S.add(b)
    elif b == 1:
        S.add(a)
    elif a == N:
        T.add(b)
    elif b == N:
        T.add(a) 

if S.isdisjoint(T):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i=0; i<N; i++) cin >> A[i];
    int B[110]={0};
    for (int i=0; i<N; i++){
        B[A[i]]++;
    }
    int count=0;
    for (int i=0; i<=100; i++){
        if (B[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  set<string> se;
  se.insert("AKIHABARA");

  se.insert("AKIHABAR");
  se.insert("AKIHABRA");
  se.insert("AKIHBARA");
  se.insert("KIHABARA");

  se.insert("KIHBARA");
  se.insert("KIHABRA");
  se.insert("KIHABAR");
  se.insert("AKIHBRA");
  se.insert("AKIHBAR");
  se.insert("AKIHABR");

  se.insert("KIHBAR");
  se.insert("AKIHBR");
  se.insert("KIHABR");
  se.insert("KIHBRA");

  se.insert("KIHBR");

  if (se.find(s) == se.end()) NO();
  else YES();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007 
typedef long long ll;
 
int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n,w;
	cin>>n>>w;
	vector<ll> value(n),weight(n);
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>weight[i]>>value[i];
		sum+=value[i];
	}
	vector<ll> dp(sum+1,1e18+1);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=sum-value[i];j>=0;j--)
		{
			dp[j+value[i]]=min(dp[j]+weight[i],dp[j+value[i]]);
		}
	}
	
	ll m=1e18+1;
	for(int i=dp.size()-1;i>=0;i--)
	{
		//cout<<dp[i]<<" "<<i<<"\n";
		if(dp[i]<=w)
		{
			m=i;
			break;
		}
	}
		
	cout<<m<<"\n";
 
	return 0;
}

Measured memory_bytes: 1024
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


s, t = ns().split()
print(t + s)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = acos(-1) ;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	//ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0;
	  int a[9],n,b; for(int i=0;i<9;i++) cin>>a[i];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    for(int& i:a) if(i==b) i=0;
  }
  cout<<(!(a[0]+a[1]+a[2])||!(a[3]+a[4]+a[5])||!(a[6]+a[7]+a[8])||!(a[0]+a[3]+a[6])||!(a[1]+a[4]+a[7])||!(a[2]+a[5]+a[8])||!(a[0]+a[4]+a[8])||!(a[2]+a[4]+a[6])?"Yes":"No");

}


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

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		br.readLine();
		List<String> a=Arrays.asList(br.readLine().split(" "));
		int n1=Integer.parseInt(a.get(0));
        int min=n1,max=n1;
        long sum=n1;
        for(Iterator<String> i=a.iterator();i.hasNext();){
			String s=i.next();
        	int n2=Integer.parseInt(s);
            if(n2<min) min=n2;
            if(n2>max) max=n2;
            sum=sum+n2;
		}
        System.out.println(min+" "+max+" "+(sum-n1));
	}
}

Measured memory_bytes: 25552
#include <stdio.h>

#define MAX 100000
#define INFTY 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];


void merge(struct Card 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].value=INFTY;
  R[n2].value=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(struct Card  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);
  }
}

int partition(struct Card A[],int p,int r){
  int i,j;
  struct Card x,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i=i+1;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quicksort(struct Card A[],int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }

  mergeSort(A,n,0,n);
  quicksort(B,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



Measured memory_bytes: 4056
#include <iostream>

using namespace std;

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int five = 0,seven = 0;
    for(int i = 0; i < 3;i++){
        if(a[i] == 5) five++;
        else if(a[i] == 7) seven++;
    }
    if(five == 2 && seven == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/

int main(){
    string s; cin >> s;
    int n = s.size(); 
    set<char> se;
    rep(i, n) se.insert(s[i]);
    if(se.size() == n){
        cout << n / 2 << endl;
        return 0;
    }
    int ans = 100;
    for(auto it : se){
        int max_len = 0;
        int pos = -1;
        rep(i, n){
            if(s[i] == it){
                max_len = max(max_len, int(i) - pos - 1);
                pos = i;
            }
        }
        max_len = max(max_len, n - pos - 1);
        ans = min(ans, max_len);
        //cout << ans << " " << max_len << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int re = 0;
        for(int i=0;i<n;i++){
            if(sc.nextInt()>=k)re++;
        }
        System.out.println(re);
    }
}


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

maxL = 0
minR = float('inf')
for _ in range(M):
    l, r = map(int, input().split())
    maxL = max(maxL, l)
    minR = min(minR, r)


ans = minR - maxL + 1
ans = max(ans, 0)
print(ans)


Measured memory_bytes: 43752
#include <cstdio>
#include <vector>
#include <map>
#include <string>

using namespace std;

map<string,int> item;

const int INF = 2000000000;


class Recipe{
public:
	string To;
	vector<string> From;
	int GetCost();
};

map<string,Recipe> recipe;

int Recipe::GetCost(){
	if(From.size() == 0){
		return INF;
	}
	int c = 0;
	vector<string>::iterator it;
	for(it = From.begin();it<From.end();it++){
		c += item[*it] < recipe[*it].GetCost() ? item[*it] :recipe[*it].GetCost() ;
	}
	return c;
}


int itemn;
int recipen;

int main(){
	int self;
	char str[256];
	while(scanf("%d",&itemn) != EOF){
		//if(itemn == 0){break;}
		//printf("CASE\n");
		item.clear();
		recipe.clear();
		//printf("ITEMS %d:\n",itemn);
		for(int i=0;i<itemn;i++){
			scanf("%s %d",str,&self);
			item[str] = self;
			//printf("%s	%d\n",str,self);
		}
		if(scanf("%d",&recipen) == EOF) break;
	
		for(int i=0;i<recipen;i++){
			Recipe r;
			scanf("%s %d",str,&self);
			r.To = str;
			for(int j=0;j<self;j++){
				scanf("%s",str);
				r.From.push_back(str);
			}
			recipe[r.To] = r;
		}
		scanf("%s",str);
		
		//printf("TARGET:%s\n",str);
		printf("%d\n" , item[str] < recipe[str].GetCost() ? item[str] : recipe[str].GetCost() );
	}
	return 0;
}

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

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if(u == s) a--;
	else b--;
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a , b , c , k;
  scanf("%d %d %d %d",&a ,&b ,&c ,&k);

  int count = 0;

  while(a >= b && count < k){
    b *= 2;
    count ++;
  }

  while(b >= c && count < k){
    c*= 2;
    count ++;
  }

  if(a < b && b < c){
    printf("Yes\n");
  }

  else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
int main(){

 long long n,m,b,k,a=1000000000011;
	 	scanf("%lld",&n);
		for(m=1;m<1000001;m++)
		{
			if(n%m==0)
		b=n/m;
			k=m+b-2;
		if(a<k){
		}
		else a=k;
		
	}
	
		printf("%lld",a);
	
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> A>>B;
    
    ans = (A+B+1)/2;
    cout << ans << endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;




int main() {
	int n, t;
	cin >> n >> t;
	vector<pii> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i].first >> d[i].second;
	}

	sort(d.begin(), d.end());
	vector<vector<int>> dp(n, vector<int>(t + 1));

	for (int i = d[0].first;i < t;i++) {

		dp[0][i] = d[0].second;

	}
	{
		int last = 0;
		for (int j = 1; j < n;j++) {
			last = max(last, d[j].second);
		}
		dp[0][t] = dp[0][t - 1] + last;

	}

	for (int i = 1; i < n;i++) {
		int td = d[i].first;
		for (int j = 0; j < t;j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= td) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - td] + d[i].second);
			}
			dp[i][j];


		}


		int last = 0;
		for (int j = i + 1; j < n;j++) {
			last = max(last, d[j].second);

		}

		dp[i][t] = dp[i][t - 1] + last;



	}

	int ans = 0;
	for (int i = 0;i < n;i++) {
		ans = max(ans, dp[i][t]);

	}
	cout << ans << endl;

}



Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
char ch[1314520];
int main(){
	int cnt=0,bj1,bj2;
	scanf("%s",ch);
	for(int i=0;i<strlen(ch);i++){
		if(ch[i]=='A'){
			bj1=i;
			break;
		}
	}
for(int i=strlen(ch)-1;i>=0;i--){
		if(ch[i]=='Z'){
			bj2=i;
			break;
		}
	}
	printf("%d\n",bj2-bj1+1);
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  
  int counter = 0, current = 0;
  for (int i = 0; i < n; i++) {
    if (d.at(i) == current) continue;
    current = d.at(i);
    counter++;
  }
  
  cout << counter << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,k;
    cin>>n>>k;
    vi p(n);
    rep(i,n)cin>>p[i];

    int begin=0;
    ll max,tmax=0;

    rep(i,k){
        tmax+=p[i];
    }
    max=tmax;
    repa(i,k,n){
        tmax+=-p[i-k]+p[i];
        if(tmax>max){
            max=tmax;
            begin=i-k+1;
        }
    }

    double ans=(max+(double)k)/2;

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

    return 0;
}

Measured memory_bytes: 1024