akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int d = Integer.parseInt(br.readLine());
        System.out.println(problem115a(d));
    }

    private static String problem115a(int d) {
        StringBuilder sb = new StringBuilder("Christmas");
        for (int i = 0; i < (25 - d); i++) {
            sb.append(" Eve");
        }
        return sb.toString();
    }
}

Measured memory_bytes: 20948
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  vll a(n + 1, 0);
  rep(i, m) {
	ll x, y;
	cin >> x >> y;
	a[x]++; a[y]++;
  }
  ok = true;
  FOR(i, 1, n + 1) if (a[i] % 2 == 1) ok = false;
  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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


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

int gcd3(int a,int b,int c){
    return gcd(a,gcd(b,c));
}


int main(){
    ll k; cin >> k;
    ll ans=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans+=gcd3(a,b,c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

struct Node {
    int key;
    Node * parent, *left, *right;
};

Node *root, *NIL;

Node* find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;   
    if(y == NIL) {
        root = z;
    } else if(z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

Node * treeMinimun(Node *x) {
    while(x->left != NIL) x = x->left;
    return x;
}

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

void deletetree(Node *z) {
    Node *y;
    Node *x;

    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    if(y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }
    
    if(x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if(y != z) {
        z->key = y->key;
    }
    free(y);
}

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

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

int main() {
    int n, x;
    string com;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> com;
        if(com == "insert") {
            cin >> x;
            insert(x);
        } else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if(com == "find") {
            cin >> x;
            Node*t = find(root, x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(com == "delete") {
            cin >> x;
            deletetree(find(root, x));
        }
    }
    return 0;
}


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

void eat(int& my_cookie, int& your_cookie){
if(my_cookie % 2 == 1){
my_cookie -= 1;
}
your_cookie += my_cookie/2;
my_cookie /= 2;
}

int main(){
int A, B, K;
cin >> A >> B >> K;
for (int i=0; i<K; i++){
if (i % 2 == 0){//高橋くんのターン
eat(A, B);
}
else{//青木くんのターン
eat(B,A);
}
}
cout << A << " " << B;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    rep(i,n){
        cin >> a[i];
        s ^= a[i];
    }

    rep(i,n)cout << (s^a[i]) << " ";
    cout << endl;
}


Measured memory_bytes: 3856
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline ll read(){
	ll re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
ll n;ll m=200000;
struct BIT{
	ll a[200010];
	void clear(){
		memset(a,0,sizeof(a));
	}
	ll lowbit(ll x){
		return x&(-x);
	}
	void add(ll x,ll val){
		for(;x<=m;x+=lowbit(x)) a[x]+=val;
	}
	ll sum(ll x){
		ll re=0;
//		cout<<"getsum "<<x<<' ';
		for(;x>0;x-=lowbit(x)) re+=a[x];
		//cout<<re<<'\n';
		return re;
	}
}T;
struct ele{
	ll val,num;
}a[100010];ll w[100010];
bool cmp1(ele l,ele r){
	return l.val<r.val;
}
bool cmp2(ele l,ele r){
	return l.num<r.num;
}
ll x[100010];ll lim;
bool check(ll val){
	ll i;ll sum=0,re=0;T.clear();
	for(i=1;i<=n;i++){
		if(a[i].val<val) x[i]=-1;
		else x[i]=1;
	}
	T.add(100000,1);
	for(i=1;i<=n;i++){
		sum+=x[i];
		re+=T.sum(sum+100000);
		T.add(sum+100000,1);
	}
//	cout<<"check "<<val<<' '<<re<<'\n';
	return re>=(lim/2+lim%2);
}
int main(){
	ll i;
	n=read();lim=n*(n+1)/2;
	for(i=1;i<=n;i++) a[i].val=read(),a[i].num=i;
	sort(a+1,a+n+1,cmp1);
	for(i=1;i<=n;i++) w[i]=a[i].val;
	sort(a+1,a+n+1,cmp2);
	ll l=1,r=n,mid;
	while(l<r){
		mid=(l+r)>>1;mid++;
		if(check(w[mid])) l=mid;
		else r=mid-1;
	}
	printf("%lld\n",w[l]);
} 

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;

string A, B, C;

int main() {
	while(cin >> A, A != "0") {
		cin >> B >> C;

		reverse(A.begin(), A.end());
		reverse(B.begin(), B.end());
		reverse(C.begin(), C.end());

		int n = B.size();

		ll dp[55][2] = { 0 };

		dp[0][0] = 1;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 2; j++) {
				int q = 0, s = 0, t = 0;
				if(A[i] == '?') q++;
				else s += A[i] - '0';
				if(B[i] == '?') q++;
				else s += B[i] - '0';
				if(C[i] != '0') t = C[i] - '0';

				if(q == 2) {
					for(int a = 0; a <= 9; a++) {
						if(i == n - 1 && a == 0) continue;
						for(int b = 0; b <= 9; b++) {
							if(i == n - 1 && b == 0) continue;
							if(i == n - 1 && (t == 0 || (a + b + j) % 10 == 0)) continue;
							if((C[i] == '?' || (a + b + j) % 10 == t)) {
								int nj = a + b + j >= 10;
								(dp[i + 1][nj] += dp[i][j]) %= MOD;
							}
						}
					}
				}
				else if(q == 1) {
					for(int a = 0; a <= 9; a++) {
						if(i == n - 1 && a == 0) continue;
						if((i == n - 1 && (s + a + j) % 10 == 0)) continue;
						if(C[i] == '?' || (s + a + j) % 10 == t) {
							if(s + a + j >= 10) {
								(dp[i + 1][1] += dp[i][j]) %= MOD;
							}
							else {
								(dp[i + 1][0] += dp[i][j]) %= MOD;
							}
						}
					}
				}
				else { // q == 0
					if((i == n - 1 && (s + j) % 10 == 0)) continue;
					if(C[i] == '?' || (s + j) % 10 == t) {
						if((s + j) >= 10) {
							(dp[i + 1][1] += dp[i][j]) %= MOD;
						}
						else {
							(dp[i + 1][0] += dp[i][j]) %= MOD;
						}
					}
				}
			}// for j
		}// for i
		cout << dp[n][0] << endl;
	}// while
}// main

Measured memory_bytes: 3156
def main():
  num = list(map(int,input().split()))
  if num[0] in [1,3,5,7,8,10,12] :
    if num[1] in [1,3,5,7,8,10,12] :
      print('Yes')
    else:
      print('No')
  elif num[0] in [4,6,9,11] :
    if num[1] in [4,6,9,11] :
      print('Yes')
    else:
      print('No')
  elif num[0] ==2 :
    if num[1] ==2 :
      print('Yes')
    else:
      print('No')
      
main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int N, M;
bool G[8][8];

int main(){
    cin >> N >> M;
    rep(i, N){
        rep(j, N){
            G[i][j] = false;
        }
    }
    rep(i, M){
        int a,b;
        cin >> a >> b;
        G[a-1][b-1] = true;
        G[b-1][a-1] = true;
    }

    vector<int> v;
    set<vector<int>> l;
    rep(i, N){
        v.push_back(i);
    }
    int ans = 0;
    do {
        bool flag = true;
        rep(i, N-1){
            if (!G[v[i+1]][v[i]]) {
                flag = false;
                break;
            }
        }

        if (flag){
            ans++;
        }


    } while (next_permutation(v.begin()+1, v.end()));


    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())

li = [[0 for i in range(10)]for j in range(10)]

for k in range(1,n+1):
    atama = int(str(k)[0])
    ushiro = int(str(k)[-1])
    li[atama][ushiro] += 1

point = 0

for l in range(1,10):
    for m in range(1,10):
        point += li[l][m]*li[m][l]
print(point)

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<bool>h(H,false);
  vector<bool>w(W,false);
  vector<vector<char>>a(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a.at(i).at(j);
      if(a.at(i).at(j)=='#'){
        h.at(i)=true;
        w.at(j)=true;
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(h.at(i)==true&&w.at(j)==true){
        cout << a.at(i).at(j);
      }
    }
    if(h.at(i)==true){
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		for(int i = 1; i <= N; i++) {
			if(i % 3 != 0 && i % 5 != 0) {
				ans += i;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35756
n=int(input())
a=list(map(int,input().split()))
x=1
li=[0,0,0]
for i in range(n):
    x*=li.count(a[i])
    for j in range(3):
        if li[j]==a[i]:
            li[j]+=1
            break 
print(x%1000000007)    
        
    
        

Measured memory_bytes: 14056
#!/usr/bin/env python3
# CGL_2_D: Segments/Lines - Distance

from math import sqrt


class Segment:
    def __init__(self, p0, p1):
        self.end_points = (p0, p1)

    def another(self, p):
        if p == self.end_points[0]:
            return self.end_points[1]
        else:
            return self.end_points[0]

    def distance(self, other):
        def _distance(p, seg):
            p0 = seg._closest_point(p)
            p1 = seg.another(p0)
            x, y = p
            x0, y0 = p0
            x1, y1 = p1
            vp = (x-x0, y-y0)
            vseg = (x1-x0, y1-y0)
            if dot(vp, vseg) <= 0:
                return length(vp)
            else:
                x, y = vp
                return length(projection(vp, orthogonal(vseg)))

        if self.intersect(other):
            return 0.0

        dists = []
        for p0 in self.end_points:
            dists.append(_distance(p0, other))
        for p1 in other.end_points:
            dists.append(_distance(p1, self))

        return min(dists)

    def intersect(self, other):
        p0, p1 = self.end_points
        p2, p3 = other.end_points

        if convex(p0, p2, p1, p3):
            return True
        else:
            if (p0 in other or p1 in other
                    or p2 in self or p3 in self):
                return True

        return False

    def _closest_point(self, p):
        p0, p1 = self.end_points
        x, y = p
        x0, y0 = p0
        x1, y1 = p1
        if length((x0-x, y0-y)) < length((x1-x, y1-y)):
            return p0
        else:
            return p1

    def __contains__(self, p):
        p0, p1 = self.end_points
        x0, y0 = p0
        x1, y1 = p1
        x, y = p
        v = (x1-x0, y1-y0)
        v0 = (x-x0, y-y0)
        v1 = (x-x1, y-y1)
        if dot(orthogonal(v0), v1) == 0:
            if abs(length(v0) + length(v1) - length(v)) < 1e-10:
                return True
        return False


def dot(v1, v2):
    x1, y1 = v1
    x2, y2 = v2
    return x1 * x2 + y1 * y2


def orthogonal(v):
    x, y = v
    return -y, x


def length(v):
    x, y = v
    return sqrt(x**2 + y**2)


def projection(p, v):
    x, y = v
    r = dot(p, v) / dot(v, v)
    return (x*r, y*r)


def convex(p0, p1, p2, p3):
    ret = []
    for pa, pb, pc in zip([p0, p1, p2, p3],
                          [p1, p2, p3, p0],
                          [p2, p3, p0, p1]):
        xa, ya = pa
        xb, yb = pb
        xc, yc = pc
        v1 = (xb - xa, yb - ya)
        v2 = (xc - xb, yc - yb)
        ret.append(dot(orthogonal(v1), v2))

    return all([d > 0 for d in ret]) or all([d < 0 for d in ret])


def run():
    q = int(input())

    for _ in range(q):
        x0, y0, x1, y1, x2, y2, x3, y3 = [int(i) for i in input().split()]

        s0 = Segment((x0, y0), (x1, y1))
        s1 = Segment((x2, y2), (x3, y3))

        print("{:.10f}".format(s0.distance(s1)))


if __name__ == '__main__':
    run()



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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size();
	vector<ll> ct(2019,0);
	ll ret=0, mul=1;
	int now=0;
	ct[0]=1;
	for (int i=n-1; i>=0; i--) {
		now=(now+(s[i]-'0')*mul)%2019;
		ret+=ct[now]++;
		mul=(mul*10)%2019;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3748
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    vector<int> v(n), c(n);

    for (int i = 0; i < n; ++i) cin >> v[i];
    for (int i = 0; i < n; ++i) cin >> c[i];

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int diff = v[i] - c[i];
        ans += max(0, diff);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int n, m, a;
    cin >> n >> m >> a;
    if (!n && !m && !a)
      break;
    vector<vector<int>> line;
    REP(i, m) {
      int h, p, q;
      cin >> h >> p >> q;
      line.push_back({h, p, q});
    }
    sort(ALL(line), greater<vector<int>>());

    int now = a;
    REP(i, m) {
      if (now == line[i][1]) {
        now = line[i][2];
      } else if (now == line[i][2]) {
        now = line[i][1];
      }
      // cout << "now:" << now << endl;
    }

    cout << now << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
N = int(input())
S = input()
R = S[::-1]

if S.count(")") == 0:
    print(S+")"*N)
    exit(0)
elif S.count("(") == 0:
    print("("*N+S)
    exit(0)

f = R.index(")")
g = S.index("(")

t = [0 for k in range(N)]
l = 0
for k in range(N-f):
    if S[k] == ")":
        l += 1
    else:
        l -= 1
    t[k] = l

s = [0 for k in range(N)]
m = 0
for k in range(len(S)-g):
    if S[-1-k] == "(":
        m += 1
    else:
        m -= 1
    s[k] = m

print("("*max(t)+S+")"*max(s))


Measured memory_bytes: 3064
import java.util.Scanner;

//A Thief
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Case = 1;
		while(true){
			int W = sc.nextInt();
			if(W==0)break;
			int n = sc.nextInt();
			int[] w = new int[n+1];
			int[] v = new int[n+1];
			for(int i=1;i<=n;i++){
				String[] s = sc.next().split(",");
				v[i] = Integer.parseInt(s[0]);
				w[i] = Integer.parseInt(s[1]);
			}
			int[][] dp = new int[n+1][W+1];
			int maxV = Integer.MIN_VALUE;
			int minW = Integer.MAX_VALUE;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=W;j++){
					if(j-w[i]>=0){
						dp[i][j] = Math.max(Math.max(dp[i-1][j], dp[i][j-w[i]]), dp[i-1][j-w[i]]+v[i]);
						if(maxV < dp[i][j]){
							maxV = dp[i][j];
							minW = j;
						}
						else if(maxV == dp[i][j]){
							minW = Math.min(minW, j);
						}
					}
					else dp[i][j] = dp[i-1][j];
				}
			}
			System.out.println("Case " + Case++ + ":\n" + maxV + "\n" + minW);
			
		}
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	char a[2] = { 'S','W' };
	char b[2] = { 'o','x' };
	string c[4] = { "SS","SW","WS","WW" };
	REP(i, 4)
	{
		string t = c[i];
		FOR(j, N - 1, 1)
		{
			char d = S[j];
			if (t[j] == 'W')
			{
				REP(k, 2)
				{
					if (d == b[k])continue;
					d = b[k];
					break;
				}
			}
			if (d == 'o')
			{
				t += t[j - 1];
			}
			else
			{
				REP(k, 2)
				{
					if (t[j - 1] == a[k])continue;
					t += a[k];
					break;
				}
			}
		}
		char d = S[0];
		if (t[0] == 'W')
		{
			REP(k, 2)
			{
				if (d == b[k])continue;
				d = b[k];
				break;
			}
		}
		if (d == 'o')
		{
			if (t[1] != t[N - 1])continue;
		}
		else
		{
			if (t[1] == t[N - 1])continue;
		}
		d = S[N - 1];
		if (t[N - 1] == 'W')
		{
			REP(k, 2)
			{
				if (d == b[k])continue;
				d = b[k];
				break;
			}
		}
		if (d == 'o')
		{
			if (t[0] != t[N - 2])continue;
		}
		else
		{
			if (t[0] == t[N - 2])continue;
		}
		cout << t << endl;
		return 0;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
int main(){
	ll x,y,z; cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
	}
	
		

		

Measured memory_bytes: 256
import java.util.*;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      while (true) {
         int H = Integer.parseInt(sc.next());
         int W = Integer.parseInt(sc.next());
         if ((H > 300 || W > 300) || (H == 0 && W == 0)) break;
         for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
               if ((i == 0 || i == H - 1) || (j == 0 || j == W - 1)) {
                  System.out.print("#");
               } else {
                  System.out.print(".");
               }
            }
            System.out.println();
         }
         System.out.println();
      }
   }
}

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

int main(){
  int64_t N,K,Q,c,d;
  cin>> N >>K >>Q;
  vector<int> a(Q);
  vector<int> b(N);
  K -= Q;
  for(c=0;c<N;c++){
    b[c]=K;
  }
  
  for(int i=0;i<Q;i++){
    cin>> d;
    a[i] = d-1;
    b[a[i]] += 1;
  }
  for(int i=0;i<N;i++){
    if(b[i]>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
  }
}

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

int main() {
    int i, j, k, l, n = 0;
    int a[2], cnt;
    vector<vector<int> > v;
    
    while(1) {
        cin >> a[0] >> a[1];
        if(a[0] < 1 && a[1] < 1) break;
        v.push_back(vector<int>(a, a+sizeof(int)));
        ++n;
    }

    for(i=0; i<n; ++i) {
        cnt = 0;
        for(j=1; j<=v[i][0]-2; ++j) {
            for(k=j+1; k<=v[i][0]-1; ++k) {
                for(l=k+1; l<=v[i][0]; ++l) {
                    if(j+k+l == v[i][1]) ++cnt;
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 3132
n = gets.chomp.to_i
ps = gets.chomp.split(" ").map(&:to_i)

ans = 0

(1..n - 2).each do |index|
  if ps[index].between?(ps[index - 1], ps[index + 1])
    ans += 1
  elsif ps[index].between?(ps[index + 1], ps[index - 1])
    ans += 1
  end
end

puts ans

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

using namespace std;

#define i64 int64_t
#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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 (b < a) { a = b; return 1;} return 0;}

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int used[101][101];
    rep(i, 101) {
        rep(j, 101) {
            used[i][j] = 0;
        }
    }

    cout << n * (n - 1) / 2 - n / 2 << endl;

    if (n % 2 == 0) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (i != j && i + j != n + 1 && used[i][j] != 1) {
                    cout << i << " " << j << endl;
                    used[i][j] = used[j][i] = 1;
                }
            }
        }
    } else {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (i != j && i + j != n && used[i][j] != 1) {
                    cout << i << " " << j << endl;
                    used[i][j] = used[j][i] = 1;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict
import bisect
n,k = map(int,input().split())
a = list(map(int,input().split()))
aa = [0]
cur = 0
for i in a:
  cur = (cur+i-1) % k
  aa.append(cur)
d = defaultdict(list)
for i in range(n+1):
  d[aa[i]].append(i)
ans = 0
for i in d.values():
  for j in i:
    ans += bisect.bisect_right(i,j+k-1)-bisect.bisect_right(i,j)
print(ans)

Measured memory_bytes: 127232
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	static int N;
	public static void main(String[] args) {
		//0 48 || 1 49 || B 66
		int N=sc.nextInt();
		int K=sc.nextInt();

		
		
		
		
		
		p((int)Math.ceil((double)(N-K)/(K-1))+1);
		
		
		
		
		
		
		
	}
	static int a,b,c;
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23892
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N - 1; i++) {
      int n; cin >> n; n -= 1;
      A[n]++;
    }
    for (int i = 0; i < N; i++) {
        cout << A[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 4048
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
string ss;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s >> ss;

  bool f = true;
  REP(i, s.length()) {
    if(s[i] != ss[i]) f = false;
  }

  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3584
n = input()
if n[-1] == "2" or n[-1] == "4"  or n[-1] == "5"  or n[-1] == "7"  or n[-1] == "9":
    print('hon')
elif  n[-1] == "0" or n[-1] == "1"  or n[-1] == "6" or n[-1] == "8":
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9052
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> snuke(n, 0);
  rep(i,k) {
    int d;
    cin >> d;
    rep(j,d) {
      int idx;
      cin >> idx;
      snuke[idx-1]++;
    }
  }
  int result = 0;
  rep(i,n) {
    if (snuke[i] == 0) result++;
  }
  cout << result << endl;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
struct Pos {
  int x, y;
};

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << v[v.size() - 1] - v[0] << endl;
}


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

int main()
{
    int n;
    cin >> n;
    int lo, hi;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
        lo = min(lo, v[i]);
        hi = max(hi, v[i]);
    }
    int ans = 1e9;
    for(int i=lo; i<=hi; i++){
        int t = 0;
        for(auto e: v) t += (e-i)*(e-i);
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,k,i,max=-1,min=124;

	for(i=0;i<5;i++){
		scanf("%d",&a);
		max=a>max?a:max;
		min=a<min?a:min;
	}
	scanf("%d",&k);

	printf("%s",max-min>k?":(":"Yay!");
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#define M 1000000007
using namespace std;

int modexp(int x, int e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n, c; cin >> n >> c;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    long long dp[401][401] = {};
    long long sum[401][401] = {};
    for (int i = 0; i <= 400; i++)
        for (int j = 1; j <= 400; j++) {
            sum[i][j] = sum[i][j-1] + modexp(j, i, M);
            if (sum[i][j] >= M) sum[i][j] -= M;
        }
    for (int i = 0; i < n; i++) {
        for (int k = 0; k <= c; k++) {
            long long temp = 0;
            if (i == 0) temp = sum[k][b[0]] - sum[k][a[0]-1];
            else
                for (int ai = 0; ai <= k; ai++)
                    temp += dp[i-1][k-ai] * (sum[ai][b[i]] - sum[ai][a[i]-1]) % M;
            temp %= M;
            if (temp < 0) temp += M;
            dp[i][k] = temp;
        }
    }
    cout << dp[n-1][c] << endl;
}


Measured memory_bytes: 2816
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    # ワーシャルフロイド
    def warshall_floyd(d, N):
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    d[i][j]=min(d[i][j], d[i][k] + d[k][j])
    
    N,M,L=MI()
    ABC=LLIN(M)
    d=[[float("inf")] * N for i in range(N)]
    for i in range(N):
        d[i][i] = 0
    
    for a,b,c in ABC:
        a-=1
        b-=1
        d[a][b]=c
        d[b][a]=c

    warshall_floyd(d,N)

    D=[[float("inf")] * N for i in range(N)]
    for i in range(N):
        for j in range(N):
            if d[i][j]<=L:
                D[i][j] = 1
        
    warshall_floyd(D,N)

    Q=I()
    ST=LLIN_(Q)
    for s,t in ST:
        if D[s][t]==inf:
            print(-1)
        else:
            print(D[s][t]-1)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 125148
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.stream.Stream;
import java.util.Collection;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        pushpush solver = new pushpush();
        solver.solve(1, in, out);
        out.close();
    }

    static class pushpush {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];

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

            List<Long> list = new ArrayList<>();
            boolean is_odd = true;
            for (int i = 0; i < n; i++) {
                if (is_odd) {
                    list.add(a[i]);
                } else {
                    list.add(0, a[i]);
                }
                is_odd = !is_odd;
            }

            if (n % 2 == 0) {
                out.print(list.stream().map(Object::toString).collect(Collectors.joining(" ")));
            } else {
                Collections.reverse(list);
                out.print(list.stream().map(Object::toString).collect(Collectors.joining(" ")));
            }


        }

    }
}



Measured memory_bytes: 77868
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		long top = N;
		long sum = 0;
		for (long i = 1; i <= N; i++) {
			long bottom = N / (i + 1);
			if (top == bottom) {
				break;
			}

			for (long j = top; j > bottom; j--) {
				long mod = N % j;
				if (mod == i) {
					sum += j;
				}
				if (mod >= i) {
					break;
				}
			}
			top = bottom;
		}
		System.out.println(sum);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public char nextChar() throws IOException {
			return (char) skip();
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int a[50005],b[50005];
    vector<P> mpa(100005),mpb(100005);
    rep(i,100005){
        mpb.at(i).first=mpa.at(i).first=0;
        mpb.at(i).second=mpa.at(i).second=i;
    }
    rep(i,n/2)cin>>a[i]>>b[i];
    rep(i,n/2){
        mpa.at(a[i]).first++;
        mpb.at(b[i]).first++;
    }
    sort(mpa.begin(),mpa.end(),greater<P>());
    sort(mpb.begin(),mpb.end(),greater<P>());
    P a1=mpa.at(0);
    P a2=mpa.at(1);
    P b1=mpb.at(0);
    P b2=mpb.at(1);
    if(a1.second==b1.second){
        if(a2.first>b2.first)cout<<n-b1.first-a2.first<<endl;
        else cout<<n-a1.first-b2.first<<endl;
    }
    else cout<<n-a1.first-b1.first<<endl;
    return 0;
}


Measured memory_bytes: 2176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBuffet solver = new BBuffet();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBuffet {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt() - 1;
            }
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = sc.nextInt();
            }
            int[] c = new int[n - 1];
            for (int i = 0; i < n - 1; i++) {
                c[i] = sc.nextInt();
            }
            int ans = 0;
            for (int i = 0; i < n; i++) {
                ans += b[a[i]];
                if (i < n - 1 && a[i] == a[i + 1] - 1) {
                    ans += c[a[i]];
                }
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

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

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

    }
}



Measured memory_bytes: 22996
#include<cstdio>
#include<iostream>
using namespace std;
int a[10007],dp[8001][16001],i;
int main()
{
	string s;
	cin>>s;
	int f1,f2;
	cin>>f1>>f2;
	int k=0,m=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='T')	
		{
			k++;
			a[k]=m;
			m=0;	
		}
		else 
			m++;
	}
	k++;
	a[k]=m;

	dp[1][a[1]+8000]=1;
	for(int i=3;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	dp[0][8000]=1;
	for(int i=2;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
			dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
			dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	
	int ans;
	if(k%2==0){ 
		ans=dp[k][f2+8000]&&dp[k-1][f1+8000];
	}
	else{
		ans=dp[k][f1+8000]&&dp[k-1][f2+8000];
	}
	
	cout<<(ans==0?"No":"Yes");
	return 0;
}

Measured memory_bytes: 497792
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b' ');
    let x: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0; n];
    for i in 0..m - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[m - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut cost1 = 0;
    let mut cost2 = 0;
    for i in 0..m {
        if x < av[i] {
            cost1 += 1;
        } else {
            cost2 += 1;
        }
    }
    let ans = min(cost1, cost2);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    std::sort(a.begin(), a.end());
    i64 x = 0;
    i64 prev = 0;
    for (int i = 0; i < n; i++) {
        if ((a[i] - prev) % 2) x ^= (a[i] - prev) * (n - i);
        prev = a[i];
    }

    std::cout << (x ? "first" : "second") << std::endl;

    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n,k; cin >> n >> k;
    vl num(k);
    for(int i=1;i<=n;i++)num[i%k]++;

    ll res = 0;
    for(int a=0;a<k;a++){
        int b = (k - a) % k;
        int c = (k - a) % k;
        if((b+c) % k != 0)continue;
        res += num[a]*num[b]*num[c];
    }
    out(res);
}


Measured memory_bytes: 1792
<?php 
  fscanf(STDIN, "%d", $x);

  $ans = strval(floor($x / 11));
  $ans *= 2;	
  $amari = $x % 11;

  if($amari >= 1 && $amari <=6){
    $ans++;
  }else if($amari > 6){
    $ans+=2;
  }
	echo $ans;
  ?>

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

using namespace std;

int main()
{
  int N, L;
  cin >> N >> L;

  vector<string> s(N);

  for(int i = 0; i < N; i++) {
    cin >> s[i];
  }

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

  string ans = "";
  for(int i = 0; i < N; i++) {
    ans += s[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i] -= i+1;
    sort(all(a));
    auto cnt = [&](int now) {
        ll ret;
        rep(i,n) ret += abs(a[i]-now);
        return ret;
    };
    cout << cnt(a[n/2]) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}


int main(void) {

	string n;
	cin >> n;


	string arr[] = {
	"pon",
	"pon",
	"hon",
	"bon",
	"hon",
	"hon",
	"pon",
	"hon",
	"pon",
	"hon",

	};
	cout << arr[n[n.size() - 1] - '0'] << endl;



	return 0;
}

Measured memory_bytes: 3128