akhauriyash/Code-Regression huggingface dataset:
/*
 * Author       : YangDavid
 * Created Time : 2020年01月13日 星期一 20时15分28秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 50505;
typedef bitset<maxn> BS;

BS bs[maxn];
int n, m, t, xp[maxn*2], yp[maxn*2];

void sol1() {
	for(int i = 0; i < n; ++i)
		bs[i][i] = true;
	for(int i = m-1; i >= 0; --i)
		bs[xp[i]] = bs[yp[i]] = bs[xp[i]] | bs[yp[i]];
	BS ful; ful.set();
	for(int i = 0; i < n; ++i)
		ful &= bs[i];
	if(!ful.any()) { puts("-1"); exit(0); }
	int z = ful._Find_first();
	ful.reset();
	ful[z] = 1;
	string s;
	for(int i = m-1; i >= 0; --i) {
		if(ful[xp[i]]) {
			ful[yp[i]] = true;
			s += '^';
		} else {
			if(ful[yp[i]])
				ful[xp[i]] = true;
			s += 'v';
		}
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
}

void sol2() {
	if(n == 2) { puts("-1"); exit(0); }
	vector<int> B(n), cnt(n);
	for(int i = 0; i < n; ++i)
		B[i] = i, cnt[i]++;
	string s;
	for(int i = m-1; i >= 0; --i) {
		if(cnt[B[xp[i]]] > 1) {
			s += 'v';
			cnt[B[xp[i]]]--, cnt[B[yp[i]]]++;
			B[xp[i]] = B[yp[i]];
		} else {
			s += '^';
			cnt[B[yp[i]]]--, cnt[B[xp[i]]]++;
			B[yp[i]] = B[xp[i]];
		}
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
}

int main() {
	scanf("%d%d%d", &n, &m, &t);
	for(int i = 0; i < m; ++i) {
		scanf("%d%d", &xp[i], &yp[i]);
		xp[i]--, yp[i]--;
	}
	if(t == 1) sol1();
	else sol2();

    return 0;
}


Measured memory_bytes: 311808
import bisect
n,m = map(int,input().split())
p = [0]*(n+1)
mod = 10**9+7

a = [int(input()) for i in range(m)]

p[0]=1

for i in range(1,n+1):
  k = bisect.bisect_left(a,i)
  k2 = bisect.bisect_right(a,i)
  if k == k2:
    p[i] += p[i-1]
    if i >= 2:
      p[i] += p[i-2]
    p[i] = p[i]%mod
#print(p)
print(p[-1]%mod)

Measured memory_bytes: 7848
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define int long long
#define N 200005
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1 == p2)?EOF:*p1++)
using namespace std ;
//char buf[(1 << 22)] , *p1 = buf , *p2 = buf ;
inline int read ()
{
    char c = getchar () ; int x = 0 , f = 1 ;
    while (c < '0' || c > '9') { if (c == '-') f = -1 ; c = getchar () ; }
    while (c >= '0' && c <= '9'){ x = x * 10 + c - '0' ; c = getchar () ; }
    return x * f ;
}
int n , s ;
void getfac (int B)
{

}
bool check (int n , int b)
{
    int ret = 0 ;
    while (n > 0)
    {
        ret += n % b ;
        n /= b ;
    }
    return ret == s ;
}
signed main ()
{
//    freopen (".in" , "r" , stdin) ; freopen (".out" , "w" , stdout) ;
    n = read () ;
    s = read () ;
    int dif = n - s ;
    int sqt = sqrt (n) + 1 ;
    for (int i = 2 ; i <= sqt ; i ++) if (check (n , i)) return cout << i , 0 ;
    if (s == n) return cout << n + 1 , 0 ;
    if (s > n) return cout << -1 , 0 ;
    int lim = dif / (sqt - 1) + 1 ;
    for (int i = lim ; i >= 1 ; i --)
    {
        if (dif % i == 0 && s - i <= dif / i && s >= i && i <= dif / i)
        {
            cout << dif / i + 1 ;
            exit (0) ;
        }
    }
    puts ("-1") ;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a !=  b) || (b == c && a != b))
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

map<char,int> mp;

int decode(){
    string s;
    cin >> s;
    int n = s.size();
    int a = 1;
    int ret = 0;
    for(int i = 0; i < n; i++){
        if(isdigit(s[i])){
            a = s[i] - '0';
        }else{
            ret += a*mp[s[i]];
            a = 1;
        }
    }
    //cout << "!" << ret << endl;
    return ret;
}
int main(){
    mp['m'] = 1000;
    mp['c'] = 100;
    mp['x'] = 10;
    mp['i'] = 1;
    int t;
    cin >> t;
    while(t--){
        int sum = decode() + decode();
        //cout << sum << endl;
        if(sum/1000){
            if(sum/1000 > 1)cout << sum/1000;
            cout << "m";
            sum %= 1000;
        }
        if(sum/100){
            if(sum/100 > 1)cout << sum/100;
            cout << "c";
            sum %= 100;
        }
        if(sum/10){
            if(sum/10 > 1)cout << sum/10;
            cout << "x";
            sum %= 10;
        }
        if(sum){
            if(sum > 1)cout << sum;
            cout << "i";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3172
#include<stdio.h>
#define MAX(x,y) (x)>(y)?(x):(y);

int main(){
  long long int a,b,c,d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  long long int ans = a*c;
  ans = MAX(ans, a*d);
  ans = MAX(ans, b*c);
  ans = MAX(ans, b*d);
  printf("%lld\n", ans);
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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 main () {
  ll x, y;
  cin >> x >> y;

  ll ans = 1;
  while (x*2 <= y) {
    x *= 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000],B[200000];

LL ans = 0;

void solve(){
	sort(A,A+N);
	sort(B,B+N);
	if(N%2==1) ans = B[N/2] - A[N/2] + 1;
	else ans = (B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1])+1;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i] >> B[i];

    solve();

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

Measured memory_bytes: 6292
N, A, B = map(int, input().split())

ans = 0
for i in range(N+1):
    str_number = list(str(i))
    str_number = list(map(lambda x: int(x), str_number))
    s = sum(str_number)
    if s >= A and s <= B:
        ans += i

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>

int main(){
  int n,i,a,b,c;
  scanf("%d",&n);
  for (i = 0, a = 1, b = 1, c = 0; i <= n; i++){
    a = b;
    b = c;
    c = a + b;
  }
  printf("%d\n",c);
  return 0;	 
}



Measured memory_bytes: 2148
import sys
from collections import Counter
input = sys.stdin.readline
N, M = map(int, input().split())
X = list(map(int, input().split()))
edges = []
e = [[] for _ in range(N + 1)]
for _ in range(M):
  u, v, c = map(int, input().split())
  edges.append((c, u, v))
  e[u].append((v, c))
  e[v].append((u, c))
edges.sort()
table = [0] + X[: ]
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)
 
  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
 
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1
 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
 
  def Count(self, x):
    return -self.root[self.Find_Root(x)]
uf = UnionFind(N)
use = []
emx = [0] * (N + 1)
for i in range(M):
  c, u, v = edges[i]
  if uf.isSameGroup(u, v):
    rt = uf.Find_Root(u)
    emx[rt] = max(emx[rt], c)
    if table[rt] >= emx[rt]: use.append(i)
  else:
    ur = uf.Find_Root(u)
    vr = uf.Find_Root(v)
    uf.Unite(u, v)
    rt = uf.Find_Root(u)
    cmx = max(emx[ur], emx[vr], c)
    emx[rt] = cmx
    if table[ur] + table[vr] >= cmx: use.append(i)
    table[rt] = table[ur] + table[vr]
use.reverse()
vis = [0] * (N + 1)
evis = Counter()
res = M
for i in use:
  mx, s, _ = edges[i]
  if vis[s]: continue
  sta = [s]
  vis[s] = 1
  while len(sta):
    x = sta.pop()
    for y, c in e[x]:
      if c > mx: continue
      if evis[min(x, y) * M + max(x, y)]: continue
      evis[min(x, y) * M + max(x, y)] = 1
      res -= 1
      if vis[y]: continue
      sta.append(y)
      vis[y] = 1
print(res)

Measured memory_bytes: 133708
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc167 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {

        public constructor(public readonly args: string[][]) {

        }

        public main(this: TaskA): void {
            const s:string = this.args[0][0];
            const t:string = this.args[1][0];
            if (s === t.substring(0,s.length)) {
                console.log('Yes');
            } else {
                console.log('No');
            }

        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}

Measured memory_bytes: 29616
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = io.r<int>();
        int[][][] flr = new int[4][][];

        for (int i = 0; i < 4; i++)
        {
            flr[i] = new int[3][];
            for (int j = 0; j < 3; j++)
            {
                flr[i][j] = new int[10];
            }
        }
        string[] info = io.r<string>(n);
        for (int i = 0; i < n; i++)
        {
            int[] buf = info[i].Split(' ').Select(c => int.Parse(c)).ToArray();
            flr[buf[0] - 1][buf[1] - 1][buf[2] - 1] += buf[3];
        }
        int k = 0;
        foreach (int[][] buf in flr)
        {
            foreach (int[] buf2 in buf)
            {
                foreach (int buf3 in buf2)
                {
                    io.w(" " + buf3, false);
                }
                io.w("");
            }
            k++;
            if (k != 4) { io.w("####################"); }
        }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10392
N, K = map(int, input().split())
if K == 0:
    print(N * N)
    exit()
ans = 0
for i in range(N):
    if i < K:
        continue
    ans += (N // (i + 1)) * (i - K + 1) + max(N % (i + 1) - K + 1, 0)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N;

void solve() {
    if (N == 1) {
        cout << 1 << endl;
        cout << 0 << endl;
    }
    else if (N == 2) {
        cout << 2 << endl;
        cout << 0 << endl;
        cout << "11" << endl;
    }
    else {
        cout << N-1 << endl;
        for (int i = 0; i < N-1; ++i) {
            cout << "0";
            for (int j = 0; j < i; ++j) cout << "1";
            cout << "0" << endl;
        }
    }
}

int main() {
    while (cin >> N) {
        solve();
    }
}
    



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

typedef priority_queue<int> P;
int i, N, a[300000];
long long d[100000], m;
P q;
main(){
    cin >> N;
    for(; i < N * 3; ++i){
        cin >> a[i];
        q.push(-a[i]);
        m += a[i];
        if(!(i ^ N - 1)){
            *d = m;
        }
        if(N <= i && i < N * 2){
            m += q.top();
            q.pop();
            d[i - N + 1] = m;
        }
    }
    q = P();
    m = 0;
    for(i = N * 3; --i + 1;){
        q.push(a[i]);
        m += a[i];
        if(i == N * 2){
            d[i - N] -= m;
        }
        if((N <= i) && (i < N * 2)){
            m -= q.top();
            q.pop();
            d[i - N] -= m;
        }
    }
    cout << *max_element(d, d + N + 1) << endl;
}


Measured memory_bytes: 4068
import java.util.Scanner;

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

        int[][] paper = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                paper[i][j] = 0;
            }
        }

        while (sc.hasNext()) {
            String S = sc.next();
            int x = Integer.parseInt(S.split(",")[0]);
            int y = Integer.parseInt(S.split(",")[1]);
            int s = Integer.parseInt(S.split(",")[2]);

            switch (s) {
                case 1:
                    paper = smallInk(x, y, paper);
                    break;
                case 2:
                    paper = mediumInk(x, y, paper);
                    break;
                case 3:
                    paper = bigInk(x, y, paper);
                    break;
            }
        }

        int none = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                max = (paper[i][j] > max)? paper[i][j] : max;
                none = (paper[i][j] == 0)? none + 1 : none;
            }
        }
        System.out.println(none);
        System.out.println(max);
    }

    private static int[][] smallInk(int x, int y, int[][] paper) {
        paper[x][y]++;
        if (x - 1 >= 0) paper[x-1][y]++;
        if (x + 1 < 10) paper[x+1][y]++;
        if (y - 1 >= 0) paper[x][y-1]++;
        if (y + 1 < 10) paper[x][y+1]++;

        return paper;
    }

    private static int[][] mediumInk(int x, int y, int[][] paper) {
        paper[x][y]++;
        if (x - 1 >= 0) paper[x-1][y]++;
        if (x + 1 < 10) paper[x+1][y]++;
        if (y - 1 >= 0) paper[x][y-1]++;
        if (y + 1 < 10) paper[x][y+1]++;
        if (x - 1 >= 0 && y - 1 >= 0) paper[x-1][y-1]++;
        if (x - 1 >= 0 && y + 1 < 10) paper[x-1][y+1]++;
        if (x + 1 < 10 && y - 1 >= 0) paper[x+1][y-1]++;
        if (x + 1 < 10 && y + 1 < 10) paper[x+1][y+1]++;

        return paper;
    }

    private static int[][] bigInk(int x, int y, int[][] paper) {
        paper[x][y]++;
        if (x - 1 >= 0) paper[x-1][y]++;
        if (x + 1 < 10) paper[x+1][y]++;
        if (y - 1 >= 0) paper[x][y-1]++;
        if (y + 1 < 10) paper[x][y+1]++;
        if (x - 1 >= 0 && y - 1 >= 0) paper[x-1][y-1]++;
        if (x - 1 >= 0 && y + 1 < 10) paper[x-1][y+1]++;
        if (x + 1 < 10 && y - 1 >= 0) paper[x+1][y-1]++;
        if (x + 1 < 10 && y + 1 < 10) paper[x+1][y+1]++;
        if (x - 2 >= 0) paper[x-2][y]++;
        if (x + 2 < 10) paper[x+2][y]++;
        if (y - 2 >= 0) paper[x][y-2]++;
        if (y + 2 < 10) paper[x][y+2]++;

        return paper;
    }
}

Measured memory_bytes: 25816
ans = "Yay!"
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if max(a,b,c,d,e) - min(a,b,c,d,e) > k:
    ans = ":("
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    while(1){
        cin>>n;
        if(n==0) break;
        vector<set<int>> vs(n);
        for(int i=0;i<n;i++){
            int m;
            cin>>m;
            for(int j=0;j<m;j++){
                int t;
                cin>>t;
                vs[i].insert(t);
            }
        }
        int k;
        cin>>k;
        vector<int> vi(k,0);
        for(int i=0;i<k;i++) cin>>vi[i];
        bool ok=true;
        int cnt=0;
        int who=0;
        for(int i=0;i<n;i++){
            ok=true;
            for(int j=0;j<k;j++){
                if(vs[i].find(vi[j])==vs[i].end()){
                    ok=false;
                    break;
                }
            }
            if(ok){
                cnt++;
                who=i+1;
            }
        }
        if(cnt==1) cout<<who<<endl;
        else cout<<"-1"<<endl;
    }
    return 0;
}


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

#define MX 200005

struct job{
    int t;
    int d;
};

job A[MX];

bool cmp(job A, job B){
    return A.d < B.d;
}

int main()
{
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d%d", &A[i].t, &A[i].d);
    }

    sort(A+1, A+n+1, cmp);

    int cur_time = 0;
    for (int i = 1; i <= n; i++){
        if (cur_time + A[i].t <= A[i].d){
            cur_time += A[i].t;
        }
        else{
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	map<int, int> m;
	for (int i = 0; i < k; i++) {
		int x;
		cin >> x;
		for (int i = 0; i < x; i++) {
			int d;
			cin >> d;
			m[d]++;
		}
	}

	cout << n - m.size();


}

Measured memory_bytes: 3612
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map { it.toInt() }
    val digitSum = { x: Int ->
        x.toString()
            .map { it.toString()  }
            .map { it.toInt() }
            .sum()
    }
    (1..n)
        .filter {
            val sum = digitSum(it)
            sum in a..b
        }
        .sum()
        .let { println(it) }
}

Measured memory_bytes: 41336
// https://atcoder.jp/contests/abc158/tasks/abc158_d

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int S_MAX = 1e5;
const int Q_MAX = 2*1e5;

string S;
int Q;
bool r = false;
string T;

int main() {
  cin >> S;
  cin >> Q;

  REP(q, Q) {
    int typ;
    cin >> typ;
    if (typ == 1) {
      r = !r;
    }
    if (typ == 2) {
      int f;
      char c;
      cin >> f >> c;
      if (r ^ (f == 2)) {
        S.push_back(c);
      } else {
        T.push_back(c);
      }
    }
  }

  reverse(T.begin(), T.end());
  string ans = T + S;
  if (r) reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 1248
s = input()
t = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1, len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i-1][j-1]+1, dp[i][j-1], dp[i-1][j])
        else:
            dp[i][j] = max(dp[i][j-1], dp[i-1][j])
            
ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0:
    if s[i-1] == t[j-1] and dp[i][j] == dp[i-1][j-1]+1:
        ans = s[i-1] + ans
        i -= 1
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        
print(ans)

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>
#define IS istream
#define OS ostream
#define OP operator

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT IS& OP>>(IS &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT IS& OP>>(IS &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, priority_queue<T> v) {while (!v.empty()) {O << v.top() << ' '; v.pop();} return O;}
TCT OS& OP<<(OS &O, stack<T> v) {while (!v.empty()) {O << v.top() << '\n'; v.pop();} return O;}
TCT OS& OP<<(OS &O, queue<T> v) {while (!v.empty()) {O << v.front() << ' '; v.pop();} return O;}
TCT12 IS& OP>>(IS &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 OS& OP<<(OS &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT12 OS& OP<<(OS &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 OS& OP<<(OS &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;





void _main() {
        string a, b; cin >> a >> b;
        int ans = 0;
        for (int i = 0; i < 3; i++) ans += a[i] == b[i];
        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};

function main(input) {
  const o = new I(input, String);

  const N = Number(o.a());
  const s = o.a();

  let countR = 0;
  let countB = 0;
  for ( let i = 0; i < s.length; i++) {
    if (s[i] === "R") {
      countR += 1;
    } else {
      countB += 1;
    }
  }

  console.log(countR > countB ? "Yes":"No");
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
using ll = long long;

int main() {
    ll a,v;
    ll b,w;
    ll t;
    cin>>a>>v>>b>>w>>t;
    if(a==b)cout<<"YES"<<endl;
    else if(v<=w)cout<<"NO"<<endl;
    else if(abs(a-b)<=t*abs(v-w))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3672
S = input()

month_flg0 = True
month_flg1 = True

if (S[:2] > '12' or S[:2] < '01'):
    month_flg0 = False

if (S[2:] > '12' or S[2:] < '01'):
    month_flg1 = False

if month_flg0 and month_flg1:
    print('AMBIGUOUS')
elif not(month_flg0) and not(month_flg1):
    print('NA')
elif month_flg0:
    print('MMYY')
else:
    print('YYMM')


Measured memory_bytes: 38384
def run():
  N = int(input())
  dp = [0] * (N+1)
  dp[1] = 1
  for n in range(1, N+1):
    if n == 1: continue
    dp[n] = dp[n-1]+1
    draw_money = 6
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 6
    draw_money = 9
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 9
  print(dp[N])
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 3828
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	    long n=gl();
	    long m=gl();

	    //System.out.println(m);
	    if(n>=Math.floorDiv(m, 2)) {
	        System.out.println(Math.floorDiv(m, 2));
	    } else {
	    	long c=n;
	    	m-=2*n;
	    	c+=Math.floorDiv(m, 4);
	    	System.out.println(c);
	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35512
import sys

L = list(sys.stdin.readline().strip())
mod = 10**9 + 7
ls = len(L)

# 左からi桁目で、L以下が確定しているかどうか（True /False）の場合の(a, b)の組み合わせの総数
dp = [[0 for i in (True, False)] for _ in range(ls)]
# 1からしか始まらない
dp[0][False] = 2
dp[0][True] = 1
 
for i in range(ls-1):
    for j in (True, False):
        if L[i+1] == "1":
            dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False]
            dp[i+1][False] = 2 * dp[i][False]
        else:
            dp[i+1][True] = 3 * dp[i][True]
            # dp[i+1][False] = 1 * dp[i][False]
            dp[i+1][False] = 1 * dp[i][False]
        dp[i+1][True] %= mod
        dp[i+1][False] %= mod
 
print(sum(dp[ls-1]) % mod)

Measured memory_bytes: 26012
#include <cstdio>
#include <algorithm>
using namespace std;
#define LL unsigned long long
LL a,b,n;
int main()
{
	scanf("%llu%llu%llu",&a,&b,&n);
	LL ans;
	if(b-1<=n)
		ans=max((a*n)/b-a*(n/b),(a*(b-1))/b);
	else
		ans=(a*n)/b-a*(n/b);
	printf("%llu\n",ans);
	return 0;
}

Measured memory_bytes: 1708
using System;
using System.IO;
using System.Collections.Generic;

namespace ABC122C
{
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var Q = ss.Next(int.Parse);
            var S = ss.Next();

            var sums = new int[N];

            for (var i = 1; i < N; i++)
            {
                sums[i] = sums[i - 1];
                if (S[i - 1] != 'A' || S[i] != 'C') continue;
                sums[i]++;
            }

            for (var i = 0; i < Q; i++)
            {
                var L = ss.Next(int.Parse) - 1;
                var R = ss.Next(int.Parse) - 1;
                var res = sums[R] - sums[L];
                sw.WriteLine(res);
            }
            //---------------------------------
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = {' '};
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

Measured memory_bytes: 17804
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = 0;
		int big = Math.max(a, b);
		int small = Math.min(a,b);
		sum += big;
		big--;
		sum += Math.max(big,small);
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b = MAP()
a -= 1

s = deque()
tmp = (b+1)//2-(a+1)//2
s.appendleft(str(tmp % 2))
i = 1
while 2**i <= b:
    x = max(0, a%(2**(i+1)) - (2**i-1))
    y = max(0, b%(2**(i+1)) - (2**i-1))
    tmp = y - x
    s.appendleft(str(tmp % 2))
    i += 1
t = list(s)
ans = "".join(t)
print(int(ans, 2))

Measured memory_bytes: 10256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string arr[105];
    int n=0;
    scanf("%d", &n);
    int l=0;
    scanf("%d", &l);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(&arr[0],&arr[n]);
    for(int i=0;i<n;i++){
        cout<<arr[i];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[51];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    long double ans=(a[1]+a[2])*1.0/2;
    for(int i=3;i<=n;i++){
        ans+=a[i];
        ans/=2;
    }
    printf("%.5Lf",ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int mod = n % 10;

        if (mod == 2 || mod == 4 || mod == 5 || mod == 7 || mod == 9) {
            System.out.println("hon");
        } else if (mod == 0 || mod == 1 || mod == 6 || mod == 8) {
            System.out.println("pon");
        } else if (mod == 3) {
            System.out.println("bon");
        }

    }
}

Measured memory_bytes: 35704
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int count=0;
  for(int i=0;i<n;i++){
    if(a[a[i]-1]==i+1)
      count++;
  }
  cout << count/2 << endl;
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define v(T) vector<T>
#define imposs {cout<<"-1\n";return 0;}
#define LL_MAX LLONG_MAX
#define LL_MIN LLONG_MIN

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef multiset<int> msi;
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

int ansl;
vll a;

void P(ll k, ll i, ll j) {
  //ansl++;
  //a[k] = a[i] + a[j];
  printf("+ %lld %lld %lld\n", i, j, k);
}
void LT(ll k, ll i, ll j) {
  //ansl++;
  //a[k] = a[i] < a[j];
  printf("< %lld %lld %lld\n", i, j, k);
}

void D(ll i) {
  P(i, i, i);
}

void ans() {
    P(2,0,1);//a[2] = a[0] + a[1];
    P(2,2,0);//a[2] = a[2] + a[0];
    P(2,2,1);//a[2] = a[2] + a[1];

    LT(4,3,2);//a[4] = a[3] < a[2];

    rep(i,30) {
      P(5+i,5+i,4);
      rep(j,i+1) {
        D(5+i);
      }
    }
    
    //A
    drep(i,30) {
      P(36,35,3);
      rep(j,i) P(36,36,4+j);
      LT(40+i,36,0);
      P(36,40+i,3);
      rep(j,i) D(36);
      P(35,35,36);
    }
    P(36,3,3);
    P(35,3,3);
    //B
    drep(i,30) {
      P(36,35,3);
      rep(j,i) P(36,36,4+j);
      LT(70+i,36,1);
      P(36,70+i,3);
      rep(j,i) D(36);
      P(35,35,36);
    }

    rep(i,30) rep(j,30) {
      P(36,40+i,70+j);
      LT(36,4,36);
      rep(k, i+j) D(36);
      P(37,37,36);
    }
    P(2,3,37);//a[2] = a[3] + a[37];
}

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

  printf("31282\n");
  ans();

  //rep(A,11) rep(B,11) {
  //if(1){
  //  ansl = 0;
  //  a = vll(1000);
  //  a[0] = A;
  //  a[1] = B;
  //  ans();
  //  if (a[2] != a[0] * a[1]) cout << a[0] << " " << a[1] << " " << a[2] << endl;
  //}

  //cout << ansl << endl;

  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
void fun(int a[],int n)
{
	int i,j,max,pos,tmp;
	for(i=0;i<n-1;i++)
	{
		max=a[i];
		pos=i;
		for(j=i+1;j<n;j++)
		{
			if(a[j]>max)
			{
				max=a[j];
				pos=j;
    		}
        }
		tmp=a[i];
		a[i]=max;
		a[pos]=tmp;    
	}
} 
int main()
{
	int n,x,a[101]={0},i,b[101]={0},s,j=0;
	scanf("%d %d",&n,&x);
	s=n;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		x-=a[i];
	}
	for(i=0;i<n;i++)
	{
		b[j]=x/a[i];
		j++;
	}
	fun(b,n);
	s+=b[0];
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200005;

int tree[4*MAXN],lazy[4*MAXN],A[MAXN];
vector<int> pos[MAXN];

void updatenode(int now,int L,int R,int val){
	tree[now]+=val;
	lazy[now]+=val;
}

void pushdown(int now,int L,int R){
	int mid=(L+R)/2;
	updatenode(2*now,L,mid,lazy[now]);
	updatenode(2*now+1,mid+1,R,lazy[now]);
	lazy[now]=0;
}

void build(int now,int L,int R){
	if(L==R){
		tree[now]=A[L];
		return;
	}
	int mid=(L+R)/2;
	build(2*now,L,mid);
	build(2*now+1,mid+1,R);
	tree[now]=max(tree[2*now],tree[2*now+1]);
}

int query(int now,int L,int R,int x,int y){
	if(L>=x && R<=y)return tree[now];
	if(L>y || R<x)return INT_MIN;
	pushdown(now,L,R);
	int mid=(L+R)/2;
	return max(query(2*now,L,mid,x,y),query(2*now+1,mid+1,R,x,y));
}

void update(int now,int L,int R,int x,int y,int val){
	if(L>=x && R<=y){
		updatenode(now,L,R,val);
		return;
	}
	if(L>y || R<x)return;
	int mid=(L+R)/2;
	pushdown(now,L,R);
	update(2*now,L,mid,x,y,val);
	update(2*now+1,mid+1,R,x,y,val);
	tree[now]=max(tree[2*now],tree[2*now+1]);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,m,l,r;
	cin >> n >> m;
	int ans=n-m;
	for(int i=1;i<=n;i++){
		cin >> l >> r;
		pos[l].push_back(r);
	}
	for(int i=0;i<=m+1;i++)A[i]=-m+i-1;
	build(1,0,m+1);
	for(int i=0;i<=m+1;i++){
		if(i)update(1,0,m+1,0,m+1,-1);
		for(auto isi : pos[i])update(1,0,m+1,0,isi,1);
		ans=max(ans,query(1,0,m+1,i+2,m+1));
	}
	cout << max(ans,0) << endl;
	return 0;
}

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

int h, w, n;
int c[110][110];

int main() {
	scanf("%d%d%d", &h, &w, &n);
	int i = 0, j = 0;
	for (int k = 1; k <= n; ++k) {
		int a; scanf("%d", &a);
		while (a--) {
			c[i][j] = k;
			if (i & 1) {
				--j;
				if (j < 0)
					j = 0, ++i;
			}
			else {
				++j;
				if (j >= w)
					j = w - 1, ++i;
			}
		}
	}
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			printf("%d%c", c[i][j], j + 1 == w ? '\n' : ' ');
	return 0;
}



Measured memory_bytes: 3768
import java.util.Scanner;
	
	public class Main{
		
		static int diffStr(String s){
			int n = s.length();
			int i = 0;
			int a = 0;
			int b = n-1;int count = 0;
			while(i!=n/2){
				if(s.charAt(a)!=s.charAt(b)){
					count++;
					}
				a++;b--;
				i++;
				}
			return count;
		}
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		System.out.println(diffStr(s));
		}
	} 

Measured memory_bytes: 23252
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public long nextInt(){
        long ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
}

class Main {
    public static void main(String args[]) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        MyScanner sc = new MyScanner();
        long a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        if(c <= a + b + 1){
            System.out.println(b + c);
        }else{
            System.out.println(a + b * 2 + 1);
        }
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

int main() {
    string w;
    cin>>w;
    
    int cnt[26] = {0};
    for(auto& i : w) cnt[i-'a']++;
    rep(i,26) if(cnt[i] % 2 == 1) {
        cout<<"No"<<"\n";
        return 0;
    }
    cout<<"Yes"<<"\n";


    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    T,A=map(int,input().split())
    H=list(map(int,input().split()))
    tmp=INF
    for i,h in enumerate(H):
        t=T-0.006*h
        if tmp > abs(t-A):
            ans=i
            tmp=abs(t-A)
    print(ans+1)

if __name__ == '__main__':
    main()


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

const int N = 2005;
const int mod = 1e9 + 7;
long long dp[N];

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

  dp[0] = 1;
  for (int i = 0; i <= s; i++) {
    for (int add = 3; add <= s; add++) {
      if(i - add < 0) continue;
      dp[i] += dp[i - add];
      dp[i] %= mod;
    }
  }

  cout << dp[s] << '\n';

}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main() {
	unsigned long long lucas[100];
	lucas[0] = 2;
	lucas[1] = 1;
	int n; cin >> n;
	for (int i = 2; i <= n; i++) 
		lucas[i] = lucas[i - 1] + lucas[i - 2];
	cout << lucas[n] << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

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

    Graph G(n+1);

    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> memo(n+1, -1);
    queue<int> que;

    memo[1] = 0;
    que.push(1);

    int cnt = 0;
    while(!que.empty()) {
        cnt++;
        int v = que.front();
        que.pop();
        for(int nv: G[v]) {
            if (memo[nv] != -1) continue;
            memo[nv] = v;
            que.push(nv);
        }
    }
    for(int i=2; i<n+1; i++) {
        if(memo[i]==-1) {
            cout << "No" << endl;
            return 0;
        }
    }


            cout << "Yes" << endl;
    for(int v=2; v<n+1; v++) {
        cout << memo[v] << endl;
    }
    return 0;
}

Measured memory_bytes: 10156
#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main () {
	// This is C problem
	ll n, x; cin >> n;
	for (int i = sqrt (n) + 1; i >= 1; i--) {
		if (n % i == 0) {
			x = i + n / i - 2;
			cout << x << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int mx=0,cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
            cnt++;
            if(cnt>mx)mx=cnt;
        }

        else {
            cnt=0;
        }
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String...args) {
		Scanner in = new Scanner(System.in);
		String str = "";
		while(true) {
			List<Integer> l = new ArrayList<Integer>();
			int from = in.nextInt(), to = in.nextInt();
			if((from|to) == 0) break;
			System.out.print(str);
			for(int i = from; i <= to; i++)
				if(i%4==0)
					if(i%100==0) {
						if(i%400==0) l.add(i);
					} else {
						l.add(i);
					}

			if(l.isEmpty()) System.out.println("NA");
			else for(int i = 0; i < l.size(); i++) System.out.println(l.get(i));
			str = "\n";
		}
	}
}

Measured memory_bytes: 12000
use std::io::*;
use std::str::FromStr;

fn gcd(a: i64, b: i64) -> i64 {
    if a < b {
        gcd(b, a)
    } else if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let n: usize = read();
    let x: i64 = read();
    let mut xi: Vec<i64> = (0..n).map(|_| read()).collect();
    xi.push(x);
    xi.sort();
    let mut ans = xi[1] - xi[0];
    for i in 1..n {
        ans = gcd(ans, xi[i + 1] - xi[i]);
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 6396
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

## BFS
from collections import deque

def main():

    #入力受け取り
    N, Q = mi()
    x = li2(N-1)

    cnt = [0]*N
    for i in range(Q):
        p0, p1 = mi()
        cnt[p0-1] += p1

    #隣接リスト作成
    adj = [[] for i in range(N)]
    for i in range(N-1):
        x[i][0] -= 1
        x[i][1] -= 1
        adj[x[i][0]].append(x[i][1])
        adj[x[i][1]].append(x[i][0])

    que = deque()
    ans = [0]*N

    # BFS
    que.append((0, 0))
    num = 0
    while que!=deque():
        v = que.popleft()
        ans[v[1]] = ans[v[0]] + cnt[v[1]]
        for next in adj[v[1]]:
            if next != v[0]:
                que.append((v[1], next))

    for k in ans:
        print(k, '', end='')

if __name__ == "__main__":
    main()

Measured memory_bytes: 89008
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main ( String[] args ) throws Exception {
        Scanner in = new Scanner( System.in );
        int N = Integer.parseInt( in.next() );
        int[] L = new int[ N * 2 ];
        for ( int i = 0; i < N * 2; i++ ) {
            L[ i ] = Integer.parseInt( in.next() );
        }
        Arrays.sort( L );
        int cnt = 0;
        for ( int i = 0; i < N * 2; i++ ) {
            if ( i % 2 == 0 ) {
                cnt += L[ i ];
            }
        }
        System.out.println( cnt );
    }
}

Measured memory_bytes: 20948
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int solve(int n,int m){
    int a[n];
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]+a[j]<=m)
            ans=max(ans,a[i]+a[j]);
        }
    }
    if(ans!=0)
    return ans;
    else return -1;
}


int main(void){
    int n,m;
    vector<int>ans;
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        ans.push_back(solve(n,m));
    }
    for(int i=0;i<ans.size();i++){
        if(ans[i]!=-1)cout<<ans[i]<<endl;
        else cout<<"NONE"<<endl;
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int X, A, B;
  cin >> X >> A >> B;
  if (A >= B) {
    cout << "delicious" << endl;
  } else if (B - A <= X) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a;
	char b[100];
	int count1=0, count2=0;
	scanf("%d", &a);
	int i;
	
	for (i = 0; i < a+1; i++) {
		scanf("%c", &b[i]);
	}

	for (i = 0;  b[i]!='\0'; i++) {
		if (b[i] == 'R') {
			count1++;
		}
		else if(b[i]=='B') {
			count2++;
		}
	}
	
	if (count1 > count2) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128