akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main() {
	int a, b, c;
	scanf("%d %d", &a, &b);
	c = a + b;
	if (c == 0) {
		printf("0\n");
	}
	else if (1 <= c) {
		printf("1\n");
	}
	else {
		printf("-1\n");
	}
	return 0;
}


Measured memory_bytes: 2580
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n,k;
	cin>>n>>k;
	cout<<min(n%k,k-n%k)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll n, dp[N][3], arr[N][3];

int main() 
{
    inlld(n);
    for(ll a=1; a<=n; a++)
        inlld3(arr[a][0], arr[a][1], arr[a][2]);
    for(ll a=0; a<3; a++)
        dp[1][a]=arr[1][a];
    for(ll a=2; a<=n; a++)
    {
        dp[a][0]=arr[a][0]+max(dp[a-1][1], dp[a-1][2]);
        dp[a][1]=arr[a][1]+max(dp[a-1][0], dp[a-1][2]);
        dp[a][2]=arr[a][2]+max(dp[a-1][0], dp[a-1][1]);
    }
    printf("%lld\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
    return 0;
}



Measured memory_bytes: 4992
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

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

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val W = sc.next().toInt()
        val w = IntArray(N)
        val v = IntArray(N)
        repeat(N) {
            w[it] = sc.next().toInt()
            v[it] = sc.next().toInt()
        }

        val dp = Array(N + 1) { LongArray(W + 1) }
        for (i in 1..N) {
            for (j in 1..W) {
                dp[i][j] = arrayOf(dp[i][j], dp[i - 1][j]).max()!!
                if (j - w[i - 1] >= 0) {
                    dp[i][j] = arrayOf(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]).max()!!
                }
            }
        }
        pw.println(dp[N][W])
    }
}


Measured memory_bytes: 198932
s = input()
word_count = len(s)//2
front = s[:word_count]
if len(s)%2 == 0:
    back = s[word_count:]
else:
    back = s[word_count+1:]

back_reversed = back[::-1]

ans = 0

for i in range(word_count):
    if front[i] != back_reversed[i]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
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 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a(n);
	input(a,n);
	sort(all(a));
	
	rep(i,1,n-1,1)
	{
		if(a[i]==a[i-1])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}




Measured memory_bytes: 1792
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ans = 0;
	cin >> N;

	vector<pair<SINT32,SINT32>> AKA(N);
	vector<pair<SINT32,SINT32>> AO(N);

	rep(i,0,N) {
		cin >> AKA[i].first;
		cin >> AKA[i].second;
	}
	rep(i,0,N) {
		cin >> AO[i].first;
		cin >> AO[i].second;
	}

	
	sort(AKA.begin(),AKA.end());
	sort(AO.begin(),AO.end());

	rep(i,0,AO.size()) {
		SINT32 max = -1;
		SINT32 maxNO = INF;
		rep(j,0,AKA.size()) {
			if ((AO[i].first > AKA[j].first) && (AO[i].second > AKA[j].second)) {
				if (max < AKA[j].second) {
					max = AKA[j].second;
					maxNO = j;
				}
			}
		}
		if (max != -1) {
			ans++;
			AKA.erase(AKA.begin() + maxNO);
		}
	}
	


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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;

const long MOD = 1e9 + 7;
int main()
{
  int n;
  cin >>n;
  string s;
  cin >> s;
  int x=0;
  int max =0;
  
  for (int i = 0; i < n; ++i)
  {
    if (s[i]=='I'){
      x++;
    }else{
      x--;
    }
    if (max < x)max = x;
  }


  cout << max<< endl;

  return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <string>

using ll = long long;

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    vector<vector<int> > neigh(n);

    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        neigh[s].push_back(t);
        neigh[t].push_back(s);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        bool flag = true;
        for (int to : neigh[i]) {
            if (to != i && h[to] >= h[i]) {
                flag = false;
            }
        }
        if (flag) {
            ++ans;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 9272
A, B, C, X, Y = map(int, input().split())

if X > Y:
    price = 2 * C * Y + A * (X - Y)
else:
    price = 2 * C * X + B * (Y - X)

print(min(A * X + B * Y, 2 * C * max(X, Y), price))


Measured memory_bytes: 2940
#include <cstdio>
#include <utility>
using namespace std;
typedef pair<int,int> P;
int d[10],v[10];
P p[9];
int gcd(int a,int b) {
	return b?gcd(b,a%b):a;
}
int lcm(int a,int b) {
	return a/gcd(a,b)*b;
}
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<n;i++) {
			scanf("%d %d",&d[i],&v[i]);
		}
		for(int i=0;i+1<n;i++) {
			int x=v[i]*d[i+1],y=d[i]*v[i+1],g=gcd(x,y);
			p[i]=P(x/g,y/g);
		}
		int m=n-1;
		for(int i=0;i+1<m;i++) {
			int l=lcm(p[i].second,p[i+1].first);
			p[i+1].second*=(l/p[i+1].first);
			for(int j=0;j<=i;j++)
				p[j].first*=(l/p[i].second);
			p[i].second=p[i+1].first=l;
		}
		for(int i=0;i<m;i++) {
			printf("%d\n",p[i].first);
		}
		printf("%d\n",p[m-1].second);
	}
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	ll a,b,c; cin>>a>>b>>c;
	ll left=a*b*4, right=(c-a-b)*(c-a-b);

	if(c-a-b<0) {
		cout<<"No"<<endl;
		return 0;
	}
	if(left<right)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
x = -1
y = -1
for i in range(N + 1):
    for j in range(N - i + 1):
        k = int(Y / 1000 - 10 * i - 5 * j)
        if i + j + k ==N:
            x = i
            y = j
            z = k
if x == -1:
    z = -1
print(str(x) + " " + str(y) + " " + str(z))


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        
        Long X = scanner.nextLong();
        Long i = 100L;
        int count = 0;
        while(i < X){
            i += i/100;
            count += 1;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35736
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)


Measured memory_bytes: 38384
#include <stdio.h>

int max(int a,int b){return a > b ? a : b;}
int min(int a,int b){return a < b ? a : b;}
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);

    if(a != b)
    {
        for (int i = 0; i < max(a,b); i++)
        {
            printf("%d",min(a,b));
        }
    }
    else
    {
        for (int i = 0; i < a; i++)
        {
            printf("%d",b);
        }
        
    }
    
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int k,x; cin>>k>>x;
    cout<<(500*k>=x ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,m,x;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(res i=1;i<=m;++i) cin>>x,n-=x;
	cout<<(n<=0?"Yes":"No")<<'\n';
	cout<<flush;	 
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define It iterator
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int row[20][100]={{0},{0,4,2,0,9,7}};
int c[20][100]={{0},{1,0,1,0,1,0,0,1,0,1}};

int n,k,total=0;

int main(){
    cin>>n>>k;
    //freopen("test.in","r",stdin);
    rep(i,2,12) rep(j,1,6) {
        row[i][j]=(row[i-1][j]+11-3)%11;
        c[i][row[i][j]]++;
    }

    if((n<=2)||(k>=11)||(k<0)) {cout<<0<<endl; return 0;}
    n-=2;
    total=n/11*5;
    rep(i,1,(n%11)+1) total+=c[i][k];
    cout<<total<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline()[:-1]
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 MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
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

def main():
    S = input()
    if S == 'A':
        print('T')
    elif S == 'T':
        print('A')
    elif S == 'C':
        print('G')
    elif S == 'G':
        print('C')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

MOD = 10**9+7

x = int(input())

a = 100
count = 0
while a < x:
    a = int(a*1.01)
    count += 1

print(count)


Measured memory_bytes: 68648
N = int(input())
se = set()
ans = 'Yes'
s = input()
se.add(s)
c = s[-1]
for i in range(N-1):
    s = input()
    if s in se or s[0] != c:
        ans = 'No'
        break
    c = s[-1]
    se.add(s)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n; 
    cin >> n;
    if(n < 1200) out("ABC");
    else if(n < 2800) out("ARC");
    else out("AGC");
}

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

int main()
{
  string str; 
  getline(cin, str);
  
  for (int i = 0; i < str.size(); i++){
    if (str[i] == 'a' && str[i + 1] == 'p' && str[i + 2] == 'p' && str[i + 3] == 'l' && str[i + 4] == 'e'){
      str.replace(i, 5, "peach");
    }
    else if (str[i] == 'p' && str[i + 1] == 'e' && str[i + 2] == 'a' && str[i + 3] == 'c' && str[i + 4] == 'h'){
      str.replace(i, 5, "apple");
    }
  }
  cout << str << endl;
  return (0);
}

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

int cnt(int x) {
	x = x - ((x >>> 1) & 0x55555555);
  	x = (x & 0x33333333) + ((x >>> 2) & 0x33333333);
  	x = (x + (x >>> 4)) & 0x0f0f0f0f;
  	x = x + (x >>> 8);
  	x = x + (x >>> 16);
  return x & 0x3f;
}

void main() {
	int m, n;
	scanf("%d %d\n", &n, &m);
	auto bs = new int[m];
	foreach(i; 0..m) {
		auto l = readln.chomp.split.to!(int[]);
		l = l[1..$];
		auto add = 1;
		auto sum = 0;
		foreach(x; l) {
			sum |= add << (x-1);
		}
		bs[i] = sum;
	}
	int r;
	auto p = readln.chomp.split.to!(int[]);
	foreach(x; 0..2^^n) {
		bool acc = true;
		foreach(i; 0..bs.length) {
			acc &= cnt(x & bs[i]) % 2 == p[i];
		}
		if (acc) ++r;
	}
	r.write;
}


Measured memory_bytes: 256
import math
import collections

k = int(input())

gcd_sum_dict = collections.defaultdict(int)
for i in range(1, k+1):
    gcd_sum_dict[i] = 0
    for j in range(1, k+1):
        gcd_sum_dict[i] += math.gcd(i, j)

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        ans += gcd_sum_dict[math.gcd(i, j)]

print(ans)

Measured memory_bytes: 68392
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
vector<int> a(3);
cin>>a[0]>>a[1]>>a[2];
sort(a.begin(),a.end(),greater<int>());
cout<<(a[0]-a[1])+(a[1]-a[2])<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
point = [K - Q for i in range(N)]

for i in range(Q):
    point[A[i]-1] += 1

for i in range(N):
    if point[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11800
//还以为是gcd调了好一会
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
ll x, y;
ll a, b;
ll n;
/*
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}
ll time(ll a, ll b)
{
	return a / gcd(a, b);
}
*/
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		if (i == 0) cin >> x, cin >> y;
		else
		{
			cin >> a >> b;
			ll timea, timeb;
			timea = (x - 1) / a + 1;
			timeb = (y - 1) / b + 1;
			if (timea > timeb)
				swap(timea, timeb);
			if (a * timea >= x && b * timea >= y)
				x = a * timea, y = timea * b;
			else
				x = a * timeb, y = timeb * b;
		}
	}
	cout << x + y << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a),n/2));
	else
	  return (a*(power((a*a),n/2)));    
}
int main()
{
  IOS;
   int n;
   cin>>n;
   if(n>81)
   {
   cout<<"No"<<endl;
   return 0;
   }
   for(int i=1;i<10;i++)
   {
       if(n%i==0)
       {
           if(n/i<=9)
           {
               cout<<"Yes"<<endl;
               return 0;
           }
       }
   }
   cout<<"No"<<endl;
   return 0;
   
}

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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

int N;
V<> X, Y;

int GetDist(int x1, int y1, int x2, int y2) {
    return abs(x1 - x2) + abs(y1 - y2);
}

signed main() {
    IOS;

    cin >> N;
    X.resize(N);
    Y.resize(N);
    REP(i, N) {
        cin >> X[i] >> Y[i];
    }

    int ans = 0;

    // 左下のほうにいる→ x + y が小さい
    // 右上のほうにいる→ x + y が大きい
    V<pii> cand_ld; // (x+y, ind)
    V<pii> cand_ru;
    REP(i, N) {
        cand_ld.pb(mp(X[i] + Y[i], i));
        cand_ru.pb(mp(X[i] + Y[i], i));
    }
    SORT(cand_ld);
    SORT(cand_ru);
    reverse(all(cand_ru));

    REP(i, (ll)min(100LL, N)) {
        REP(j, (ll)min(100LL, N)) {
            int ind1 = cand_ld[i].second;
            int ind2 = cand_ru[j].second;
            if(ind1 == ind2) { continue; }
            chmax(ans, GetDist(X[ind1], Y[ind1], X[ind2], Y[ind2]));
        }
    }

    // 左上のほうにいる→ x が小さく y が大きい
    // 右下のほうにいる→ x が大きく y が小さい
    V<pii> cand_lu, cand_rd;
    REP(i, N) {
        cand_lu.pb(mp(Y[i] - X[i], i));
        cand_rd.pb(mp(X[i] - Y[i], i));
    }
    SORT(cand_lu);
    SORT(cand_rd);
    reverse(all(cand_lu));
    reverse(all(cand_rd));

    REP(i, (ll)min(100LL, N)) {
        REP(j, (ll)min(100LL, N)) {
            int ind1 = cand_lu[i].second;
            int ind2 = cand_rd[j].second;
            if(ind1 == ind2) { continue; }
            chmax(ans, GetDist(X[ind1], Y[ind1], X[ind2], Y[ind2]));
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 22164
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int S, W;

signed main(){
	cin >> S >> W;
	if(W >= S) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
//https://atcoder.jp/contests/abc176/submissions/16116488
const int INF=2.147e9;
int qlen=0;
static inline int Abs(int x){return x<0?-x:x;}
struct nodetag{int y,x,cost;}Q[50000];
static inline void qfix(int idx)
{
  while(1)
  {
    int midx=idx;
    rep(i,2){int cidx=idx*2+i+1;if(cidx<qlen&&Q[midx].cost>Q[cidx].cost){midx=cidx;}}
    if(midx==idx){if(!idx){break;}idx=(idx-1)/2;}
    else{struct nodetag sw=Q[idx];Q[idx]=Q[midx];Q[midx]=sw;idx=midx;}
  }
}
static inline void qpush(int y,int x,int cost)
{
  Q[qlen].y=y;Q[qlen].x=x;Q[qlen].cost=cost;qfix(qlen);qlen++;
}
static inline struct nodetag qpop(void)
{
  if(qlen<=0){exit(EXIT_FAILURE);}
  struct nodetag res=Q[0];qlen--;if(qlen){Q[0]=Q[qlen];qfix(0);}
  return res;
}
const int dx[24]={0,1,0,-1,0,0,1,1,1,1,-1,-1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2},
          dy[24]={1,0,-1,0,2,-2,1,2,-1,-2,1,2,-1,-2,0,1,2,-1,-2,0,1,2,-1,-2};
int main(void)
{
  int H=IN(),W=IN(),Ch=IN(),Cw=IN(),Dh=IN(),Dw=IN(),dist[H][W],field[H][W];char str[W+1];
  rep(i,H)
  {
    if(!scanf("%s",str)){return -1;}
    rep(j,W){dist[i][j]=INF;field[i][j]=(str[j]=='#');}
  }
  qpush(Ch-1,Cw-1,0);dist[Ch-1][Cw-1]=0;
  while(qlen)
  {
    struct nodetag pos=qpop();
    rep(i,24)
    {
      int ny=pos.y+dy[i],nx=pos.x+dx[i],warp=!(Abs(dx[i])+Abs(dy[i])<=1),need=dist[pos.y][pos.x]+warp;
      if(0<=ny&&ny<H&&0<=nx&&nx<W&&!field[ny][nx]&&need<dist[ny][nx])
      {
        dist[ny][nx]=need;qpush(ny,nx,need);
      }
    }
  }
  return OUT(dist[Dh-1][Dw-1]<INF?dist[Dh-1][Dw-1]:-1),0;
}

Measured memory_bytes: 9520
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;

bool isPalindrome(string str)
{
	ll i,j,k,l,n;
	l=str.length();
	for(i=0;i<l/2;i++)
	{
		if(str[i]==str[l-i-1])
			continue;
		else
			return 0;
	}
	return 1;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
		double x,y;
		cin>>x;
		y=x/3;
		y=y*y*y;
		cout<<fixed<<setprecision(12)<<y<<"\n";
		return 0;
}
	

Measured memory_bytes: 3776
#include <stdio.h>
#include <string.h>

int main(void)
{
	char code[1000];
	char decode[1000];
	int i;
	
	scanf("%[^\n]", code);
	
	i = 0;
	while (code[i] != '\0'){
		if (code[i] == 'A'){
			decode[i] = 'X';
		}
		else if (code[i] == 'B'){
			decode[i] = 'Y';
		}
		else if (code[i] == 'C'){
			decode[i] = 'Z';
		}
		else {
			decode[i] = code[i] - 3;
		}
		i++;
	}
	
	decode[i] = '\0'; 
	
	printf("%s\n", decode);
	
	return (0);
}

Measured memory_bytes: 1748
n,m,x,y = map(int,input().split())
x_list = [int(i) for i in input().split()]
y_list = [int(i) for i in input().split()]

x_list.append(x)
x_list.sort()
y_list.append(y)
y_list.sort()

if max(x_list) < min(y_list):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  int n; cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  int mid = n / 2;
  int left = d[mid-1], right = d[mid];
  int ans = right - left;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
bn = list(map(int, input().split()))

sum_an = bn[0]
for i in range(N-1):
    if i == N-2:
        sum_an += bn[i]
    else:
        sum_an += min(bn[i], bn[i+1])
print(sum_an)


Measured memory_bytes: 38384
N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]
def naiseki(A,B,M):
    res = 0
    for i in range(M):
        res = res + A[i]*B[i]
    return res
def solve(N,M,C):
    res = 0
    for i in A:
        if naiseki(i,B,M) + C > 0:
            res = res + 1
    return res
print(solve(N,M,C))


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

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

			var B = new int[A.Length];
			CountingSort(A, B, A.Max());

			System.Console.WriteLine(string.Join(" ", B));

		}

		static void CountingSort(int[] A, int[] B, int k)
		{
			var C = new int[k + 1];
			for (int i = 0; i < A.Length; i++)
			{
				C[A[i]]++;
			}

			for (int i = 1; i < C.Length; i++)
			{
				C[i] += C[i - 1];
			}

			for (int i = A.Length - 1; 0 <= i; i--)
			{
				B[C[A[i]] - 1] = A[i];
				C[A[i]]--;
			}
		}
	}
}



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

int N;
int X[1001];

const int INF = 2000000000;
int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++){
      string s; cin >> s;
      if( s == "x" ) X[i] = -INF;
      else {
        stringstream sin(s);
        sin >> X[i];
      }
    }
    int r = -1000000009;
    int l =  1000000009;
    bool f = true;
    bool nf = true;
    for(int i=0;i<N;i++){
      if(i < N-1 &&  X[i] == X[i+1] && X[i] == -INF ) f = false;
      if( X[i] == -INF ){
        nf = false;
        if( i & 1 ){//even
          if( i > 0 ) r = max( X[i-1]+1,r );
          if( i < N-1 ) r = max( X[i+1]+1,r );
        } else {
          if( i > 0 ) l = min( X[i-1]-1,l );
          if( i < N-1 ) l = min( X[i+1]-1,l );
        }
      } else {
        if( i & 1 ){
          if( i > 0 && X[i-1] != -INF && X[i-1] >= X[i] ) f = false;
          if( i < N -1 && X[i+1] != -INF && X[i+1] >= X[i] ) f = false;
        } else {
          if( i > 0 && X[i-1] != -INF && X[i-1] <= X[i] ) f = false;
          if( i < N -1 && X[i+1] != -INF && X[i+1] <= X[i] ) f = false;
        }
      }
      //cout << X[i] << " " << l <<" "<< r << endl;
    }
    //  cout << f<< " "<< nf << " " << l << " " << r << endl;
    if( !f ) cout << "none" << endl;
    else if( nf ) cout << "ambiguous" << endl;
    else if( l == r ) cout << l << endl;
    else if( l < r ) cout << "none" << endl;
    else cout << "ambiguous" << endl;
  }
}

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

int  main(){

	long long  n;
	cin >> n;

	vector<long long > a(n);
	for(long long  i=0;i<n;i++){
		cin >> a[i];
	}

	long long  temp = 0;

	bool tan = true;

	for(long long  i=n-1;i>=0;i--){
		if(tan){
			temp+=a[i];
			tan=false;
		}else{
			temp-=a[i];
			tan=true;
		}
	}

	vector<long long > ans(n);
	ans[0]=temp;

	//cout << ans[0] << "\n";

	for(long long  i=1;i<n;i++){
		ans[i] = (a[i-1]-ans[i-1]/2)*2;
	}

	for(long long  i=0;i<n;i++){
		cout << ans[i] << " ";
	}
	cout << "\n";


	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll sum[n+1];
    sum[n]=0;
    for(int i=n-1;i>=0;i--){
        sum[i]=sum[i+1]+a[i];
    }
    ll ok=1,ng=200001;
    ll hold[200001];
    while(ng-ok>1){
        ll mid=(ok+ng)/2;
        ll t=0;
        for(int i=0;i<n;i++){
            t+=n-(lower_bound(a,a+n,mid-a[i])-a);
        }
        hold[mid]=t;
        if(t>=m)ok=mid;
        else ng=mid;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        int tmp=lower_bound(a,a+n,ok-a[i])-a;
        ans+=sum[tmp]+a[i]*(n-tmp);
    }
    ans-=(hold[ok]-m)*ok;
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int ans=0;
	rep(i,n){
		set<char> cnt;
		cnt.insert(a[i]),cnt.insert(b[i]),cnt.insert(c[i]);
		if(cnt.size()==3) ans+=2;
		else if(cnt.size()==2) ans+=1;
	}
	cout<<ans<<endl;
}

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

int main() {
  int n;
  cin>>n;
  if(n<112){
    cout<<"111"<<endl;
  }
  else if(n<223){
    cout<<"222"<<endl;
  }
  else if(n<334){
    cout<<"333"<<endl;
  }
  else if(n<445){
    cout<<"444"<<endl;
  }
  else if(n<556){
    cout<<"555"<<endl;
  }
  else if(n<667){
    cout<<"666"<<endl;
  }
  else if(n<778){
    cout<<"777"<<endl;
  }
  else if(n<889){
    cout<<"888"<<endl;
  }
  else{
    cout<<"999"<<endl;
  }
  
}

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

int main (){

	long s,c,ans;

	cin >> s >> c;

	if(2*s>=c){
		ans = c/2;
	}
	else if(2*s<c){
		ans = (s + (c-2*s)/4);
	}

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

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

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil -> prev = nil;
  nil -> next = nil;
}

Node *searchList(int key) {
  for (Node *cur = nil -> next; cur != nil; cur = cur -> next) {
    if(cur -> key == key) return cur;
  }
  return nil;
}

void insert(int key) {
  Node *n = (Node *)malloc(sizeof(Node));
  n -> key = key;
  n -> next = nil -> next;
  n -> prev = nil;
  nil -> next -> prev = n;
  nil -> next = n;
}

void deleteNode(Node *n) {
  if(n == nil) return;

  n -> prev -> next = n -> next;
  n -> next -> prev = n -> prev;

  free(n);
}

void deleteFirstNodeWithKey(int key) {
  deleteNode(searchList(key));
}

void deleteFirst() {
  deleteNode(nil -> next);
}

void deleteLast() {
  deleteNode(nil -> prev);
}

void printList() {
  for (Node *cur = nil -> next; cur != nil; cur = cur -> next) {
    printf("%d", cur -> key);
    if(cur != nil -> prev) {
      printf(" ");
    }
  }
  puts("");
}

int main() {
  int n;
  scanf("%d", &n);
  init();
  for(int i = 0; i < n; i++) {
    char cmd[20];
    int key;
    scanf("%s%d", cmd, &key);

    if(cmd[0] == 'i') { // insert
      insert(key);
      continue;
    }

    if(strlen(cmd) == 6) { // delete
      deleteFirstNodeWithKey(key);
      continue;
    }

    if(cmd[6] == 'F') { //deleteFirst
      deleteFirst();
      continue;
    }

    { // deleteLast
      deleteLast();
      continue;
    }


  }

  printList();
}

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

using namespace std;
typedef long long ll;

const int N = 200'010, M = 998244353;
pair<int, int> a[N];
ll dp[N];
int t[4 * N];

int get(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (l == tl && r == tr) return t[v];
    int tm = (tl + tr) / 2;
    return max(get(v * 2, tl, tm, l, min(r, tm)),
               get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm) update(v * 2, tl, tm, pos, new_val);
        else update(v * 2 + 1, tm + 1, tr, pos, new_val);
        t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);
    sort(a, a + n);
    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
        int idx = lower_bound(a, a + n, make_pair(a[i].first + a[i].second, 0)) - a - 1;
        int r = (idx == i) ? i : get(1, 0, n - 1, i, idx);
        update(1, 0, n - 1, i, r);
        dp[i] = (dp[i + 1] + dp[r + 1]) % M;
    }
    printf("%lld\n", dp[0]);
}


Measured memory_bytes: 9004
using System;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] s1 = Console.ReadLine().Split(' ');
        string ans = "";

        for(int i = 0; i < N; i++)
        {
            ans += s1[0][i].ToString() + s1[1][i].ToString();
        }

        Console.WriteLine(ans);
    }
}


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

counts = {}
for e in A:
    if e not in counts:
        counts[e] = 0
    counts[e] += 1

ans = 0
for e in counts:
    ans += counts[e] * (counts[e]-1) // 2

for i in range(0, len(A)):
    print(ans - counts[A[i]] + 1)


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int X; cin >> X;
  if (X%2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  int mod = 0;
  REP(i,100000000) {
    mod = mod*10 + 7;
    mod %= X;
    if (mod == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int S = sc.nextInt();
		// スペース区切りの整数の入力
		int W = sc.nextInt();
        if(S>W){
            System.out.println("safe");
        }else{
          System.out.println("unsafe");
        }
	}
}

Measured memory_bytes: 35740
#include<iostream>
#include<stack>

#define MAX_H 100
#define MAX_W 100

using namespace std;
typedef pair<int,int> P;

int h,w,res;
stack<P> fields;
P now;
char field[MAX_H][MAX_W+1];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};//EAºA¶AãÌÔ

void dfs(int x,int y,char fruit){

    fields.push(P(x,y));
    field[x][y]='%';

    while(!fields.empty()){
        now=fields.top();
        fields.pop();
        x=now.first; y=now.second;
//      cout<<x<<','<<y<<endl;
        for(int i=0;i<4;i++){
            int nx=x+dx[i]; int ny=y+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&field[nx][ny]!='%'&&fruit==field[nx][ny]){
                fields.push(P(nx,ny));
                field[nx][ny]='%';
//              cout<<"[nx,ny="<<nx<<ny<<"]"<<endl;
            }
        }
    }
   
    return;
}

int main(){

    while(1){
        res=0;
        cin>>h>>w;
        if(w==0) break;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>field[i][j];
            }
        }

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(field[i][j]!='%'){
                    dfs(i,j,field[i][j]);
                    res++;
//                  cout<<"res="<<res<<endl;
                }
            }
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()

void solve(){
    
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int t=0;
   while(1)
   {
   	  if(t==0)
   	  {   
   	  	  if(c-b<=0)
   	  	  {
   	  	  	 cout<<"Yes\n";
   	  	  	 return;
   	  	  }
   	  	  else
   	  	  {
   	  	  	 c-=b;
   	  	  }
   	  	  t=t^1;
   	  }
   	  else
   	  {
   	  	 if(a-d<=0)
   	  	 {
   	  	 	 cout<<"No\n";
   	  	 	 return;
   	  	 }
   	  	 else
   	  	 {
   	  	 	 a-=d;
   	  	 }
   	  	 t=t^1;
   	  }

   }
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int> a(4),b(4);
	int hit=0,blow=0;
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		for(int i=0;i<4;i++){
			if(a[i]==b[i]) hit++;
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(a[i]==b[j]) blow++;
			}
		}
	blow -=  hit;
	cout<<hit<<" "<<blow<<endl;
	blow=0;
	hit=0;
	}
}

Measured memory_bytes: 0
<?php
//error_reporting(0);
//$K = trim(fgets(STDIN));
list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$A = explode(" ",trim(fgets(STDIN)));
for($i=1;$i<=3;$i++) {
  if (($A*$B*$i) % 2 == 1) {
    printf("Yes\n");
    exit;
  }
}

printf("No\n");


Measured memory_bytes: 3828
#include <stdio.h>

int main (){
	
	int kata, lowercase;
	
	scanf ("%d %d",&kata, &lowercase);
	char  huruf [kata+5]; 
	scanf("%s",huruf); 
 	huruf [lowercase-1]+=32;
 	printf ("%s",huruf);
 	
	return 0;
}


Measured memory_bytes: 1708
MOD = 10**9 + 7
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = [0 for i in range(2001)]
for a in A:
	cnt[a] += 1
total = [0]
for i in range(2000):
	total.append(total[i] + cnt[i+1])

base = 0
loop = 0
keisu = K*(K-1)//2 % MOD
for i in range(N):
	a = A[i]
	for j in range(i+1, N):
		if a > A[j]:
			base += 1
	loop = (loop + total[a-1] * keisu) % MOD

print((base*K + loop) % MOD)

Measured memory_bytes: 3188