akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;
ld PI = M_PI;
ll INF = INT_MAX;
/* sample input

*/

int main()
{
	ll n;
	ll x1, y1, x2, y2;
	ll minx, miny, maxx, maxy;
	vector<P> vx;
	cin >> x1 >> y1 >> x2 >> y2;
	cin >> n;

	minx = x1 < x2 ? x1 : x2;
	maxx = x1 < x2 ? x2 : x1;
	miny = y1 < y2 ? y1 : y2;
	maxy = y1 > y2 ? y1 : y2;


	for (ll i = 0; i < n; i++) {
		ll tempx, tempy;
		cin >> tempx >> tempy;
		if (minx <= tempx&&tempx <= maxx &&miny <= tempy&&tempy <= maxy) {
			vx.push_back(P(tempx, tempy));
		}
	}

	if ((x2 - x1)*(y2 - y1) >= 0) {
		sort(vx.begin(), vx.end());
	}
	else {
		sort(vx.begin(), vx.end(),greater<P>());
	}

	ll vsize = vx.size();
	ll *v, *dp;
	ll res = 0,res2=0;
	v = new ll[vsize];
	dp = new ll[vsize];
	for (ll i = 0; i < vsize; i++) {
		v[i]=vx[i].second;
	}

	if (vsize > 0) {
		res = 1;
	}
	//dp[i]:最後がa[i]であるような最長の増加分分裂の長さ
	//for (ll i = 0; i < vsize; i++) {
	//	dp[i] = 1;
	//	for (ll j = 0; j < i; j++) {
	//		if (v[j] < v[i]) {
	//			dp[i] = max(dp[i], dp[j] + 1);
	//		}
	//		res = max(res, dp[i]);
	//	}
	//	//ll temp = *lower_bound(dp, dp + ll(i), INF);
	//	res = max(res, dp[i]);
	//}
	//dp[i]:最後がa[i]であるような最長の増加分分裂の長さ
	fill(dp, dp + vsize, INF);
	for (ll i = 0; i < vsize; i++) {
		*lower_bound(dp, dp + vsize, v[i]) = v[i];
	}
	res = ll(lower_bound(dp, dp + vsize, INF) - dp);




	if (res == min(abs(x1 - x2)+1, abs(y1 - y2) + 1)) {
		res2 = 1;
		res--;
	}


	ld answer = (abs(x1 - x2) + abs(y1 - y2))*100.0L + ld(res)*(PI*5.0L - 20.0L) + ld(res2)*(PI*10.0L - 20.0L);


	cout << setprecision(18) << answer;


	return 0;
}

Measured memory_bytes: 7404
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = input()
    if (N[0] == N[1] == N[2]) or (N[1] == N[2] == N[3]):
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

const double PI = acos(-1.0);

int main()
{
	double X = 0.0,Y = 0.0;
	int A,B,R = 90;
	while(scanf("%d,%d",&A,&B),(A || B)){
		X += A * cos(R * PI / 180.0);
		Y += A * sin(R * PI / 180.0);
		R -= B;
		if(R > 180) R -= 360;
		if(R < -180) R += 360;
	}

	printf("%d\n%d\n",(int) X,(int) Y);

	return 0;
}

Measured memory_bytes: 3460
#include <stdio.h>

int main(){
	int w, h, x, y, r;
	int a, b, c, d;
	scanf("%d %d %d %d %d",&w ,&h ,&x ,&y ,&r);
	
	a = x + r;
	b = y + r;
	c = x - r;
	d = y - r;
	
	if(a > w || b > h)printf("No\n");
	else if(0 > c || 0 > d)printf("No\n");
	else printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    const int value = 2019;
    ll L, R;
    cin >> L >> R;
    ll num = R - L + 1; //LからRまでの間にある整数の個数
    ll ans;
    if(num >= value){
        ans = 0;
    }else{
        ans = 2018;
        for(ll j = L; j <= R; j++){
            for(ll k = j + 1; k <= R; k++){
            ll a = j * k;
            ans = min(ans, a % value);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(s[k-1] == 'A'){
        s[k-1] = 'a';
    }
    else if(s[k-1] == 'B'){
        s[k-1] = 'b';
    }
    else{
        s[k-1] = 'c';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;
string s;

ll f(int i, char c1, char c2) {
    ll k = count(s.begin(), s.begin() + i, c1);
    ll res = 0;

    for (int d = 1; i + d < n; d++) {
        if (s[i + d] == c2) {
            if (i - d < 0 || s[i - d] != c1) {
                res += k;
            } else {
                res += k - 1;
            }
        }
    }

    return res;
}

int main() {
    fastio();

    cin >> n >> s;

    ll ans = 0;
    for (int j = 1; j < n - 1; j++) {
        if (s[j] == 'R') {
            ans += f(j, 'B', 'G') + f(j, 'G', 'B');
        } else if (s[j] == 'G') {
            ans += f(j, 'R', 'B') + f(j, 'B', 'R');
        } else {
            ans += f(j, 'R', 'G') + f(j, 'G', 'R');
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

ll C[42][42];
void init_math(){
	C[0][0] = 1;
	rep1(i,41){
		C[i][0] = 1;
		rep1(j,i){
			C[i][j] = C[i-1][j]+C[i-1][j-1];
		}
		C[i][i+1] = 0;
	}
}
ll f(int n,int m){
	return (1LL<<(n+m-1))-1+C[n+m][n];
}

int main(){
	init_math();
	vector<pair<ll,P>> vec;
	vec.pb(pair<ll,P>(1,P(0,0)));
	for(int n = 1 ; n <= 40 ; n ++){
		for(int m = 1 ; n+m <= 41 ; m ++){
			vec.pb(pair<ll,P>(f(n,m),P(n,m)));
		}
	}
	sor(vec);
	/*ll ret = 0;
	for(int i = 0 ; i+1 < vec.size() ; i ++){
		ret = max( ret , vec[i+1]-vec[i] );
	}
	cout << ret << endl;*/
	
	vector<int> ret;
	
	ll n;
	cin >> n;
	int t = 0;
	
	int W = 2;
	while((1LL<<W)-1 <= n)W ++;
	vector<int> vec_;
	n -= (1LL<<(W-1))-1;
	for(int i = W/2 ; i >= 3 ; i --){
		while(n >= C[W][i]){
			n -= C[W][i];
			vec_.pb(i);
		}
	}
	sor(vec_);
	int loc = 0;
	for(int i = 0 ; i < W ; i ++){
		while(loc < vec_.size() && vec_[loc] == i){
			ret.pb(++loc);
		}
		ret.pb(vec_.size()+1);
	}
	rrep1(i,vec_.size()){
		ret.pb(i);
	}
	t += vec_.size()+1;
	
	//int cnt = 0;
	while(n>0){
		int k = 0;
		while(k+1 < vec.size() && vec[k+1].fr <= n)k ++;
		//cnt += vec[k].sc.fr + vec[k].sc.sc;
		if(vec[k].fr == 1){
			ret.pb(t+1);
			ret.pb(t+1);
			t ++;
		}
		else {
			rep(i,vec[k].sc.fr){
				ret.pb(t+1);
			}
			ret.pb(t+2);
			rep(i,vec[k].sc.sc){
				ret.pb(t+1);
			}
			ret.pb(t+2);
			t += 2;
		}
		n -= vec[k].fr;
		//cout << vec[k].sc.fr << " " << vec[k].sc.sc << endl;
	}
	cout << ret.size() << endl;
	rep(i,ret.size()){
		printf("%d%c",ret[i],(i+1==ret.size())?'\n': ' ');
	}
	//cout << cnt << endl;
}

Measured memory_bytes: 256
from itertools import permutations, product
from collections import Counter
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

zero = []
one = []
two = []
for i, j in product(range(N), repeat=2):
	if (i + j) % 3 == 0:
		zero.append(c[i][j])
	elif (i + j) % 3 == 1:
		one.append(c[i][j])
	else:
		two.append(c[i][j])

zero = Counter(zero)
one = Counter(one)
two = Counter(two)

iwakan_min = float("inf")

for p, q, r in permutations(range(0, C), r=3):
	iwakan = 0
	for key, value in zero.items():
		iwakan += value * (D[key - 1][p])
	for key, value in one.items():
		iwakan += value * (D[key - 1][q])
	for key, value in two.items():
		iwakan += value * (D[key - 1][r])
	if iwakan < iwakan_min:
		iwakan_min = iwakan

print(iwakan_min)

Measured memory_bytes: 7992
#include<iostream>

using namespace std;

int main(){
    int k,s;
    cin>>k>>s;

    int ans=0;
    for(int x=0;x<=k;++x){
        for(int y=0;y<=k;++y){
            int z=s-x-y;
            if(0<=z&&z<=k) ++ans;
        }
    }

    cout<<ans<<endl;
}

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

int main(){
    long long int N,P;
    cin >> N>>P;
    long long int S[N];
    long long int  count[P]={};
    for( int i=0;i<N;i++){
        char s;
        cin >>s;
        S[i]=s-'0';
    }
    long long int ans=0;
    if(P==2){
        for( int i=0;i<N;i++){
            if(S[N-1-i]%2==0){
                ans+=N-i;
            }
        }
    }else if(P==5){
        for( int i=0;i<N;i++){
            if(S[N-1-i]%5==0){
                ans+=N-i;
            }
        }
    }else{
        count[0]++;
        long long int r=0;
        long long int tenmod=1;
        for( int i=0;i<N;i++){
            r=(r+tenmod*S[N-1-i])%P;
            count[r]++;
            tenmod=(10*tenmod)%P;
        }   
        for( int i=0;i<P;i++){
            ans+=count[i]*(count[i]-1)/2;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1920
n, m = map(int, input().split())
l = list(map(int, input().split()))

def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)
def lcm(x, y):
    return (x * y) // gcd(x, y)

k = 1

for i in l:
    i //= 2
    k = lcm(k, i)
    if (k // i) % 2 == 0 or k > m:
        print(0)
        break
else:
    print(m // k - m // (k * 2))

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


def main():
    import sys
    input = sys.stdin.readline

    a, b, c = map(int, input().split())
    k = int(input())
    count = 0

    while a >= b:
        b *= 2
        count += 1

    while b >= c:
        c *= 2
        count += 1

    if count <= k:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n, m;
	cin >> n >> m;

	vector<vector<int>> v(n+1, vector<int>(m+1));

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			cin >> v[i][j];
		}
	}
	

	vector<bool> pres(m+1, true);
	vector<int> cnt(m+1);
	int ans = n;

	for(int i = 1; i <= m + 2; i++) {
		for(int j = 1; j <= n; j++) {
			for(int k = 1; k <= m; k++) {
				if(pres[v[j][k]]) {
					cnt[v[j][k]]++;
					break;
				}
			}
		}

		int mx = 0;
		for(int j = 1; j <= m; j++) {
			mx = max(mx, cnt[j]);
		}

		ans = min(ans, mx);
		for(int j = 1; j <= m; j++) {
			if(cnt[j] == mx) pres[j] = false;
			cnt[j] = 0;
		}

		bool flag = false;

		for(int j = 1; j <= m; j++) {
			if(pres[j]) flag = true;
		}

		if(!flag) break;
	}

	cout << ans;

	return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long n, temp_n, fx = 0;
    
    cin >> n;
    temp_n = n;
    while(temp_n > 0){
        fx += temp_n % 10;
        temp_n /= 10;
    }
    
    if(n % fx == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
        
    return 0;
}

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

int main(void)
{
	int N, X, min = 1000;
	cin >> N >> X;
	int *m = new int[N];
	for (int i = 0; i < N; ++i) {
		cin >> m[i];
		X -= m[i];
		if (m[i] < min)	min = m[i];
	}

	cout << N + int(X / min) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
  double x,q;
  while(  cin >> q ){
    if(q == -1.0)break;
    x = q/2;
    while(fabs(pow(x,3) - q) >= 0.00001*q )x = x - (pow(x,3) - q)/(3*pow(x,2));
    printf("%.10f\n",x);
  }
  return 0;
}

Measured memory_bytes: 1236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in[] = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int arr[][]=new int[n][3];
        int dp[][] = new int[n+1][3];
        for(int i=0;i<n;i++){
            in = br.readLine().split(" ");
            arr[i][0] = Integer.parseInt(in[0]);
            arr[i][1] = Integer.parseInt(in[1]);
            arr[i][2] = Integer.parseInt(in[2]);
        }
        for(int i=1;i<=n;i++){
            dp[i][0] = Math.max(dp[i-1][1], dp[i-1][2])+arr[i-1][0];
            dp[i][1] = Math.max(dp[i-1][0], dp[i-1][2])+arr[i-1][1];
            dp[i][2] = Math.max(dp[i-1][1], dp[i-1][0])+arr[i-1][2];
        }
        System.out.println(Math.max(Math.max(dp[n][0],dp[n][1]), dp[n][2]));
    }
}



Measured memory_bytes: 51612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(ll i=0;i<x;i++)

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

int dis[110];

int main(){
  int N,K;
  cin>>N>>K;
  rep(i,K){
    int d;
    cin>>d;
    int a[d];
    rep(j,d){

      cin>>a[j];
      dis[a[j]]++;
    }
  }
  int ans=0;
  for(int i=1;i<=N;i++){
    if(dis[i]==0) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\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; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;  // 大会の参加者(人)
  int M;  // アリーナの数
  cin >> N >> M;

  if (N % 2 == 1) {
    F0R(i, M) {
      cout << (i + 1) << ' ' << (N - i) << newl;
    }
  }
  else {
    int a = 1, b = N / 2;
    int s = 1;
    F0R(i, M) {
      int l, r;
      if (i % 2 == 0) {
        l = a - i / 2;
      }
      else {
        l = b - i / 2;
      }
      r = l + s;
      if (l < 1) l += N;
      if (r > N) r -= N;

      cout << l << ' ' << r << newl;

      s++;
    }
  }
}
#endif


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

public class Main {

	static long x1, x2, xor;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		long[] arr = sc.nextLongArr(n);
		xor = 0;
		long sum = arr[0] + arr[1];
		for (int i = 2; i < arr.length; i++) {
			xor ^= arr[i];
		}
		x1 = arr[0];
		x2 = arr[1];
		if (sum - xor < 0 || (sum - xor) % 2 == 1) {
			pw.println(-1);
			pw.close();
			return;
		}
		long fixed = (sum - xor) / 2;
		if ((xor ^ fixed) != xor + fixed) {
			pw.println(-1);
			pw.close();
			return;
		}
		for (int i = 60; i >= 0; i--) {
			long bit = (1l << i);
			if ((bit & xor) == 0)
				continue;
			if (fixed + bit <= x1) {
				fixed += bit;
			}
		}
		pw.println(fixed == 0 ? -1 : Math.max(arr[0] - fixed, -1));

		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

		public long[] nextLongArr(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Long.parseLong(next());
			}
			return arr;
		}

	}

}


Measured memory_bytes: 26000
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

int main()
{
    string a, b, c; cin >> a >> b >> c;
    string ans = "NO";
    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        ans = "YES";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <set>

void neko(std::set<intmax_t>& divs, intmax_t a) {
  for (intmax_t i = 2; i*i <= a; ++i) {
    if (a % i == 0) {
      divs.insert(i);
      a /= i;
    }
  }
  if (a > 1) divs.insert(a);
}

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);

  std::set<intmax_t> divs;
  for (auto ai: a)
    neko(divs, ai);

  intmax_t res = 0;
  for (auto d: divs) {
    intmax_t cur = 0;
    for (auto ai: a) {
      if (ai % d != 0) continue;
      cur += ai;
    }
    res = std::max(res, cur);
  }

  printf("%jd\n", res);
}



Measured memory_bytes: 2812
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int vis[11];
int check(int n)//检查当前数是否在这k个数中
{
	while(n)
	{
		if(vis[n%10]==1)
			return 0;
		n/=10;
	}
	return 1;
}
int main()
{
	int n,k;
	int x;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>x;
		vis[x]=1;
	}
	for(int i=n;;i++)
	{
		if(check(i))
		{
           cout<<i<<endl;
           return 0;
		}
	}
	return 0;
}


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

int main(){
    ll n;
    int s = 0; 
    cin >> n;
    int cnt = 1;
    while(n > 9){
        if(n%10 != 9) s = 1;
        n /= 10;
        cnt++;
    }
    if(s == 0) cout << n + 9*(cnt-1) << endl;
    else{
        cout << n + 9*(cnt-1)-1 << endl;
    }
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 24;

int main(void){
    vi a(10);

    for(auto && aa : a){
        cin >> aa;
    }

    sort(all(a), greater<int>());

    rep(i, 3) cout << a[i] << endl;

	return 0;
}

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


int main(){
	string S;
	cin >> S;
	int N = S.size();
	vector<int> chil(N, 0);
	
	//Rのみ考えて、RLの変更点まで連続したRが偶数個か奇数個判定し、加算(左から攻める)
  	int cntR = 1;
	for(int i = 1; i < N; i++){
		if(S.at(i) == 'R'){
			cntR++;
		}
		if(S.at(i) == 'L'){
			if(cntR % 2 == 0){
				chil.at(i) += cntR / 2;
				chil.at(i - 1) += cntR / 2;
			} else {
				chil.at(i) += cntR / 2;
				chil.at(i - 1) += (cntR - cntR / 2);
			}
			cntR = 0;
		}
	}
	
	//Lのみ考えて、Rと同様の操作(右から攻める)
  	int cntL = 1;
	for(int i = N - 2; i >= 0; i--){
		if(S.at(i) == 'L'){
			cntL++;
		}
		if(S.at(i) == 'R'){
			if(cntL % 2 == 0){
				chil.at(i) += cntL / 2;
				chil.at(i + 1) += cntL / 2;
			} else {
				chil.at(i) += cntL / 2;
				chil.at(i + 1) += (cntL - cntL / 2);
			}
			cntL = 0;
		}
	}
	
	for(int i = 0; i < N; i++) cout << chil[i] << " ";
  	cout << endl;
}

Measured memory_bytes: 1024
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]) {
    def simpleCal: Unit = {
      val input = readLine().split(" ")
      val a: Int = input(0).toInt
      val b: Int = input(2).toInt
      val op: String = input(1)

      val calResult: Any = op match {
          case "+" => a + b
          case "-" => a - b
          case "*" => a * b
          case "/" => a / b
          case "?" => "end"
      }

      if(calResult != "end") {
        println(calResult)
        simpleCal
      }
    }

    simpleCal
  }
}

Measured memory_bytes: 43616
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//ソートすればいいんですか？
//???

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


	int N, T;
	scanf("%d", &N);
	scanf("%d", &T);
	int AB[3000];
	rep(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		AB[i] = (a << 12) + b;
	}
	sort(AB, AB + N);

	vector<int> dp(T);
	int saidai = 0;
	rep(i, N) {
		int a = AB[i] >> 12;
		auto dp2 = dp.begin() + a;
		int b = AB[i] & ((1 << 12) - 1);
		chmax(saidai, dp[0] + b);
		rep(j, T - a) {
			if (dp[j] < dp2[j] + b) dp[j] = dp2[j] + b;
		}
	}
	printf("%d", saidai);

	Would you please return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
void trap(ll a, ll b);
ll ans = 0;
void para(ll a, ll b){
    //cout << "para " << a << " " << b << " " << ans << endl;
    if(a == b){
        ans += a;
        return;
    }
    if(a < b) swap(a, b);
    if(b == 0) return;
    ll times = (a - 1) / b;
    if(times == 1){
        ans += b;
        trap(a - b, a);
        return;
    }
    ans += 2 * times * b;
    para(a - b * times, b);
    //ans += a;
    //trap(b - a, b);
}

void trap(ll a, ll b){
    if(a == 0) return;
    //cout << ans << " " << a << " " << b << endl;
    ans += (b - a);
    para(a, b - a);
}
int main() {
    //cout.precision(10);
    ll x, n;
    cin >> n >> x;
    ans += x;
    trap(x, n);
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16

ll mod_pow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

vector<ll> newton_interpol(ll D, const vector<ll>& X, const vector<ll>& Y, ll mod){
  vector<ll> res(D, 0), C(D);
  vector<vector<ll>> dp(D + 1, vector<ll>(D + 1, 0));

  // construct C array
  for(ll i = 0; i < D; i++) {
    ll sum = 0, crt = 1;
    for(ll j = 0; j < i; j++) {
      sum += crt * C[j] % mod;
      sum %= mod;
      crt *= (X[i] - X[j] + mod) % mod;
      crt %= mod;
    }
    C[i] = (Y[i] - sum + mod) % mod;
    C[i] *= mod_pow(crt, mod - 2, mod);
    C[i] %= mod;
  }

  // calc polynomial (dp)
  dp[0][0] = 1;
  for(ll i = 0; i < D; i++) {
    for(ll j = 0; j <= i; j++) {
      res[j] += C[i] * dp[i][j] % mod;
      res[j] %= mod;
    }
    if(i == D - 1) break;
    for(ll j = 0; j <= i; j++) {
      (dp[i + 1][j] += dp[i][j] * (D - X[i])) %= mod;
      (dp[i + 1][j + 1] += dp[i][j]) %= mod;
    }
  }

  return res;
}

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

  ll p;
  vector<ll> X,Y;

  cin>>p;
  X.resize(p); Y.resize(p);

  rep(i,p){
    X[i]=i;
    cin>>Y[i];
  }

  vector<ll> b=newton_interpol(p,X,Y,p);

  rep(i,p)cout<<b[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 72832
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	p = p.split("\n");//2 or more
	let N = parseInt(p[0]);//N
	//let N = parseInt(p[0].split(" ")[0]);//N M
	//let K = parseInt(p[0].split(" ")[1]);//N M
	//let h = (p[1].split(" ").map(Number));//a1 a2 a3...
	
	let a=new Array(N);
	let b=new Array(N);
	let c=new Array(N);
    let z=new Array(N+1);
    for(let i=0;i<N;i++){
        let h = (p[i+1].split(" ").map(Number));
        z[i]=new Array(3);
        a[i]=h[0];
        b[i]=h[1];
        c[i]=h[2];
        z[i]=[a[i],b[i],c[i]];
    }
	let m = new Array(N);
    m[0]=z[0];
    //console.log(N,a,b,c);
    //return;
    for(let i=1;i<N;i++){
        let t=[0,0,0];
        for(let j=0;j<3;j++){
            t[j]=+z[i][j]+Math.max(m[i-1][(j+1)%3],m[i-1][(j+2)%3])
        }
        //console.log(t);
        m[i]= (t);
    }
	//console.log(c);
	console.log(max(m[N-1]));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 58916
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = a - 2 * b;
		if(ans < 0) ans = 0;
		System.out.println(ans);

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

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

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(c)      \
	for (auto i : c) \
		cout << i << ' ';

void solve()
{
	ll n;
	cin >> n;
	map<ll, ll> m;
	rep(i, 0, n)
	{
		ll x;
		cin >> x;
		m[x]++;
	}
	ll res = 0;
	for (auto i : m)
	{
		ll f = i.second;
		if (f & 1)
			res++;
	}
	cout << res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

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

void solve(long long A, std::string op, long long B){
    if (op == "+") cout << A + B << '\n';
    else cout << A - B << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    cin >> A;
    std::string op;
    std::cin >> op;
    long long B;
    cin >> B;
    solve(A, op, B);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int n;
vector<ll>a;
map<pair<pair<ll,ll>,pair<ll,ll> >,ll> mp;

ll calc(pair<pair<ll,ll>,pair<ll,ll> > p){
    if(mp.find(p)!=mp.end())return mp[p];

    ll c = p.first.first;
    ll d = p.second.first;
    ll l = p.first.second;
    ll r = p.second.second;
    if(r-l==1){
        return c*a[l] + d*a[r];
    }
    ll mi = (1LL<<60);
    for(ll i=l+1;i<r;i++){
        chmin(mi,calc(MP(MP(c,l),MP(c+d,i)))+calc(MP(MP(c+d,i),MP(d,r)))-(c+d)*a[i]);
    }
    return mp[p] = mi;
}

int main(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin >> a[i];
    cout << calc(MP(MP(1,0),MP(1,n-1))) << endl;
    return 0;
}

Measured memory_bytes: 20608
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int sum = 0;
	int w, h, n;
	cin >> w >> h >> n;
	int x, y, a, b;
	cin >> a >> b;
	x = a; y = b;
	for (int i = 1; i < n; i++){
		cin >> a >> b;
		if (x <= a == y <= b){
			sum += max(abs(x - a), abs(y - b));
		}
		else{
			sum += abs(x - a) + abs(y - b);
		}
		x = a;
		y = b;
	}
	cout << sum << endl;
	char c; cin >> c;
}

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

using i64 = long long;

const int N = 100000 + 7;

int n;
int s[N], e[N];
i64 d[N], t;
int u[N], v[N];

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", d + i), e[i] = i, s[i] = 1;
	std::sort(e + 1, e + n + 1, [](int a, int b) {
		return d[a] < d[b];
	});
	for (int i = n; i > 1; --i) {
		int j = std::lower_bound(e + 1, e + n + 1, d[e[i]] - n + s[e[i]] * 2, [](int a, i64 b) {
			return d[a] < b;
		}) - e;
		if (d[e[j]] != d[e[i]] - n + s[e[i]] * 2) return printf("-1"), 0;
		s[e[j]] += s[e[i]], t += s[e[i]];
		u[i] = e[i], v[i] = e[j];
	}
	if (d[e[1]] != t) return printf("-1"), 0;
	for(int i = 2; i <= n; i++)
		printf("%d %d\n", u[i], v[i]);
	return 0;
}


Measured memory_bytes: 6152
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int N, K;
LL ans = 1;

int main()
{
	in >> N >> K;

	rep(i, N)
	{
		if (i == 0)
		{
			ans = K;
		}
		else
		{
			ans *= (K - 1);
		}
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

bool isprime[1000001];

int main(){
    memset(isprime, true, sizeof(isprime));
    isprime[0] = false;
    isprime[1] = false;

    for(int i=2;i<1000001;i++){
        if(isprime[i]){
            for(int j=2;i*j<1000001;j++){
                isprime[i*j] = false;
            }
        }
    }

    int a,d,n;
    while(cin >> a >> d >> n){
        int pos=0;

        if(!(a|d|n)) break;

        while(n){
            if(isprime[a+d*pos]) n--;
            if(n == 0) break;
            pos++;
        }
        cout << a+d*pos << endl;
    }
}

Measured memory_bytes: 0
import java.util.*;

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

    int h = sc.nextInt();
    int w = sc.nextInt();

    String[][] a = new String[h][w];

    for (int i = 0; i < h; i++) {
      a[i] = sc.next().split("");
    }

    int[] x = new int[h];
    int[] y = new int[w];
    
    for (int i = 0; i < h; i++) {
      int c = 0;
      for (int j = 0; j < w; j++) {
        if (a[i][j].equals(".")) c++;
      }
      if (c == w) {
        x[i] = 1;
      } else {
        x[i] = 0;
      }
    }
    
    for (int i = 0; i < w; i++) {
      int c = 0;
      for (int j = 0; j < h; j++) {
        if (a[j][i].equals(".")) c++;
      }
      if (c == h) {
        y[i] = 1;
      } else {
        y[i] = 0;
      }
    }

    String s = "";
    for (int i = 0; i < h; i++) {
      s = "";
      for (int j = 0; j < w; j++) {
        if (x[i] == 0 && y[j] == 0) s += a[i][j];
      }
      if (s != "") System.out.println(s);
    }

  }
}


Measured memory_bytes: 29944
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let s = {
                use std::io::Read;
                let mut s = String::new();
                std::io::stdin().read_to_string(&mut s).unwrap();
                s
            };
            let mut iter = s.split_whitespace();
            input_inner!{iter, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($iter:expr) => {};
        ($iter:expr, ) => {};

        ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($iter, $t);
            input_inner!{$iter $($r)*}
        };
        ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($iter, $t);
            input_inner!{$iter $($r)*}
        };
    }
    macro_rules! read_value {
        ($iter:expr, ( $($t:tt),* )) => {
            ( $(read_value!($iter, $t)),* )
        };
        ($iter:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        };
        ($iter:expr, chars) => {
            read_value!($iter, String).chars().collect::<Vec<char>>()
        };
        ($iter:expr, usize1) => {
            read_value!($iter, usize) - 1
        };
        ($iter:expr, $t:ty) => {
            $iter.next().unwrap().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        n:usize, m:usize,
        sc:[(usize1, i32); m],
    }
    let mut num = vec![-1; n];
    for (s, c) in sc {
        if num[s] < 0 {
            num[s] = c
        } else if num[s] != c {
            println!("-1");
            return;
        }
    }
    if n != 1 && num[0] == 0 {
        println!("-1");
        return;
    }
    for i in 0..n {
        if num[i] == -1 {
            print!("{}", if n != 1 && i == 0 { 1 } else { 0 });
        } else {
            print!("{}", num[i]);
        }
    }
}


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

int main()
{
  	vector<pair<int,int>> v;
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
      int x;
      cin>>x;
      v.push_back(make_pair(x,i));
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
      cout<<v[i].second<<" ";
    }
	return 0;
}

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

using namespace std;

int main(){
	string s;
	cin>>s;
	if(s.size()==4){
		if(s[0]!='A' or s[2]!='C' or isupper(s[1]) or isupper(s[3])) cout<<"WA";
		else cout<<"AC";
		}
	else{
		if(s[0]!='A' or isupper(s[1]) or isupper(s[s.size()-1])) cout<<"WA";
		else{
			int c = 0;
			for(int i =2; i<s.size()-1;i++){
				if(isupper(s[i])){
					if(s[i]=='C') c++;
					else{
						cout<<"WA";
						break;
						}
					}
				}
				if(c==1) cout<<"AC";
				else cout<<"WA";
				
			}
		
		}		
	
	return 0;
	}


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

using namespace std;
typedef long long ll;

int main()
{
  int n, k;
  vector<ll> h;
  cin >> n >> k;

  int a;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    h.push_back(a);
  }

  ll res = 1e+10;
  sort(h.begin(), h.end());
  for (int i = 0; i < n - k + 1; i++)
  {
    ll tmp = h[i + k - 1] - h[i];
    if (tmp < res)
    {
      res = tmp;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SSS"){cout<<0<<endl;}
  else if(s=="RSS"){cout<<1<<endl;}
  else if(s=="SRS"){cout<<1<<endl;}
   else if(s=="SSR"){cout<<1<<endl;}
   else if(s=="RRS"){cout<<2<<endl;}
   else if(s=="RSR"){cout<<1<<endl;}
   else if(s=="SRR"){cout<<2<<endl;}
  else{cout<<3<<endl;}
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n, i, count = 0;
    string s;
    cin >> s;
    n = s.length();
    for(i=1; i<n; i++){
        if(s[i] != s[i-1]) count++;
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 512
require 'prime'


n, m = gets.chomp.split.map(&:to_i)
f = m.prime_division
l = f.length
g = Array.new(l)
(0..(l-1)).each do |i|
  g[i] = f[i][1]
end


ans = 1
(0..(l-1)).each do |i|
  tmp = 1
  ((n)..(g[i] + n - 1)).each do |i|
    tmp *= i
  end
  (1..g[i]).each do |i|
    tmp /= i
  end
  ans *= tmp
  ans %= 1000000007
end
p ans



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

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

  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int ans = 0;
  for (int i = 0; i < k; i++) {
    if (a > 0) {
      a--;
      ans += 1;
    } else if (b > 0) {
      b--;
    } else {
      c--;
      ans += -1;
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int x[N]; rep(i,N) cin >> x[i];

  int pos = 0;
  ll result = 1;
  rep(i,N) {
    while (2*(pos-i)<x[pos]&&pos<N-1) pos++;
    // cout << (pos+1)-i << endl;
    result *= (pos+1)-i; result %= MOD;
  }
  cout << result << endl;
  return 0;
}

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

int main()
{
	int N;
	char s[11];
	set<string> S;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << endl;
	return 0;
}

Measured memory_bytes: 15644
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    char a,b;
    cin>>a>>b;
    if(a>b)cout<<">\n";
    if(a<b)cout<<"<\n";
    if(a==b)cout<<"=\n";

    return 0;
}


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

using namespace std;

void solve() {
    string S;
    cin >> S;
    int ans;
    if (S == "RRR")
    {
        ans = 3;
    }
    else if (S == "RRS" || S == "SRR")
    {
        ans = 2;
    }
    else if (S == "SSS")
    {
        ans = 0;
    }
    else
    {
        ans = 1;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3624
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  cnt=0
  print(-k+((n-2)*(n-1))//2+n-1)
  for i in range(2,n+1):
    print(1,i)
    cnt+=1
  for i in range(2,n):
    for j in range(i+1,n+1):
      if cnt==-k+((n-2)*(n-1))//2+n-1:
        break
      print(i,j)
      cnt+=1
      


Measured memory_bytes: 3608
import numpy as np

x = input().split(' ')
n = int(x[0])
m = int(x[1])

x = input().split(' ')
heights = {}
for i in range(n):
  heights[i] = int(x[i])




ways = []

for i in range(m):
  x = input().split(' ')
  ways.append([int(x[0])-1, int(x[1])-1])
  
#こっから接続辞書を作る
ways_dict = {}

bool_array = [1]*n

for way in ways:
  if heights[way[0]] > heights[way[1]]:
      bool_array[way[1]] = 0
  elif  heights[way[0]] == heights[way[1]]:
    bool_array[way[0]] = 0
    bool_array[way[1]] = 0
  else:
    bool_array[way[0]] = 0




for higher_idx, ways in ways_dict.items():
  for way in ways_dict[higher_idx]:
    bool_array[way] = 0
      
print(np.array(bool_array).sum())

Measured memory_bytes: 55204
#include<stdio.h>
 
struct dice{
  int s1[6];
  int jmen[24],zmen[24];
};
   struct dice D;
int main(){

  int i,j,n;
 
  for(i=0;i<6;i++)
    scanf("%d",&D.s1[i]);
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&D.jmen[i],&D.zmen[i]);
 
  
    if( D.s1[0]== D.jmen[i]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[1]){
      if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[2]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[0]);
    }
    else if(D.jmen[i] == D.s1[3]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[5]);
    }
    else if(D.jmen[i] == D.s1[4]){
      if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[5]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[3]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[2]);
    }
  }
  return 0;
}


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

int main(){
  int n;
  cin >>n;
  int a[n];
  int sum=0;
  long long ans=1000000000;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long q;
  for(int r=0; r<=100;r++){
    q=0;
  for(int i=0;i<n;i++){
    q+=(a[i]-r)*(a[i]-r);
  }
  ans=min(ans,q);}
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7

    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i, a in enumerate(A):
        i += 1
        if i % 2 != 0 and a % 2 != 0:
            ans += 1
    print(ans)



if __name__ == '__main__':
    solve()

Measured memory_bytes: 72776
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args){
		int i, n, m, a, b;
		TreeSet<Integer> setA = new TreeSet<Integer>();
		TreeSet<Integer> setB = new TreeSet<Integer>();
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			for(i = 0; i < n; i++) {
				a = sc.nextInt();
				setA.add(a);
			}
			m = sc.nextInt();
			for(i = 0; i < m; i++) {
				b = sc.nextInt();
				setB.add(b);
			}
			setA.retainAll(setB);
			for(int output : setA) {
				System.out.println(output);
			}
		}
	}
}



Measured memory_bytes: 163140