akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e7+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
bool is_prime[100100];
int prime[100100];
int p = 0;

int main(){
	fill(is_prime, is_prime + 100100, 1);
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i < 100100; i++){
		if (is_prime[i]){
			prime[p] = i;
			p++;
			for (int j = i * 2; j < 100100; j += i){
				is_prime[j] = 0;
			}
		}
	}
	while (cin >> n&&n){
		int ans = 0;
		REP(i, p){
			for (int j = i; j < p; j++){
				if (prime[i] + prime[j] == n)ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1296
#include<stdio.h>

int main(){
    int a,b;
    int i=0;
    int r,tmp;
    scanf("%d%d",&a,&b);
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  printf("%d",b);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2124
import sys
from random import randint
input = sys.stdin.readline
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [randint(0, 25) for i in range(D)]
last = [0] * 26
def score(day, score):
  for i in range(26): score -= (day - last[i]) * c[i]
  return score
def run(day):
  global last
  last = [0] * 26
  res = 0
  for d in range(day):
    contest = t[d]
    last[contest] = d + 1
    res = score(d + 1, res) + s[d][contest]
  return res


for d in range(1, D + 1):
  mx = -float("inf")
  mxx = randint(0, 25)
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx

for _ in range(3):
  ll = randint(1, 340)
  for l in range(ll, ll + 15):
    last = [0] * 26
    run(l)
    #print(last)
    zmx = -float("inf")
    zmxz = 0
    for z in range(26):
      t[l - 1] = z

      for d in range(l + 1, D + 1):
        mx = -float("inf")
        mxx = t[d - 1]
        for x in range(26):
          t[d - 1] = x
          res = score(d, 0) + s[d - 1][x]
          if mx < res:
            mx = res
            mxx = x
        t[d - 1] = mxx
        last[mxx] = d
      zres = run(D)
      if zres > zmx:
        zmx = zres
        zmxz = z
    t[l - 1] = zmxz

for x in t: print(x + 1)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

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

    int n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    
    ll sum = 0;
    rep(i,n)sum+=a[i];

    vector<ll> ans(n);
    ans[0] = sum;
    for(ll i = 1;i<n;i+=2)
    {
        ans[0]-=2*a[i];
    }

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

    rep(i,n)
    {
        cout<<ans[i]<<" ";
    }

    return 0;
}

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

using namespace std;

int main()
{
	int t;
t=1;
	while(t--)
	{
	
	
	int a[1000];
	
	int i,j,k,n;
	
	
	for(i=1;i<=5;i++)
{
		cin>>a[i];
 
 
 if(a[i]==0)
 k=i;
 	
}

cout<<k<<endl;
	}



}


Measured memory_bytes: 3596
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::fmt::Debug;
use std::i64::MAX;
use std::collections::BinaryHeap;
use std::cmp::Ordering;
use std::collections::VecDeque;


fn main() {
    let mut sc = Scanner::new();
    let n = sc.parse::<usize>();
    let mut a: Vec<u64> = (0..n).map(|_| { sc.parse::<u64>() }).collect::<Vec<_>>();
    a.sort();

    let mut q = VecDeque::new();
    for i in (0..n).rev() {
        q.push_back(a[i]);
    }

    let mut ans = 1;
    let mut count = 0;
    while q.len() > 1 && count < 2 {
        let v1 = q.pop_front().unwrap();
        if *q.front().unwrap() == v1 {
            count += 1;
            ans *= v1;
            q.pop_front();
        }
    }
    if count < 2 {
        ans = 0;
    }
    println!("{}", ans);
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
//#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n, a[105], ma;
int cnt[105];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		chmax(ma, a[i]);
		cnt[a[i]]++;
	}
	if (ma % 2 == 0 && cnt[ma / 2] != 1) {
		cout << "Impossible" << endl; return 0;
	}
	if (ma % 2 && cnt[ma / 2 + 1] != 2) {
		cout << "Impossible" << endl; return 0;
	}
	for (int i = ma / 2 + 1; i <= ma; i++) {
		if (cnt[i] < 2) {
			cout << "Impossible" << endl; return 0;
		}
	}
	if (ma % 2) {
		REP(i, ma / 2 + 1) {
			if (cnt[i]) {
				cout << "Impossible" << endl; return 0;
			}
		}
	}
	else {
		REP(i, ma / 2) {
			if (cnt[i]) {
				cout << "Impossible" << endl; return 0;
			}
		}
	}
	cout << "Possible" << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
const double eps = 0.000000000001;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
int gcd(int a, int b) {
	if (!b)return a; return gcd(b, a%b);
}
int f(int a, int c, int d) {
	return a - (a / c) - (a / d) + (a / (c/gcd(c, d)*d));
}

signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << f(b, c, d) - f(a - 1, c, d) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int sec, min, hour, time;
	
	 
	scanf("%d", &time);
	
	sec = time % 60;
	min = (time / 60) % 60;
	hour = time / 3600;

 
	 printf("%d:%d:%d\n", hour,min,sec);
	 return 0;
}

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

int main(){
  int n,t;
  cin >> n >> t;
  //nは帰宅経路の個数　tは制限時間
  int a[n],b[n];
  //aがコスト bが時間
  for (int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  //入力終わり
  int ans=1010;
  for (int i=0;i<n;i++){
    if(t>=b[i]){
      ans=min(ans,a[i]);
    }
  }
  if(ans==1010){
  cout << "TLE" << endl;
  }
  else{
    cout << ans << endl;
  }
}

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

int n,s[1<<N];
multiset<int>a,b,c;
multiset<int>::iterator it,it1;

int main(){
	scanf("%d",&n);
	for(int i=0;i<(1<<n);++i)scanf("%d",&s[i]);
	sort(s,s+(1<<n));
	a.insert(s[(1<<n)-1]);
	for(int i=0;i<(1<<n)-1;++i)b.insert(s[i]);
	while(b.size()){
		for(it=a.end(),--it;;--it){
			it1=b.lower_bound(*it);
			if(it1==b.begin()){
				puts("No");exit(0);
			}
			--it1;
			b.erase(it1);
			c.insert(*it1);
			if(it==a.begin())break;
		}
		while(c.size()){
			it1=c.begin();
			a.insert(*it1);
			c.erase(it1);
		}
	}
	
	puts("Yes");
}

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

#define int long long
signed main(){
    int n,a,b;
    cin >> n >>a >>b;
    int x0,x1,p,ans;
    p=0;ans=0;
    cin >> x0;
    for(int i= 1;i<n;i++){
        cin >> x1;
        if(b> a*(x1-x0)){
            p+= x1-x0;
        }else{
            ans+= p*a +b;
            p=0;
        }
        x0 =x1;
    }
    ans+= p*a;
    cout << ans;
    return 0;

  
    
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;

ll s[51];
ll p[51];

ll f(int N, ll X){
	if(N==0){
		return (X<=0 ? 0 : 1);
	}else if(X <= 1+s[N-1]){
		return f(N-1,X-1);
	}else{
		return p[N-1] + 1 + f(N-1, X-1-s[N-1]-1);
	}
}


int main(){
	int N;
	ll X;
	cin >> N >> X;
	s[0] = 1;
	p[0] = 1;
	for(int i=1;i<=N;i++) s[i] = 2*s[i-1]+3;
	for(int i=1;i<=N;i++) p[i] = 2*p[i-1]+1;
	
	cout << f(N,X) << endl;

	
	return 0;
}

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

int main() {
	long long N; cin >> N;
	long long M; cin >> M;
	vector<long long> A(M);
	long long sum = 0;
	for (int i = 0; i < M; i++)
	{
		cin >> A[i];
		sum += A[i];
	}
	if (sum > N)cout << -1;
	else cout << N - sum;
	cout << endl;
}

Measured memory_bytes: 3716
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        p: usize,
        q: usize,
        r: usize
    };

    let x1 = p + q;
    let x2 = p + r;
    let x3 = q + r;

    let mut min = std::cmp::min(x1, x2);
    min = std::cmp::min(min, x3);

    println!("{}", min);
}


Measured memory_bytes: 2172
#include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int n,x;
        cin >> n >> x;
        if(n == 0 && x == 0)
        {
            return 0;
        }
        int c = 0;
        for(int i = 1;i < n + 1;i++)
        {
            for(int j = 1;j < n + 1;j++)
            {
                for(int k = 1;k < n + 1;k++)
                {
                    if((i + j + k) == x && i < j && j < k)
                    {
                        c++;
                    }
                }
            }
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int a1,a;
int main(){
	string s1,s2;
	cin>>s1;
	for(int i=0;i<s1.size();i++)
	   {
	   	  if(s1[i]=='p') a1++;  
	   }
	a=s1.size()/2;
	cout<<a-a1;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	vecl(A);
	pb(A, a * c)
		pb(A, a * d)
		pb(A, b * c)
		pb(A, b * d)
		sorts(A);
	ce(A[3])
    return 0;
}



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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int A, B, C; cin >> A >> B >> C;
	if(B < A) swap(A, B);
	if(A < C and C < B) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
//#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e7 + 7;
//const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
const int N = 1000;
int value[N]; 
double  weight[N], height[N];
char ch;

double BMI(double height, double weight){
   return weight / pow(height / 100.0, 2);	
}

void solve(){
   int c = 0;
   while(cin >> value[c] >> ch >> weight[c] >> ch >> height[c]) c++;
   
   for(int i = 0; i < c; i++){
	   if (BMI(height[i] * 100.0, weight[i]) >= 25.00){
		    cout << value[i] << endl; 
		  } 
	 }  
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3112
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int sum, max_sum;
		int num, c_num;
		int [] number = new int[100000];
		
		num = scanner.nextInt();
		c_num = scanner.nextInt();
		while(num != 0 || c_num != 0) {
			sum = max_sum = 0;
			
			for(int i = 0; i < num; i++) {
				number[i] = scanner.nextInt();
			}
			
			for(int i = 0; i < c_num; i++) {
				sum += number[i];
			}
			max_sum = sum;
			
			for(int i = 1; i < num - c_num + 1; i++) {
				sum -= number[i - 1];
				sum += number[i + c_num - 1];
				if (sum > max_sum ) {
					max_sum = sum;
				}
			}

			System.out.println(max_sum);
			
			num = scanner.nextInt();
			c_num = scanner.nextInt();
		}
	}
}

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

int main(){

	int n;
	cin >> n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	
	for(int i=1;i<=n;i++){
		cout << "node " << i << ": ";
		cout << "key = " << a[i] << ", ";
		if (i/2 > 0){
			cout << "parent key = " << a[i/2] << ", ";
		}
		if(i*2 <= n){
			cout << "left key = " << a[i*2] << ", ";
		}
		if(i*2+1 <= n){
			cout << "right key = " << a[i*2+1]<< ", ";
		}
		cout << endl;
	}
	return 0;
}




Measured memory_bytes: 3088
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll k, X, Y;
  cin >> k >> X >> Y;
  ll x = X, y = Y;
  int xs = (x >= 0) ? 1 : -1;
  int ys = (y >= 0) ? 1 : -1;
  x = x * xs;
  y = y * ys;
  if(k % 2 == 0 && (x+y) % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  vector<ll> a, b;
  while(x > k && x + y > 2 * k) {
    x -= k;
    a.push_back(x);
    b.push_back(y);
  }
  while(y > k && x + y > 2 * k) {
    y -= k;
    a.push_back(x);
    b.push_back(y);
  }

  if(x + y != k) {
    bool swapped = false;
    if(x > y) {
      swapped = true;
      swap(x, y);
    }
    ll c = (-x + y) / 2;
    ll nx = x + c - k;
    ll ny = y - c;
    if(swapped) swap(nx, ny);
    a.push_back(nx);
    b.push_back(ny);
    x = nx;
    y = ny;
    if(abs(x) + abs(y) != k) {
      bool swapped = false;
      if(abs(x) > abs(y)) {
        swapped = true;
        swap(x, y);
      }
      ll c = (-abs(x) + abs(y)) / 2;
      ll ny = abs(y) - c;
      if(abs(y - ny) != c) ny *= -1;
      ll nx = abs(x) + c - k;
      if(abs(x - nx) != k - c) nx *= -1;
      if(swapped) swap(nx, ny);
      x = nx;
      y = ny;
      a.push_back(x);
      b.push_back(y);
    }
  }
  a.push_back(0);
  b.push_back(0);
  cout << a.size() << endl;
  REP(i, a.size()) {
    cout << (abs(X) - a[i]) * xs << " " << (abs(Y) - b[i]) * ys << endl;
  }
  return 0; 
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  int count = 0;

  for (int i = a; i <= b; i++)
  {
    if (c % i == 0)
    {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3112
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}

const int M = 123456;
char isPrime[M*2+1];

void sieve()
{
    REP(i, 2, M*2+1) isPrime[i]=1;
    for(int i=2; i*i <= 2*M; i++) {
        if (isPrime[i]) {
            for(int j=i+i; j<M*2+1; j+=i) {
                isPrime[j]=0;
            }
        }
    }
}

void solve()
{
    int n;
    while(cin>>n, n){
        int s = 0;
        REP(i, n+1, 2*n+1) {
            s += isPrime[i];
        }

        cout << s << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    sieve();
    solve();
}

Measured memory_bytes: 3344
#include<iostream>
#include<cstdio>
//#include<cmath>
//#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
struct train
{
	int ci,si,fi;
}m[507];
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int N;
int main()
{
	N=read();
	for(int i=1;i<=N-1;i++)
	   {m[i].ci=read();
	   	m[i].si=read();
	   	m[i].fi=read();}
    for(int i=1;i<=N;i++)
       {
       	int t=0;
       	for(int j=i;j<=N-1;j++)
       	   {
       	   	if(m[j].si>t)t=m[j].si;
       	   	else if(!(t%m[j].fi));
       	   	else t+=m[j].fi-t%m[j].fi;
       	   	t+=m[j].ci;
       	   }
         cout<<t<<endl;
	   }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	int Q; cin >> Q; 
	long long int ans = 0; 
	priority_queue<long long> Small; 
	priority_queue<long long, vector<long long>, greater<long long>> Large; 	
	for(int q = 0; q < Q; q++){
		int r; 
		cin >> r; 
		if(q == 0){
		    long long int a, b; cin >> a >> b; 
			Small.push(a); Large.push(a); ans = b; 			
		}
		else if(r == 1){
		    long long int a, b; cin >> a >> b; 
			long long int x, y; 
			x = Small.top(); y = Large.top(); 
			if(a < x){
				Small.pop(); Large.push(x); 
				Small.push(a); Small.push(a); 
				ans += abs(a-x) + b; 
			}
			else if(a > y){
				Large.pop(); Small.push(y); 
				Large.push(a); Large.push(a); 
				ans += abs(a-y) + b; 
			}
			else{
				Small.push(a); 
				Large.push(a); 
				ans += b; 
			}
		}
		else if(r == 2){
			cout << Small.top() << " " << ans << endl; 
		}
	}
}

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


int main() {
  int a,b;
  
  cin >> a >> b;
  
  int tasu = a+b;
  int hiku = a-b;
  int kakeru = a*b;
  
  int saidai = max(tasu,hiku);
  saidai = max(saidai,kakeru);
  
  cout << saidai;
  
  
}


Measured memory_bytes: 256
import fractions

A, B, C, D = map(int, input().split())

lcm = (C*D)//fractions.gcd(C, D)

a = ((A-1)//C+(A-1)//D)-(A-1)//lcm
b = (B//C+B//D)-B//lcm

print((B-A+1)-(b-a))


Measured memory_bytes: 5560
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+4;
int n,m,a[N];
bool od,ev;
int Gcd(int a,int b) {
	return !b?a:Gcd(b,a%b);
}
ll Lcm(int a,int b) {
	int g=Gcd(a,b);
	return 1ll*a*b/g;
}
int main() {
	scanf("%d%d",&n,&m);
	for (register int i=1;i<=n;++i) {
		scanf("%d",&a[i]);
		a[i]>>=1;
		if (a[i]&1) od=true;
		else ev=true;
	}
	if (od&&ev) {
		puts("0");
		return 0;
	}
	ll lcm=1;
	for (register int i=1;i<=n;++i)
		lcm=Lcm(lcm,a[i]);
//	if (lcm<=m) printf("%d\n",1+(m-lcm)/(lcm<<1));
	if (lcm<=m) {
		for (register int i=1;i<=n;++i)
			if ((lcm/a[i])%2==0) {
				puts("0");
				return 0;
			}
		printf("%d\n",1+(m-lcm)/(lcm<<1)); 
	}
	else puts("0");
	return 0;
}

Measured memory_bytes: 640
X = int(input())
P = [True] * 100100
for i in range(2, 100100):
    if not P[i]:
        continue
    for j in range(i*2, 100100, i):
        P[j] = False
for i in range(X, 100100):
    if P[i]:
        print(i)
        break

Measured memory_bytes: 3828
#include <iostream>
#include <string.h>
using namespace std;
long long w[100005];
long long v[100005];
long long dp[100005];
int main() {
	int N, W; cin >> N >> W;
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];
	memset(dp, 0xff, sizeof(dp));
	dp[0] = 0;
	long long maxv = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = W; j >= w[i]; j--) {
			if (~dp[j - w[i]]) {
				dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
				maxv = max(maxv, dp[j]);
			}
		}
	}
	cout << maxv << endl;
}


Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	char s[10000]; scanf("%s",&s);
	int n = strlen(s);
	int x, y; scanf("%d %d",&x,&y);
	x += n; y += n;
	vector<int> a,xlen,ylen; int cnt = 0;
	rep(i, 0, n) {
		if (s[i] == 'F') cnt++;
		else {
			a.push_back(cnt);
			cnt = 0;
		}
	}
	a.push_back(cnt);
	rep(i, 0, a.size()) {
		if (i % 2) ylen.push_back(a[i]);
		else xlen.push_back(a[i]);
	}
	vector<vector<bool>> dp(a.size()+1);
	rep(i, 0, a.size()+1) dp[i].resize(2 * n+1,false);
	dp[0][n] = true;
	rep(i, 0, xlen.size())rep(j, 0, 2 * n+1) {
		if (dp[i][j]) {
			if(j+xlen[i]<=2*n)dp[i + 1][j + xlen[i]] = true;
			if(j-xlen[i]>=0&&i!=0)dp[i + 1][j - xlen[i]] = true;
		}
	}
	if (!dp[xlen.size()][x]) {
		printf("No");
		return 0;
	}
	rep(i, 0, a.size() + 1)rep(j, 0, 2 * n + 1) dp[i][j] = false;
	dp[0][n] = true;
	rep(i, 0, ylen.size())rep(j, 0, 2 * n + 1) {
		if (dp[i][j]) {
			if(j+ylen[i]<=2*n)dp[i + 1][j + ylen[i]] = true;
			if(j-ylen[i]>=0)dp[i + 1][j - ylen[i]] = true;
		}
	}
	if (!dp[ylen.size()][y]) {
		printf("No");
		return 0;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 16128
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yay!");
    } else {
        println!(":(");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    yn(a <= 8 &&  b <= 8);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
typedef long long ll;
ll sma, sum, n;
bool ans = true;
int main(void){
    // Your code here!
    sma = 1000000000000;
    cin >> n;
    for (ll i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        if (a != b) ans = false;
        sum += a;
        if (a > b) sma = min(sma, b);
    }
    if (ans) cout << 0 << endl;
    else cout << sum - sma << endl;
}


Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      abc: [(usize, usize, usize); n-1],
      q: usize,
      k: usize,
      xy: [(usize, usize); q]
   }
   let mut to = vec![vec![]; n];
   for (a, b, c) in abc {
      to[a - 1].push((b - 1, c));
      to[b - 1].push((a - 1, c));
   }
   let mut d = vec![0; n];
   {
      let mut q = std::collections::VecDeque::new();
      q.push_back((k - 1, k - 1));
      while let Some((v, p)) = q.pop_front() {
         for &(u, c) in to[v].iter() {
            if u == p {
               continue;
            }
            d[u] = d[v] + c;
            q.push_back((u, v));
         }
      }
   }
   for (x, y) in xy {
      println!("{}", d[x - 1] + d[y - 1]);
   }
}


Measured memory_bytes: 22780
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std; 
int n;
int a[200005];
int b[200005];
int ans[2000005];
int main()
{
	int n,m;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
   scanf("%d",&a[i]);
   m=a[i]/n;
   b[i]=m;	
}	
for(int i=n;i>=1;i--)
{
	if(a[i]==1)
	{
		b[i]=1;
		for(int j=1;j<=sqrt(i);j++)
		{
			if(i%j==0)
			{
				if(a[j]==0)
				a[j]=1;
				else
				a[j]=0;
				int c=i/j;
				if(c*c!=i)
				{
				if(a[c]==0)
				a[c]=1;
				else
				a[c]=0;	
				}
				
			}
		}
	}
	else
	{
		b[i]=0;
	}
}
int at=0;
for(int i=1;i<=n;i++)
{
	if(b[i]==1)
	{
		ans[at++]=i;
	}
}
printf("%d\n",at);
if(at==0)
{
printf("\n");
}
else
{
	for(int i=0;i<at-1;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[at-1]);	
}

}
 

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
 
int main(){
	int n, k;
	cin >> n >> k;
	ll v[n];
	for(int i=0; i<n; i++) cin >> v[i];

	ll ans=-(ll)(1e10);
	for(int i=0; i<=n; i++){
		for(int j=0; j<=n; j++){
			if(i+j>n) continue;

			vector<ll> t;
			int negative=0;
			for(int l=0; l<i; l++){
				t.push_back(v[l]);
				if(v[l]<0) negative++;
			}
			for(int l=0; l<j; l++){
				t.push_back(v[n-1-l]);
				if(v[n-1-l]<0) negative++;
			}
			sort(t.begin(), t.end());

			ll sum=0;
			for(int l=min(negative, k-(i+j)); l<t.size(); l++){
				sum+=t[l];
			}
			ans=max(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <string>
          #define ll int
          #define N 100000
          #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
          #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
          #define po pop_back
          #define pb push_back
          #define pp pair<ll,ll>
          #define lb lower_bound
          #define fi first
          #define se second
          #define debug(x) cout << #x << " = " << x << endl
          #define ub upper_bound
          #define ibs ios_base::sync_with_stdio(false)
          #define cti cin.tie(0)
          #define all(x) x.begin(),x.end()
          #define PI 3.14159265
          #define cot cout.tie(0)
          using namespace std;
         /**
          * @author :: Sawlani
          *
          */
          double fac[11];
           vector <pair <double,double>  > v;

          void factorial()
          {
              fac[1]=1;
              f(i,2,9)
              fac[i]=fac[i-1]*(i);
          }
          double dis(ll i,ll j)
          {
              double p=(v[i].fi-v[j].fi)*(v[i].fi-v[j].fi);
              double z=(v[i].se-v[j].se)*(v[i].se-v[j].se);
              double ans=sqrt(p+z);
              return ans;
          }
          int main()
          {
                factorial();

              ll n;
              cin >>  n;
              f(i,1,n)
              {
                  double x,y;
                  cin >>  x >>  y;

                  v.pb({x,y});

              }
               
               double sum=0;
              f(i,1,n)
              {
                  f(j,i+1,n)
                  {
                     sum+=2.0*fac[n-2+1]*dis(i-1,j-1);
                   }
              }
              cout << fixed << setprecision(6) ;
               double ans=sum/(double)fac[n];
              cout << ans << endl;

          }


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int a, b;
  cin >> a >> b;
  if(a+b==15) cout << "+" << endl;
  else if(a*b==15) cout << "*" << endl;
  else cout << "x" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a>>b>> c>>k;
  int i,sum=0,p=max(a,max(b,c));
  for(i=0;i<k;i++){
    p=p*2;
  }
  sum=p+a+b+c-max(a,max(b,c));
  cout << sum;
                  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  string j="No";
  cin>>N;
  for(int a=0; a<10; a++){
    for(int b=0; b<10; b++){
      if(a*b==N)
      {
        j="Yes";
      }
    }
  }
  cout<<j<<endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)

struct Parsed{
	int index,id;
	Parsed(){}
	Parsed(int index,int id):index(index),id(id){}
};
struct Area{
	bool valid;
	int size;
	Area(){}
	Area(bool valid,int size):valid(valid),size(size){}
};

int memory;
map<char,int> toid;   // name -> id
map<int,Area> toarea; // id -> (valid flg,size)

int remain_memory()
{
	int size=0;
	foreach(i,toarea)
		size+=i->second.size;
	return memory-size;
}

Parsed parse_expr(const string& s,int index);

Parsed parse_variable(const string& s,int index)
{
	char var=s[index];
	if(toid.find(var)==toid.end())
		toid[var]=-1;
	return Parsed(index+1,toid[var]);
}

Parsed parse_assign(const string& s,int index)
{
	char var=s[index];
	Parsed p=parse_expr(s,index+2);
	toid[var]=p.id;
	return p;
}

Parsed parse_malloc(const string& s,int index)
{
	index+=7;
	int size=0;
	rep(i,s.size()-index)
		if(!isdigit(s[index+i])){
			size=atoi(s.substr(index,i).c_str());
			index+=i;
			break;
		}
	if(remain_memory()<size)
		return Parsed(index+1,0);
	
	int id=toarea.size();
	toarea[id]=Area(true,size);
	return Parsed(index+1,id);
}

Parsed parse_clone(const string& s,int index)
{
	Parsed p=parse_expr(s,index+6);
	if(p.id==-1 || !toarea[p.id].valid)
		throw "Error(parse_clone)";
	if(p.id){
		int id=toarea.size();
		if(remain_memory()>=toarea[p.id].size){
			toarea[id]=Area(true,toarea[p.id].size);
			return Parsed(p.index+1,id);
		}
		else
			return Parsed(index+1,0);
	}
	return Parsed(p.index+1,0);
}

Parsed parse_expr(const string& s,int index)
{
	if(s[index]=='('){
		Parsed p=parse_expr(s,index+1);
		return Parsed(p.index+1,p.id);
	}
	else if(s.substr(index,4)=="NULL")
		return Parsed(index+4,0);
	else if(s[index]=='m')
		return parse_malloc(s,index);
	else if(s[index]=='c')
		return parse_clone(s,index);
	else{
		if(index+1<s.size() && s[index+1]=='=')
			return parse_assign(s,index);
		else
			return parse_variable(s,index);
	}
	
}

void parse_free(const string& s)
{
	Parsed p=parse_expr(s,5);
	
	if(p.id==-1 || !toarea[p.id].valid)
		throw "Error(parse_free)";
	if(p.id)
		toarea[p.id]=Area(false,0);
}

void parse_line(const string& s)
{
	if(s[0]=='f')
		parse_free(s);
	else
		parse_expr(s,0);
}

int main()
{
	while(cin>>memory && memory!=-1){
		cin.ignore();
		vector<string> lines;
		for(string s;getline(cin,s),s.size();)
			lines.push_back(s);
		
		toid.clear();
		toarea.clear();
		toarea[0]=Area(true,0);
		
		try{
			rep(i,lines.size())
				parse_line(lines[i]);
			
			foreach(i,toid)
				toarea[i->second].size=0;
			int res=0;
			foreach(i,toarea)
				if(i->second.valid)
					res+=i->second.size;
			
			cout<<res<<endl;
		}
		catch(const char* message){
			cout<<"Error"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
int INF=2e+9;
int travelcost(int A1,int A2,pint zahyo[90001]){
	return abs(zahyo[A1].first-zahyo[A2].first)+abs(zahyo[A1].second-zahyo[A2].second);
}
int main(){
	int H,W,D;
	int A[300][300];
	pint zahyo[90001];
	vector<int> costsum[90000];
	int Q;
	int L[100000],R[100000];
	scan(H);scan(W);scan(D);
	rep(i,H){
		rep(j,W){
			scan(A[i][j]);
			zahyo[A[i][j]].first=i;
			zahyo[A[i][j]].second=j;
		}
	}
	for(int i=0;i<D;i++){
		costsum[i].push_back(0);
	}
	for(int i=D+1;i<=H*W;i++){
		costsum[i%D].push_back(costsum[i%D].back()+travelcost(i,i-D,zahyo));
	}
	scan(Q);
	rep(i,Q){
		scan(L[i]);scan(R[i]);
		int mod=L[i]%D;
		prin(costsum[mod][(R[i]-1)/D]-costsum[mod][(L[i]-1)/D]);
	}

	return 0;
}


Measured memory_bytes: 7168
X,N = map(int,input().split())

if N==0:
  print(X)

else:
  P = list(map(int,input().split()))
  if X not in P:
    print(X)
  
  else:
      a = X+1
      b = X-1
      
      while a in P:
        a+=1
      while b in P:
        b-=1
      
      if abs(X-a)<abs(X-b):
        print(a)
      else:
        print(b)

Measured memory_bytes: 9200
#include <stdio.h>
#include <string.h>
int main(void){
char s[100 + 1];
scanf("%s", s);
int n = strlen(s); // 文字列の長さを得る s
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
// 奇数文字目
if (s[i] == 'L') {
puts("No");
return 0;
}
} else {
// 偶数文字目
if (s[i] == 'R') {
puts("No");
return 0;
}
}
}
puts("Yes");
return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド
		Scanner sc = new Scanner(System.in);

		for(int i = 1;;i++) {
		int a = sc.nextInt();
		if(a == 0)
			break;
		System.out.println("Case " + i  + ": " + a);
		}
	}
}



Measured memory_bytes: 42460
S = input()
if S == "keyence":
  print("YES")
  exit()
if S[0] != "k":
  if S[-7:] == "keyence":
    print("YES")
  else:
    print("NO")
elif S[1] != "e":
    if S[-6:] == "eyence":
      print("YES")
    else:
      print("NO")
elif S[2] != "y":
    if S[-5:] == "yence":
      print("YES")
    else:
      print("NO")
elif S[3] != "e":
    if S[-4:] == "ence":
      print("YES")
    else:
      print("NO")
elif S[4] != "n":
    if S[-3:] == "nce":
      print("YES")
    else:
      print("NO")
elif S[5] != "c":
    if S[-2:] == "ce":
      print("YES")
    else:
      print("NO")
elif S[6] != "e":
    if S[-1] == "e":
      print("YES")
    else:
      print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int digit(ll x){
    int res=0;
    while(x>0){
        x/=10;
        res++;
    }
    return res;
}

int digitSum(ll x){
    int res=0;
    while(x>0){
        res+=x%10;
        x/=10;
    }
    return res;
}

ll f(ll N){
    vector<ll> cand;
    ll d=digit(N);
    cand.push_back(N);
    ll dwdig=0;
    for(int i=0;i<d-3;i++) dwdig=dwdig*10+9;
    ll ten=1;
    for(int i=0;i<d-3;i++) ten=ten*10;
    for(ll i=1;i<=9;i++){
        for(ll j=0;j<=9;j++){
            for(ll k=0;k<=9;k++){
                ll res=i*100*ten+j*10*ten+k*ten+dwdig;
                if(N>res) continue;
                cand.push_back(res);
            }
        }
    }

    int mit=0;
    for(int i=0;i<cand.size();i++){
        ll l=cand[mit];
        ll ls=digitSum(l);
        ll r=cand[i];
        ll rs=digitSum(r);
        if(rs*l>ls*r) mit=i;
    }
    return cand[mit];
}

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

  ll K;
  cin>>K;
  vector<ll> ans;
  rep(i,9) ans.push_back(i+1);
  for(int i=19;i<=99;i+=10) ans.push_back(i);

  ll N=100;
  while(ans.size()<K){
      ll nex=f(N);
      ans.push_back(nex);
      N=nex+1;
  }
  rep(i,K) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] a = new int[n];
        long money = 1000;

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

        for (int i = 1; i < n; i++) {
            if (a[i-1] < a[i]) {
                long t = money / a[i-1];
                money += (a[i] - a[i-1]) * t;
            }
        }

        System.out.println(money);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 32624
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  int a, b;
  a = stoi(S.substr(0,2));
  b = stoi(S.substr(2,2));

  string ans;
  bool aM = false;
  bool bM = false;
  if(a > 0 && a < 13) aM = true;
  if(b > 0 && b < 13) bM = true;
  if(aM && bM) ans = "AMBIGUOUS";
  else if(!aM && bM) ans = "YYMM";
  else if(aM && !bM) ans = "MMYY";
  else ans = "NA";

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define ll  long long
  #define ld long double
  #define pb push_back
  #define mp3 make_pair
  #define rep1(i,a,b) for(ll i=a;i<=b;i++)
  #define rep2(i,a,b) for(ll i=a;i<b;i++)
  const ll  mod=998244353;
  template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
  template<typename T> T add(T a,T b,ll m){a+=b;while(a>=0)a-=m;while(a<0)a+=m; return a;}
  template<typename T> T mul(T a,T b,ll m){return (a*1ll*b)%m;}

 int main(){
   IOS;
 string s;
 cin>>s;
 ll ans=0;
 for(ll i=0;i<s.length();i++){
   ans+=s[i]-'0';
 }
 if(ans%9==0)
 cout<<"Yes"<<endl;
 else 
 cout<<"No"<<endl;
 }

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

bool isPrime(Int n){
  if(n == 0 || n == 1) return 0;
  for(Int i = 2; i * i <= n; i++) if( n % i == 0 ) return 0;
  return 1;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n;
  cin>>n;

  Int ans = 0;
  while(n--){
    Int num;
    cin>>num;
    ans += isPrime(num);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3088
function Main(input) {
    var S = input[0];

    var mae = parseInt(S.substr(0, 2), 10);
    var usiro = parseInt(S.substr(2, 2), 10);

    var isMaeMM = 1 <= mae && mae <= 12;
    var isUsiroMM = 1 <= usiro && usiro <= 12;

    if (isMaeMM && isUsiroMM) {
        console.log('AMBIGUOUS');
    } else if (isMaeMM) {
        console.log('MMYY');
    } else if (isUsiroMM) {
        console.log('YYMM');
    } else {
        console.log('NA');
    }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372