akhauriyash/Code-Regression huggingface dataset:
from collections import deque

S = input()
Q = int(input())
rev = False
ans = deque(S)
for i in range(Q):
    tfc = input()
    if tfc == '1':
        rev = not rev
    else:
        t,f,c = tfc.split()
        if f == '1':
            if rev: ans.append(c)
            else: ans.appendleft(c)
        elif f == '2':
            if rev: ans.appendleft(c)
            else: ans.append(c)

if rev: ans.reverse()

print(''.join(ans))

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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << "\t|";
    __f(comma + 1, args...);
}

#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}


int visited[100005];
int dp[100005];
vector<int> adj[100005]; // array of vector

int dfs(int node) {
    if (dp[node] > 0)
        return dp[node];
    visited[node] = 1;
    int ans = 0;
    for (auto kid : adj[node]) {
        ans = max(ans, 1 + dfs(kid));
    }
    dp[node] = ans;
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        adj[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
//        mem0(visited);
        ans = max(ans, dfs(i));
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
  int n , k;
  cin >> n >> k;
  int c = 1;
  for (int i = 0; i < n; i++) {
    int a = c * 2;
    int b = c + k;
    if( a >= b) {
      c = b;
    } else {
      c = a;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a[101][101];
    int b[101];
    int c;
    int n, m;
    int i, j;

    scanf("%d%d", &n, &m);
    for (i = 1; i <= n; i++){
        for (j = 1; j <= m; j++){
            scanf("%d", &a[i][j]);
        }
    }

    for (i = 1; i <= m; i++){
        scanf("%d", &b[i]);
    }

    for (i = 1; i <= n; i++){
        c = 0;
        for (j = 1; j <= m; j++){
            c += a[i][j]*b[j];
        }
        printf("%d\n", c);
    }
    return (0);
}



Measured memory_bytes: 2056
#できなかった
n=int(input())
r=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted([list(map(int,input().split())) for i in range(n)])
ans=0
for bx,by in b:
    ypoint=-1
    index=-1
    for num,(rx,ry) in enumerate(r):
        if bx>rx and by>ry and ypoint < ry:
            ypoint=ry
            index =num
    if ypoint>=0:
        ans+=1
        r.pop(index)
print(ans)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int score,max,min,sum=0;
			score=sc.nextInt();
			max=score;
			min=score;
			sum+=score;
			for(int i=1;i<n;i++){
				score=sc.nextInt();
				if(score>max){
					max=score;
				}
				else if(score<min){
					min=score;
				}
				sum+=score;
			}
			sum-=max+min;
			System.out.printf("%d\n",sum/(n-2));
		}
	}
}


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

#define PI 3.14159265359
#define eps 1e-8
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
typedef long long int ll;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

double tick() { 
	static clock_t oldticks;
	clock_t newticks = clock();
	double diff = 1.0 * (newticks - oldticks) / CLOCKS_PER_SEC; 
	oldticks = newticks;
	return diff;
}

bool prime[10000010];
inline void sieve(){
	prime[0]=prime[1]=0;
	for(int i=2;i<10000010;i++)
		prime[i]=1;
	for(int i=2;i<sqrt(10000010);i++){
		if(prime[i]==1){
			for(int j=i*i;j<10000010;j+=i)
				prime[j]=0;
		}
	}
}

inline bool isPrime(ll n){
    if (n <= 1)
        return false; 
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}

inline int toInt(string s){
	//return atoi(s.c_str());
	int x=(int)s[0]-48;
	return x;
}

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

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

inline bool isLeap(int yy){
	return ((yy%4 == 0 && yy%100 != 0) || yy%400 == 0);
}

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
	
    int h,w;
    cin >> h >> w;
    char C[h][w];

    FOR(i,0,h){
        FOR(j,0,w)
            cin >> C[i][j];
    }

    FOR(i,0,h){
        FOR(j,0,w){
            cout << C[i][j];
        }
        cout << endl;
        FOR(j,0,w){
            cout << C[i][j];
        }
        cout << endl;
    }
	
    //cerr << tick();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int main()
{
	char ch;
	cin >> ch;
	if(ch=='A')	cout << "T";
	else if(ch=='T')	cout << "A";
	else if(ch=='G')	cout << "C";
	else if(ch=='C')	cout << "G";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lld unsigned long long int
#define MAX 90000000
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
using namespace std;

int n, l, s, m, d = MAX, val, aux;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%d %d", &n, &l);
    s = ((l+l+n-1)*n)/2;
    for(int i =1; i<=n; i++){
        val = s-(l+i-1);
        aux = abs(s-val);
        if(aux<d){m=val;d=aux;}
    }
    printf("%d\n", m);
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	static Scanner in;
	static PrintWriter out;

	static void solve() {
		int N = in.nextInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = in.nextInt();
		}
		int cnt4 = 0, cnt2 = 0;
		for(int t : a) {
			if(t % 4 == 0) {
				cnt4++;
			} else if(t % 2 == 0) {
				cnt2++;
			}			
		}
		if (cnt2 == N) {
			out.println("Yes");
			return;
		}
		N = N - (cnt2 / 2) * 2;
		float t = (N  - 1) / 2.0f;
		if (t <= cnt4) {
			out.println("Yes");
			return;
		}
		out.println("No");
		return;
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		out.close();
		in.close();
	}

}


Measured memory_bytes: 50576
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	string s,t;
	int ans=0;
	while(cin>>s){
		t = s;
		reverse(t.begin(),t.end());
		if(s==t)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1188
Imports System

Module Test1
Sub Main()
dim Input as string, Output as string, S_base(10) As String,A_int as integer
Input ="" : Output ="" : A_int=0
Do
Input=Console.ReadLine()
If input Is Nothing Then exit do
S_base(A_int)=Input
A_int=A_int+1
Loop
Dim a As Integer, A_out As String
a = S_base(0)
If a > 999 Then
A_out = "ABD" 
Else
A_out = "ABC"
End If
Output=A_out.tostring
Console.WriteLine(Output)
End sub
End Module

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
  int K;
  cin >> K;
  cout << VI{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}[K - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
player_num,first_point,q = gets.chomp.split.map(&:to_i)
a = []
q.times{ a << gets.to_i }

players_points = Array.new(player_num, first_point - a.length)

def p_winner arr
  arr.each do |point|
    puts point.positive? ? "Yes" : "No"
  end
end

def move_round players_points, a
  a.each do |ansered_player_index|
    players_points[ansered_player_index - 1] = players_points[ansered_player_index - 1] + 1
  end
  return players_points
end

p_winner move_round(players_points, a)

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int W;
    cin>>n>>W;
    int v[n+1],w[n+1],L[n+1][W+1];
    for(int i=1;i<=n;i++){
        cin>>v[i]>>w[i];
    }
    //i番目までのものから重さj以下になるように選ぶ
    for(int j=0;j<=W;j++) L[0][j]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(w[i]>j) L[i][j]=L[i-1][j];
            else L[i][j]=max(L[i-1][j-w[i]]+v[i],L[i-1][j]);
        }
    }
    cout<<L[n][W]<<"\n";
}



Measured memory_bytes: 7008
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
ll pow2(ll x, ll n) { //x^n 計算量O(logn)
	ll ans = 1ll;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

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

	ll d,g;
	cin >> d >> g;
	
	Array p(d, 0), c(d, 0);
	REP(i, d) {
		cin >> p[i] >> c[i];
	}
	ll ans = INF;
	for (ll bit = 0; bit < (1LL << d); bit++) {
		ll max = 0;
		ll sum = 0;
		ll num = 0;
		REP(i, d) {
			if ((bit & (1LL << i)) != 0) {
				sum += (i + 1) * 100 * p[i] + c[i];
				num += p[i];
			}
			else {
				max = i;
			}
		}
		if (g > sum) {
			ll n = (g - sum) / ((max + 1) * 100);
			if ((g - sum) % ((max + 1) * 100) != 0) n++;
			if (n < p[max]) {
				sum += (max+1)*100 * p[max];
				num += n;
			}
		}
		if(g<=sum) chmin(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func count(d int) int {
	cnt := 0
	for {
		if d%2 != 0 {
			break
		}
		cnt++
		d >>= 1
	}
	return cnt
}

func main() {
	var n int
	var d int
	fmt.Scanf("%d", &n)
	cnt := math.MaxInt64
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &d)
		ccnt := count(d)
		if ccnt < cnt {
			cnt = ccnt
		}
		if cnt == 0 {
			break
		}
	}
	fmt.Printf("%d", cnt)
}


Measured memory_bytes: 512
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 101
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int n,a[N];
int need[N],use[N];
int main()
{
	re(n);
	for(int i=1;i<=n;++i)re(a[i]);
	sort(a+1,a+n+1);
	for(int i=a[n]/2+1;i<=a[n];++i)
		need[i]=2;
	if(a[n]%2==0)++need[a[n]/2];
	for(int i=1;i<=n;++i)
		if(need[a[i]])
			--need[a[i]],use[i]=1;
	for(int i=1;i<=n;++i)
		if(need[i])
		{
			puts("Impossible");
			return 0;
		}
	for(int i=1;i<=n;++i)
		if(!use[i] && a[i]<(a[n]+3)/2)
		{
			puts("Impossible");
			return 0;
		}
	puts("Possible");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

//#include <bits/stdc++.h>

using namespace std;

int main()
{
	int N, M;
	int tmpa, tmpb;
	cin >> N >> M;
	//vector<vector<int>> V(100000,vector<int>(100000));
	vector<int> H;
	vector<int> V(100000);
	int count = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> tmpa;
		H.push_back(tmpa);
	}

	for (int i = 0; i < M; i++)
	{
		cin >> tmpa >> tmpb;
		tmpa = tmpa - 1;
		tmpb = tmpb - 1;
		V[tmpa] = max(V[tmpa], H[tmpb]);
		V[tmpb] = max(V[tmpb], H[tmpa]);
		auto test = 1;
	}

	for (int i = 0; i < N; i++)
	{
		if (V[i] < H[i])
		{
			count++;
		}
	}


	cout << count << endl;
	return 0;
}

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

int main() {
  int m,k;
  cin>>m>>k;
  if (k>=pow(2,m)||(m==1&&k==1)) {
    cout<<-1;
    return 0;
  }
  if (m==0) {
    cout<<"0 0";
    return 0;
  } else if(m==1){
    cout<<"0 0 1 1";
    return 0;
  }else{
    for (int i = 0; i < pow(2,m); i++) {
      if (i!=k) cout<<i<<" ";
    }
    cout<<k<<" ";
    for (int i = pow(2,m)-1; i >=0; i--) {
      if (i!=k) cout<<i<<" ";
    }
    cout<<k;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = s.length();
    for (int i = 0; i < ans; i++) {
        //置き換えるじゃなくてsの文字回分xを出す
        cout << "x";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

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

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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

int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){

    
    cin >> n;
    P((1+n)/2);
    
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define amari(x) ((x) % 1000000007)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  long a, b;

  cin >> a >> b;

  if ((a < 0 && b < 0) || (a > 0 && b > 0)) {
    if (a > 0 || (a-b) % 2) {
      cout << "Positive" << endl;
    } else {
      cout << "Negative" << endl;
    }
  } else {
    cout << "Zero" << endl;
  }

  return 0;
}


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

int main() {
int kazu;
cin >> kazu;
int iti, zyuu, hyaku, sen;
  iti = kazu % 10;
  zyuu = (kazu % 100 - iti)/10;
  hyaku = (kazu % 1000 - zyuu - iti)/100;
  sen = (kazu - hyaku - zyuu - iti)/1000;
  
  
	if ((sen == hyaku && hyaku == zyuu) ||( hyaku == zyuu && zyuu== iti)){
      cout << "Yes" << endl;
    }
  	else {
      cout << "No" << endl;

    }
}

Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
d = {}
s = 0
for i in a:
    s += i
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
for _ in range(int(stdin.readline())):
    b, c = list(map(int, stdin.readline().split()))
    if b in d:
        s += d[b]*(c-b)
        if c not in d:
            d[c] = d[b]
        else:
            d[c] += d[b]
    d[b] = 0
    print(s)

Measured memory_bytes: 23452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}





int main(){

  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  FOR(i,0,N){
    cin >> A[i];
  }

  FOR(i,K,N){
    if(A[i]>A[i-K]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

}



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

const int N = 1e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

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

int sum[N];

vector<pair<int,int> > G[N];

int n;

long long res = 0;
long long MIN = 1LL << 60;

bool to_me[N];
bool to_father[N];
int ojc[N];

void dfs(int x) {
// 	printf("dfs %d\n", x);
	sum[x] ++;
	for (auto p: G[x]) {
		int y = p.first;
		int e = p.second;
		if (sum[y] == 0) {
			dfs(y);
			sum[x] += sum[y];
			long long added = max(min(2 * sum[y] - 2, 2 * n - 2 * sum[y]), min(2 * sum[y], 2 * n - 2 * sum[y] - 2)) * (long long)e;
			if (sum[y] > n - sum[y]) {
				to_me[y] = true;
			} else {
				to_father[y] = true;
			}
			res += added;
			ojc[y] = x;
//			MIN = min(MIN, added - min(2 * sum[y] - 1, 2 * n - 2 * sum[y] - 1) * (long long)e);
// 			printf("%lld\n", res);
		}
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i ++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		G[a].push_back(make_pair(b, c));
		G[b].push_back(make_pair(a, c));
	}
	dfs(1);
	for (int x = 1; x <= n; x ++) {
		bool OK = true;
		for (auto p: G[x]) {
		int y = p.first;
		if (y == ojc[x]) {
			if (n - sum[x] > sum[x]) {
				OK = false;
			}
		}
			else if (sum[y] > n - sum[y]) {
				OK = false;
			}
		}
		if (OK) {
// 			printf("dobre %d\n", x);
			for (auto p: G[x]) {
				int y = p.first;
				int e = p.second;
				long long added = max(min(2 * sum[y] - 2, 2 * n - 2 * sum[y]), min(2 * sum[y], 2 * n - 2 * sum[y] - 2)) * (long long)e;
				MIN = min(MIN, added - min(2 * sum[y] - 1, 2 * n - 2 * sum[y] - 1) * (long long)e);
			}
		}
	}
	printf("%lld\n", res - MIN);
}


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

int main(){
	string S;
	cin >> S;
	vector<int> ans;
	for(int i=0; i<S.size(); i++){
		int cnt = 0, MAX = i;
		for(int j=i+1; j<S.size(); j++){
			if(S[j-1] == S[i] && S[j] != S[i]){
				cnt = 1;
			}else if(S[j-1] != S[i] && S[j] != S[i]){
				cnt++;
			}else if(S[j-1] != S[i] && S[j] == S[i]){
				if(MAX < cnt) MAX = cnt;
			}
		}
		if(MAX < cnt) MAX = cnt;
		ans.push_back(MAX);
	}
	int MIN = ans[0];
	for(int i=1; i<ans.size(); i++){
		MIN = min(ans[i], MIN);
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
  long int N;
  cin >> N;
  long int a[N];
  long long int nmin=9223372036854775807;
  long long int prediff=9223372036854775807;
  long long int allval=0;
  long long int left, right, diff;
  for(int i=0; i<N; i++){
    cin >> a[i];
    allval+=a[i];
  }

  left=0;
  for(int i=0; i<N-1; i++){
    left+=a[i];
    right=allval-left;
    diff = abs(left-right);
    //if(prediff<diff) break;
    if(diff<nmin){
      nmin = diff;
      prediff = diff;
    }
  }
  cout << nmin << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}
  
Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node x, int k){
  if(x == NIL || k == x->key) return x;
  if(k < x->key) return treeSearch(x->left,k);
  else return treeSearch(x->right,k);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
   
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;



}

void inorder(Node u){
 if(u!=NIL){
    if(u->left!=NIL) inorder(u->left);
    
    printf(" %d",u->key);
       
    if(u->right!=NIL) inorder(u->right);
   }
}
void preorder(Node u){
   printf(" %d",u->key);
  if(u!=NIL){
    if(u->left!=NIL) preorder(u->left);
    
    if(u->right!=NIL) preorder(u->right); 
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    x = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;
  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
  }
  

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
#define N 2005
using namespace std;
int n,m,sum,rd[N];
int dep[N],f[N],ans[N];
struct E 
{
	int u,v; 
	E(int u=0,int v=0) : u(u),v(v) {} 
};
vector<E> now;
struct Edge
{
	int next,to;
}edge[N<<1];int head[N],cnt;
void add_edge(int from,int to)
{
	edge[++cnt].next=head[from];
	edge[cnt].to=to;
	head[from]=cnt;
}

template <class T> inline void read(T &x)
{
	char c;int sign=1;
	while((c=getchar())>'9'||c<'0') if(c=='-') sign=-1; x=c-48;
	while((c=getchar())>='0'&&c<='9') x=(x<<1)+(x<<3)+c-48; x*=sign;
}

void dfs(int rt,int fa)
{
	f[rt] = fa;
	dep[rt] = dep[fa] + 1;
	for(int i=head[rt];i;i=edge[i].next)
	{
		int v=edge[i].to;
		if(v == fa) continue;
		dfs(v,rt);
	}
}
void sig(int u,int v)
{
	if(dep[u] < dep[v]) swap(u,v);
	while(dep[u] > dep[v]) { ++ans[u]; u = f[u]; }
	while(u != v) { ++ans[u]; ++ans[v]; u = f[u]; v = f[v]; }
}
bool operator == (E a,E b) { return (a.u == b.u) && (a.v == b.v); }
vector<E> solve(vector<E> rt)
{
	if(!rt.size()) return rt;
	int u,v;//v is leaf
	for(v=1;v<=n;++v) if(rd[v] == 1) break;
	if(v > n) return rt;
	for(int i=head[v];i;i=edge[i].next)
	{
		u = edge[i].to;
		if(rd[u]) break;
	}
	--rd[u]; --rd[v];
	vector<E> nxt,l;//有v点的边加入l集合 
	int pos[N],id[N];
	//id表示l中的元素在rt中的位置 
	//pos表示rt中的元素在nxt中的位置 
	memset(pos,-1,sizeof(pos));
	for(int i=0;i<(int)rt.size();++i)
	{
		if(rt[i].u == v || rt[i].v == v)
		{
			l.push_back(rt[i]);
			id[l.size() - 1] = i;
		}
		else
		{
			nxt.push_back(rt[i]);
			pos[i] = nxt.size() - 1;
		}
	}
	if(!l.size()) return solve(rt);
	for(int i=0;i + 1<(int)l.size();i += 2)//配对 
	{
		if(l[i].v == v) swap(l[i].u,l[i].v);
		if(l[i + 1].v == v) swap(l[i + 1].u,l[i + 1].v);
		if(l[i] == l[i + 1])
		{
			if(rt[id[i]] == rt[id[i + 1]]) swap(rt[id[i]].u,rt[id[i]].v);
			continue;
		}
		nxt.push_back(E(l[i].v,l[i + 1].v));
		pos[id[i]] = pos[id[i + 1]] = nxt.size() - 1;
	}
	if(l.size() & 1)//落单 
	{
		int p = l.size() - 1;
		if(l[p].v == v) swap(l[p].u,l[p].v);
		if(l[p].v != u)
		{
			nxt.push_back(E(u,l[p].v));
			pos[id[p]] = nxt.size() - 1;
		}
	}
	nxt = solve(nxt);
	for(int i=0;i<(int)rt.size();++i)
	  if(pos[i] != -1 && !(rt[i].u == nxt[pos[i]].u || rt[i].v == nxt[pos[i]].v))
		swap(rt[i].u,rt[i].v);
	return rt;
}

int main()
{
	read(n);read(m);
	for(int i=1;i<n;++i)
	{
		int x,y;
		read(x);read(y);
		add_edge(x,y);
		add_edge(y,x);
		++rd[x];++rd[y];
	}
	dfs(1,0);
	for(int i=1;i<=m;++i)
	{
		int u,v; read(u);read(v);
		sig(u,v); now.push_back(E(u,v));
	}
	for(int i=2;i<=n;++i) sum += min(2,ans[i]);
	printf("%d\n",sum);

	now = solve(now);
	for(int i=0;i<(int)now.size();++i) printf("%d %d\n",now[i].u,now[i].v);
	return 0;
}

Measured memory_bytes: 64768
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	rep(i,0,n){
		if(i) cout<<endl;
		int data[9][9]={},error[9][9]={};
		rep(j,0,9) rep(k,0,9) cin>>data[j][k];
		rep(j,0,9){
			int count[9]={};
			rep(k,0,9) count[data[j][k]-1]++;
			rep(k,0,9){
				if(count[data[j][k]-1]>1) error[j][k]=1;

			}
		}rep(j,0,9){
			int count[9]={};
			rep(k,0,9) count[data[k][j]-1]++;
			rep(k,0,9){
				if(count[data[k][j]-1]>1) error[k][j]=1;
			}
		}rep(j,0,3)rep(k,0,3){
			int count[9]={};
			rep(l,0,3)rep(m,0,3) count[data[3*j+l][3*k+m]-1]++;
			rep(l,0,3)rep(m,0,3){
				if(count[data[3*j+l][3*k+m]-1]>1) error[3*j+l][3*k+m]=1;
			}
		}rep(j,0,9){
			rep(k,0,9){
				if(error[j][k]) cout<<"*";
				else cout<<" ";
				cout<<data[j][k];
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i<(int)n;i++)
#define ll long long 
using namespace std;
bool prime(int x){
  int key=0;
  rep2(i,2,sqrt(x)+1) if(x%i==0) key=1;
  if(key==0) return true;
  else return false;
}
  
int main() {
  ll a,b;
  cin  >>a>>b;
  cout <<a/__gcd(a,b)*b<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d\n", &a, &b, &c, &d)

	max := int(math.Max(float64(b), float64(d)))
	min := int(math.Min(float64(a), float64(c)))

	if (max - min) >= (b-a)+(d-c) {
		fmt.Println(0)
	} else {
		fmt.Println((b - a) + (d - c) - (max - min))
	}
}


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

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
     }

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

    for (size_t i = 0; i < n; i++)
    {
        if(a[i]==b[n-1]){
            cout << b[n-2] << endl; 
        }else{
            cout << b[n-1] << endl; 
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

int main(void)
{
	int n, s[10000];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> s[i];
	
	int q, t[500];
	cin >> q;
	for (int i = 0; i < q; i++) cin >> t[i];
	
	int c = 0;
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < n; j++) {
			if (s[j] == t[i]) {
				c++;
				break;
			}
		}
	}
	
	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 3108
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));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int k = Integer.parseInt(st.nextToken());
        int t = Integer.parseInt(st.nextToken());
        int array[] = new int[t + 1];
        st  = new StringTokenizer(br.readLine());
        for(int i = 1;i <= t;i++){
            array[i] = Integer.parseInt(st.nextToken());
        }
        Arrays.sort(array);
        int start = 1;
        int ans[] = new int[k + 1];
        for(int i = t ;i >= 1;i--){
            for(int j = 1;j <= array[i];j++){
                ans[start] = i;
                start += 2;
                if(start > k)start = 2;
            }
        }
        int days = 0;
        for(int i = 2;i <= k;i++){
            if(ans[i] == ans[i - 1])++days;
        }
        if((k & 1) == 0 && array[t] > k/2 && array[t] < k)--days;
        System.out.print(days);
    }
}

Measured memory_bytes: 8404
require 'pp'

N,M,C = readline.chomp.split.map(&:to_i)
B = readline.chomp.split.map(&:to_i)
count = 0
N.times do |i|
  a = readline.chomp.split.map(&:to_i)
  ans = B.zip(a).map {|bi,ai| bi*ai}.inject(:+) + C
  count += 1 if ans > 0
end
puts count



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

int main() {
    //
    string str;
    int cnt = 0;

    cin >> str;

    for (int i = 0; i < str.size() / 2; i++){
        if (str.at(i) != str.at(str.size() - 1 - i)) cnt++;
    }

    cout << cnt;
    //
}


Measured memory_bytes: 3624
#include <iostream>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

template<int N>
struct sieve {
	bool s[N];
	constexpr sieve() : s() {
		for (int i = 0; i < N; i++)
			s[i] = true;
		for (int i = 4; i < N; i += 2)
			s[i] = false;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
	}
};

int main() {
	enum {N = 10001};
	constexpr sieve<N> s;
	vector<int> t = {5};
	for (int i = 7; i < N; i += 6)
		if (s.s[i - 2] && s.s[i])
			t.push_back(i);
	for (int n; (n = in());) {
		auto r = upper_bound(t.begin(), t.end(), n) - 1;
		outl(*r - 2, ' ', *r);
	}
}


Measured memory_bytes: 3152
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Stack<Integer> stack = new Stack<Integer>();
        while(sc.hasNextInt()){
            int a=sc.nextInt();
            if(a==0){
                System.out.println(stack.pop());
            }else{
                stack.push(a);
            }
        }
    }
}

Measured memory_bytes: 26124
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split())) +[0]

miss = 0
ex = 0
target = 0

for i in range(n+1):
    target = max(a[i]-ex, 0)
    if b[i] > target:
        ex = b[i]-target
    else:
        miss += target-b[i]
        ex = 0

print(sum(a) - miss)

Measured memory_bytes: 19116
//Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  int path[8];
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//
    return false;
  }
  
  void make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return;
    }

    //don't move
    
    if (can_good_pos(now) ){
      path[now]=-1;
      make_next(now+1,Q,S,CANMOVE,NG);
    }

    if ( flag == CANNOTMOVE)return;//

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      path[now]=i;

      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	make_next(now+1,Q,S,CANNOTMOVE,NG);//
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
        
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
if (80<now.cnt+(max(now.x[0],dx)-min(now.x[0],dy)+
max(now.y[0],dy)-min(now.y[0],dy))*3)continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    rep(i,m){
      int f,s;
      cin>>f>>s;
      NG.insert(mp(f,s));
    }
    cin>>dx>>dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 30000
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000001
#define VMAX 20000

int main() {

	unsigned short *A, *B;

	int C[VMAX + 1];
	int n, i, j;
	scanf("%d", &n);

	A = (unsigned short*)malloc(sizeof(short) * n + 1);
	B = (unsigned short*)malloc(sizeof(short) * n + 1);

	for (i = 0; i <= VMAX; i++) C[i] = 0;

	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		C[A[i+1]]++;
	}

	for (i = 1; i <= VMAX; i++) C[i] = C[i] + C[i-1];

	for (j = 1; j <= n; j++) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}

	for (i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 10592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b, c;

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

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        solve();
    }

    void solve() {
        int ans = 3;
        if (a == b && b == c) {
            ans = 1;
        } else if (a == b || b == c || c == a) {
            ans = 2;
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21076
#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 reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  i64 x, a, b;
  cin >> x >> a >> b;

  if (a >= b) cout << "delicious" << "\n";
  else if (b - a <= x) cout << "safe" << "\n";
  else cout << "dangerous" << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <bitset>

using namespace std;

typedef long long ll;

const int MOD = 998244353; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 305;
const int MAX_X = 155;

Modint dp [MAX_N][MAX_N][MAX_N];
int arr [MAX_N];
bitset<MAX_X> pdp [MAX_N][MAX_N][MAX_N];
// <position, # taken, # 0>

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

  int n = s.size();
  for (int i = 0; i < n; i++) {
    arr[i] = s[i] - '0';
  }

  dp[0][n][0] = Modint(1);
  for (int i = 0; i < n; i++) {
    for (int j = n; j >= 1; j--) {
      for (int k = 0; k < n; k++) {
        if (arr[j - 1] == 0) {
          dp[i + 1][j - 1][k] += dp[i][j][k];
          dp[i + 1][j][k] += dp[i][j][k];
        } else {
          dp[i + 1][j - 1][k] += dp[i][j][k];
          dp[i + 1][j][k + 1] += dp[i][j][k];
        }
      }
    }
  }

  pdp[0][0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (pdp[i][j][k].any()) {
          pdp[i + 1][j][k] |= pdp[i][j][k];
          pdp[i + 2][j][k] |= pdp[i][j][k] << 1;
          pdp[i + 2][j + 1][k + (arr[i] == 0)] |= pdp[i][j][k];
          pdp[i + 2][j + 1][k + (arr[i + 1] == 0)] |= pdp[i][j][k];
          pdp[i + 1][j + 1][k + (arr[i] == 0)] |= pdp[i][j][k] >> 1;
        }
      }
    }
  }
  
  Modint ans (0);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (pdp[i][j][k].any()) {
          // cerr << " " << i << " " << k << " " << j - k << " | " << dp[n - i + j][i][k] << endl;
          ans += dp[n - i + j][i][k];
        }
      }
    }
  }

  cout << ans - Modint(1) << endl;
}


Measured memory_bytes: 339236
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = input()
    A = map(int,raw_input().split())

    q = partition(A,0,n-1)
    for i in range(n-1):
        if i == q:
            print "[{}]".format(A[q]),
        else:
            print A[i],
    print A[-1]

def partition(A,p,r):
    x = A[r]
    i = p - 1
    for j in range(p,r):
        if A[j] <= x:
            i += 1
            a = A[i]
            A[i] = A[j]
            A[j] = a
    b = A[i+1]
    A[i+1] = A[r]
    A[r] = b
    return i+1

if __name__ == "__main__":
    main()

Measured memory_bytes: 14688
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arra=limii()
arrb=limii()

times=sum(arrb)-sum(arra)

plus=0
minus=0

for i,j in zip(arra,arrb):
    if j-i>0:
        plus+=(j-i)//2
    elif j-i<0:
        minus+=i-j

if plus>=minus:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);
		int c = Integer.parseInt(tmpArray[2]);
		
		int result = -1;
		int wake = a - 1;
		int sleep = b;
		boolean awake = true;
		//????????§???60??±??????????????°???????????????
		for(int i = 1; i <= 60*60; i++){
//			if(awake){
//				System.out.println("time "+i+": awake");
//			}
//			else{
//				System.out.println("time "+i+": sleep");
//			}
			
			if(i == c && awake){
				result = i;
				break;
			}
			
			if(i % 60 == 0){
				c += 60;
			}
			
			wake--;
			sleep--;
			if(awake && wake < 0){
				awake = false;
				sleep = b - 1;
			}
			else if(!awake && sleep < 0){
				awake = true;
				wake = a - 1;
			}
			


		}
		
		System.out.println(result);
	}

}

Measured memory_bytes: 24332