akhauriyash/Code-Regression huggingface dataset:
n, q = map(int, input().split())
s = input()

ml = [0 for i in range(n)]
for i in range(n-1):
    if s[i]+s[i+1] == 'AC':
        ml[i] = 1

def cumulative_sum(collection):
    result = [0]
    for item in collection:
        result.append(result[-1] + item)
    return result
csml = cumulative_sum(ml)

for i in range(q):
    l, r = map(int, input().split())
    print(csml[r-1] - csml[l-1] , flush=True)


Measured memory_bytes: 13996
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int a,b;
    cin >> a >> b;
    if( a < 6){
        cout << 0 << endl;
    }
    else if(a <= 12){
        cout << b / 2 << endl;
    }
    else{
        cout << b << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

vector<pair<double, double> > koch(vector<pair<double, double> > p){
    vector<pair<double, double> >ret;
    for(int i = 0;i < (p.size() - 1);i++){
        pair<double, double> p1 = p[i];
        pair<double, double> p2 = p[i+1];

        double xsabun = p2.first - p1.first;
        double ysabun = p2.second - p1.second;
        pair<double, double> s ( p1.first+(xsabun/3), p1.second+(ysabun/3));
        pair<double, double> t ( p2.first-(xsabun/3), p2.second-(ysabun/3));

        pair<double, double> u;
        double distance=sqrt(xsabun*xsabun+ysabun*ysabun)/sqrt(3);
        if(xsabun>=0){
            double angle1=atan(ysabun/xsabun)+(M_PI/6); 
            u.first = p1.first+(distance*cos(angle1));
            u.second = p1.second+(distance*sin(angle1));
        } else {
            double angle2=atan(ysabun/xsabun)-M_PI/6;
            u.first = p2.first+(distance*cos(angle2));
            u.second = p2.second+(distance*sin(angle2));
        }
        ret.push_back(p1);
        ret.push_back(s);
        ret.push_back(u);
        ret.push_back(t);
    }

    ret.push_back(p.back());
    return ret;
}

int main(void){
    int n;
    cin >> n;
    vector<pair<double, double>> p = {pair<double, double>(0.0, 0.0), pair<double, double>(100.0, 0.0)};

    for(int i = 0;i < n;i++){
        p = koch(p);
    }

    cout << fixed;
    for(int i = 0;i < p.size();i++){
        cout << std::setprecision(8) << p[i].first << " " << p[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 3768
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll K;
  cin >> K;
  ll N = 50;
  ll a[N];
  for(int i = 0; i < N; i++) a[i] = i;

  ll s = K / N;
  ll r = K % N;

  for(int i = 0; i < N; i++) a[i] += s;

  for(int i = 0; i < r; i++){
    a[i] += N;
    for(int j = 0; j < N; j++){
      if(i != j) a[j] -= 1;
    }
  }

  cout << N << endl;
  for(int i = 0; i < N; i++) cout << a[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <map>
#include <algorithm>
using namespace  std;

int f[200];

int main()
{
    int x,n;
    scanf("%d%d",&x,&n);
    for (int i=0;i<n;++i){
        int t;scanf("%d",&t);
        f[t]=1;
    }
    int ans=0;
    for (int i=1;i<=101;++i){
        if (f[i]==0){
            if (abs(i-x) < abs(x-ans))
                ans = i;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 3820
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            int S = 0;
            N = int.Parse(Console.ReadLine());

            for (int i=1; i<=N;i++)
            {
                S = S + i;

            }
            Console.WriteLine(S);
            Console.ReadKey();

        }
    }
}


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

int n;
int sum[10] = {0};

void solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if(x > 3200) x = 3200;
    ++sum[x / 400];
  }
  solve();
  return 0;
}

void solve() {
  int ans = 0;
  for(int i = 0; i < 8; ++i) ans += (sum[i] > 0);
  if(ans > 0)
    cout << ans;
  else
    cout << 1;
  cout << " ";
  cout << ans + sum[8] << endl;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
data = []
for i in range(M):
    a, b = map(int, input().split())
    heapq.heappush(data, (b, a))

cut = 0
answer = 0
for i in range(M):
    b, a = heapq.heappop(data)
    if cut <= a:
        answer += 1
        cut = b

print(answer)

Measured memory_bytes: 16700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
 
int main() {
  int N; cin >> N;
  bool swin = true;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a % 2 == 1) swin = false;
  }
  
  if (swin) cout << "second" << endl;
  else cout << "first" << endl;
}

Measured memory_bytes: 384
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


ll s[200010];
ll q[200010];
int main()
{
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> s[i];
    ll p = 0;
    ll po = 1;
    map<ll,ll>jud;
    while(jud[po]==0){
        jud[po] = 1;
        q[++p] = po;
        po = s[po];
    }
    ll x = 0;
    for(int i = 1; i <= p; i++){
        if(q[i]==po){
            x = i;
            if(k<x){
                cout << q[k+1] << endl;
                return 0;
            }
            k -= (i-1);
            break;
        }
    }
    k++;
    k %= (p-x+1);
    if(k==0) k = (p-x+1);
    cout << q[k+x-1] << endl;
    return 0;
}


Measured memory_bytes: 18984
import numpy as np
C = np.array([list(map(int, input().split())) for _ in range(3)])
c12 = C[1]-C[0]
c23 = C[2]-C[1]
if len(set(c12)) == 1 and len(set(c23)) == 1:
    CT = C.T
    ct12 = CT[1]-CT[0]
    ct23 = CT[2]-CT[1]
    if len(set(ct12)) == 1 and len(set(ct23)) == 1:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 12480
#include<bits/stdc++.h>
#define toup toupper
#define tolow tolower
const int mod = 1000000;
const int maxn = 10000;
typedef long long ll;
using namespace std;

int length(ll n){
	return (int)log10(n) + 1;
}

ll quickpow(ll x, ll y){
	ll res = 1;
	while(y){
		if(y & 1) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}

ll fac(ll x){
	if(x == 0 || x == 1) return 1;
	return x * fac(x - 1);//mod
}


int main(){
	char a[10];
	cin >> a;
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	for(int i = 0; i < 3; i++){
		if(a[i] == 'a') cnt1++;
		if(a[i] == 'b') cnt2++;
		if(a[i] == 'c') cnt3++;
	}
	if(cnt1 == 1 && cnt2 == 1 && cnt3 == 1) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

double es[200000+10];

int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  REP(i, n) {
    double p;
    scanf("%lf", &p);
    es[i] = (p+1)/2;
  }
  double cur = 0;
  REP(i, k) {
    cur += es[i];
  }
  double maxi = cur;
  for(int i = k; i < n; ++i) {
    cur -= es[i-k];
    cur += es[i];
    maxi = max(maxi, cur);
  }
  printf("%.10f\n", maxi);
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main () {
  int M, D;
  cin >> M >> D;
  int ans = 0;
  for(int i = 22; i <= D; i++){
    if(i % 10 == 1)continue;
    if(4 <= (i / 10) * (i % 10) && M >= (i / 10) * (i % 10)){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n;
void init(){
    n = read();
}
void solve(){
    int ans = 1000 * (n / 500);
    n %= 500;
    ans += 5 * (n / 5);
    cout << ans << endl;
}
int main(){
    init();
    solve();
    return 0;
}

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

int main(){
  string s; cin >> s;
  int b = 0, w = 0;
  for (int i = 0; i < s.size(); i++){
    if (i%2 == 0){
      if (s.at(i) == '1') b++;
    }else{
      if (s.at(i) == '0') b++;
    }
  }
  for (int i = 0; i < s.size(); i++){
    if (i%2 == 0){
      if (s.at(i) == '0') w++;
    }else{
      if (s.at(i) == '1') w++;
    }
  }
  cout << min(b, w) << endl;
  return 0;
}

Measured memory_bytes: 512
<?php
list ($N, $K) = fscanf(STDIN, "%d %d");
$x = explode(" ", trim(fgets(STDIN)));

$ans = min(array_map(
    function($item1, $item2) {
        return $item2 - $item1 + min(abs($item1), abs($item2));
    },
    array_slice($x, 0, $N-$K+1),
    array_slice($x, $K-1)));

print "$ans\n";
?>

Measured memory_bytes: 18932
#include <stdio.h>
int main(void){
    int i,c=0,a[200],n,b=0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    
    
    for(;;){
        for(int j=0;j<n;j++){
            if(a[j]%2==0) a[j]=a[j]/2;
            else{ 
                b=1;
                break;
            }
        }
        if(b==0) c++;
        else break;
    }
    
    printf("%d\n",c);
    
    return 0;
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n) ans += i;
  cout << ans << endl;
}

Measured memory_bytes: 384
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define rep(i, m, n) for(int i = m; i < n; i++)
#define Rep(i, m, n) for(int i = m; i > n; i--)
#define repl(i, m, n) for(ll i = m; i < n; i++)
#define Repl(i, m, n) for(ll i = m; i > n; i--)
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
using namespace std;
typedef vector<int> vi;		typedef pair<int, int> ii;		typedef vector<ii> vii;
typedef vector<ll> vl;

signed main() {
	fastio;
	vl beauty;
	int n, k; cin >> n >> k;
	ll sum = 0;
	int a[n]; rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) {
		sum = 0;
		rep(j, i, n) {
			sum += a[j];
			beauty.pb(sum);
		}
	}
	bool check[beauty.size() + 1];
	int num;
	rep(i, 0, (int)beauty.size() + 1) check[i] = 1;
	Rep(j, 50, -1) {
		num = 0;
		Rep(i, (int)beauty.size() - 1, -1) {
			if(check[i]) if((beauty[i] >> j) & 1) num++;
		}
		if(num >= k) {
			Rep(i, (int)beauty.size() - 1, -1) {
				if(check[i]) if(!((beauty[i] >> j) & 1)) check[i] = 0;
			}
		}
	}
	ll ans = LLONG_MAX;
	rep(i, 0, (int)beauty.size()) {
		if(check[i]) ans &= beauty[i];
	}
	cout << ans;
 	return 0;
}



Measured memory_bytes: 6512
while True:
    a, op, b = map(str, input().split())
    a, b = int(a), int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break


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

lli n;

int main(void){
	cin >> n;
	vector<lli> b(n+1);
	for(int i = 1; i <= n; i++){
		cin >> b[i];
	}
	stack<lli> st;
	while(n > 0 && b[1] == 1){
		for(int i = n; i >= 1; i--){
			if(i == b[i]){
				st.push(b[i]);
				b.erase(b.begin()+i);
				n--;
				break;
			}
		}
	}
	if(n != 0) cout << -1 << endl;
	else{
		while(!st.empty()){
			cout << st.top() << endl;
			st.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Grid = vector<vector<int>>;
const ll INF = 10011032323450010;
const ld PI = 3.14159265358979323846;



int main() {
     
   int A,B,ans=-1;
   cin>>A>>B;
   rep3(i,100000){
       if((A==(int)floor(i*0.08))&&(B==(int)floor(i*0.10))){
           ans=i;
           break;
       }
   }
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N=0;
    long int max=0,sum=0;
    long int a=0;

    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%ld",&a);
        if(max<a){
            max=a;
            //printf("a");
        } else {
            sum+=max-a;
            //printf("b");
        }
    }

    printf("%ld",sum);
    return 0;
}


Measured memory_bytes: 1716
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		int count = 0;
		int T = sc.nextInt();
		int[]Arr = new int[T];
		for(int i =0; i<T; i++) {
			Arr[i] = sc.nextInt();
			
		}
		
		for(int i =0; i<T; i++) {
			boolean LOL = true;
			for(int j =0; j<i; j++) {
				if(Arr[j] >Arr[i]) {
					LOL = false;
					break;
				}
				
			}
			if(LOL) {
				count++;
			}
		}
		System.out.println(count);
		
	}

}


Measured memory_bytes: 35756
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int expiration = sc.nextInt();
            int buyday = sc.nextInt();
            int eatday = sc.nextInt();
            if(-buyday + eatday >= expiration + 1){
              System.out.println("dangerous");
            } else if(-buyday + eatday <= 0) {
              System.out.println("delicious");
            } else {
              System.out.println("safe");
            }
      }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  for(double i=0; i<10000; i++) {
    if (floor(i*0.08) == a && floor(i*0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 888
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	for ; ; N++ {
		flag := true

		for i := 2; i*i <= N; i++ {
			if N%i == 0 {
				flag = false
				break
			}
		}
		if flag {
			break
		}
	}

	fmt.Println(N)
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){

int X;
scanf("%d",&X);

if (400<=X && X<=599){puts("8");}
if (600<=X && X<=799){puts("7");}
if (800<=X && X<=999){puts("6");}
if (1000<=X && X<=1199){puts("5");}
if (1200<=X && X<=1399){puts("4");}
if (1400<=X && X<=1599){puts("3");}
if (1600<=X && X<=1799){puts("2");}
if (1800<=X && X<=1999){puts("1");}

return 0;

}

Measured memory_bytes: 1612
import java.io.*;class Main{
public static void main(String[]_)throws Exception{
int i,a,x,y;
float b;
BufferedReader B=new BufferedReader(new InputStreamReader(System.in));
for(String s;(s=B.readLine())!=null;){
_=s.split(",");
x=Integer.valueOf(_[10]);
y=Integer.valueOf(_[11]);
for(a=i=0;i<10;)a+=Integer.valueOf(_[i++]);
b=x+y;
b=a*x/b;
for(a=i=0;i<10;i++){
a+=Integer.valueOf(_[i]);
if(b<=a){
System.out.println(i+1);
break;
}
}
}
}
}

Measured memory_bytes: 9168
import heapq
import sys


def input(): return sys.stdin.readline().rstrip()


H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
data = [[0]*W for i in range(H)]

for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == ".":
            data[i][j] = 1
        else:
            data[i][j] = 0


def trans(h, w):
    return W*(h) + w


P = [(0, -1), (0, 1), (1, 0), (-1, 0)]
DXY = []
for i in range(0, 3):
    for j in range(-2, 3):
        if i==0 and j==0:
            pass
        else:
            DXY.append((i,j))
            
G = [[] for i in range(H*W)]
H_L = [i for i in range(H)]
W_L = [i for i in range(W)]
for i in H_L:
    for j in W_L:
        if data[i][j] == 1:
            for dx, dy in P:
                if 0 <= dx+i < H and 0 <= dy+j < W and data[dx+i][dy+j] == 1:
                        u, v = trans(i, j), trans(dx+i, dy+j)
                        G[u].append((v, 0))
                        G[v].append((u, 0))
            for dx, dy in DXY:
                if 0 <= dx+i < H and 0 <= dy+j < W and data[dx+i][dy+j] == 1:
                        u, v = trans(i, j), trans(dx+i, dy+j)
                        G[u].append((v, 1))
                        G[v].append((u, 1))


D = [10**6+100 for i in range(H*W)]
D[trans(ch-1, cw-1)] = 0
que = []
heapq.heapify(que)
heapq.heappush(que, (0, trans(ch-1, cw-1)))

while que:
    cost, v = heapq.heappop(que)
    if D[v] < cost:
        continue
    for node, cost in G[v]:
        if D[node] > D[v] + cost:
            D[node] = D[v] + cost
            heapq.heappush(que, (D[node], node))

ans = D[trans(dh-1, dw-1)]

if ans == 10**6+100:
    print(-1)
else:
    print(ans)


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b;

int main()
{
    _FastIO;
    cin >> a >> b;
    if(a < b) swap(a , b);
    int ans = max((2 * a) - 1 , (a + b));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
base = [a, b, c, d, e, 0]
Q = [(1, el) for el in base]
L = {el: 1 for el in base}
H = []
while Q:
    l, p = heappop(Q)
    if L[p] < l: continue
    if l+1 < L.get(p ^ e, 17):
        L[p^e] = l+1
        if l+1 < 16: heappush(Q, (l+1, p^e))
    if l+3 < 16:
        for q, r in H:
            if l+r+3 <= 16:
                if l+r+3 < L.get(p & q, 17):
                    L[p & q] = l+r+3
                    if l+r+3 < 16: heappush(Q, (l+r+3, p & q))
                if l+r+3 < L.get(p ^ q, 17):
                    L[p ^ q] = l+r+3
                    if l+r+3 < 16: heappush(Q, (l+r+3, p ^ q))
            else: break
    if l < 7: H.append((p, l))
print(*(L[e & eval(s)] for s in open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]),sep='\n')

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n), f(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for(int i = 0; i < n; ++i) {
    cin >> f[i];
  }
  sort(a.rbegin(), a.rend());
  sort(f.begin(), f.end());

  auto ok = [&] (long long M) {
    multiset<int> s(f.begin(), f.end());
    long long needed = 0;
    for(int x : a) {
      // x * y <= M ==> y <= M / x
      auto it = s.upper_bound(M / x);
      if(it != s.begin()) --it;
      // (x - ?) * y <= M --> x - ? <= M / y 
      needed += max(0LL, x - M / *it);
      s.erase(it);
    }
    return needed <= k;
  };

  long long lo = 0, hi = 1e13;
  while(lo != hi) {
    long long mid = (lo + hi) / 2;
    if(ok(mid)) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  cout << lo << '\n';
}

Measured memory_bytes: 14288
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

vector<int> jumps;
vector<int> scores;
ll N, K;

tuple<ll, ll, ll> solve(int from, int max_cnt) {
    if (max_cnt == 0) return make_tuple(0, -1, 0);

    int pos = from;
    int cnt = 0;
    ll sum = 0;
    ll max_score = -1e16;
    for(;;) {
        // jump to next
        pos = jumps[pos];
        sum += scores[pos];
        ++cnt;

        max_score = max(max_score, sum);
        if (pos == from) break;
        if (cnt >= max_cnt) return make_tuple(max_score, -1, max_cnt);
    } 
    return make_tuple(max_score, sum, cnt);
}


int main()
{
    // read input
    cin >> N >> K;
    jumps.assign(N, 0);
    scores.assign(N, 0);
    rep(i, 0, N) cin >> jumps[i];
    rep(i, 0, N) --jumps[i];
    rep(i, 0, N) cin >> scores[i];

    ll ans = scores[0];
    rep(from, 0, N) {
        ll max_score, offset, cnt;
        tie(max_score, offset, cnt) = solve(from, K);

        // printf("from: %d, max_score: %lld, offset: %lld, cnt: %lld\n", from, max_score, offset, cnt);

        if (offset <= 0) {
            ans = max(ans, max_score);
            continue;
        }
        else 
        {
            ans = max(ans, offset*(K/cnt-1) + max_score);

            max_score = get<0>(solve(from, K%cnt));
            ans = max(ans, offset*(K/cnt) + max_score);
        }
    }

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



Measured memory_bytes: 3672
N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = gets.to_i
n = K - 1
puts N[n]


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		long answer = k;

		for (int i = 1; i < n; i++) {
			answer = answer * (k - 1);
		}

		System.out.println(answer);
	}

}


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

int main() {
  string s;
  cin >> s;
  if(s.at(0)==s.at(1) && s.at(2) == s.at(3) && s.at(1) == s.at(3)){
    cout << "No" << endl;
  }
  else if(s.at(0)==s.at(1) && s.at(2) == s.at(3)){
    cout << "Yes" << endl;
  }
  else if (s.at(0)==s.at(2) && s.at(1) == s.at(3)){
    cout << "Yes" << endl;
  }
  else if (s.at(0)==s.at(3) && s.at(1) == s.at(2)){
    cout << "Yes" << endl;
  }   
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int h, w;
  string s;
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    cin >> s;
    for(int j = 0; j < 2; j++) cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
H, W = map(int, sys.stdin.readline().split())
INF = float('inf')
S = [[INF] * W for i in range(H)]
for i in range(H):
    a = list(sys.stdin.readline())
    for j in range(W):
        if a[j] == '#':
            S[i][j] = 0

ma = 0
for i in range(1, H):
    for j in range(W):
        S[i][j] = min(S[i][j], S[i - 1][j] + 1)

for i in range(H - 2, -1, -1):
    for j in range(W):
        S[i][j] = min(S[i][j], S[i + 1][j] + 1)

for i in range(H):
    for j in range(1, W):
        S[i][j] = min(S[i][j], S[i][j - 1] + 1)

for i in range(H):
    for j in range(W - 2, -1, -1):
        S[i][j] = min(S[i][j], S[i][j + 1] + 1)

for i in range(H):
    for j in range(W):
        ma = max(ma, S[i][j])

print(ma)


Measured memory_bytes: 137180
END { load __FILE__ unless $stdin.eof? }

k = gets.to_i

x = y = 0
idx = (1..).each do |i|
  x = (x * 10 + 7) % k
  y = (y * 100 + 77) % k
  break i if x == 0
  break -1 if x == y
end

puts idx


Measured memory_bytes: 14392
#include<iostream>
using namespace std;
int main()
{
int h,n,i,sum=0;
  cin>>h>>n;
  int arr[n];
  for(i=0;i<n;i++)
  {cin>>arr[i];
     sum=sum+arr[i];
  }
  if(sum>=h)
    cout<<"Yes";
  else
    cout<<"No";
 
 
 
}

Measured memory_bytes: 640
L = []
for _ in xrange(3):
    S = sorted(map(lambda (a,b):(a,float(b)),
                   [raw_input().split()for _ in xrange(8)]),
               key=lambda (n,m):m)
    print "{} {}".format(*S.pop(0))
    print "{} {}".format(*S.pop(0))
    L.extend(S)
L.sort(key=lambda (n,m):m)
print "{} {}".format(*L[0])
print "{} {}".format(*L[1])

Measured memory_bytes: 4240
import java.util.Scanner;

public class Main {
	
	private static final long MOD = 1000000007;
	
	private static String[] strs = new String[2];
	private static long[][][] dp = new long[100][5][5];
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int i , j , n;
		n = scan.nextInt();
		for (i = 0;i < 2;i ++) {
			strs[i] = scan.next();
		}
		
		if (strs[0].charAt(0) == strs[1].charAt(0)) {
			dp[0][0][0] = 1;
			dp[0][1][1] = 1;
			dp[0][2][2] = 1;
		} else {
			for (i = 0;i < 3;i ++) {
				for (j = 0;j < 3;j ++) {
					if (i != j) {
						dp[0][i][j] = 1;
					}
				}
			}
		}
		
		for (i = 1;i < n;i ++) {
			if (strs[0].charAt(i) == strs[1].charAt(i)) {
				if (strs[0].charAt(i - 1) != strs[1].charAt(i - 1)) {
					for (j = 0;j < 3;j ++) {
						for (int color1 = 0;color1 < 3;color1 ++) {
							for (int color2 = 0;color2 < 3;color2 ++) {
								if (color1 != color2 && color1 != j && color2 != j) {
									dp[i][j][j] = (dp[i][j][j] + dp[i - 1][color1][color2]) % MOD;
								}
							}
						}
					}
				} else {
					for (int color1 = 0;color1 < 3;color1 ++) {
						for (int color2 = 0;color2 < 3;color2 ++) {
							if (color1 != color2) {
								dp[i][color2][color2] = (dp[i - 1][color1][color1] + dp[i][color2][color2]) % MOD;
							}
						}
					}
				}
			} else {
				if (strs[0].charAt(i) == strs[0].charAt(i - 1)) {
					for (int color1 = 0;color1 < 3;color1 ++) {
						for (int color2 = 0;color2 < 3;color2 ++) {
							dp[i][color1][color2] = dp[i - 1][color1][color2];
						}
					}
				} else {
					if (strs[0].charAt(i - 1) != strs[1].charAt(i - 1)) {
						for (int color1 = 0;color1 < 3;color1 ++) {
							for (int color2 = 0;color2 < 3;color2 ++) {
								for (int color3 = 0;color3 < 3;color3 ++) {
									for (int color4 = 0;color4 < 3;color4 ++) {
										if (color1 != color2 && color1 != color3 && 
											color2 != color4 && color3 != color4) {
											dp[i][color3][color4] = (dp[i - 1][color1][color2] + dp[i][color3][color4]) % MOD;
										}
									}
								}
							}
						} 
					} else {
						for (int color1 = 0;color1 < 3;color1 ++) {
							for (int color2 = 0;color2 < 3;color2 ++) {
								for (j = 0;j < 3;j ++) {
									if (j != color1 && j != color2 && color1 != color2) {
										dp[i][color1][color2] = (dp[i - 1][j][j] + dp[i][color1][color2]) % MOD;
									}
								}
							}
						} 
					}
				}	
			}
		}
		
		long ans = 0;
		for (i = 0;i < 3;i ++) {
			for (j = 0;j < 3;j ++) {
				ans = (ans + dp[n - 1][i][j]) % MOD;
			}
		}
		System.out.println(ans);
		
	}
	
	
}



















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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    string s;
    cin >> s;
    int maxcnt = 0;
    int cnt = 0;
    rep(i, s.length()) {
        if (s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T')
            cnt++;
        else
            cnt = 0;
        maxcnt = max(cnt, maxcnt);
    }

    cout << maxcnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int X, Y; cin >> X >> Y;

    bool ok = false;

    // t: 鶴の数
    // k: 亀の数
    // パターンは以下の X + 1 通り
    // (鶴:X, 亀: 0), (鶴:X - 1, 亀: 1), ... ,(鶴:0, 亀: X)
    for (int t = 0; t <= X; t++) {
        int k = X - t;
        if (2 * t + 4 * k == Y) {
            ok = true;
            break;
        }
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  if (x < y) {
    swap(x, y);
  }
  while (1) {
    if (x % y == 0)
      break;
    else {
      swap(x, y);
      y = y % x;
    }
  }
  return y;
}


int main()
{
  ll x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
}



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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int answer = 0;
  
  for (int i = 1; i < s.size() - 1; i++) {
    int variety = 0;
    vector<bool> ch(26, false);
    for (int j = 0; j < i; j++) ch[s.at(j) - 'a'] = true;
    for (int j = i; j < s.size(); j++) {
      if (ch[s.at(j) - 'a']) {
        variety++;
        ch[s.at(j) - 'a'] = false;
      }
    }
    answer = max(answer, variety);
  }   
  
  cout << answer << endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
a = []
for i in range(N):
    x,y = map(int,input().split())
    a.append([x,y])
max_v, inf = 10**5, float("inf")
dp = [0] + [inf]*max_v
 
for w, v in a:
    for i, j in zip(range(max_v-v, -1, -1), range(max_v, -1, -1)):
        if dp[i]+w <= W and dp[j] > dp[i]+w:
            dp[j] = dp[i]+w
 
for weight, value in zip(dp[::-1], range(max_v, -1, -1)):
    if weight != inf:
        print(value)
        break

Measured memory_bytes: 51900
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N = int(input())

dp = [0] * (N+1)
for i in range(N+1):
    dp[i] = i

#print(dp)


for i in range(1, N+1):
    pow6 = 6
    while pow6 <= N:
        if i >= pow6:
            dp[i] = min(dp[i], dp[i-pow6]+1)

        pow6 *= 6

    pow9 = 9
    while pow9 <= N:
        if i >= pow9:
            dp[i] = min(dp[i], dp[i-pow9]+1)

        pow9 *= 9

print(dp[N])


Measured memory_bytes: 43500
n = int( input() )
s = []
for _ in range( n ):
    s.append( input() )

for i in range( n ):
    s[i] = "".join( sorted( s[i] ) )

found = {}
cnt = 0
for s_i in s:
    if s_i in found:
        found[ s_i ] = found[ s_i ] + 1
    else:
        found[ s_i ] = 0

for key in found:
    c = found[key]
    cnt = cnt + c * ( c + 1 ) // 2

print( cnt ) 

Measured memory_bytes: 19472
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    B = LI()

    res = []
    T = B[:]
    for _ in range(n):
        for i in range(len(T))[::-1]:
            if i + 1 == T[i]:
                res.append(T[i])
                T = T[:i] + T[i+1:]
                break
        else:
            print(-1)
            return 0

    print(*[i for i in reversed(res)], sep='\n')
    return 1


main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	string s;
	int k;
	cin >> s >> k;
	int len = s.length();
	FOR(i, min(len,k)) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;

	return 0;
}


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

using namespace std;

int main()
{
    int n, k;
    
    while (scanf("%d %d", &n, &k) && n){
        int S[128];
        for (int i = 0; i < k; i++){
            scanf("%d", S + i);
        }
        
        bool flag = true;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < k; j++){
                int x;
                scanf("%d", &x);
                S[j] -= x;
                if (S[j] < 0) flag = false;
            }
        }
        
        if (flag) printf("Yes\n");
        else printf("No\n");
    }
    
    return (0);
}

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

int main()
{
    int out = 0;
    string s;
    cin >> s;

    for (int i = 0; i < 3; ++i)
    {
        if (s[i] == 'o') ++out;
    }

    cout << 700+100*out << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int n;
cin >> n;

cout << n/3 << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
const long long INF = 1LL<<60;
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
ll dp[110][100100];

signed main(){
	ll n,m; cin>>n>>m;
	vi w(n),v(n);
	rep(i,0,n) cin>>w[i]>>v[i];
	rep(i,0,110) rep(j,0,100100) dp[i][j]=INF;
	dp[0][0]=0;
	rep(i,0,n){
		rep(sum_v,0,100100){
			if(sum_v-v[i]>=0) chmin(dp[i+1][sum_v],dp[i][sum_v-v[i]]+w[i]);
			chmin(dp[i+1][sum_v],dp[i][sum_v]);
		}
	}
	ll res=0;
	rep(i,0,100100){
		if(dp[n][i]<=m) res=i;
	}
	cout<<res;
	
	return 0;
}

Measured memory_bytes: 86272
import os
import sys
from collections import Counter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = [int(sys.stdin.buffer.readline()) for _ in range(N)]

A = np.array(A, dtype=int)
# 全部偶数になるように取れば勝てる
if np.all(A % 2 == 0):
    print('second')
else:
    print('first')


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

int SumOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void){
  int n;
  int sum = 0;
  cin >> n;
  sum = SumOfDigits(n);
  if(n % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int d[] = {1,0,-1,0,1};

int main(){
  int h,w;
  cin>>h>>w;
  char C[1010][1010];
  for(int i=1; i<=h; i++){
    for (int j=1; j<=w; j++) cin >> C[i][j];
  }
  int V[1010][1010] = {0};

  queue<pii> Q;
  for(int i=1; i<=h; i++){
    for (int j=1; j<=w; j++){
      if (C[i][j] == '#'){
        V[i][j] = 1;
        Q.push(make_pair(i,j));
      }
    }
  }

  while(!Q.empty()){
    int tmp_h = Q.front().first;
    int tmp_w = Q.front().second;
    Q.pop();
    rep(i,4){
      if (V[tmp_h+d[i]][tmp_w+d[i+1]] == 0 && tmp_h+d[i] >= 1 && tmp_h+d[i] && tmp_h+d[i] <= h
        && tmp_w+d[i+1] >= 1 && tmp_w+d[i+1] <= w){
        V[tmp_h+d[i]][tmp_w+d[i+1]] = V[tmp_h][tmp_w] + 1;
        Q.push(make_pair(tmp_h+d[i], tmp_w+d[i+1]));
      }
    }
  }
  int ans = -1;
  for(int i=1; i<=h; i++){
    for (int j=1; j<=w; j++){
      ans = max(ans, V[i][j]);
    }
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 16160
if __name__ == '__main__':
    N = int(input())

    xu_list = [list(map(str, input().split())) for i in range(N)]

    answer = 0
    for xu in xu_list:
        if xu[1] == 'JPY':
            answer += int(xu[0])
        elif xu[1] == 'BTC':
            answer += float(xu[0]) * 380000.0

    print(answer)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func isPrime(x int) bool {
	if x < 2 {
		return false
	}

	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	isp := make([]bool, 100001)
	for i := 1; i < len(isp); i++ {
		isp[i] = isPrime(i)
	}
	s := make([]int, 100001)
	for i := 1; i < len(s); i++ {
		lk := 0
		if isp[i] && isp[(i+1)/2] {
			lk = 1
		}
		s[i] = lk + s[i-1]
	}

	var wr = bufio.NewWriter(os.Stdout)
	q := readInt()
	for i := 0; i < q; i++ {
		l, r := readInt(), readInt()
		wr.WriteString(strconv.Itoa(s[r]-s[l-1]) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define N 16'001
#define O 8'000

using namespace std;

bool X[2][N]{};
bool Y[2][N]{};

int main() {
  string s;
  int x, y;
  cin >> s;
  cin >> x >> y;

  int i = 0;
  int M = s.size();
  int d = 0;
  while (i < M && s[i++] == 'F') {
    ++d;
  }
  X[0][d + O] = true;
  d = 0;
  while (i < M && s[i++] == 'F') {
    ++d;
  }
  Y[0][d + O] = true;
  Y[0][-d + O] = true;

  int j = 1;
  while (i < M) {
    d = 0;
    while (i < M && s[i++] == 'F') {
      ++d;
    }
    for (int k = 0; k < N; ++k) {
      if ((k - d) >= 0 && (k + d) < N) {
        X[j % 2][k] = X[(j - 1) % 2][k - d] || X[(j - 1) % 2][k + d];
      } else if ((k - d) >= 0) {
        X[j % 2][k] = X[(j - 1) % 2][k - d];
      } else if ((k + d) < N) {
        X[j % 2][k] = X[(j - 1) % 2][k + d];
      }
    }

    d = 0;
    while (i < M && s[i++] == 'F') {
      ++d;
    }
    for (int k = 0; k < N; ++k) {
      if ((k - d) >= 0 && (k + d) < N) {
        Y[j % 2][k] = Y[(j - 1) % 2][k - d] || Y[(j - 1) % 2][k + d];
      } else if ((k - d) >= 0) {
        Y[j % 2][k] = Y[(j - 1) % 2][k - d];
      } else if ((k + d) < N) {
        Y[j % 2][k] = Y[(j - 1) % 2][k + d];
      }
    }
    ++j;
  }
  bool res = X[(j - 1) % 2][x + O] && Y[(j - 1) % 2][y + O];
  if (res) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<pair<pair<int, int>, pair<int, string>>> point(2 * N);
  rep(i, 2 * N)
  {
    cin >> point[i].first.first >> point[i].first.second;

    if (i < N)
    {
      point[i].second.first = i;
      point[i].second.second = "r";
    }
    else
    {
      point[i].second.first = i - N;
      point[i].second.second = "b";
    }
  }
  sort(point.begin(), point.end());

  int ans = 0;
  vector<pair<int, int>> kouho;
  vector<bool> is_paired(N);

  rep(i, 2 * N)
  {
    if (point[i].second.second == "r")
      kouho.push_back(make_pair(point[i].first.second, point[i].second.first));
    else
    {
      sort(kouho.rbegin(), kouho.rend());
      rep(j, kouho.size())
      {
        if (!is_paired[kouho[j].second] && kouho[j].first < point[i].first.second)
        {
          is_paired[kouho[j].second] = true;
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	
	int n,i;
	cin>>n;
	int a[2][n];
	rep(i,n)cin>>a[0][i];
	rep(i,n)cin>>a[1][i];
	int dp[2][n];
	dp[0][0]=a[0][0];
	dp[1][0]=a[0][0]+a[1][0];
	for(i=1;i<n;i++){
		dp[0][i]=dp[0][i-1]+a[0][i];
	}
	for(i=1;i<n;i++){
		dp[1][i]=max(dp[1][i-1],dp[0][i])+a[1][i];
	}
	cout<<dp[1][n-1]<<endl;
	
//	rep(i,n)cout<<dp[0][i]<<" ";
//	cout<<endl;
//	rep(i,n)cout<<dp[1][i]<<" ";
	
//////////////////////////////////////////////////////
return 0;}











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

using namespace std;

const int MAXVAL = 2e5;

vector <int> d;
vector <int> cnt;

int main()
{
    #ifdef HOME
        freopen("input.txt", "rt", stdin);
    #endif // HOME
    int n;
    scanf("%d", &n);
    d.resize(n);
    cnt.resize(MAXVAL);
    for (int i = 0; i < n; i++){
        scanf("%d", &d[i]);
        cnt[d[i]]++;
    }
    int ans = 0;
    for (int i = 2; i < MAXVAL; i++){
        ans = max(ans, cnt[i - 2] + cnt[i - 1] + cnt[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int Getsum(int n) {
	int ret = 0;
	while (n) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

int solve(int n,int a, int b) {
	int ret = 0;
	for (int i = 1; i <= n; i++) {
		int now = Getsum(i);
		if (now >= a && now <= b)
			ret += i;
	}
	return ret;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << solve(n,a,b) << endl;
}

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

#include <stdlib.h>

using namespace std;

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

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

  ans.push_back(0);
  int temp = abs(h[0] - h[1]);
  ans.push_back(temp);

  for(int i=2; i<n; i++){
    int min = ans[i-1]+abs(h[i]-h[i-1]);
    for(int j=2; j<=k; ++j){
      if(ans[i-j] + abs(h[i] - h[i-j]) < min){
        min = ans[i-j] + abs(h[i] - h[i-j]);
      }
      if(i-j == 0){
        break;
      }
    }
    ans.push_back(min);
  }

  cout << ans[n-1] << endl;
        return 0;
}

Measured memory_bytes: 1400
// Aizu Vol0 0056: Goldbach's Conjecture
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);

#define MAX  50000
#define SQRT 223     // sqrt(MAX)
#define HALF 25000

char table[MAX + 5];
int combi[MAX + MAX];

void PutInt(int n)
{
	char s[22], *p;

	if (n) {
		p = s + 20, *p = 0;
		while (n) *--p = (n % 10) + '0', n /= 10;
		puts(p);
	}
	else putchar('0'), putchar('\n');
}

int main()
{
	int i, n;
	char buf[100];
	char *p, *p2, *pmax;
	int *q;

	pmax = table + MAX;
	for (p = table + 3, i = 3; i <= SQRT; p += 2, i += 2) {
		if (!*p) {
			for (p2 = p + i; p2 <= pmax; p2 += i) *p2 = 1;
		}
	}
	combi[4] = 1;
	for (p = table + 3, q = combi + 5; p < pmax; p += 2, q += 2) {
		if (!*p) *q = 1;
	}
	for (i = 3, p = table + 3; i < HALF; i += 2, p += 2, pmax -= 2) {
		if (!*p) {
			for (p2 = p, q = combi + i + i; p2 < pmax; p2 += 2, q += 2) {
				if (!*p2) (*q)++;
			}
		}
	}
#if 0
	for (i = 2; i < 200; i++) printf("[%d]=%d\n", i, combi[i]);
#endif

	while (1) {
		gets(buf);
		n = atoi(buf);
		if (n == 0) break;
		PutInt(combi[n]);
	}
	return 0;
}

Measured memory_bytes: 748
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}
	var m int
	fmt.Scan(&m)
	p := make([]int, m)
	x := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&p[i])
		fmt.Scan(&x[i])
	}

	sum := 0
	for _, v := range t {
		sum += v
	}
	for i := 0; i < m; i++ {
		ans := sum + (x[i] - t[p[i]-1])
		fmt.Println(ans)
	}
}


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

int main() {
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else if(n==2){
        int a;
        int b;
        cin >> a;
        cin >> b;
        
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256