akhauriyash/Code-Regression huggingface dataset:
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    if n == 1 {
        return "Hello World".to_string();
    }

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    return (a + b).to_string();
}


Measured memory_bytes: 2104
use std::io;
use std::collections::HashMap;

fn main() {
    let mut map = HashMap::new();
    map.insert("SUN".to_string(), 0);
    map.insert("MON".to_string(), 1);
    map.insert("TUE".to_string(), 2);
    map.insert("WED".to_string(), 3);
    map.insert("THU".to_string(), 4);
    map.insert("FRI".to_string(), 5);
    map.insert("SAT".to_string(), 6);

    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    println!("{}", 7-map.get(s.trim()).unwrap());
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
	int n,m,k,i;
	
	scanf("%d",&k);
	scanf("%d %d",&n,&m);
	
	for(i = n;i <= m;i++)
		if(i % k == 0)
		{
			printf("OK\n");
			break;
		}
			
	if(i > m)
		printf("NG\n");
		
	return 0;
}

Measured memory_bytes: 1644
#include <iostream>
using namespace std;
using ll = long long int;

int main()
{
    int n;  cin >> n;
    ll sum = 0;

    for(int i=1; i<=n; i++){
        if(i%3 && i%5) sum += i;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3120
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        exit()
    ans = ["#"*w]
    ans += ["#"+("."*(w-2))+"#" for _ in range(h-2)]
    ans += ["#" * w]
    print(*ans, sep="\n")
    print()


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


int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);

  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  for(int i=0; i<n; i++){
    cin >> b.at(i);
  }
  for(int i=0; i<n-1; i++){
    cin >> c.at(i);
  }

  int ans = 0;
  for(int i=0; i<n; i++){
    ans += b.at(a.at(i)-1);
    if(i < n-1 && a.at(i)+1 == a.at(i+1)){
      ans += c.at(a.at(i)-1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ans = 0
for i in range(2 ** (n-1)):
    l = [0] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            l[j] = ' '
        else:
            l[j] = ''
    num = ''
    for k in range(n-1):
        num += s[k] + l[k]
    num += s[-1]
    ans += sum(list(map(int, num.split())))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int f(int X){
  int sum=0;
  while(X>0){
    sum+=X%10;
    X/=10;
  }
  return sum;
}
int main(){
  int x;
  cin>>x;
  if(x%f(x)==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
    

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long y=0,a[100000],b[100000],c[100000],flg1[100000];
int main(void)
{
	long long n,i,j,x,r;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%lld",&a[i]);
	}
	for(i=0;i<n;i++){
	    scanf("%lld",&b[i]);
	}
	for(i=0;i<n;i++){
	    scanf("%lld",&c[i]);
	}
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
/*	for(i=0;i<n;i++){
	    printf("%d\n",a[i]);
	}
	for(i=0;i<n;i++){
	    printf("%d\n",b[i]);
	}
	for(i=0;i<n;i++){
	    printf("%d\n",c[i]);
	}*/
	for(i=0;i<n;i++) flg1[i]=0;
	x=0;r=0;
	for(i=0;i<n;i++){
		if(a[i]<b[r]){
		    flg1[r]++;
		}
		else{
		    r++;
			i--;
		}
		if(n<=r) break;
	}
//	for(i=0;i<n;i++) printf("%d\n",flg1[i]);
	r=0;
	for(i=0;i<n;i++){
	    x+=flg1[i];
		flg1[i]=0;
	//	printf("%d %d %d\n",x,flg1[i],i);
		if(b[i]<c[r]){
			y+=(n-r)*x;
	//		printf("%d+=(%d-%d)*%d\n",y,n,r,x); 
		}
		else{
		    r++;
			i--;
		}
		if(n<=r) break;
	}
	printf("%lld\n",y);
	return 0;
}

Measured memory_bytes: 3328
//package atcoder// TODO: ←消す

fun main(args: Array<String>) = ABC161A.main()

object ABC161A {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (a,b,c)= readInts()
        println("$c $a $b")
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int ans = 0;
  for(int i = 0;i < 2;i++){
    if(A < B){
      ans += B;
      B--;
    }
    else{
      ans += A;
      A--;
    }
  }


  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<pair<int,int>>> G(N);
  pair<int,int> P;
  
  for(int i=0; i<N-1; i++){
      int a, b, c;
      cin >> a >> b >> c;
      a--;
      b--;
      P = make_pair(b,c);
      G.at(a).push_back(P);
      P = make_pair(a,c);
      G.at(b).push_back(P);
  }
  
  
  vector<int> color(N,-1);
  color.at(0) = 0;
  queue<int> Q;
  Q.push(0);
  while(Q.size()){
    int x = Q.front();
    int y = color.at(x);
    Q.pop();
    for(int i=0; i<G.at(x).size(); i++){
      P = G.at(x).at(i);
      int a = P.first;
      int b = P.second;
      if(color.at(a) == -1){
        Q.push(a);
        if(b %2 != 0){
          color.at(a) = abs(y - 1);
        }
        else{
          color.at(a) = y;
        }
      }
    }
  }

  
  for(int i=0; i<N; i++){
    cout << color.at(i) << endl;
  }
      
}

Measured memory_bytes: 6784
def examA():
    A, B = LI()
    ans = A*B
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    for a in A:
        if a==0:
            print(0)
            return
    ans = 1
    for a in A:
        ans *= a
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<60
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int h, w, cnt = 0;
	in(n);
	cin >> h >> w;

	rep(i, n){
		int a, b;
		cin >> a >> b;
		if(a >= h && b >= w)
			++cnt;
	}

	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

minute = 60*H + M
thetaA = 2*math.pi * minute/(60*12)
thetaB = 2*math.pi * M/60
d = math.sqrt(A**2+B**2 - 2*A*B*math.cos(abs(thetaA-thetaB)))
print(d)

Measured memory_bytes: 9436
while(True):
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
        h = [c-d for c,d in zip(a,b)].count(0)
        v = sum([a.count(d) for d in b]) - h
        print(h,v)
    except:
        break


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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    int a = (i / 10000) % 10;
    int b = (i / 1000) % 10;
    int c = (i / 10) % 10;
    int d = (i / 1) % 10;
    if (a == d && b == c) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,i;
	char c[105];
	cin>>n;
	rep(i,n){
		cin>>c[i];
		if(c[i]=='Y'){
			cout<<"Four"<<endl;
			return 0;
		}
	}
	cout<<"Three"<<endl;
} 
	

Measured memory_bytes: 256
x, a, b = gets.chomp.split(" ").map(&:to_i)
limit_day = 10 ** 9 + 1
buy_day = limit_day - a
eat_day = buy_day + b
onaka = limit_day + x
kowasu = onaka + 1
if eat_day <= limit_day
    puts "delicious"
elsif limit_day + x >= eat_day
    puts "safe"
else
    puts "dangerous"
end

Measured memory_bytes: 14252
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

void Main(){
    ll N, D, x, y;
    sll(N);
    sll(D);
    D = D * D;
    ll ans = 0;
    rep(i, N){
        cin >> x >> y;
        ans += (x*x + y*y) <= D;
    }

    cout << ans <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3252
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    Q *= 4; H *= 2;
    S = min({Q, H, S});
    D = min(D, 2 * S);
    ll ans = (N / 2) * D + (N % 2) * S;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
#define MAX 10000
#define NIL -1
 
typedef struct{
  int p,l,r;
}Node;
 
Node T[MAX];
int D[MAX],H[MAX],n;
 
void setDepth(int,int);
int setHeight(int);
int getSibling(int);
void print(int);
 
int main(){
  int i,v,l,r,root = 0;
 
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].p = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }
 
  for(i=0;i<n;i++){
    if(T[i].p == NIL)root = i;
  }
  
  setDepth(root,0);
  setHeight(root);
 
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}
 
void setDepth(int u, int d){
 
  if(u == NIL)return;
  D[u] = d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}
 
int setHeight(int u){
  int h1,h2;
 
  h1 = h2 = 0;
  if(T[u].l != NIL)h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL)h2 = setHeight(T[u].r) + 1;
  return H[u] = (h1 > h2 ? h1 : h2); 
}
 
int getSibling(int u){
 
  if(T[u].p == NIL)return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL)
    return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL)
    return T[T[u].p].r;
  return NIL;
}
 
void print(int u){
  int deg;
 
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].p,getSibling(u));
 
  deg = 0;
 
  if(T[u].l != NIL)deg++;
  if(T[u].r != NIL)deg++;
 
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
 
  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}

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

char maze[51][51];
int dp[51][51];

int main()
{
	char temp;
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			cin >> temp;
			dp[i][j] = temp - '0';
		}
	}
	for (int i = 1; i < h; ++i)dp[i][0] += dp[i - 1][0];
	for (int i = 1; i < w; ++i)dp[0][i] += dp[0][i - 1];
	for (int i = 1; i < h; ++i){
		for (int j = 1; j < w; ++j){
			dp[i][j] += min(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}


Measured memory_bytes: 3252
import heapq

N,M = (int(i) for i in input().split())
A = list(map(int,input().split()))
A.sort()
D = []
len = 0
BC = [0] * M

for i in range(M):
    BC[i] = list(map(int,input().split()))
BC.sort(key = lambda x:x[1],reverse = True)
for i in range(M):
    D.extend([BC[i][1]] * BC[i][0])
    len += BC[i][0]
    if len > N:
        break
cnt = min(N,len)
for i in range(cnt):
    if A[0] < D[i]:
        heapq.heapreplace(A,D[i])
    else:
        break
print(sum(A))


Measured memory_bytes: 83820
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> up(n);
	vector <int> mid(n);
	vector <int> down(n);
	for (int i = 0; i < n; ++i) {
		cin >> up[i];
	}
	sort(up.begin(), up.end());
	for (int i = 0; i < n; ++i) {
		cin >> mid[i];
	}
	sort(mid.begin(), mid.end());
	for (int i = 0; i < n; ++i) {
		cin >> down[i];
	}
	sort(down.begin(), down.end());
	vector <long long int> midans(n, 0);
	long long int pu, pm;
	pu = pm = 0;
	for (int pm = 0; pm < n; ++pm) {
		while (pu < n && up[pu] < mid[pm]) pu++;
		midans[pm] = pu;
	}
	long long int ans = 0;
	long long int pref = 0;
	for (int pd = 0; pd < n; ++pd) {
		while (pm < n && mid[pm] < down[pd]) {
			pref += midans[pm];
			pm++;
		}
		ans += pref;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

void solve() {
	int w, h, n;
	cin >> w >> h >> n;
	int l, r, d, u;
	l = 0, r = w, d = 0, u = h;
	for (int i = 0; i < n; ++i) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1)
			l = max(l, x);
		else if (a == 2)
			r = min(r, x);
		else if (a == 3)
			d = max(d, y);
		else
			u = min(u, y);
	}
	int width = max(0, r - l);
	int height = max(0, u - d);
	cout << width * height << endl;
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 8;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

int main()
{
    int N;
    ll X, D;
    cin >> N >> X >> D;
    using P = pair<ll, int>;
    using PP = pair<P, ll>;
    vector<PP> p(N, {{0, 1}, 0});
    vector<vector<int>> e(N);
    cin >> p[0].first.first;
    p[0].second = X;
    for (int i = 1; i < N; i++) {
        cin >> p[i].first.first;
        int pr;
        cin >> pr;
        e[pr - 1].push_back(i);
        p[i].second = D;
    }
    auto rec = fix([&](auto&& self, const int s) -> P {
        for (const int to : e[s]) {
            const auto sub = self(self, to);
            p[s].first.first += sub.first;
            p[s].first.second += sub.second;
        }
        return p[s].first;
    });
    rec(0);
    auto comp = [](const PP& p1, const PP& p2) { return p1.first.first * p2.first.second < p2.first.first * p1.first.second; };
    sort(p.begin(), p.end(), comp);
    vector<ll> dp(N * N * N + 1, INF<ll>);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        vector<ll> tmp(N * N * N + 1, INF<ll>);
        for (int j = 0; j <= N * N * N; j++) {
            if (dp[j] == INF<ll>) { continue; }
            for (int k = 0; k <= min((ll)N, p[i].second); k++) { tmp[j + k * p[i].first.second] = min(tmp[j + k * p[i].first.second], dp[j] + k * p[i].first.first); }
        }
        dp = tmp;
    }
    for (int i = 0; i < N; i++) { p[i].second -= min(p[i].second, (ll)N); }
    ll ans = 0;
    for (ll i = 0; i <= N * N * N; i++) {
        if (dp[i] > X) { continue; }
        ll rest = X - dp[i];
        ll sum = i;
        for (int j = 0; j < N; j++) {
            const ll used = min(p[j].second, rest / p[j].first.first);
            rest -= used * p[j].first.first;
            sum += used * p[j].first.second;
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
};


Measured memory_bytes: 2220
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
s = []
t = []
for i in range(n):
    S,T = LS()
    s.append(S)
    t.append(int(T))
x = input()

idx = s.index(x)
if idx==n-1:
    print(0)
    exit()
print(sum(t[idx+1:]))


Measured memory_bytes: 5716
import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
	    Scanner s=new Scanner(System.in);
	long a=s.nextLong();
	long b=s.nextLong();
	
	long p=a*b;
	long h=gcd(a,b);
	
	System.out.println(p/h);
	
	}
	static long gcd(long a, long b) 
    { 
      if (b == 0) 
        return a; 
      return gcd(b, a % b);  
    } 
}

Measured memory_bytes: 21844
#include<iostream>

int main() {

	int N;
	std::cin >> N;
	int res = 0;
	int sum = 0;


	for (int i = 0; i < 15; i++) {
		for (int j = 0; j < 26; j++) {
			sum = 7 * i + 4 * j;
			if (sum == N) {
				res++;
				break;
			}
					}
		if (sum == N)break;
	}

	if (res ==1 )std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

}

Measured memory_bytes: 760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		sc.close();

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			char cA = a.charAt(i);
			char cB = b.charAt(i);
			char cC = c.charAt(i);
			if (cA == cB && cB == cC) {
				// 全て一致
			} else if (cA == cB || cB == cC || cC == cA) {
				// ２つ一致
				cnt++;
			} else {
				// ばらばら
				cnt += 2;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21972
# 文字列の問題で、同じような文字列をまとめたいので、
# どう考えても Trie を使いたい気持ちになる

# あとは適当にやったらなんとかなった
# 1100 点の割には簡単っぽい

class TrieNode:
    def __init__(self):
        self.child = {}
        self.count = 0  # 自身を含めた部分木の大きさ

class Trie:
    def __init__(self):
        self.root = TrieNode()

    def add(self, s):
        node = self.root
        node.count += 1
        for c in s:
            c = ord(c) - 97
            if c not in node.child:
                node.child[c] = TrieNode()
            node = node.child[c]
            node.count += 1
        node.child[26] = TrieNode()
        node.child[26].count += 1

    def query(self, s):
        res = [[0]*27 for _ in range(26)]
        node = self.root
        for c in s:
            c = ord(c) - 97
            res_c = res[c]
            for i, child in node.child.items():
                res_c[i] += child.count
            node = node.child[c]
        return res

from itertools import groupby
import sys
input = sys.stdin.readline
N = int(input())
S = [input()[:-1] for _ in range(N)]
trie = Trie()
for s in S:
    trie.add(s)

Q = int(input())
KP = [input().split() for _ in range(Q)]
Ans = [-1] * Q
Idx_Q = sorted(range(Q), key=lambda x: KP[x][0])
for v, g in groupby(Idx_Q, key=lambda x: KP[x][0]):
    K = int(v) - 1
    L_K = trie.query(S[K])
    for idx in g:
        _, P = KP[idx]
        P = [ord(c) - 97 for c in P]
        ans = 1
        for i, pi in enumerate(P):
            for pj in P[:i]:
                ans += L_K[pi][pj]
            ans += L_K[pi][26]
        Ans[idx] = ans
print("\n".join(map(str, Ans)))


Measured memory_bytes: 214020
m=1e9+7,P[2][3333]={1};*p,*q;c,i;f(j){q[j]=*p*!~c+c*p[j];j<i&&f(j+1);q[j]=(1L*q[j]+q[j+1]+m)%m;}main(){for(gets(&c);c=1-getchar()%3;f(0))p=P[i%2],q=P[++i&1];printf("%d",*q);}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int n,i,prime=0,count=0,j;

  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    for(j=2;j<=sqrt(A[i]);j++){
      if((A[i]%j)==0){
        count++;
      }
    }
    if(count==0){
      prime++;
    }
    count=0;
  }
  printf("%d\n",prime);
  return 0;
}



Measured memory_bytes: 2060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
const int inf = 1e+6;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

char maze[51][51];
int H, W;

int d[51][51];

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

int bfs() {
    rep(i, H) {
        rep(j, W) {
            d[i][j] = inf;
        }
    }
    
    queue<P> que;

    que.push(make_pair(0, 0));
    d[0][0] = 1;

    while(!(que.empty())) {
        P p = que.front(); que.pop();

        if(p.first == H - 1 && p.second == W - 1) break;

        rep(i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if(0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] == '.' && d[nx][ny] == inf) {
                que.push(make_pair(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    return d[H - 1][W - 1];

}

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

    int countpath = 0;

    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            cin >> maze[i][j];
            if(maze[i][j] == '.') countpath ++;
        }
    }

    if(bfs() == inf) {
        cout << -1 << "\n";
        return 0;
    }

    cout << countpath - bfs() << "\n";
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;
    int d;
    cin >> d;

    cout << fixed << setprecision(10) << (double((d + 1)/2)) / (double)d << endl;
    return 0;
}



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

int main() {
  string s, cor = "CODEFESTIVAL2016";
  cin >> s;
  int ans = 0;
  for(int i = 0; i < cor.size(); i++) if(s[i] != cor[i]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
if S == "SUN":
  print(7)
if S == "MON":
  print(6)
if S == "TUE":
  print(5)
if S == "WED":
  print(4)
if S == "THU":
  print(3)
if S == "FRI":
  print(2)
if S == "SAT":
  print(1)

Measured memory_bytes: 9036
#include <iostream>
using namespace std;
const int N=100;

int main(){
    //0 0??????????????\??????
    int M[N][N];
    int n,u,k,v;
    
    cin>>n;
    
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=0;
    
    for(int i=0;i<n;i++){
        cin>>u>>k;
        //??¬??¢???0?????????
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            //??¬??¢???0?????????
            v--;
            //??¨u???v?????´????????????
            M[u][v]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j)
                cout<<" ";
            cout<<M[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
  
using namespace std;
  
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
  
typedef vector<int> vi;
typedef pair<int,int> pii;
  
int main(void) {
  int i,j;
  string s;
  char a[6][6]={"abcde","fghij","klmno","pqrst","uvwxy","z.?! "};
  while(cin>>s){
    string ans="";
    if(s.size()%2){
      cout<<"NA"<<endl;
      continue;
    }
    rep(i,s.size()){
      if(s[i]<'1' || s[i]>'6' || s[i+1]<'1' || s[i+1]>'5'){
    ans="NA";
    break;
      }
      ans+=a[s[i]-'0'-1][s[i+1]-'0'-1];
      i++;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3148
N , Q = gets.split.map!{|a| a.to_i}
S = gets.chomp!
l = Array.new(Q).map!{Array.new(2)}
Q.times do |i|
    l[i] = gets.split.map!{|a| a.to_i}
end

count = Array.new(S.size)
count[0] = 0

(S.size - 1).times do |i|
    count[i + 1] = count[i]
    if S[i + 1] == 'C' && S[i] == 'A'
        count[i + 1] += 1
    end
end

Q.times do |i|
    puts count[l[i][1] - 1] - count[l[i][0] - 1]
end


Measured memory_bytes: 16508
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,c[225816],prev[225816];
ll ls[225816],ch[225816],ans[225816],top[225816];
std::vector<int> g[225816];

void solve(int v, int p){
	int u,i,tmp;
	ll x=0ll;
	tmp = prev[c[v]];
	prev[c[v]] = v;
	for(i=(g[v].l_ength()-1); i>=0; --i){
		ls[v] = 0ll;
		u = g[v][i];
		if(u==p){
			continue;
		}
		solve(u,v);
		x = (ch[u]+ls[v]);
		x *= (x+1);
		x /= 2;
		ans[c[v]] -= x;
		ch[v] += ch[u];
	}
	++ch[v];
	if(tmp<n){
		ls[tmp] -= ch[v];
	}else{
		top[c[v]] -= ch[v];
	}
	prev[c[v]] = tmp;
}

int main(void){
	int i,a,b;
	std::cin >> n;
	std::fill(ans,ans+n,(1ll)*n*(n+1)/2);
	std::fill(prev,prev+n,n);
	std::fill(top,top+n,n);
	for(i=0; i<n; ++i){
		std::cin >> c[i];
		--c[i];
	}
	for(i=1; i<n; ++i){
		std::cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	solve(0,n);
	for(i=0; i<n; ++i){
		ans[i] -= (top[i]*(top[i]+1)/2ll);
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 41672
from math import sqrt

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
p_1 = 0
p_2 = 0
p_3 = 0
p_inf = 0
for i, j in zip(x, y):
    p_1 += abs(i - j)
    p_2 += (i - j) ** 2
    p_3 += abs((i - j)) ** 3
    p_inf = max(p_inf, abs(i - j))

print(p_1)
print(sqrt(p_2))
print(p_3 ** (1 / 3))
print(p_inf)


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

using namespace std;

int main()
{
    int a, b, h, m;
    
    cin >> a >> b >> h >> m;
    
    double t = h * 60 + m;
    double theta_h = - 2 * M_PI * t / 720;
    double theta_m = - 2 * M_PI * m / 60;

    // aの座標(0, a)、bの座標(0, b)
    
    double xa = 0 * cos(theta_h) - a * sin(theta_h);
    double ya = 0 * sin(theta_h) + a * cos(theta_h);

    double xb = 0 * cos(theta_m) - b * sin(theta_m);
    double yb = 0 * sin(theta_m) + b * cos(theta_m);

    cout << setprecision(15) << sqrt(pow(xa - xb, 2) + pow(ya - yb, 2)) << endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	int socket = 1;
	int ans = 0;
	while(socket < b){
		socket += a - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{   
    string s;
    cin>>s;
    if(s[s.size()-1]=='s'){
        //[s.size()-1];
        cout<<s<<"es"<<endl;
    }
    else{
        cout<<s<<'s'<<endl;
    }
        
    return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

float s(float a) {
	a *= 1000;
	if (a > 0) {
		a += 0.5;
	}
	else {
		a -= 0.5;
	}
	int b = a;
	a = b;
	a /= 1000;
	return a;
}

int main() {
	float a, b, c, d, e, f;
	while (~scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f)) {
		float x, y;
		if (a == 0) {
			y = c / b;
			x = (f - e * y) / d;
		}
		else if (d == 0) {
			y = f / e;
			x = (c - b * y) / a;
		}else {
			b *= d;
			c *= d;
			e *= a;
			f *= a;
			y = (c - f) / (b - e);
			x = (c / d - b / d * y) / a;
		}
		printf("%.3f %.3f\n", s(x), s(y));
	}
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  int i,c;
  cin >> s >> t;
  i = 0 ;
  c = 0;
  while (s[i]!=0){
    if(s[i]!=t[i]){
      c++;
    }
  i++;
  }
  cout << c <<endl;
}

Measured memory_bytes: 3916
count = int(input())
ans=0
int_list = list(map(int,input().split()))
even_list = [i for i in int_list if i%2 ==0]
if len(even_list) != count:
    print("0")
else:
    while len([i for i in even_list if i%2 ==0]) == count:
        even_list = [i/2 for i in even_list]
        ans+=1
    print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ret -= ret / n;
    return ret;
}

int main() {
    char c;
    cin >> c;

    cout << char(c+1) << endl;
    return 0;
}


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10**8)

def dfs(x, c=-1, p=-1):
    k = 1
    for y, ei in G[x]:
        if y == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k; k+=1
        dfs(y, ans[ei], x)

n = int(input())
G = [[] for _ in range(n)]
ans = [0] * (n-1)
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1; b-=1
  G[a].append((b, i))
  G[b].append((a, i))

dfs(0)
mx = 0
for g in G:
    mx = max(mx, len(g))
print(mx)
for a in ans:
    print(a)

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

using namespace std;

int main(void) {
  int k; // Size of lake
  int n; // Number of houses
  vector<int> a; // Positions of houses along the lake;
  
  // Read input
  cin >> k >> n;
  for (int i = 0; i < n ; i++) {
    int e;
    cin >> e;
    a.push_back(e);
  }

  int minDist = 1e9;
  for (int i = 0; i < n; i++) {
    int dist;
    int start = a[i];
    int end = a[(i - 1 < 0 ? (n - 1) : (i - 1))];
    if (end < start)
      end = end + k;
    dist = end - start;
    if (dist < minDist)
      minDist = dist;
  }
  cout << minDist << endl;
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int a, b;
  cin >> a >> b;

  int ans = 0;

  if (b != 1) {
    b -= a;
    ++ans;
    while (b > 0) {
      ++b;
      b -= a;
      ++ans;
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(int i=a; i<n; i++)
#define ford(i,a,n) for(int i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"  "<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 23

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t=1;
  // cin>>t;
  while(t--)
  {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll fl=0;
    while(a>0 && c>0)
    {
      c-=b;
      if(c<=0) fl=1;
      a-=d;
    }
    if(fl) cout<<"Yes\n";
    else
    {
      if(c>0) cout<<"No\n";
      else cout<<"Yes\n";
    }
  }
  return 0;
}

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

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}

ll power(ll x,ll y,ll p)
{
  ll res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    y=y>>1;
    x=(x*x)%p;
  }
  return res;
}

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y&1)
      res=res*x;
    y=y>>1;
    x=x*x;
  }
  return res;
}


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

#define ll long long
#define matrix vector< vector<int> >

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {

    a += b;
    if(a >= mod)
        a -= mod;
    return a;
}

int mul(int a, int b) {

    return (ll)a * b % mod;
}

int n;

void print(matrix a) {

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)
            cout << a[i][j] << " ";
        cout << endl;
    }
    cout << endl;
}

matrix mat_pow(matrix mat, ll k) {

    if(k == 0) {
        matrix sol(n, vector<int>(n));
        for(int i = 0; i < n; i++)
            sol[i][i] = 1;
        return sol;
    }

    matrix temp(n, vector<int>(n));
    temp = mat_pow(mat, k / 2);
    matrix sol(n, vector<int>(n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            for(int k = 0; k < n; k++)
                sol[i][j] = add(sol[i][j], mul(temp[i][k], temp[k][j]));
    
    if(k & 1) {
        matrix ans(n, vector<int>(n));
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                for(int k = 0; k < n; k++)
                    ans[i][j] = add(ans[i][j], mul(mat[k][j], sol[i][k]));
        return ans;
    }
    return sol;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll k;
    cin >> n >> k;

    matrix mat(n, vector<int>(n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> mat[i][j];
    
    mat = mat_pow(mat, k);
    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            ans = add(ans, mat[i][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4988
A, B = map(int, input().split())
 
def f(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return x + 1
    else:
        return 0
print(f(B) ^ f(A-1))

Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  double x[n+1];
  for(int i=0;i<n;i++){
    scanf("%lf",&x[i]);
    x[i]=(x[i]+1)/2;
   // printf("%lf\n",x[i]);
  }

  
	double sum=0;
  for(int i=0;i<k;i++){					//最初の3個の期待値
    	sum+=x[i];
  }
//  printf("スタート%lf\n",sum);
  double max=sum;
  for(int i=0;i<n-k;i++){
    sum=sum-x[i]+x[k+i];
  //  printf("%lf\n",sum);
      if(sum>max)max=sum;
    }
  
 
  printf("%.12lf",max);
    return 0;
  }

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    int n,nn;
    int sn=0;
    cin>>n;
    nn=n;
    while(nn){
        sn+=nn%10;
        nn/=10;
    }
    if(n%sn){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		int N = Integer.parseInt(line);
		int[] W = new int[N];
		String[] str = reader.readLine().split(" ");
		int sum_all = 0;
		for (int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(str[i]);
			sum_all += W[i];
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			int sum = 0;
			int subsum = 0;
			int sum_minus = 0;
			for (int k = 0; k < i; k++) {
				sum += W[k];
			}
			subsum = sum_all - sum;
			sum_minus = Math.abs(sum - subsum);
			if (sum_minus < min) {
				min = sum_minus;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int k,x;
    cin>>k>>x;
    if(500*k>=x){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		String s[] =sc.nextLine().split(" ");
		int a=Integer.parseInt(s[0]);
		int b=Integer.parseInt(s[2]);
		if(s[1].equals("+"))System.out.println(a+b);
		else System.out.println(a-b);
		
		
		
	}

	}


Measured memory_bytes: 9676
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;



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

    int len = n.size();

    // dp[j][k]: jは使用した非ゼロ, kは0の時=状態
    int dp[4][2] = {0};
    dp[0][0] = 1;
    rep(i, len){
        int nextdp[4][2] = {0};
        int num = n[i] - '0'; //上位i+1桁目の数字をチェック
        rep(j, K+1)rep(k, 2)rep(d, 10){
            int nj = j, nk = k; 
            if (d != 0) nj++;
            if (nj > K) continue;
            if (k == 0){
                if (d > num) continue;
                if (d < num) nk = 1;
            }            
            nextdp[nj][nk] += dp[j][k];
        }        
        memcpy(dp, nextdp, sizeof(nextdp));
    }
    cout << dp[K][0] + dp[K][1] << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1005;
int p[N], n, k;
vector<ll> a, b;
ll pw2[100];
int main() {
    pw2[0] = 1;
    for (int i = 1; i <= 60; i++) pw2[i] = pw2[i-1]*2;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
    for (int i = 1; i <= n; i++) {
        ll tmp = 0;
        for (int j = i; j <= n; j++) {
            tmp += p[j];
            a.push_back(tmp);
        }
    }
//    for (auto x : a) cout << x << " ";
//    cout <<endl;
    ll ans = 0;
    int t = 60;
    while (t >= 0) {
        int num = 0;
        for (auto x : a) if (x&pw2[t]) num++;
        if (num >= k) {
            ans ^= pw2[t];
            b.clear();
            for (auto x : a) if (x&pw2[t]) b.push_back(x);
            a = b;
//            cout << t << endl;
//            for (auto x : a) cout << x << " ";
//            cout <<endl;
        }
        t--;
    }
    cout << ans << endl;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5;
const ll mod = 1e9 + 7;

int n;
ll k;

struct Matrix
{
    int n = 0, m = 0;
    v2d <ll> s;
    Matrix() {}
    Matrix(v2d <ll> &a)
    {
        n = a.size();
        if (n)
        {
            m = a[0].size();
        }
        s = a;
    }
    Matrix iden(int n)
    {
        v2d <ll> s(n, vector <ll> (n));
        for0(i, n)
        {
            s[i][i] = 1;
        }
        return Matrix(s);
    }
    Matrix operator*(Matrix a)
    {
        assert(m == a.n);
        int p = a.m;
        v2d <ll> r(n, vector <ll> (p));
        for0(i, n)
        {
            for0(j, p)
            {
                for0(k, m)
                {
                    r[i][j] += s[i][k] * a.s[k][j];
                    r[i][j] %= mod;
                }
            }
        }
        return Matrix(r);
    }
    Matrix power(Matrix a, ll b)
    {
        if (b == 0)
        {
            return iden(a.n);
        }
        Matrix k = power(a, b >> 1);
        if (b & 1)
        {
            return k * k * a;
        }
        return k * k;
    }
};

ll res = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    v2d <ll> a(n, vector <ll> (n));
    for0(i, n)
    {
        for0(j, n)
        {
            cin >> a[i][j];
        }
    }
    Matrix r(a);
    r = r.power(r, k);
    a = r.s;
    for0(i, n)
    {
        for0(j, n)
        {
            res += a[i][j];
            res %= mod;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1792