akhauriyash/Code-Regression huggingface dataset:
ichi = input().split()
n = int(ichi[0])
m = int(ichi[1])
a = [[0 for j in range(m)] for i in range(n)]
for i in range(n):
    input_a = input().split()
    for j in range(m):
       a[i][j] = int(input_a[j])
b = []
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c=0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)

Measured memory_bytes: 7936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();

		long sum = a + b;

		if (sum % 2 != 0) {
			System.out.println("IMPOSSIBLE");
			return;
		}

		System.out.println(sum / 2);
	}
}

Measured memory_bytes: 21844
import math


N = int(input())
Nsq = int(math.sqrt(N)) + 1
ans = 10**9

for n in range(1, Nsq):
    if N % n == 0:
        A = n
        B = N // n

        F = max(len(str(B)), len(str(A)))
        ans = min(ans, F)


print(ans)


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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100001
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(ll i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(ll i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<ll> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = 1e9+7;
const int minf = (-1)*(1e9+7);

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}

void solve(ll test){

    ll n,k;
    cin >> n >> k;

    ll a[n];
    fr(i,0,n,1)cin >> a[i];

    vector<string> ans;
    fr(i,0,n-k,1){
        if(a[i+k] > a[i])ans.pb("Yes");
        else ans.pb("No");
    }

    for(auto u : ans){
        cout << u << endl;
    }

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        // cout << endl;
    }
    return 0;
}


Measured memory_bytes: 13128
import math

A, B, H, M = map(int, input().split())

A_degree = (360 / (60 * 12)) * (H * 60 + M)
B_degree = (360 / 60) * M

A_x = A * math.cos(math.radians(A_degree))
A_y = A * math.sin(math.radians(A_degree))

B_x = B * math.cos(math.radians(B_degree))
B_y = B * math.sin(math.radians(B_degree))

ans = math.sqrt((A_x - B_x)**2 + (A_y - B_y)**2)

print(ans)

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

int main() {
  int N; cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for(int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  for(int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (V.at(i) - C.at(i) > 0) {
      ans += V.at(i) - C.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split(" "))
s = [list(map(int, input().split(" ")))[1:] for i in range(m)]
p = list(map(int, input().split(" ")))

ans = 0
for i in range(2 ** n):
    state = "{:010b}".format(i)[::-1]
    for j in range(m):
        count = 0
        for si in s[j]:
            count += int(state[si-1])
        if count % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
from fractions import gcd
A, B = map(int,input().split())
C = gcd(A,B)
C0 = C
 
p = {}
for i in range(2,10**6):
    if C % i == 0:
        p[i] = 0
        while C % i == 0:
            C //= i
            p[i] += 1
    if i * i > C0:
        break
if C != 1:
  p[C] = 1
 
print(len(p) + 1)

Measured memory_bytes: 5560
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

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

    int n,m;
    int sum = 0;
    cin >> n >> m;


    for(int i= 0; i< m; ++i)
    {
	int x;
	cin >> x;
	sum+=x;
    }
    cout << (sum > n ? -1 : n - sum);
    
    return 0;
}


Measured memory_bytes: 3656
///
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun May 20 12:45:59 2018
//
package main

import (
	"fmt"
)

const MOD int64 = 1e9 + 7

var H, W, A, B int64
var dp []int64

func pow(n, m int64) int64 {
	if m == 0 {
		return 1
	} else if m%2 == 0 {
		ret := pow(n, m/2) % MOD
		return (ret * ret) % MOD
	} else {
		return (n * pow(n, m-1)) % MOD
	}
}

func comb(n, k int64) int64 {
	return (((dp[n] * pow(dp[k], MOD-2)) % MOD) * pow(dp[n-k], MOD-2)) % MOD
}

func main() {
	fmt.Scan(&H, &W, &A, &B)

	dp = make([]int64, H+W+1)
	dp[0] = 1
	for i := 1; i < len(dp); i++ {
		dp[i] = (int64(i) * dp[i-1]) % MOD
	}

	var ans int64
	for i := B + 1; i <= W; i++ {
		ans += (comb(H-A+i-2, i-1) * comb(A+W-i-1, A-1)) % MOD
	}

	fmt.Println(ans % MOD)
}


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

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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

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

	mint ans = 0;
	mint col = m;
	for (int x=n-1;x>=0;--x) {
		mint now = col;
		now *= c(n-1,x);
		if (x<=k) ans += now;
		col *= m-1;
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 6200
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

string s, t ;

signed main(){
	t = "keyence" ;
	cin >> s ; int n = siz(s) ;
	int l = 0, r = 0 ;
	while (s[l] == t[r] && l < n && r < siz(t)) l++, r++ ;
	if (l == n && r == siz(t)) PRINT("YES") ;
	rep(i, l + 1, n - 1) {
		int ll = i, rr = r ;
		while (s[ll] == t[rr] && ll < n && rr < siz(t)) ll++, rr++ ;
		if (ll == n && rr == siz(t)) PRINT("YES") ;
	}
	PRINT("NO") ;
	return 0 ;
}

/*
Ð´´úÂëÊ±Çë×¢Òâ£º
	1.ll£¿Êý×é´óÐ¡£¬±ß½ç£¿Êý¾Ý·¶Î§£¿
	2.¾«¶È£¿
	3.ÌØÅÐ£¿
	4.ÖÁÉÙ×öÒ»Ð©
Ë¼¿¼ÌáÐÑ£º
	1.×î´óÖµ×îÐ¡->¶þ·Ö£¿
	2.¿ÉÒÔÌ°ÐÄÃ´£¿²»ÐÐdp¿ÉÒÔÃ´
	3.¿ÉÒÔÓÅ»¯Ã´
	4.Î¬»¤Çø¼äÓÃÊ²Ã´Êý¾Ý½á¹¹£¿
	5.Í³¼Æ·½°¸ÊÇÓÃdp£¿Ä£ÁËÃ´£¿
*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef vector< ll > vl;
typedef vector< vl > vvl;
const ll MAX = 1e5+5;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define EE '\n'
#define ll long long int
#define forn(i,j,n) for ( auto i=j ; i<n ; i++ )
#define fornd(i,j,n) for ( auto i=j ; i>n ; i-- )
#define PI 3.14159265
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
#define SOT(A) sort(A.begin(),A.end())
#define SOTR(A) sort(A.rbegin(),A.rend())

const int N = 200043;
const int MOD = 998244353;
//////////////// ncr ///////////////////////
int mul(int x, int y) {return (x * 1ll * y) % MOD;}
int binpow(int x, int y){
    int z = 1;
    while(y){
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
int inv(int x) {return binpow(x, MOD - 2);}
int divide(int x, int y) {return mul(x, inv(y));}
int fact[N];
void precalc(){
    fact[0] = 1;
    for(int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
}
int C(int n, int k)  {return divide(fact[n], mul(fact[k], fact[n - k]));}

/////////////// ncr  ///////////////////////


//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve(){
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) {
    	if (is_prime[i]) {
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main()
{
	int n,x,y;
	cin>>n>>x>>y;
	map<int,int> A;
	forn(i,1,n+1){
	    forn(j,i+1,n+1){
	        int a=min({abs(j-i),(abs(x-j)+1+abs(y-i)),(abs(x-i)+1+abs(y-j))});
	        if(A.find(a)==A.end()){
	            A[a]=0;
	        }
	        A[a]++;
	    }
	}
	forn(i,1,n){
	    if(A.find(i)==A.end()){
	        cout<<0<<EE;
	    }
	    else cout<<A[i]<<EE;
	}
    
    
}	




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
string s;
cin>>s;
if(s[0]!=s[1]&&s[2]==s[3]&&s[4]==s[5]){
    cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int N, M;
  std::cin >> N >> M;
  std::vector<int > A(N), B(M);
  std::vector<bool > existA(N*M+4, false);
  std::vector<bool > existB(N*M+4, false);
  bool ok = true;
  for (int i=0; i<N; i++) {
    std::cin >> A[i];
    if (existA[A[i]]) {
      ok=false;
    }
    existA[A[i]]=true;
  }
  for (int i=0; i<M; i++) {
    std::cin >> B[i];
    if (existB[B[i]]) {
      ok=false;
    }
    existB[B[i]]=true;
  }
  if (!ok) {
    printf("0\n");
    return 0;
  }
  int afound = 0, bfound = 0;
  Mint ans(1);
  for (int i=N*M; i>0; i--) {
    //printf("i=%d\n", i);
    if (existA[i] && existB[i]) {
      afound++;
      bfound++;
    } else if (existA[i]) {
      afound++;
      ans *= Mint(bfound);
    } else if (existB[i]) {
      bfound++;
      ans *= Mint(afound);
    } else {
      int amari = afound*bfound-(N*M-i);
      if (amari<=0) {
        printf("0\n");
        return 0;
      }
      ans *= Mint(amari);
    }
    //printf("ans=%lld\n", ans.x);
  }
  std::cout << ans.x << std::endl;
  return 0;
}

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

using namespace std;

int n, k;
int stones[100];
bool memo[100001] = {};
bool done[100001] = {};

bool dp(int rem)
{
    if (done[rem])
    {
        return memo[rem];
    }

    for (int i = 0; i < n; i++)
    {
        if (rem - stones[i] < 0)
        {
            done[rem] = true;
            return memo[rem] = false;
        }
        if (!dp(rem - stones[i]))
        {
            done[rem] = true;
            return memo[rem] = true;
        }
    }
    done[rem] = true;
    return memo[rem] = false;
    
}

int main(void)
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &stones[i]);
    }
    if (dp(k))
        printf("First\n");
    else
        printf("Second\n");
}

Measured memory_bytes: 7028
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=3000 +117;
const int MM=10000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int l,n;
int a[NN]={};
const LD pi=3.1415926535897932385;
int main(){
	//open();
	n=read();
	l=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	LD x=0;
	LD y=0;
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			LD rad=(a[i]+a[j])/2.0/l;
			int cnt=n-(j-i+1);
			x+=cos(rad*2*pi)*cnt;
			y+=sin(rad*2*pi)*cnt;
			rad+=1/2.0;
			cnt=j-i-1;
			x+=cos(rad*2*pi)*cnt;
			y+=sin(rad*2*pi)*cnt;
		}
	}
	LD all=(LD)n*(n-1)*(n-2)/6;
	x/=all;
	y/=all;
	printf("%.11Lf %.11Lf\n",x,y);
	close();
	return 0;
}

Measured memory_bytes: 384
import sys
# from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
# from heapq import heapify, heappop, heappush
# from math import floor, ceil,pi,factorial
# from operator import itemgetter
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9 + 7

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

aa = list(accumulate([0]+a))
bb = list(accumulate([0]+b))

ans = 0
for i in range(len(aa)):
    sub = k-aa[i]
    cnt = 0
    if 0 <= sub:
        cnt += i
        t = bisect_right(bb, sub)
        if 0 < t: cnt += t-1
    ans = max(ans, cnt)

print(ans)


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e5+3;
const int INF = 1e9;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    //int ntest; cin >> ntest; while(ntest--)
    {
        int n,m,x; cin >> n >> m >> x;
        vector<int> c(n);
        vector<vector<int>> a(n, vector<int>(m));
        fori(i,n) {
            cin >> c[i];
            fori(j,m) cin >> a[i][j];
        };

        int ans = INF;
        fore(b,1,1<<n) {
            int cost = 0;
            vector<int> r(m);
            fori(i,n) {
                if((b>>i)&1) {
                    cost += c[i];
                    fori(j,m) {
                        r[j] += a[i][j];
                    }
                }
            }
            int ok = 1;
            fori(j,m) ok &= r[j] >= x;

            if(ok) mmin(ans, cost);
        }

        if(ans == INF) ans = -1;
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long a[n],i,sum=0;
    map<long long,long long> m;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        m[a[i]]++;
    }
    long long q,b,c,t;
    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        t=m[b];
        sum-=(t*b);
        sum+=(t*c);
        m[b]=0;
        m[c]+=t;
        cout<<sum<<endl;
    }
    return 0;
}


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

using namespace std;

int main(){
  int i, n, m, ohajiki;
  vector<int> sequence;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> m;
      sequence.push_back(m);
    }

    i = 0;
    ohajiki = 32;
    while(1){
      ohajiki = ohajiki - ((ohajiki - 1) % 5);
      cout << ohajiki << endl;
      if(ohajiki == 0) break;

      if(sequence[i] >= ohajiki) ohajiki = 0;
      else ohajiki -= sequence[i];
      cout << ohajiki << endl;
      if(ohajiki == 0) break;
      if(i == sequence.size()-1) i = 0;
      else ++i;
    }

    sequence.clear();
  }

  return 0;
}

Measured memory_bytes: 0
n = int(input())
s = str(input())

l = [chr(i) for i in range(65,65+26)]*2

alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
    alpha_dict[chr(c)] = i

ans = ''
for i in range(len(s)):
  j = alpha_dict[s[i]]
  ans += l[j+n]
  
print(ans)

Measured memory_bytes: 3064
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 1e5 + 10;
string s;
int n;

void solve() {
	cin >> n;
	while (n > 0) {
		if (n % 10 == 7) {
			cout << "Yes";
			return;
		}
      n /= 10;
	}
	cout << "No";
}
int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 3616
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
struct node{
    long long n;
    int id;
}seq[100005];
long long A[100005],B[100005];
bool cmp(node a,node b){
    return a.n > b.n;
}
int main(){
    long long t;
    std::cin >> t;
    long long t1,t2;
    for(int i = 1; i <= t; i++){
        std::cin >> t1 >> t2;
        seq[i].n = t1 + t2;
        seq[i].id = i;
        A[i] = t1;
        B[i] = t2;
    }
    std::sort(seq + 1, seq + 1 + t,cmp);
    int cnt = 0;
    long long res = 0;
    while(cnt <= t){
        cnt++;
        if (cnt % 2) res += A[seq[cnt].id];
        else res -= B[seq[cnt].id];
    }
    std::cout << res ;
}


Measured memory_bytes: 3328
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def f1(ss):
	return (len(ss)-1)*9

def f2(ss):
	ll=len(ss)
	return (((ll-1)*(ll-2))//2)*9*9
	
def f3(ss):
	ll=len(ss)
	return (((ll-1)*(ll-2)*(ll-3))//6)*9*9*9
	
def fk1(ss):
	aa=int(ss[0])
	return aa+f1(ss)
	
def fk2(ss):
	aa=int(ss[0])
	ret=f2(ss)
	ret+=(aa-1)*f1(ss)
	for i, c in enumerate(ss):
		if i == 0:
			continue
		if int(c)>0:
			ret += fk1(ss[i:])
			break
	return ret
	
def fk3(ss):
	aa=int(ss[0])
	ret = f3(ss)
	ret += (aa-1)*f2(ss)
	for i, c in enumerate(ss):
		if i == 0:
			continue
		if int(c)>0:
			ret += fk2(ss[i:])
			break
	return ret	

def main():
	n = input()
	k = int(input())
	if k== 1:
		return fk1(n)
	elif k==2:
		return fk2(n)
	else:
		return fk3(n)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364;

int main(){
	int t; cin>>t;
	rep(q,t){
		int n,d; cin>>n>>d;
		priority_queue<int,vector<int>,greater<int>>  pq;
		pq.push(d);
		rep(i,n-1){
			int x=pq.top(); pq.pop();
			int y=127^x;
			pq.push(127);
			pq.push(y);
		}
		long long ans=0;
		while(pq.size()){ans+=pq.top();pq.pop();}
		cout<<ans<<endl;
	}
	return 0;
}


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

#define fs first
#define sc second

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    cout << max({a + b, a - b, a * b}) << endl;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>

int main()
{
	int N;
	std::cin >> N;
	int* d = new int[N];
	for (int i=0; i<N; i++) std::cin >> d[i];
	std::sort(d, d+N);
	std::cout << d[N/2] - d[N/2-1] << std::endl;
	delete[] d;
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

template <typename T> T hungarian(vector<vector<T>>& A) {
    const T inf = numeric_limits<T>::max();
    const int N = (int)A.size();
    const int M = (int)A[0].size();
    vector<int> P(M), way(M);
    vector<T> U(N, 0), V(M, 0), minV;
    vector<bool> used;

    for (int i = 0; i < N; ++i) {
        P[0] = i;
        minV.assign(M, inf);
        used.assign(M, false);
        int j0 = 0;
        while (P[j0]) {
            int i0 = P[j0], j1 = 0;
            used[j0] = true;
            T delta = inf;
            for (int j = 1; j < M; ++j) {
                if (used[j]) continue;
                T curr = A[i0][j] - U[i0] - V[j];
                if (curr < minV[j]) minV[j] = curr, way[j] = j0;
                if (minV[j] < delta) delta = minV[j], j1 = j;
            }
            for (int j = 0; j < M; ++j) {
                if (used[j]) U[P[j]] += delta, V[j] -= delta;
                else minV[j] -= delta;
            }
            j0 = j1;
        }
        do {
            P[j0] = P[way[j0]];
            j0 = way[j0];
        } while (j0);
    }
    return -V[0];
}

int N;
vector<int> v[100];

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

    while (cin >> N, N) {
        int sum = 0;
        REP (i, N) {
            int mul = 1;
            v[i].resize(3);
            REP (j, 3) cin >> v[i][j], mul *= v[i][j];
            sort(v[i].begin(), v[i].end());
            sum += mul;
        }
        vector<vector<int>> A(N + 1, vector<int>(N + 1));
        REP (i, N) REP (j, N) if (i != j) {
            int yes = 1;
            REP (k, 3) yes &= (v[i][k] < v[j][k]);
            if (yes) A[i + 1][j + 1] = -(v[i][0] * v[i][1] * v[i][2]);
        }
        cout << sum + hungarian<int>(A) << endl;
    }
}


Measured memory_bytes: 3152
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	A := make([]int, n)
	for i := range A {
		A[i] = nextInt()
	}
	sort.Ints(A)
	S := make([][]bool, 1000001)
	for i := range S {
		S[i] = make([]bool, 2)
	}
	for _, a := range A {
		if !S[a][1] {
			if S[a][0] {
				S[a][0] = false
				S[a][1] = true
				continue
			}
			S[a][0] = true
			for j := 2; 1000001 > j*a; j++ {
				S[j*a][1] = true
			}
		}
	}
	ans := 0
	for _, a := range A {
		if S[a][0] {
			ans += 1
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 31436
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

vector<int> make_prime_table(int n)
{
	vector<int> p(n + 1, 0);
	iota(p.begin(), p.end(), 0);
	p[0] = 0;
	p[1] = 0;
	p[2] = 2;
	for (int i = 2; i * i <= n; ++i) {
		if (p[i]) {
			for (int j = i * i; j <= n; j += i) {
				p[j] = 0;
			}
		}
	}
	return p;
}

int main()
{
	const int N = 100000;
	auto p = make_prime_table(N);
	vector<int> like2017(N + 1);

	like2017[0] = 0;
	for (int i = 1; i <= N; ++i) {
		like2017[i] = like2017[i - 1] + (p[i] && p[(i + 1) / 2]);
	}
	
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int l, r;
		cin >> l >> r;
		int ans = like2017[r] - like2017[l - 1];
		cout << ans << endl;
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  
  if (n[0] == n[1] && n[1] == n[2]){
    cout << "Yes" << endl;
  }else if (n[1] == n[2] && n[2] == n[3]){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

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

int main(void){
    int h,w;
    while(true){
        cin >> h >> w;
        if(w==0 && h==0) return 0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] list = new int[n];

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

        int count = 0;
        loop : while (true) {
            boolean isStart = false;
            for (int i = 0; i < n; i++) {
                if (list[i] == 0) {
                    if (isStart) {
                        break;
                    } else if (i == n - 1){
                        break loop;
                    }
                }
                else {
                    if (!isStart) {
                        isStart = true;
                        count++;
                    }
                    list[i]--;
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
bool sortbysec(const pair<pair<string,int>,int> &a, 
              const pair<pair<string,int>,int> &b) 
{ 
	if(a.first.first==b.first.first)
		return a.first.second > b.first.second;
    return (a.first.first < b.first.first); 
} 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<pair<pair<string,int>,int>>A(n);
       for(ll i=0;i<n;i++)
       {
           cin>>A[i].first.first>>A[i].first.second;
           A[i].second=i+1;
       }
       sort(A.begin(),A.end(),sortbysec);
       for(ll i=0;i<n;i++)
       {
           cout<<A[i].second<<endl;
       }
    } 
    return 0;
}


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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

void f(int n){
  if(n >= 10) f(n / 10);
  int k = n % 10;
  if(k == 9) cout << '1';
  if(k == 1) cout << '9';
}

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

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  int n; cin >> n;
  f(n); 
  cout << endl;
     
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for(int i=0; i<n; i++){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end()); sort(b.begin(), b.end());
  if(n&1){
    cout << b[n/2]-a[n/2]+1 << endl;
  }
  else{
    cout << b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1 << endl;
  }
}


Measured memory_bytes: 4760
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def meguru_bisect(left, right):
        """
        is_okを定義して下さい
        :param left: 取りうる最小の値-1
        :param right: 取りうる最大の値+1
        :return: is_okを満たす最小(もしくは最大)の値
        """
        while abs(left - right) > 1:
            mid = (left + right) // 2
            if is_ok(mid):
                right = mid
            else:
                left = mid
        return right

    def is_ok(x):
        total = 0
        for i in range(n):
            total += max(0, A[i] - x // F[i])
        return total <= k

    n, k = map(int, input().split())
    A = sorted(list(map(int, input().split())))
    F = sorted(list(map(int, input().split())), reverse=True)

    left = -1
    right = 10 ** 12 + 1
    res = meguru_bisect(left, right)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 108620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstdlib>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cassert>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = (int)1e5 + 1;
const ld EPS = 1e-9;
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e9 + 10;
const ld PI = acosl(-1);
const int N = (int)1e6 + 2;


int a[N];

void solve() {
	int n, k, s;
	cin >> n >> k >> s;
	for (int i = 0; i < k; i++) {
		a[i] = s;
	}

	int val = 0;
	for (int j = 2; ; j++) {
		if (s % j != 0) {
			val = j;
			break;
		}
	}
	for (int i = k; i < n; i++) {
		a[i] = val;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	//auto trash = freopen("a.in", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}

Measured memory_bytes: 1664
#include <stdio.h>

long long max(long x, long y){return x>y ? x: y;}

int main(void){
    long long a,b,c,d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
   
    printf("%lld", max(a*c, max(a*d, max(b*c, b*d))));
    
    return 0;
}

Measured memory_bytes: 1688
using System;
using System.Collections.Generic;
using System.Linq;

namespace AGC012
{
    public class B
    {
        private void Run()
        {
            var input = Console.ReadLine().Trim().Split();
            var N = int.Parse(input[0]);
            var M = int.Parse(input[1]);

            var edges = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();

            while (M-- > 0)
            {
                input = Console.ReadLine().Trim().Split();
                var a = int.Parse(input[0]) - 1;
                var b = int.Parse(input[1]) - 1;
                edges[a].Add(b);
                edges[b].Add(a);
            }

            var Q = int.Parse(Console.ReadLine().Trim());
            var queries = new List<Tuple<int, int, int>>();
            while (Q-- > 0)
            {
                input = Console.ReadLine().Trim().Split();
                var v = int.Parse(input[0]) - 1;
                var d = int.Parse(input[1]);
                var c = int.Parse(input[2]);
                queries.Add(Tuple.Create(v, d, c));
            }

            var color = new int[N];
            var maxUsedDistance = new int[N];
            foreach (var query in queries.AsEnumerable().Reverse())
            {
                var v = query.Item1;
                var d = query.Item2;
                var c = query.Item3;

                var q = new Queue<Tuple<int, int>>();
                q.Enqueue(Tuple.Create(v, d));
                while (q.Count > 0)
                {
                    var t = q.Dequeue();
                    var index = t.Item1;
                    var rest = t.Item2;

                    if (color[index] == 0) { color[index] = c; }
                    if (rest == 0) { continue; }
                    if (maxUsedDistance[index] >= rest) { continue; }
                    maxUsedDistance[index] = rest;

                    foreach (var edge in edges[index])
                    {
                        if (maxUsedDistance[edge] > rest - 1) { continue; }
                        q.Enqueue(Tuple.Create(edge, rest - 1));
                    }
                }
            }
            Console.WriteLine(string.Join(Environment.NewLine, color));
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new B().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  if(N%2==0){
    printf("%lf\n",0.5);
    return 0;
  }
  printf("%lf\n",(double)(N+1)/(2*N));
  return 0;
}

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

const int maxn = 1e5;
int a[maxn + 10], s[maxn + 10];
int n;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);	cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        s[i] = s[i - 1] + abs(a[i] - a[i - 1]);
    }
    for (int i = 1; i < n; ++i)
        cout << s[i - 1] + (s[n] - s[i + 1]) + abs(a[i + 1] - a[i - 1]) + abs(a[n]) << '\n';
    cout << s[n - 1] + abs(a[n - 1]);
}


Measured memory_bytes: 2048
#include<cstdio>
#define MAXN 10000
int n;
int a[MAXN+5],b[MAXN+5];
int main()
{
	long long timesa=0LL,timesb=0LL;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=b[i])
		{
			if(a[i]>b[i])
				timesb+=1LL*a[i]-1LL*b[i];
			else if(a[i]<b[i])
			{
				if((b[i]-a[i])%2==0)
					timesa+=1LL*(b[i]-a[i])/2;
				else
				{
					timesa+=1LL*(b[i]-a[i])/2+1LL;
					timesb+=1LL;
				}
			}
		}
	}
	if(timesa>=timesb)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	double weight;
	
	while (cin >> weight) {
		if (weight <= 48.0) cout << "light fly"; 
		else if (weight <= 51.0) cout << "fly";
		else if (weight <= 54.0) cout << "bantam";
		else if (weight <= 57.0) cout << "feather";
		else if (weight <= 60.0) cout << "light";
		else if (weight <= 64.0) cout << "light welter";
		else if (weight <= 69.0) cout << "welter";
		else if (weight <= 75.0) cout << "light middle";
		else if (weight <= 81.0) cout << "middle";
		else if (weight <= 91.0) cout << "light heavy";
		else cout << "heavy";
		cout << endl;
	}
	
	return 0;
}

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

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

    int num = 0;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if(500*i + 100*j + 50*k == x){
                    num++;
                }
            }
        }
    }
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 256
def walk(x, y):
        #print x,y
        global s
        global c
        global v
        if 0 <= x < w and 0 <= y < h:
                if v[y][x] is False:
                        if s[y][x] == '@' or s[y][x] == '.':
                                v[y][x] = True
                                c += 1
                                #print 'hai'
                                walk(x-1, y)
                                walk(x, y-1)
                                walk(x+1, y)
                                walk(x, y+1)

while 1:
        c = 0
        w,h = map(int, raw_input().split())
        if w == 0 and h == 0: break
        s = ['' for i in xrange(h)]
        v = [[False for j in xrange(w)] for i in xrange(h)]
        for i in xrange(h):
                s[i] = raw_input()
        for i in xrange(w):
                for j in xrange(h):
                        if s[j][i] == '@':
                                walk(i, j)
        #print v
        print c

Measured memory_bytes: 18000
fun main(args: Array<String>) {
    val a = readIntList()
    val sum = a.sum()
    if (sum >= 22) {
        println("bust")
    } else {
        println("win")
    }
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 36416
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();
    
    string n;
    cin >> n;
    int a = 0;
    FOR(i, 1, n.length())if (n[i] != '9')a = 1;
    cout << n[0] - '0' + 9 * (n.length() - 1) - a << "\n";
}



Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))

A = []
for i in range(N):
    A.append(i+1)

count=0
for j in range(N):
    if A[j] != P[j]:
        count += 1

if count == 2 or count == 0:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 3060