akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

  vector<int> t,x,y;

  for(int i=0;i<N;i++){
    int temp;
    cin >> temp;
    t.push_back(temp);
    cin >> temp;
    x.push_back(temp);
    cin >> temp;
    y.push_back(temp);
  }
  int now_t=0,now_x=0,now_y=0;
  for(int i=0;i<N;i++){
    int dist=abs(x[i]-now_x)+abs(y[i]-now_y);
    int t_diff=t[i]-now_t;
    if(dist<=t_diff){
      if(t_diff%2==0&&dist%2==0){
        now_t=t[i];now_x=x[i];now_y=y[i];
      }
      else if(t_diff%2!=0&&dist%2!=0){
        now_t=t[i];now_x=x[i];now_y=y[i];
      }
      else{
        cout<<"No"<<endl; return 0;
      }
    }
    else{
      cout<<"No"<<endl; return 0;
    }
  }

  cout<<"Yes"<<endl;

  return 0;
}




Measured memory_bytes: 1644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {
	
	string s;

	cin >> s;

	if (s[5]=='0'&&s[6] < '5') { cout << "Heisei"; }
	else { cout << "TBD"; }

	system("PAUSE");
}

Measured memory_bytes: 504
#include<iostream>
#include<algorithm> // sort,reverse,min,lower_bound
using namespace std;
#define df 0

int lg(int n){
  int cnt=1;
  while(n){
    cnt++;
    n/=2;
  }
  return cnt;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >> n;
  int x[n];
  for(auto& a:x){
    cin >> a;
  }
  int l,q; cin >> l >> q;

  int lmax=lg(n);
  int dbl[n][lmax];
  for(int i=0;i<n;i++){
    dbl[i][0]=upper_bound(x,x+n,x[i]+l)-x-1;
    if(df)printf("[%d] ",dbl[i][0]);
  }
  for(int j=1;j<lmax;j++){
    if(df)printf("\n");
    for(int i=0;i<n;i++){
      dbl[i][j]=dbl[dbl[i][j-1]][j-1];
      if(df)printf("[%d] ",dbl[i][j]);
    }
  }

  for(int i=0;i<q;i++){
    int a, b; cin >> a >> b; a--; b--; if(a>b)swap(a,b);
    int day=0;
    for(int i=lmax-1;i>=0;i--){
      if(dbl[a][i]>=b)continue;
      day+=1<<i;
      a=dbl[a][i];
    }
    while(a<b){
      a=dbl[a][0];
      day++;
    }
    printf("%d\n",day);
  }
  
  if(df)printf("%d",lg(100000));
}

/// confirm df==0 ///


Measured memory_bytes: 8192
#include <iostream>
#include <vector>
using namespace std;
int p,q;
vector<int> a;
vector<int> memo;

void solve() {
  int pos=0;
  bool end = false;
  memo.clear();
  a.clear();
  memo.push_back(p);
  for(int i=0;;i++) {
    p*=10;
    a.push_back(p/q); //shou
    p=p-(p/q)*q; //amari
    memo.push_back(p);

    if(p==0) { //warikiri
      for(int j=0;j<(int)a.size();j++) {
        cout << a[j];
      }
      cout << endl;
      break;
    }

    for(int j=0;j<(int)memo.size()-1;j++) {
      if(p == memo[j]) {
        end = true;
        pos = j;
        break;
      }
    }

    if(end) {
      for(int j=0;j<(int)a.size();j++) {
        cout << a[j];
      }
      cout << endl;
      for(int j=0;j<pos;j++) {
        cout << " ";
      }
      for(int j=pos;j<(int)a.size();j++) {
        cout << "^";
      }
      cout << endl;
      break;
    }

  }
}

int main() {
  while(cin >> p >> q) {
    solve();
  }
}

Measured memory_bytes: 0
n = input()


tmp0 = []
tmp1 = []
for i in range(len(n)):
    if (i % 2 == 0):
        tmp0.append("0")
        tmp1.append("1")
    else:
        tmp0.append("1")
        tmp1.append("0")


ans0 = 0
ans1 = 0


for i in range(len(n)):
    if(tmp0[i] != n[i]):
        ans0 += 1
    else:
        ans1 += 1


print(min(ans0,ans1))

Measured memory_bytes: 4848
#include <iostream>
#include <map>

using namespace std;



int solve(){

    int N, M;
    
    map<string, long> mp;
    
    
    cin >> N;
    
    for (unsigned long i = 0 ; i < N; i++){
        string str;
        cin >> str;
        mp[str]++;
    }
    
    
    cin >> M;
    
    for (unsigned long i = 0 ; i < M; i++){
        string str;
        cin >> str;
        
        auto itr = mp.find(str);
        if( itr != mp.end() ) {
            mp[str]--;
            if (mp[str] < 0) {
                cout << "NO" << endl;
                return 0;
            }
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
}



int main() {
    // insert code here...
    //cout << "Hello, World!\n";
    
    solve();
    
    
    //return 0;
}


Measured memory_bytes: 24960
import collections

n = int(input())

a = list(map(int,input().split()))

q = int(input())

num_dict = dict(collections.Counter(a))

temp = [key * value for key, value in num_dict.items()]

ans = sum(temp)

for _ in range(q):
    b, c = map(int,input().split())

    if num_dict.get(b):
        num_dict[c] = num_dict[b] + num_dict.get(c, default=0)

        ans = ans - num_dict[b] * b + num_dict[b] * c

        del(num_dict[b])

    print(ans)

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

int main(){
  int K;
  cin >> K;
  
  
vector<int> vec={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};
 
  cout << vec.at(K-1) << endl;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		int count = 3000; // ?????§???????????°(??????)
		int t = 0;//?????????????????°
		int temp = 0;
		int flag = 0;
		String str;
		String[] convert = new String[2];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> compare = new ArrayList<Integer>();
		/**
		 * ???????????\???
		 */
		while (t != count) { // ?????§3000???
			str = br.readLine();
			if(str.equals("0 0")){ // "0 0"??§??????
				break;
			}
			convert = str.split(" ", 0);
			for(int j = 0; j < 2; ++j){
				temp = Integer.parseInt(convert[j]);
				if(temp < 0 || temp >10000){
					flag = 1;
					break;
				}
				compare.add(temp);
			}
			++t;
			}
		int length = compare.size();
		/**
		 * ??¨?????????
		 */
		if(flag == 0){
		for(int i = 0; i < length; i+=2){
			if(compare.get(i) > compare.get(i+1)){
				System.out.println(compare.get(i+1)+" "+compare.get(i));
			}
			else if(compare.get(i) < compare.get(i+1)){
				System.out.println(compare.get(i)+" "+compare.get(i+1));
			}
			else{
				System.out.println(compare.get(i)+" "+compare.get(i+1));
			}
		}
		}
	}

}

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

int main()
{
  string S;
  cin >> S;
  int sum = 0;
  for(int i = 0;i < 3;i++){
    if(S[i] == 'a') sum += 1;
    if(S[i] == 'b') sum += 10;
    if(S[i] == 'c') sum += 100;
  }
  if(sum == 111) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


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

int main() {
  int N; // <= 1000
  int T; // <= 50
  int A; // -60 <= A <= 50
  cin >> N >> T >> A;

  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }

  int ans = 0;
  double min_diff = abs((double)A - ((double)T - (double)h.at(0) * 0.006));
  for (int i = 1; i < N; i++) {
    double diff = abs((double)A - ((double)T - (double)h.at(i) * 0.006));
    if (diff < min_diff) {
      min_diff = diff;
      ans = i;
    }
  }

  cout << (ans + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = max((a),(b))
#define chmin(a, b) a = min((a),(b))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000
 
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
 

int main() {
    int n,m;
    cin>>n>>m;
    priority_queue<int> que;
    rep(i,n){
        int a;
        cin>>a;
        que.push(a);
    }
    rep(i,m){
        int a=que.top();
        que.pop();
        que.push(a/2);
        //cout<<a<<endl;
    }
    ll sum=0;
    rep(i,n){
        sum+=que.top();
        que.pop();
    }
    cout<<sum<<endl;
}

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

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 ll INF = 1LL << 60;

//---main---------------------------------------------
int main(){
    //main
    ll A,B,V,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if(V > W ){
        //if( abs(A-B)%(V-W)==0 && abs(A-B)/(V-W)<=T){
        if((V-W)*T>=abs(A-B)){
                cout << "YES" << endl;
                return 0;
        }
    }
    
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = n / (a+b) * a;
    ans += n % (a+b) > a ? a : n % (a+b);

    cout << ans << endl;

    return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[] a = new int[n];
        int m = in.ni();
        for (int i = 0; i < m; i++) {
            int from = in.ni()-1;
            int to = in.ni()-1;
            a[from]++;
            a[to]++;
        }
        for (int i = 0; i < n; i++) {
            out.println(a[i]);
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21844
import sys
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
a = na()
bcs = []
for i in range(m):
    bcs.append(na())
for i in range(n):
    bcs.append((1, a[i]))
bcs.sort(key=itemgetter(1))

ans = 0
rem = n
for i in range(m+n-1, -1, -1):
    use = min(rem, bcs[i][0])
    ans += use*bcs[i][1]
    rem -= use
print(ans)



Measured memory_bytes: 83864
INF = float('inf')
M = 10 ** 9 + 7


def tc():
    h, w = map(int, input().split())
    grid = [input() for _ in range(h)]

    dp = [[0] * w for _ in range(h)]
    dp[0][0] = 1
    for i in range(h):
        for j in range(w):
            if grid[i][j] == '#':
                continue
            if i > 0:
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % M
            if j > 0:
                dp[i][j] = (dp[i][j] + dp[i][j - 1]) % M

    print(dp[h - 1][w - 1])


tc()


Measured memory_bytes: 74608
from collections import Counter
from itertools import combinations
n = int(input())
S = list(input() for i in range(n))
S = [s[0] for s in S if s[0] in 'MARCH']
c = Counter(S)
ans = 0
for xyz in list(combinations(c.keys(), 3)):
    x, y, z = xyz
    ans += c[x] * c[y] * c[z]
print(ans)

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s) cout << a-1 << " " << b << "\n";
    else     cout << a << " " << b-1 << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	// writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	// defer writer.Flush()
	n := scanInt()
	v := scanFloat64s(n)
	sort.Float64s(v)
	ans := v[0]
	for i := 1; i < n; i++ {
		ans = (ans + v[i]) / 2
	}

	fmt.Println(ans)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 16769023;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

ll a[100000];
int main(){
	int n;
	scanf("%d",&n);
	ll tot=0,ans=0;
	fup(i,0,n-1,1)
	{
		scanf("%lld",a+i);
		tot^=a[i];
	}
	fup(i,0,n-1,1)a[i] &= ~tot;
	sort(a,a+n);
	int idx=59;
	fdn(i, n - 1, 0, 1)
	{
		while(idx>=0 && (a[i] & (1LL << idx)) == 0)
		{
			idx--;
		}
		if (idx < 0)break;
		if((ans&(1LL<<idx))==0)ans ^= a[i];
		fdn(j, i - 1, 0, 1)
		{
			if ((a[j] & (1LL << idx)) == 0)break;
			a[j] ^= a[i];
		}
		sort(a, a + i);
		idx--;
	}
	printf("%lld",ans+(tot^ans));
}

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

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

  cin >> a >> b >> c;
  int ans = max({
      10 * a + b + c,
      a + 10 * b + c,
      a + b + 10 * c,
    });
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
struct Graph{
  int node;
  int edge_num;
  vector<vector<int> > edge;
  vector<bool> visited,visiting;
  vector<int> dp;
  vector<int> top;
  vector<bool> used;
  
  Graph(int N)
  {
    node = N;
    edge.resize(N);
  }

  Graph(int n,int m,vector<int> a,vector<int> b){
    node = n;
    edge_num = m;
    edge.resize(node);
    rep(i,edge_num){
      edge[a[i]].push_back(b[i]);
    }
  }
  
  void add_edge(int from,int to)
  {
    edge[from].push_back(to);
  }

  void top_dfs(int v){
    if(used[v]) return;
    used[v] = true;
    for(auto w:edge[v]){
      top_dfs(w);
    }
    top.push_back(v);
  }

  void t_sort(){
    used.assign(node,false);
    rep(i,node){
      top_dfs(i);
    }
    reverse(top.begin(), top.end());
  }

  void show_top(){
    rep(i,node){
      cout << top[i] << "\n";
    }
  }
  
  bool dfs_find_loop(int v)
  {
    bool f = true;
    visiting[v] = true;
    rep(i,edge[v].size()){
      int w = edge[v][i];
      if(visited[w]) continue;
      if(visiting[w]) return false;
      f = f&&dfs_find_loop(w);
    }
    visited[v] = true;
    return f;
  }  
  bool find_loop()
  {
    bool f = true;
    visited.assign(node,0);
    visiting.assign(node,0);
    rep(i,node){
      if(!visited[i]) f = f&&dfs_find_loop(i);
    }
    // rep(i,node){
    //   if(visiting[i]){
    // 	cout << i << "\n";
    //   }
    // }
    return f;
  }

  int dfs_longest_pass(int v)
  {
    if(dp[v]>=0) return dp[v];
    int res = 0;
    rep(i,edge[v].size()){
      int w = edge[v][i];
      res = max(res,dfs_longest_pass(w)+1);
    }
    return dp[v] = res;
  }
  
  int longest_pass()
  {
    int res = 0;
    dp.assign(node,-1);
    rep(i,node){
      dfs_longest_pass(i);
    }
    rep(i,node){
      res = max(res,dp[i]);
      //      cout << dp[i] << " ";
    }
    //    cout  << "\n";
    
    return res;
  }
  
  
};

int main()
{
  int n;cin >> n;
  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n) rep(j,n-1) cin >> a[i][j];
  map<pair<int,int>,int> mp;
  int cnt=0;
  rep1(i,n){
    rep1(j,n){
      if(i>=j) continue;
      mp[{i,j}]=cnt++;
    }
  }
  vector<int> b,c;
  rep(i,n) rep(j,n-2){
    if(i+1<a[i][j]){
      if(i+1<a[i][j+1]){
	b.push_back(mp[{i+1,a[i][j]}]);
	c.push_back(mp[{i+1,a[i][j+1]}]);	
      }
      else{
	b.push_back(mp[{i+1,a[i][j]}]);
	c.push_back(mp[{a[i][j+1],i+1}]);	
      }      
    }
    else{
      if(i+1<a[i][j+1]){
	b.push_back(mp[{a[i][j],i+1}]);
	c.push_back(mp[{i+1,a[i][j+1]}]);	
      }
      else{
	b.push_back(mp[{a[i][j],i+1}]);
	c.push_back(mp[{a[i][j+1],i+1}]);	
      }      
    }    
  }
  
  Graph gp(n*(n-1)/2,b.size(),b,c);
  if(gp.find_loop()){
    cout << gp.longest_pass()+1 << "\n";
  }
  else{
    cout << -1 << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 78300
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    sscanf($line, '%d %d %d', $m, $f, $r);
    $sum = $m + $f;

    if ($m < 0 && $f < 0 && $r < 0) {
        break;
    } elseif ($sum < 30 || $m < 0 || $f < 0) {
        echo "F\n";
    } elseif ($sum < 50) {
        echo $r >= 50 ? "C\n" : "D\n";
    } elseif ($sum < 65) {
        echo "C\n";
    } elseif ($sum < 80) {
        echo "B\n";
    } else {
        echo "A\n";
    }
}

Measured memory_bytes: 6568
fun main(args: Array<String>) {
    val D = readInputLine().toInt()
    
    println(
        when (D) {
            25 -> "Christmas"
            24 -> "Christmas Eve"
            23 -> "Christmas Eve Eve"
            22 -> "Christmas Eve Eve Eve"
            else -> ""
        }
    )
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 29860
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    while( cin >> s ) {
        for( auto it=s.cbegin(); it<s.cend(); ++it ) {
            if ( *it != '@' ) {
                cout << *it;
            } else {
                int const times = *(++it) - '0';
                char const t = *(++it);
                for( int i=0; i<times; ++i )
                    cout << t;
            }
        }
        cout << endl;
    }
}

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

const int maxn = 105;
char s[maxn];

bool check(int l,int r){
	for(int i = l,j = r; i <= j; i++,j--){
		if(s[i] != s[j]) return 0;
	}
	return 1;
}

int main(){
	cin >> s + 1;
	int n = strlen(s + 1);
	if(check(1,n) && check(1,(n - 1) / 2) && check((n + 3) / 2, n)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
n=int(input())
l=list(input().split())
r=list(input().split())
m=0
for i in range(1,n+1,1):
    a=0
    b=0
    for j in range(i):
        A=int(l[j])
        a+=A
    for j in range(i-1,n,1):
        B=int(r[j])
        b+=B
    if m<a+b:
        m=a+b
print(m)


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

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

Measured memory_bytes: 3848
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int a,b;
    string s;
    cin >> a >> b >> s;

    for (int i=0; i<a+b+1; ++i)
    {
        if (i==a)
        {
            if(s[i] != '-')
            {
                cout << "No" << endl;
                return 0;
            }            
        }
        else
        {
            if(s[i] == '-')
            {
                cout << "No" << endl;
                return 0;
            } 
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    int amax = *max_element(a.begin(), a.end());
    int bmin = INT_MAX;
    int swing = -1;
    rep(i, n) if (a[i] == amax) {
        if (chmin(bmin, b[i])) swing = i;
    }
    a.erase(a.begin() + swing);
    b.erase(b.begin() + swing);
    sort(b.rbegin(), b.rend());

    int ans = 0;
    rep(i, n-1) {
        if (b[i] <= amax) break;
        if (b[i] < bmin && h - bmin <= 0) {
            ans++;
            cout << ans << '\n';
            return 0;
        }
        h -= b[i];
        ans++;
        if (h <= 0) {
            cout << ans << '\n';
            return 0;
        }
    }
    h -= bmin;
    ans++;
    if (h <= 0) {
        cout << ans << '\n';
        return 0;
    }
    ans += (h + amax - 1) / amax;
    cout << ans << '\n';
}


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

using namespace std;

typedef long long ll;

const int MAXN = 100, MAXV = 1000;

ll N, W, w[MAXN], v[MAXN];
vector<ll> dp;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];
    dp.assign(N * MAXV + 1, LLONG_MAX);
    dp[0] = 0;
    for (int i = 0; i < N; i++)
        for (int k = N * MAXV; k >= v[i]; k--)
            if (dp[k - v[i]] < LLONG_MAX)
                dp[k] = min(dp[k], dp[k - v[i]] + w[i]);
    for (int k = (int) dp.size() - 1; k >= 0; k--) {
        if (dp[k] <= W) {
            cout << k << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
import math
from scipy.misc import comb

N, M = map(int, input().split())

def factorize(M):
    P = []
    F = []
    for m in range(2, int(math.sqrt(M))+1):
        n = 0
        while M % m == 0:
            M/= m
            n +=1
        if n != 0:
            P.append(m)
            F.append(n)
    if M != 1:
        P.append(M)
        F.append(1)
    return P,F

P, F = factorize(M)

X = 1
for f in F:
    X *= int(comb(N+f-1, f, exact=True))
    X %= int(pow(10,9)+7)

print(X)
    
     


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

int main(){

    std::ios::sync_with_stdio(0);
    std::cin.tie(0);

    int n, counter = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; ++i){
        while(s[i] == s[i + 1] && i < n) ++i;
        counter++;
    }
    cout << counter << '\n';
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;


ll getv(string& S,int& i){
    ll ret = 0;
    while(S[i]>='0'&&S[i]<='9'){
        ret = ret * 10 + (S[i]-'0');
        i++;
    }
    return ret;
}
ll rule1(string S){
    ll ret = 0;
    vector<ll> type;
    vector<ll> vals;
    int i = 0;
    while(i < S.length()){
        ll val = getv(S,i);
        vals.push_back(val);
        if(i == S.length()) break;
        if(S[i] == '+') type.push_back(0);
        else type.push_back(1);
        
        i++;
    }
    
//    for(auto v:type) cout << v << " "; cout << endl;
//    for(auto v:vals) cout << v << " "; cout << endl;
    
    while(true){
        bool update = false;
        for(int i = 0; i < type.size();i++){
            if(type[i] == 1){
                update = true;
                vals[i] *= vals[i+1];
                type.erase(type.begin()+i);
                vals.erase(vals.begin()+i+1);
                break;
            }
        }
        if(update) continue;
        break;
    }
    
    ret = accumulate(vals.begin(), vals.end(), 0LL);
    return ret;
}
ll rule2(string S){
    ll ret = 0;
    vector<ll> type;
    vector<ll> vals;
    int i = 0;
    while(i < S.length()){
        ll val = getv(S,i);
        vals.push_back(val);
        if(i == S.length()) break;
        if(S[i] == '+') type.push_back(0);
        else type.push_back(1);
        
        i++;
    }
    
    ret = vals.front();
    for(int i = 0; i < type.size();i++){
        if(type[i]==1){
            ret *= vals[i+1];
        }else{
            ret += vals[i+1];
        }
    }
    
    return ret;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string S; cin >> S;
    ll A; cin >> A;
    
    ll r1 = rule1(S);
    ll r2 = rule2(S);
    
    bool f1 = r1 == A, f2 = r2 == A;
    
    if(f1&&!f2) cout << "M" << endl;
    else if(!f1&&f2) cout << "L" << endl;
    else if(f1&&f2) cout << "U" << endl;
    else cout << "I" << endl;
    return 0;
}



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

int main() {
    vector< vector<int> > S(3000 , vector <int> (2) );
    for(int i=0;i<3000;i++){
        cin>>S.at(i).at(0)>>S.at(i).at(1);
        if(S.at(i).at(0)==0&&S.at(i).at(1)==0) break;
        else cout<<min(S.at(i).at(0),S.at(i).at(1))<<" "<<max(S.at(i).at(0),S.at(i).at(1))<<endl;
    }
}



Measured memory_bytes: 3280
def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i < a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
main()

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vpii prime;
    for (int i=2; i*i<=m; ++i) {
        if (m%i==0) prime.emplace_back(i, 0);
        while (m%i==0) {
            prime.back().second++;
            m /= i;
        }
    }
    if (m > 1) prime.emplace_back(m, 1);
    combination cb(1e6+5);
    mint ans = 1;
    rep(i, sz(prime)) {
        ans *= cb(n-1+prime[i].second, prime[i].second);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  long long q, h, s, d, n, best_2L, best_1L;
  cin >> q >> h >> s >> d >> n;
  
  best_2L = min(min(q * 8, h * 4), min(s * 2, d));
  best_1L = min(min(q * 4, h * 2), s);
  
  if(n % 2 == 0){
    cout << best_2L * (n / 2) << endl;
  }
  else{
    cout << best_2L * (n / 2) + best_1L << endl;
  }
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    string s, t;
    cin >> s >> t;
    int l = (int)s.length();
    rep(i, l) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B>C+D)
  {
    cout << "Left" << endl;
  }
  else if(A+B<C+D)
  {
    cout << "Right" << endl;
  }
  else
  {
    cout << "Balanced" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys


def main():
    n = int(input())
    As = list(map(int, input().split()))
    for A in As:
        if A % 2 != 0:
            continue
        if A % 3 == 0 or A % 5 == 0:
            continue
        print("DENIED")
        sys.exit(0)
    print("APPROVED")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B;
    if(abs(A-B)%2 == 0){
        cout << (A+B)/2 << endstr;
    }
    else{
        cout << "IMPOSSIBLE" << endstr;
    }
    return 0;
}


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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> B(N,1);
	vector<bool> R(N,false);
	R[0] = true;

	for(int i=0; i<M; i++){
		int x,y; cin >> x >> y;
		if(R[x-1]){
			B[x-1]--; B[y-1]++;
			R[y-1]=true;
			if(B[x-1] == 0)R[x-1]=false;
		} else {
			B[x-1]--; B[y-1]++;
		}
	}
	int ans = 0;
	for(int i=0; i<N; i++) if(R[i])ans++;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
int main() {
	ll n,len=0,start=0,tmp=1;
  string s,t;
	cin >> n >>s;
  while(len<n/2 && start<n-1){
		t=s.substr(start,tmp);
		for(ll i=start+tmp;i<n;i++){
			if(t==s.substr(i,tmp)){
				len=tmp;
				break;
			}
		}
		if(len==tmp) tmp++;
    else start++;
    if(start+tmp>=n) start++;
	}
	cout << len << endl;
}


Measured memory_bytes: 256
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  double x[n];
  string u[n];
  REP(i, n) cin >> x[i] >> u[i];

  double r = 380000, s = 0;

  REP(i, n){
    if(u[i] == "JPY"){
      s += x[i];
    }
    else{
      s += x[i] * r;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
vector<int> G[N];
vector<int>::iterator it;
bool vis[N];
int f[N];
int main() 
{
    int n,m;
    cin>>n>>m;
    for(int i=0,u,v;i<m;i++) 
	{
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    queue<int> qu;
    qu.push(1), vis[1]=1;
    while(!qu.empty()) 
	{
        int u=qu.front();
        qu.pop();
        for(int i=0;i<G[u].size();i++) 
		{
            if(vis[G[u][i]]) 
				continue;
            f[G[u][i]]=u;
            qu.push(G[u][i]),vis[G[u][i]]=1;
        }
    }
    bool flag=0;
    for(int i=1;i<=n;i++) 
        if(!vis[i]) 
			flag=true;
    if(flag) 
	{
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++) 
        cout<<f[i]<<endl;
    return 0;
}

Measured memory_bytes: 10452
def check(X,Y):
    Hs = []
    for x,y,h in xyh:
        if h > 0:
            H = h + abs(x-X) + abs(y-Y)
            Hs.append(H)
        else:
            H = Hs[0]
            if abs(x-X) + abs(y-Y) < H:
                return False
    
    if len(set(Hs)) == 1:
        print(X,Y,Hs[0])
        return True
    else:
        return False

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda a:a[2],reverse=True)

for i in range(101):
    for j in range(101):
        if check(i,j):
            exit()

Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	immutable MAX = 10001;

	bool p[MAX];
	p[] = 1;
	p[0..2] = 0;
	foreach (i; 2..sqrt(MAX*1.0).ceil.to!int) {
		if (p[i]) {
			foreach (j; iota(i*2, MAX, i))
				p[j] = 0;
		}
	}

	foreach (line; stdin.byLine) {
		auto n = line.chomp.to!int;
		auto s = iota(1, n+1).array;
		auto rs = s.dup.reverse;
		int cnt;
		foreach (i; 0..s.length) {
			if (p[s[i]] && p[rs[i]]) cnt++;
		}
		cnt.writeln;
	}
}

Measured memory_bytes: 3084
#include<stdio.h>
int main(void)
{
	int t,h,s,m,h3,m3,s3;
	
	while (1) {
		scanf("%d %d %d", &t, &h, &s);
		if ((t == -1) && (h == -1) && (s == -1)) break;

		m = (t * 60 + h)*60 + s;
		m3 = (7200 - m )* 3;
		s3 = m3 % 60;
		h3 = (m3 / 60) / 60;
		m3 = (m3 / 60) % 60;
		m = 7200 - m;
		s = m % 60;
		h = (m / 60) / 60;
		m = (m / 60) % 60;  

		printf("%02d:%02d:%02d\n",h,m,s);
		printf("%02d:%02d:%02d\n", h3, m3, s3);
	}
	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,b;
signed main()
{
	cin>>a>>b;
	if(13<=a){
		cout<<b;
	}elif(6<=a){
		cout<<b/2;
	}else{
		cout<<0;
	}
}

Measured memory_bytes: 768
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n,k;
  cin>>n>>k;
  int a[n];
  int i;
  int count=0;
  for(i=0;i<n;i++){
  	cin>>a[i];
  	if(a[i]>=k){
  		count++;
  		
	  }
  }

  cout<<count<<endl;

  return 0;
}

Measured memory_bytes: 3856
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

D, G = map(int, input().split())
pd = []
for i in range(D):
	pd.append(list(map(int, input().split())))

#print(pd)
N = len(pd)

p_effort = []
for i in range(len(pd)):
	p_effort.append([pd[i][0], pd[i][0]*(i+1)*100+pd[i][1]])
#print(p_effort)

bonus_pattern = []
for i in range(2**N):
	bonus = [0] * N
	for j in range(N):
		if (i>>j & 1):
			bonus[N-j-1] = 1
	bonus_pattern.append(bonus)
#print(bonus_pattern)

ans = []
for bp in bonus_pattern:
	total,effort = 0,0
	for i in range(len(bp)):
		if bp[i] == 1:
			total += p_effort[i][1]
			effort += p_effort[i][0]
	#print(bp, total, effort)
	if total < G:
		for j in range(len(bp)-1,-1,-1):
			if bp[j] == 0:
				for _ in range(pd[j][0]):
					#print('here', j)
					total += (j+1)*100
					effort += 1
					if total >= G:
						break
				break
	ans.append([bp,total,effort])
#print(ans)

min_effort = float('INF')
for answer in ans:
	if answer[1]>=G:
		min_effort=min(min_effort, answer[2])

print(min_effort)

Measured memory_bytes: 41840
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int arr[n];
  int min=pow(10,9);
  int max=1;
  for(int i=0;i<n;++i) {
    cin >> arr[i];
    if (min >= arr[i]) {
      min = arr[i];
    }
    if (max <= arr[i]) {
      max = arr[i];
    }
  }
  cout << max-min << endl;
}

Measured memory_bytes: 256
def main():
    x, k, d = map(int, input().split())
    if x > 0:
        if x - d * k >= 0:
            print(x - d * k)
        else:
            a = abs(x - d * k) % d
            b = abs(x - d * k) // d
            if b % 2 == 0:
                print(a)
            else:
                print(d - a)

    else:
        if x + d * k < 0:
            c = abs(x + d * k)
            print(c)
        else:
            a = abs(x + d * k) % d
            b = abs(x + d * k) // d
            if b % 2 == 0:
                print(a)
            else:
                print(d - a)


main()


Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
  char str[6];
  scanf("%s",str);
 if(str[0]==str[1]||str[0]==str[2]||str[1]==str[2])
printf("No");
else
printf("Yes");
    return 0;
}

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

int main(){
  int N;
  long long int power = 1;
  scanf("%d",&N);
  for(int i = 1; i <= N; i++){
    power = (power*i) % (1000000000+7);
  }
    printf("%d",power);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
const int MAX_N = 100005;
int H[MAX_N];
bool check[MAX_N];

void init()
{
	for (int i = 0; i < MAX_N; ++i)
	{
		check[i] = true;
	}
	check[0] = false;
}

int main()
{
	int N;
	cin >> N;
	init();
	for (int i = 0; i < N; ++i)
	{
		cin >> H[i];
		if (i != 0 && H[i-1] < H[i])
		{
			check[i] = false;
		}
	}
	check[N] = false;

	/*
	for (int i = 0; i <= N; ++i)
	{
		cout << check[i] << " ";
	}
	cout << endl;
	*/

	int ans = 0;
	int cnt = 0;

	for (int i = 0; i <= N; ++i)
	{
		if (check[i])
		{
			cnt++;
		}
		else
		{
			ans = max(ans,cnt);
			cnt = 0;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 768
from heapq import heappush, heappop
from collections import defaultdict
n,m = map(int,input().split())
a = list(map(int,input().split()))
# edg = [[] for i in range(n)]
rank = [1] * n
par = [i for i in range(n)]
def root(x):
  if x == par[x]:
    return x
  par[x] = root(par[x])
  return par[x]
def union(a,b):
  a = root(a)
  b = root(b)
  if rank[a] < rank[b]:a,b = b,a
  if a == b: return False
  par[b] = a
  rank[a] += rank[b]
  return True
for _ in range(m):
  x,y = map(int, input().split())
  union(x,y)
d = defaultdict(list)
q = []
for i in range(n):
  ai = a[i]
  heappush(q,(ai,i))
  ri = root(i)
  heappush(d[ri],(ai,i))
if len(d.keys()) == 1:
  print(0)
else:
  ans = 0
  tmp = 0
  c = [0] * n

  for i in d.keys():
    tmp += 1
    t,p = heappop(d[i])
    c[p] = 1
    ans += t
  if 2*tmp-2 > n:
    print("Impossible")
  else:
    for _ in range(tmp-2):
      p,i = heappop(q)
      while c[i]:
        p,i = heappop(q)
      ans += p
    print(ans)


Measured memory_bytes: 125848