akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

A,B,K = map(int, input().split())

print_list = []
for i in range(A,A+K):
    if print_list.count(i) == 0:
        print_list.append(i)

for i in range(B-K+1,B+1):
    if print_list.count(i) == 0:
        print_list.append(i)

for i in print_list:
    if A-1<i and i<B+1:
        print(i)

Measured memory_bytes: 3316
A,B,C,X,Y = map(int,input().split())

minValue = float('inf')

for i in range(0,100001):
    total = 2 * i * C + max([0,X-i]) * A + max([0,Y-i]) * B
    
    if minValue > total:
        minValue = total

print(minValue)


Measured memory_bytes: 2940
from collections import deque

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    dist = [[0 for _ in range(w)] for _ in range(h)]
    dist[0][0] = 1

    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        if x == w-1 and y == h-1:
            break
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            block = 0
            if new_x < 0 or new_y < 0 or w <= new_x or h <= new_y:
                continue  

            if j == 1: block = horizontal[y][x]
            if j == -1: block = horizontal[y-1][x]
            if k == 1: block = vertical[y][x]
            if k == -1: block = vertical[y][x-1]

            if block == 0 and \
                visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
                dist[new_y][new_x] = dist[y][x]+1
    return dist[h-1][w-1]

while True:
    w, h = map(int, input().split())
    if w == 0 : break
    
    vertical = []
    horizontal = []
    
    vertical.append(list(map(int, input().split())))
    for i in range(h-1):
        horizontal.append(list(map(int, input().split())))
        vertical.append(list(map(int, input().split())))
    
    
    maze = [[0]*w for i in range(h)]
    visited = [[-1]*w for j in range(h)]
    print(bfs(maze, visited, 0, 0, h, w))


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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

void solve() {
	rd1(ll, n);
	vl A(n);
	ll ans = 1;
	for(int i = 0; i < n; i++) {
	    cin >> A[i];
	}
	
// 	db1(A);
	
	sort(A.begin(), A.end());
	
	ll md = (ll)(1e18);
	ll pv = 0;
	for(int i = 0; i < n; i++) {
	   // ll pv = ans;
        ans = (ans * A[i]);
        if(ans > md or ans < pv or ans < 0) {
            cout << -1;
            return;
        }
        pv = ans;
    }
	
	cout << ans;
	
}

int main() {
	
	fastio;

// 	rd1(ll, t);
	ll t = 1;

    while(t--) {
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 3976
import java.util.*;
import java.math.*;
import java.lang.*;
 
class Main{

	static Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
    	int n=sc.nextInt();
    	int m=sc.nextInt();
    	int r=sc.nextInt();
    	r-=n*m;
    	if(r<0)System.out.println(0);
    	else {
    		BigInteger ans = new BigInteger("1");
    		 for(int i=0;i<n-1;i++) {
    			ans=ans.multiply(BigInteger.valueOf(r+n-i-1))
    				.divide(BigInteger.valueOf(i+1));
    		}
    		System.out.println(ans);
    	}
	}
}

Measured memory_bytes: 56180
#include<stdio.h>
int main(void){
  
  long a_now,a_sp,b_now,b_sp,t;
  int i;
  long far,sp;
  
  scanf("%ld %ld",&a_now,&a_sp);
  scanf("%ld %ld",&b_now,&b_sp);
  scanf("%ld",&t);
  
  if(a_sp<b_sp){
    printf("NO\n");
    return 0;
  }
  
  
  if(a_now<b_now){
  	far = b_now-a_now;
    sp = a_sp-b_sp;
    if(sp*t>=far){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
    return 0;
  }else if(a_now>b_now){
    far = a_now-b_now;
    sp = a_sp-b_sp;
    if(sp*t>=far){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
    return 0;
  }else{
    printf("YES\n");
    return 0;
  }
  
  return 0;
}


Measured memory_bytes: 1648
#include <iostream>
#include <string>
#include <vector>

namespace ABC169
{
  using namespace std;

  /// 文字列を分割する
  std::vector<string> split(string str, string sep)
  {
    vector<string> ret; ret.clear();
    int cursor = 0;
    auto pos = str.find(sep, cursor);
    while (pos != -1)
    {
      // セパレータまでを切り取ってつっこむ
      ret.push_back(str.substr(cursor, pos - cursor));
      cursor = pos + sep.size();
      pos = str.find(sep, cursor);
    }

    // 残りを詰め込む
    if (cursor < str.size() - 1) {
      ret.push_back(str.substr(cursor, str.size() - cursor));
    }
    return ret;
  }

  class C
  {
  public:
    C() = default;
    ~C() = default;


    void Run()
    {
      long long A;
      std::string B_str;

      std::cin >> A;
      std::cin >> B_str;

      auto r = split(B_str, ".");
      long long B_upper = std::atoll( r.at(0).c_str() );
      long long B_lower = std::atoll( r.at(1).c_str());

      auto upper = A * B_upper;
      auto lower = A * B_lower;

      auto answer = upper + (lower / 100);

      std::cout << answer << std::endl;
    }
  };

}
int main()
{

  ABC169::C prob;
  prob.Run();

  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.size()/2; i++){
        if(s.at(i) != s.at(s.size() - 1 - i)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        $(writeln!(stderr(), "{} = {:?}", stringify!($arg), $arg).unwrap());*
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M, X, Y) = read!(usize, usize, i64, i64);
    let xx = read![[i64]];
    let yy = read![[i64]];
    println!(
        "{}",
        if max(X, *xx.iter().max().unwrap()) < min(Y, *yy.iter().min().unwrap()) {
            "No War"
        } else {
            "War"
        }
    )
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
import java.math.BigInteger;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String[] split = S.split("");
    int count = 0;
    for (int i = 0;i < 3;i++) {
      if (split[i].equals("R")) {
        count += 1;
      }
    }
    if (S.equals("RSR")) {
      count -= 1;
    }
    System.out.println(count);
  }
}



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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(s,element) (s.find(element)!=s.end())
#define cpresent(c,element) (find(c,element)!=c.end())
#define fi(i,n) for(int i=0;i<int(n);i++)
#define tr(i,a) for(auto i:a)
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const double PI=acos(-1);
ll mod=1e9+7;

int n;
vector<int> adj[100005];
vector<bool> used(100005,0);
vector<int> p(100005);
queue<int> q;

void bfs(int s)
{
	q.push(s);
	used[s] = true;
	p[s] = -1;
	while (!q.empty())
	{
    	int v = q.front();
    	q.pop();
    	for (int u : adj[v])
    	{
        	if (!used[u])
        	{
            	used[u] = true;
            	q.push(u);
            	p[u] = v;
        	}
    	}
	}

}

int main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int test=1;
//cin>>test;
while(test--)
{

	int m,x,y; cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	bfs(1);
	int cnt=0;
	for(int i=2;i<=n;i++)
		if(!p[i])cnt++;

	if(cnt)cout<<"No\n";
	else{
		cout<<"Yes\n";
		for(int i=2;i<=n;i++)
			cout<<p[i]<<endl;
	}


	
}
return 0;
}










Measured memory_bytes: 10192
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////

//最大公約数がぴったりxであるための必要十分条件はxの倍数でありかつ2x,3x,,,,ではない

//x^y
ll mod_pow(ll x, ll n, ll mod) {
    if (n == 0)return 1;
    ll res = mod_pow(x*x%mod, n / 2, mod);
    if (n & 1)res = res * x%mod;
    return res;
}
int main() {
	int n, k; cin >> n >> k;
	ll res[100010];//key[x]で,x以上で
	for (int i = 0; i < 100010; ++i)res[i] = 0;
	ll ans = 0, cnt;//cntは最大公約数がiの数
	for (ll i = k; i >=1; --i) {
		cnt = mod_pow(k / i, n,(ll)INF);
		for (int j = i; j <= k; j+=i) {
			cnt -= res[j];
			if (cnt < 0)cnt += INF;
		}
		res[i] = cnt;
		ans += cnt * i;
		ans %= INF;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4388
n = 0
s = []
while n < 2:
    s.append(input())
    n += 1

new_list = []


for number in s[1].split():
    new_list.append(int(number))

maximum = max(new_list)
minimum = min(new_list)
summation = sum(new_list)
print(minimum, maximum, summation)


Measured memory_bytes: 8712
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ

int h,w;
vector<vector<char>> a;
vector<vector<int>> cnt;

int dp(int y,int x){
  if (y < 0 || x < 0){
    return (0);
  }
  if (cnt[y][x] == -1){
    return (0);
  }
  if (cnt[y][x] != INT_MAX){
    return (cnt[y][x]);
  }
  
  cnt[y][x] = dp(y-1,x) % 1000000007;
  cnt[y][x] += dp(y,x-1) % 1000000007; 
  return (cnt[y][x] % 1000000007);
} 

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  a.resize(h,vector<char>(w));
  cnt.resize(h,vector<int>(w,-1));
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cin >> a[i][j];
      if (a[i][j] == '.'){
        cnt[i][j] = INT_MAX;
      }
      
    }
  }
  
  cnt[0][0] = 1;
  cout << dp(h-1,w-1) << '\n';
  return 0;
}

Measured memory_bytes: 8220
n, k = map(int, input().split())
ab = []
for i in range(n):
    ai, bi = map(int, input().split())
    ab.append((ai, bi))
ab.sort(key=lambda x:x[0])
cnt = 0
for i in range(n):
    cnt += ab[i][1]
    if cnt >= k:
        print(ab[i][0])
        exit()

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

typedef pair<int,int> P;

int main(){
	int n,m,h,k,s[1000],score[1000],a,b;
	int num[1000];
	vector<int> bou[1000];
	vector<P> swp;
	while(1){
		cin >> n >> m >> h >> k;
		if(!n) break;
		swp.clear();
		for(int i = 0;i < 1000;i++) bou[i].clear();
		for(int i = 0;i < n;i++) {
			cin >> s[i];
			num[i] = i;
		}
		for(int i = 0;i < m;i++){
			cin >> a >> b;
			bou[b - 1].push_back(a - 1);
		}
		for(int i = 0;i < h;i++){
			for(int j = 0;j < bou[i].size();j++){
				int pos = bou[i][j];
				swp.push_back(P(num[pos],num[pos + 1]));
				int tmp = num[pos];
				num[pos] = num[pos + 1];
				num[pos + 1] = tmp;
			}
		}
		int sum = 0;
		for(int i = 0;i < n;i++){
			score[num[i]] = s[i];
		}
		for(int i = 0;i < k;i++) sum += score[i];
		int ma = -1000000000;
		for(int i = 0;i < swp.size();i++){
			P p = swp[i];
			if(p.first < k && p.second >= k)
			ma = max(ma,score[p.first] - score[p.second]);
		}
		cout << min(sum - ma,sum) << endl;
	}
	return 0;
}

Measured memory_bytes: 4500
#include<stdio.h>
int main(){
    int a,b,c;
    int coins = 0;
    scanf("%d%d%d",&a,&b,&c);
    int day = 0;
    int bd =0;
    while(1){
        if (bd==7){
            coins+=b;
            bd=0;
        }
        if(coins>=c){
            break;
        }
        coins+=a;
        day++;
        bd++;
    
        
    }
    printf("%d\n",day);
    
    
}


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

int W,n,v,w;
int dp[1001],casenum;

int main(){
  casenum = 1;
  while(scanf("%d",&W), W){
    scanf("%d",&n);
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
      scanf("%d,%d",&v,&w);
      for(int i=W;i>=0;i--){
	if(i+w <= W){
	  dp[i+w] = max(dp[i+w], dp[i] + v);
	}
      }
    }

    int ansv = 0, answ = 0;
    for(int i=0;i<=W;i++){
      if(ansv < dp[i]){
	ansv = dp[i]; answ = i;
      }
    }
    printf("Case %d:\n%d\n%d\n",casenum, ansv, answ);
    casenum++;
  }
}

Measured memory_bytes: 1192
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    k = int(input())
    x = 7 % k  # k == 7の場合への対処

    # KeyInsight:
    # ◯: Mod kを取る
    # ◯: 値が(x * 10 + 7)ずつ増えていく
    # △: Modを取った後の演算について理解が浅かった
    for i in range(1, k + 1):
        if x == 0:
            print(i)
            exit()

        x = (x * 10 + 7) % k

    print(-1)


if __name__ == '__main__':
    main()


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

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

    int taste=0;
    for(int i=1; i<=n; i++){
        taste+=l+i-1;
    }

    if(l>=0){
        cout << taste-l << endl;
    }
    else{
        int T=taste-(l+n-1);
        for(int i=1; i<=n; i++){
            int t=taste-(l+i-1);
            if(abs(taste-t)==0){
                T=t;
            }
        }
        cout << T << endl;
    }

    return 0;
}

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

using namespace std;

int main(){

    int N, A, B;
    cin >> N >> A >> B;
    int sum = 0;
    int temp;
    int ans = 0;
    for(int i=0; i <= N; i++){
        sum = 0;
        temp = i;
        while(1){
            sum += temp % 10;
            temp = temp / 10;
            if(temp==0){break;}
        }

        if(A <= sum && sum <= B){

            ans = ans + i;
        }

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
taro = hanako = 0
for i in range(int(input())):
    tcard, hcard = input().split()
    if tcard == hcard:
        taro += 1
        hanako += 1
    elif tcard > hcard:
        taro += 3
    else:
        hanako += 3

print('%d %d' %(taro, hanako))

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;


int main(){
  string s; cin >> s;
  int n = s.size()+1;
  vector<int> a(n,0);
  for(int i = 1; i < n; i++){
    if(s[i-1] == '<'){
      a[i] = max(a[i-1]+1, a[i]);
    }
  }
  for(int i = n-2; i >= 0; i--){
    if(s[i] == '>'){
      a[i] = max(a[i+1]+1, a[i]);
    }
  }
  ll ans = 0;
  rep(i,n){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)        int x; cin>>x; while(x--)
const double pi=3.14159265359;
//Actual Code Is At The Top
const int mod = 1e9 + 6;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int main()
{   
	very_slow
//	no_of_test(x)
	{  
      int k,n;
	  cin>>k>>n;
	  int a[n]; int total=0;
	  for(int i=0;i<n;i++)
	  {
		  cin>>a[i];
		  total+=a[i];
	  }
	  if(total>k)
	  {
		  cout<<-1<<'\n';
	  }
	  else
	  {
		  cout<<k-total<<'\n';
	  }
	  
	}
	return 0;
}

Measured memory_bytes: 3536
#include <iostream>

using namespace std;

int main(){

    string N = ""; 
    cin >> N;
    int n = 0;

    for (int i = 0; N[i] != '\0'; i++){
        n += N[i] - '0';
    }

    if(0 == n % 9){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3256
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first

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

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

	int n; cin >> n;

	string str; cin >> str;

	std::vector<int> r , g;

	forn(i,0,n){
		if(str[i] == 'R')r.pb(i+1);
		else if(str[i] == 'G')g.pb(i+1);
	}

	bool flag ;

	ll ans = 0 , ad = n - r.size() - g.size() ;
	int tmp;

	forn(i,0,r.size()){

		forn(j,0,g.size()){
			ans += ad;
			
			flag = true;
			int mini = min(r[i] , g[j]);
			int maxi = max(r[i] , g[j]);

			tmp = mini + maxi;

			if(tmp%2 == 0 && tmp/2 <= n && tmp/2 >=1 && str[(mini + maxi)/2 - 1] == 'B'){
					ans--;

			}
			
			tmp = 2*mini - maxi; 

			if(tmp >= 1 && tmp <= n && str[tmp-1] == 'B' ){
				ans--;
			}

			tmp = 2*maxi - mini;

			if(tmp >= 1 && tmp <= n && str[tmp -1 ] == 'B')ans--; 
			





		}

	}

	cout << ans << endl;
    



}

int main(){
    SPEED;

    solve();

    return 0;
}
      
       


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

unsigned getDigit(unsigned num) {
	unsigned digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

int main(void)
{
	int N;
	std::cin >> N;

	
	uint64_t digit = getDigit(N);

	
	uint64_t num = 0;

	for (int i = 0; i < digit-1; i=i+2) {
			num += 9 * std::pow(10, i);
	}
	
	if (digit % 2 == 1) {
		num += N - static_cast<int>(std::pow(10, digit - 1)) + 1;
	}
	std::cout << num << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool solve(int p, int t);
int A[3000];
int main(){
  int n,q;
  cin >> n;
  for(int i=0;i<n;i++) cin >> A[i];    
  for(int i=0;i<n;i++) for(int j=i+1;j<n;j++)
    if(A[i]>A[j]) A[i]^=A[j]^=A[i]^=A[j];
  cin >> q;
  for(int j=0,tmp,lim,i;j<q;j++){
    cin >> tmp;
    for(i=0,lim=n-1;i<n;i++)
    if(tmp<A[i]&&((lim=(i-1>=0?i-1:0))?true:true)) break;
    if(solve(lim,tmp)) cout << "yes\n";
    else cout << "no\n";
  }
  return 0;
}
bool solve(int i, int t){
  if(t==A[i]) return true;
  if(t<=0||i==0) return false;
  if(solve(i-1,t-A[i])||solve(i-1,t)) return true;
  return false;
}

Measured memory_bytes: 1124
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>
#include <sstream>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

struct ss{
	int ct;
	bool zm,cm;
//	ss(int ct, bool zm,bool cm) : ct(ct),zm(zm),cm(cm) {}
};

int main(void){

string ws;
int bg,dy,cnt =0,tuki=0;

map <int,ss> mp;
map <int,ss>::iterator itr;

	while(!cin.eof()){
		getline(cin,ws);
			if(ws == "") {
			tuki++;
			continue;
		}
		replace(ws.begin(),ws.end(),',',' ');
		stringstream zz;
		zz << ws;
		zz >> bg >> dy;
		if(mp.end() != mp.find(bg)){
			mp[bg].ct++;
		}else{
			mp[bg].ct=1;
		}
		if(tuki==0) mp[bg].zm = true;
		else		mp[bg].cm = true;
	
	}
	for (itr = mp.begin(); itr != mp.end(); itr++){
		if(itr->second.zm && itr->second.cm)
			cout << itr->first << " " << itr->second.ct << endl;
	}
	return 0;
	
}

Measured memory_bytes: 1228
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;

ll er[1000001], p[1000000], ptr, n, d[1000][1000];

ll gcd (ll a, ll b)
{
	if (!b) return a;
	else return gcd (b, a % b);
}

int main ()
{
	for (ll i = 2; i <= 1000000; i++)
		if (!er[i])
		{
			p[ptr++] = i;
			for (ll j = i * i; j <= 1000000; j += i)
				er[j] = 1;
		}

	cin >> n;

	for (int i = 0; i < 2 * n; i += 2)
		for (int j = 0; i + j < 2 * n; j++)
			d[j][i + j] = p[i / 2];


	for (int i = 2; i < 2 * n; i += 2)
		for (int j = 0; i + j < 2 * n; j++)
			d[i + j][j] = p[i / 2 + (n + 1) / 2 - 1];


	for (int i = 0; i < 2 * n; i += 2)
		for (int j = 0; i >= j; j++)
			d[i - j][j] *= p[i / 2 + n];

	ll mx = 0;

	if (n == 2)
	{
		printf ("4 7\n23 10");
		return 0;
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (!d[i][j])
			{
				ll lcm = 1;
				if (j) lcm = lcm / gcd (lcm, d[i][j-1]) * d[i][j-1];
				if (j < n - 1) lcm = lcm / gcd (lcm, d[i][j+1]) * d[i][j+1];
				if (i) lcm = lcm / gcd (lcm, d[i-1][j]) * d[i-1][j];
				if (i < n - 1) lcm = lcm / gcd (lcm, d[i+1][j]) * d[i+1][j];

				d[i][j] = lcm + 1;
			}

			printf ("%lld ", d[i][j]);
		}
		putchar ('\n');
	}
}

Measured memory_bytes: 22400
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
ll dp[51][2];
int main()
{
    cout << fixed << setprecision(30);
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (long long i = 0; i < N; i++)
        cin >> A[i];
    //桁dpを試してみる
    //[(参考)[https://drken1215.hatenablog.com/entry/2019/02/04/013700]
    loop(i, 50)
    {
        dp[i][0] = -1;
        dp[i][1] = -1;
    }
    dp[0][0] = 0;
    loop(d, 50)
    {
        ll count = 0;
        loop(i, N) if (flagon(A[i], (49ll - d))) count++;
        ll plus0 = count * (1ll << (49ll - d));
        ll plus1 = (N - count) * (1ll << (49ll - d));
        //既にKよりも小さいことが確定しているので自由
        if (dp[d][1] != -1)
        {
            dp[d + 1][1] = max(dp[d + 1][1], dp[d][1] + max(plus0, plus1));
        }
        if (dp[d][0] != -1)
        {
            if (flagon(K, (49ll - d)))
            {
                dp[d + 1][1] = max(dp[d + 1][1], dp[d][0] + plus0); //0->1
                dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + plus1); //0->0
            }
            else
                dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + plus0); //どうあがいても0->0
        }
    }
    ll ans = max(dp[50][0], dp[50][1]);
    putout(ans);
    return 0;
}


Measured memory_bytes: 4000
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int m = stdIn.nextInt();
        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
import sys

N,K,C = map(int,input().split())
S = input()
#%%
assign_t = [False]*N
assign_b = [False]*N


i = 0
num = 0
while i<N:
    if S[i]=='o':
        assign_t[i]=True
        num += 1
        i += C+1
    else:
        i += 1

if num>K:
    print()
    sys.exit()

i = N-1
num = 0
while i>=0 and num<K:
    if S[i]=='o':
        assign_b[i]=True
        num += 1
        i -= C+1
    else:
        i -=1


for i in range(N):
    if assign_t[i] and assign_b[i]:
        print(i+1)

Measured memory_bytes: 7876
#include<stdio.h>
int main(void)
{
    int r,g,b;
    scanf("%d %d %d",&r,&g,&b);
    r>=1;
    g>=1;
    b>=1;
    int c;
    c=(100*r)+(10*g)+b;
    if(c%4==0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iomanip>

#define D(x) cout<< #x <<" = "<<x<<"\n"
#define IL(a,n) for (int i=a; i<n; i++)
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})

using namespace std;

//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;
const double PI=acos(-1.0);

/*_______________________________________________*/
int arr[MX],n;
Long dp[2][MX];

Long solve(bool flag,int pos)
{
	if(pos == n-1)
		if(flag) return -1*arr[pos];
		else return arr[pos];
	if(dp[flag][pos] != -1) return dp[flag][pos];
	Long res = 0;
	if(flag)
		res = max(-1*arr[pos]+solve(false,pos+1),arr[pos] + solve(true,pos+1));
	else
		res = max(arr[pos]+solve(false,pos+1),-1*arr[pos]+solve(true,pos+1));
	return dp[flag][pos] = res;
}

int main()
{

	n = II();
	for(int i = 0; i<n; i++) arr[i] = II();

	memset(dp,-1,sizeof(dp));
	printf("%lld\n",solve(false,0));

	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
using namespace std;
int main(void){
    int n,i,ans=0;
    int a[20],b,c[20];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    for(i=0;i<n;i++){
        cin>>b;
        ans+=b;
    }
    for(i=0;i<n-1;i++)cin>>c[i];
    for(i=0;i<n-1;i++){
        if(a[i+1]-1==a[i])ans+=c[a[i]];
    }
    cout<<ans;
}


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

int numofbits(long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

void xnumofbits(int k, int& sum, vector<int> hw){
  int l;
  xrep(k){
    l = numofbits((k&-k)-1);
    sum += hw[l];
  }
}

void xnumofbits2(int k, int l, int& sub, string s, vector<string> ss){
  int p,q,r;
  xrep(k){
    r = l;
    //cout << "r=" << r << " sub=" << sub << endl;
    xrep(r){
      p = numofbits((k&-k)-1);
      q = numofbits((r&-r)-1);
      //cout << "k=" << k << " l=" << l << " p=" << p << " q=" << q << endl;
      s = ss[p];
      if(s[q]=='#') ++sub;
    }
  }
}

int binarysearch(int H, int W, int K,string s,vector<string> ss,vector<int> sh,vector<int> sw, int count){
  int hb=(int)pow(2,H),wb=(int)pow(2,W);
  int i,j,k,l,sum,sub,score=0;
  rep(i,hb){
    rep(j,wb){
      sum = 0; sub = 0;
      k = i;
      xnumofbits(k,sum,sh);
      k = j;
      xnumofbits(k,sum,sw);
      k = i;
      l = j;
      xnumofbits2(k,l,sub,s,ss);
     if((count-(sum-sub))==K) ++score;
     //cout << "i=" << i << " j=" << j << " sum=" << sum << " sub=" << sub << " dis=" << count-(sum-sub) << " score=" << score << endl;
     }
  }
  return score;
}

int main(void){
  int H,W,K; cin >> H >> W >> K;
  string s;
  vector<string> ss(H);
  int i,j,count=0;
  vector<int> sh(H,0),sw(W,0);
  rep(i,H){
    cin >> s; ss[i]=s;
    rep(j,W) if(s[j]=='#') {++sh[i]; ++sw[j]; ++count;}
  }
//  rep(i,H) cout << sh[i] << " "; cout << endl;
//  rep(i,W) cout << sw[i] << " "; cout << endl;
//  cout << count << endl;
  cout << binarysearch(H,W,K,s,ss,sh,sw,count) << endl;
  
  return 0;
}


Measured memory_bytes: 4076
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mm[4];

signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m;
    cin>>n>>m;
    if(n==1&&m==0)
    {
        cout<<0;
        return 0;
    }
    int x,y;
    fill_n(mm,4,-1);
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        if(x==1&&(n!=1&&y==0))
        {
            cout<<-1;
            return 0;
        }
        if(mm[x]!=-1)
        {
            if(mm[x]!=y)
            {
                cout<<-1;
                return 0;
            }
        }
        mm[x]=y;
    }
    if(mm[1]==-1)
    {
        mm[1]=1;
    }
    for(int i=2;i<=n;i++)
    {
        if(mm[i]==-1)
            mm[i]=0;
    }
    for(int i=1;i<=n;i++)
        cout<<mm[i];

} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int n;
  while(cin >> n && n) {
    vector<P> a;
    a.resize(n);
    string s;
    getline(cin,s);
    for(int j=0; j<n; j++) {
      getline(cin,s);
      stringstream ss;
      ss << s;
      ss >> a[j].second;
      a[j].second*=-1;
      a[j].first=0;
      vector<int> b;
      int x;
      while(ss >> x) b.push_back(x);
      int i=0,k=0;
      vector<int> c;
      c.resize(b.size()+1);
      fill(c.begin(),c.end(),0);
      while(i<b.size()) {
        k++;
        a[j].first+=b[i];
        if(i&&c[i-1]) a[j].first+=b[i];
        if(i>=2&&c[i-2]==2) a[j].first+=b[i];
        if(b[i]==10) {
          if(k<10)c[i]=2;
          i++;
          continue;
        }
        i++;
        if(i>=b.size()) break;
        a[j].first+=b[i];
        if(i>=2&&c[i-2]==2) a[j].first+=b[i];
        if(b[i-1]+b[i]==10) {
          if(k<10)c[i]=1;
          i++;
          continue;
        }
        i++;
      }
    }
    sort(a.rbegin(),a.rend());
    for(int i=0; i<n; i++) cout << -a[i].second << " " << a[i].first << endl;
  }
  return 0;
}

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

int main()
{
  long a, b;
  
  cin >> a >> b;
  
  long ans = a * b, temp = 0;
  
  if(a < b){
    temp = a;
    a = b;
    b = temp;
  }
  
  temp = a % b;
  
  while(temp != 0){
    a = b;
    b = temp;
    temp = a % b;
  }
  
  cout << ans / b << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
public class MainClass
{
	public static void Main(string[] args)
	{
		string line = Console.ReadLine();
		string[] inputs = line.Split(' ');
		int a = int.Parse(inputs[0]);
		int b = int.Parse(inputs[1]);
		
		if(b % a == 0)
			Console.WriteLine(a + b);
		else
			Console.WriteLine(b - a);
	}
}

Measured memory_bytes: 13140
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int a, b;
        cin >> a >> b;
        int n = b - a;
        int res = (n - 1) * n / 2;

        cout << res - a << endl;

        return 0;
}


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int n;cin>>n;
    set<string>s;
    frepi(1,n,1)
    {
    	string s1;cin>>s1;
    	s.insert(s1);
    }
    cout<<s.size();
}

int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("/home/suryakant/input.txt","r",stdin);
        freopen("/home/suryakant/output.txt","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 19216
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if a[i]+a[i+1]>x:
      ans+=min(a[i+1],a[i]+a[i+1]-x)
      a[i+1]-=min(a[i+1],a[i]+a[i+1]-x)
      ans+=a[i]+a[i+1]-x
      a[i]-=a[i]+a[i+1]-x
print(ans)

Measured memory_bytes: 14132
import java.util.*;
class Pair
{
	int first;
	int second;
	public Pair(int first, int second)
	{
		this.first = first;
		this.second = second;
	}
}

class MyComparator implements java.util.Comparator<Integer>
{
	public int compare(Integer object1, Integer object2)
	{
        return (object1).compareTo(object2) * -1;
    }

}

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		Set<Integer> set = new TreeSet<Integer>(new MyComparator());
		List<Pair> list = new ArrayList<Pair>();
		int score = 0;
		while(stdIn.hasNext())
		{
			String[] str = stdIn.next().split(",");
			int num = Integer.parseInt(str[0]);
			score = Integer.parseInt(str[1]);
			if(num == 0 && score == 0)
			{
				break;
			}
			set.add(score);
			list.add(new Pair(num, score));
		}
		while(stdIn.hasNext())
		{
			int num = stdIn.nextInt();
			for(int i = 0; i < list.size(); ++i)
			{
				if(list.get(i).first == num)
				{
					score = list.get(i).second;
					break;
				}
			}
			Iterator<Integer> it = set.iterator();
			int count = 1;
			while(it.hasNext())
			{
				int temp = it.next();
				if(temp == score)
				{
					System.out.println(count);
				}
				++count;
			}
		}
	}
}

Measured memory_bytes: 12000
l=[list(map(int,input().split())) for i in range(3)]
l=sum(l,[])
n=int(input())
li=set([int(input()) for ini in range(n)])
d=[0 for i in range(9)]
for g in range(9):
  if l[g] in li:d[g]=1

for a,s,x in [(0,1,2),(3,4,5),(6,7,8),(0,4,8),(2,4,6),(0,3,6),(1,4,7),(2,5,8)]:
  if d[a]==d[x]==d[s]==1:
    print("Yes");exit()
print("No")


Measured memory_bytes: 3064
class Dice:
    def __init__(self, top: str, front: str, right: str, left: str, back: str, bottom: str) -> None:
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.back = back
        self.bottom = bottom

    def __eq__(self, other) -> bool:
        top, front = self.top, self.front

        # find top
        found = False
        for direction in 'SSSS':
            other.roll(direction)
            if other.top == top:
                found = True
                break
        if not found:
            for direction in 'EEE':
                other.roll(direction)
                if other.top == top:
                    break

        # find front
        for _ in range(4):
            other.rotate_right()
            if other.front == front:
                break

        return (
                self.right == other.right
                and self.left == other.left
                and self.back == other.back
                and self.bottom == other.bottom
        )

    def print_top(self):
        print(self.top)

    def print_right(self):
        print(self.right)

    def roll(self, direction: str) -> None:
        if direction == 'S':
            self.south()
        elif direction == 'N':
            self.north()
        elif direction == 'E':
            self.east()
        elif direction == 'W':
            self.west()

    def north(self):
        [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom]

    def south(self):
        [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top]

    def east(self):
        [self.top, self.right, self.bottom, self.left] = [self.left, self.top, self.right, self.bottom]

    def west(self):
        [self.top, self.right, self.bottom, self.left] = [self.right, self.bottom, self.left, self.top]

    def rotate_right(self) -> None:
        for direction in 'SWN':
            self.roll(direction)


dice1 = Dice(*input().split())
dice2 = Dice(*input().split())

if dice1 == dice2:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    char S[100];
    int Slen;
    char key[] = "keyence";
    int j; //Sとkeyがことなる場所
    int result=0;

    fgets(S,sizeof(S),stdin);
    Slen = strlen(S);
    //printf("%d\n",Slen);
    //for(int i=0;i<7;i++)printf("%c\n",key[i]);
   
    for(int i=0;i<Slen;i++){
        if(S[i]!=key[i]){j=i;/*printf("%d\n",j);*/break;break;}
    }
    for(int i=Slen-2;i>Slen+j-9;i--){
        if(S[i]!=key[i+8-Slen]){result++;/*printf("%d %c %c\n",i,S[i],key[i+8-Slen]);*/}
    }

    if(result==0)printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, m;

llong num[1024][1024];
pair<llong, llong> dp[1024][1024];
bool is_prime[1000005];

void sieve(llong n) {
    for (int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return;
}

pair<llong, llong> rec(int i, int j) {
    if (i >= 1024 || j < 0 || j >= 1024) return {0, 0};
    if (num[i][j] > m) return {0, 0};

    if (dp[i][j] != make_pair(-1ll, -1ll)) return dp[i][j];

    pair<llong, llong> ret = max({rec(i + 1, j - 1),
                                  rec(i + 1, j),
                                  rec(i + 1, j + 1)});

    if (ret == make_pair(0ll, 0ll) && is_prime[num[i][j]]) {
        ret.first = 1;
        ret.second = num[i][j];
    }
    else if (is_prime[num[i][j]]){
        ret.first++;
    }
    
    return dp[i][j] = ret;
}

int main() {
    {
        sieve(1000000);
        llong x, y;
        llong c = 3;
        llong w = 3;
        num[512][512] = 1;
        num[512][513] = 2;
        x = 513;
        y = 512;

        while (c <= 1000000) {
            for (int i = 0; i < w - 2; i++) {
                y--;
                num[y][x] = c;
                c++;
            }

            for (int i = 0; i < w - 1; i++) {
                x--;
                num[y][x] = c;
                c++;
            }

            for (int i = 0; i < w - 1; i++) {
                y++;
                num[y][x] = c;
                c++;
            }

            for (int i = 0; i < w; i++) {
                x++;
                num[y][x] = c;
                c++;
            }
            w += 2;
        }
    }
    
    while (1) {
        cin >> m >> n;
        if (n == 0) break;

        llong x, y;
        for (int i = 0; i < 1024; i++) {
            for (int j = 0; j < 1024; j++) {
                if (num[i][j] == n) {
                    y = i;
                    x = j;
                }
                dp[i][j] = make_pair(-1ll, -1ll);
            }
        }

        auto p = rec(y, x);

        cout << p.first << ' ' << p.second << '\n';
    }

    return 0;
}



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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const int INF = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    mcf_graph<int, long long> mcf(2 * n + 2);
    mcf.add_edge(2 * n, 2 * n + 1, n * k, INF);
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++) {
            int a;
            cin >> a;
            mcf.add_edge(i, j + n, 1, INF - a);
        }
    for (int i=0; i<n; i++) {
        mcf.add_edge(2 * n, i, k, 0);
        mcf.add_edge(i + n, 2 * n + 1, k, 0);
    }

    cout << (long long) n * k * INF - mcf.flow(2 * n, 2 * n + 1, n * k).second << "\n";
    vector<string> grid(n, string(n, '.'));
    auto edges = mcf.edges();
    for (auto &e : edges)
        if (e.from != 2 * n && e.to != 2 * n + 1 && e.flow > 0)
            grid[e.from][e.to - n] = 'X';
    for (int i=0; i<n; i++)
        cout << grid[i] << "\n";

    return 0;
}


Measured memory_bytes: 3936
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <bitset>
#include <queue>

using namespace std;

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

    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '1') ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

tmax, amax = max(t), max(a)
if not any(ti == ai == tmax == amax for ti, ai in zip(t, a)):
    print(0)
    exit()

ans = 1
for i in range(1, n - 1):
    if t[i - 1] == t[i] and a[i] == a[i + 1]:
        ans = ans * min(t[i], a[i]) % mod
print(ans)


Measured memory_bytes: 97792