akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

P dp[300005];

void update(P& a, P b){
    if(a.first < b.first){
        a.second = max(a.first, b.second);
        a.first = b.first;
    }
    else    chmax(a.second, b.first);
    return;
}

int get_value(P& a){
    return a.first + a.second;
}

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

    int n;
    cin >> n;
    int sz = 1;
    for(int i = 0; i < n; ++i)  sz *= 2;
    vector<int> a(sz);
    for(int i = 0; i < sz; ++i){
        cin >> a[i];
        dp[i] = P(a[i], 0);
    }

    // 高速ゼータ変換
    for(int i = 0; i < n; ++i){
        for(int k = 0; k < sz; ++k){
            if(k & (1 << i)){
                update(dp[k], dp[k ^ (1 << i)]);
            }
        }
    }

    int res = 0;
    for(int k = 1; k < sz; ++k){
        chmax(res, get_value(dp[k]));
        cout << res << "\n";
    }
}

Measured memory_bytes: 6144
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,d;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	a=max(a,c);
	b=min(b,d);
	printf("%d",max(0,b-a));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 3) if(s[i] == t[i]) ans++;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N, K;
  cin >> N >> K;
  if (K <= (N + 1) / 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i,j;
  char x[101]={},y[101]={},k[10];
  int c,d;
  scanf("%s%s",x,y);
  c=strlen(x);
  d=strlen(y);
  if(c>d){
    printf("GREATER\n");
    return 0;
  }
  else if(c<d){
    printf("LESS\n");
    return 0;
  }
  int count=(c-1)/9+1;
  long a[count],b[count];
  for(i=0;i<count;i++){
    for(j=0;j<10;j++){
      k[j]=' ';
    }
    strncpy(k,x+i*9,9);
    k[10]='\0';
    // printf("%s\n",k);
    a[i]=atol(k);
    for(j=0;j<10;j++){
      k[j]=' ';
    }
    strncpy(k,y+i*9,9);
    k[10]='\0';
    b[i]=atol(k);
  }
  for(i=0;i<count;i++){
    if(a[i]>b[i]){
      printf("GREATER\n");
      break;
    }
    else if(a[i]<b[i]){
      printf("LESS\n");
      break;
    }
    else if(i=count){
      printf("EQUAL\n");
    }
  }
  // printf("%s\n",x);
  // for(i=0;i<count;i++){
  //   printf("%ld %ld\n",a[i],b[i]);
  // }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

bool judge(int x) {
  string s;
  while (x) {
    s.push_back(x % 10);
    x /= 10;
  }
  for (int i = 0; i < s.size() / 2; ++i)
    if (s[i] != s[s.size() - i - 1]) return false;
  return true;
}

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  for (int i = a; i <= b; ++i) if (judge(i)) cnt++;
  cout << cnt << endl;
}


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

# listのINNER JOINを繰り返して、最後にlistの要素数を返す
list_1st = input().split()[1:]

for i in range(N-1):
  list_tmp = input().split()[1:]
  # list_1st = list(set(list_1st) & set(list_tmp))
  list_1st = [x for x in list_1st if x in list_tmp]

if N == 1:
  print(len(list_1st))
else:
  l_output = [i for i in list_1st if i != ' ']
  print(len(l_output))

Measured memory_bytes: 3064
package main

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

func gcd(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func solve(K int64) {
	ans := int64(0)
	for i := int64(1); i <= K; i++ {
		for j := int64(1); j <= K; j++ {
			for k := int64(1); k <= K; k++ {
				ans += gcd(i, gcd(j, k))
			}
		}
	}
	fmt.Println(ans)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var K int64
	scanner.Scan()
	K, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	solve(K)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<long long> A){
    ll sum=0;
    rep(i,N)sum+=A[i];

    sort(all(A));
    
    ll val=A[N-M];
    if(sum>4*val*M){
        cout<<NO<<endl;
    }else{
        cout<<YES<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            var abc = Console.ReadLine().Split().Select(double.Parse).ToArray();

            var sin = Math.Sin(Math.PI / 180 * abc[2]);
            var cos = Math.Cos(Math.PI / 180 * abc[2]);

            var s = abc[0] * abc[1] * Math.Sin(Math.PI / 180 * abc[2]) / 2;
            var l = abc[0] + abc[1] + Math.Sqrt(Math.Pow(abc[0], 2) + Math.Pow(abc[1], 2) - 2 * abc[0] * abc[1] * cos);
            var h = abc[1] * Math.Sin(Math.PI / 180 * abc[2]);

            Console.WriteLine(s.ToString("0.00000"));
            Console.WriteLine(l.ToString("0.00000"));
            Console.WriteLine(h.ToString("0.00000"));
        }
    }
}



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

int N, M;
int X[100000], Y[100000], Z[100000];
int ans;
vector< vector< pair<int, int> > > G(100001);
vector<bool> isVisited(100001); 

void dfs(vector< pair<int, int> > v){

    for(int i=0;i<v.size();i++){
        if( !isVisited[ v[i].first ] ){
            isVisited[ v[i].first ] = true;
            dfs(G[ v[i].first ]);
        }
    }
    return;
}

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++)    cin >> X[i] >> Y[i] >> Z[i];

    for(int i=0;i<M;i++){
        G[ X[i] ].push_back( make_pair(Y[i], Z[i]) );
        G[ Y[i] ].push_back( make_pair(X[i], Z[i]) );
    }

    for(int i=1;i<=N;i++){
        if( !isVisited[i] ){
            isVisited[i] = true;
            dfs(G[i]);
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 19456
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int , null_type,less<int , rb_tree_tag,tree_order_statistics_node_update>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 100000000
// order_of_key and *find_by_order

int32_t main() {
	fast;
	int n;
	cin >> n;
	int a[n];
	map<int , int > m;
	int to = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		to += a[i];
		m[a[i]]++;
	}
	int q;
	cin >> q;
	while (q--) {
		int b, c;
		cin >> b >> c;
		to -= m[b] * b;
		to += m[b] * c;
		m[c] += m[b];
		m[b] = 0;
		cout << to << "\n";
	}







}

Measured memory_bytes: 10228
list = []

n = gets.to_i
n.times do
  c, x = gets.split

  case c
  when 'insert'
    list.unshift(x)
  when 'delete'
    list.delete_at(list.index(x)) if list.index(x)
  when 'deleteFirst'
    list.shift
  when 'deleteLast'
    list.pop
  end
end

puts list.join("\s")

Measured memory_bytes: 97908
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

char board[23 * 23];
int way[4] = { -1,1,-23,23 };
int gCount;

void solve(int pos) {
	gCount++;
	board[pos] = '#';
	for (int i = 0; i < 4; i++) 
		if (board[pos + way[i]] == '.') 
			solve(pos + way[i]);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	while (cin >> W >> H, W) {
		for (int i = 0; i < 23 * 23; i++)
			board[i] = '#';
		gCount = 0;
		int s;
		for (int y = 1; y <= H; y++)
			for (int x = 1; x <= W; x++) {
				cin >> board[y * 23 + x];
				if (board[y * 23 + x] == '@') 
					s = y * 23 + x;
			}
		solve(s);
		cout << gCount << endl;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];
    double s = 0, res;
    REP(i, n) s += (1.0 / a[i]);
    res = 1.0 / s;
    printf("%.7lf\n", res);
    return 0;
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        final String S = sc.next();
        
        
                
        out.println(S.equals("ABC") ? "ARC" : "ABC");

        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 32488
#include <iostream>
using namespace std;
int main(){
  string s,t;cin>>s>>t;
  bool cann;
  bool canwrite = false;
  if(s.size() < t.size()){
    cout << "UNRESTORABLE" << endl;
  }else{
    for(int i = s.size()-t.size();0 <= i; i--){
      bool cann = true;
      for(int j = 0; t.size() > j;j++){
        if(!(t[j] == s[i+j] || s[i+j] == '?')){
          cann = false;
          break;
        }
      }
      if(cann){
        for(int j = 0; t.size() > j; j++){
          s[i+j] = t[j];
        }
        for(int j = 0; s.size() > j; j++){
          if(s[j] == '?')cout << "a";
          else cout << s[j];
        }
        cout << endl;
        canwrite = true;
        break;
      }
    }
    if(!canwrite)cout << "UNRESTORABLE" << endl;
  }
}

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

class Program
{
    static void Main(string[] args)
    {
        var X = int.Parse(Console.ReadLine());
        string result = null;
        if (X == 7 || X == 5 || X == 3)
        {
            result = "YES";
        }
        else
        {
            result = "NO";
        }

        Console.WriteLine(result);

    }

}



Measured memory_bytes: 11092
package main

import (
	"fmt"
)

func main() {
	var n, ga, sa, ba, gb, sb, bb int
	fmt.Scan(&n)
	fmt.Scan(&ga)
	fmt.Scan(&sa)
	fmt.Scan(&ba)
	fmt.Scan(&gb)
	fmt.Scan(&sb)
	fmt.Scan(&bb)

	dp1 := make([]int, n+1)
	for i := 0; i <= n; i++ {
		max := i
		if i >= ga {
			x := gb + dp1[i-ga]
			if x > max {
				max = x
			}
		}
		if i >= sa {
			x := sb + dp1[i-sa]
			if x > max {
				max = x
			}
		}
		if i >= ba {
			x := bb + dp1[i-ba]
			if x > max {
				max = x
			}
		}
		dp1[i] = max
	}
	m := dp1[n]

	dp2 := make([]int, m+1)
	for i := 0; i <= m; i++ {
		max := i
		if i >= gb {
			x := ga + dp2[i-gb]
			if x > max {
				max = x
			}
		}
		if i >= sb {
			x := sa + dp2[i-sb]
			if x > max {
				max = x
			}
		}
		if i >= bb {
			x := ba + dp2[i-bb]
			if x > max {
				max = x
			}
		}
		dp2[i] = max
	}

	fmt.Println(dp2[m])
	/*
	var resolve1 func(n int) int
	resolve1 = func(n int) int {
		if _, ok := dp1[n]; ok {
			return dp1[n]
		}

		max := n
		if n >= ga {
			x := gb + resolve1(n-ga)
			if x > max {
				max = x
			}
		}
		if n >= sa {
			x := sb + resolve1(n-sa)
			if x > max {
				max = x
			}
		}
		if n >= ba {
			x := bb + resolve1(n-ba)
			if x > max {
				max = x
			}
		}
		dp1[n] = max
		return max
	}
	dp2 := make(map[int]int)
	var resolve2 func(n int) int
	resolve2 = func(n int) int {
		if _, ok := dp2[n]; ok {
			return dp2[n]
		}

		max := n
		if n >= gb {
			x := ga + resolve2(n-gb)
			if x > max {
				max = x
			}
		}
		if n >= sb {
			x := sa + resolve2(n-sb)
			if x > max {
				max = x
			}
		}
		if n >= bb {
			x := ba + resolve2(n-bb)
			if x > max {
				max = x
			}
		}
		dp2[n] = max
		return max
	}
	*/

	// fmt.Println(resolve2(resolve1(n)))
}


Measured memory_bytes: 202240
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
line = sorted(list(map(int,input().split())))
anss = [i for i in range(max(line)+2)]
for i in range(n):
  anss.remove(line[i])
anss.append(x)
ans = sorted(anss)
a = []
for i in range(len(ans)):
  if ans[i] == x:
    a = ans[i-1:i+2]
    break
low = a[1]-a[0]
high = a[2] - a[1]
if high < low:
  print(a[2])
else:
  print(a[0])

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

using namespace std;

int main()
{
	int n[3];

	cin >> n[0] >> n[1] >> n[2];

	sort(n, n + 3);
	cout << n[0] << " " << n[1] << " " << n[2] << endl;

	return 0;
}


Measured memory_bytes: 3136
#include<iostream>

using namespace std;

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

	if (a == 0)cout << b / x + 1 << endl;
	else if (b == 0)cout << 1 << endl;
	else  cout << b / x - (a - 1) / x << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=1e5+5,mod=1e9+7;
int ans=1,n,a[N],d[N],vis[N],is[N],cnt[N],dis[N],f[N];

void work(int u){
    int len=0,s=-1,sd,las;
    while(is[u]){
	is[u]=0,++len;
	if(dis[u]){
	    if(!~s)s=len,sd=dis[u];
	    else ans=1ll*ans*((dis[u]<=len-las)+(dis[u]<len-las))%mod;
	    las=len;
	}
	u=a[u];
    }
    if(!~s)++cnt[len];
    else ans=1ll*ans*((sd<=s+len-las)+(sd<s+len-las))%mod;
}

int main(){
    //freopen("in.in","r",stdin);
    REP(i,1,n=read())a[i]=read(),++d[a[i]];
    REP(u,1,n){
	if(vis[u])continue;
	int p=u;while(!vis[p])vis[p]=u,p=a[p];
	if(vis[p]!=u)continue;
	while(!is[p])is[p]=1,p=a[p];
    }
    REP(i,1,n)if((is[i]&&d[i]>2)||(!is[i]&&d[i]>1))return puts("0"),0;
    REP(i,1,n)if(!d[i]){
	int p=i,l=0;
	while(!is[p])++l,p=a[p];
	dis[p]=l;
    }
    REP(i,1,n)if(is[i])work(i);
    REP(l,1,n){
	if(!cnt[l])continue;
	f[0]=1;
	REP(i,1,cnt[l]){
	    if(l>1&&l&1)f[i]=2ll*f[i-1]%mod;//i->p_i + i->p_{p_i}(同构)
	    else f[i]=f[i-1];//i->p_i
	    if(i>1)f[i]=(f[i]+1ll*f[i-2]*(i-1)%mod*l%mod)%mod;//i->p_{p_i}(变成2个环)
	}
	ans=1ll*ans*f[cnt[l]]%mod;
    }
    printf("%d\n",ans);
    return 0;
}
/*
 对于一个排列p_i,i向p_i连边,形成若干简单环(每个点入度出度都为1)
 a_i是p_i或p_{p_i},反映到现图上就是点i的下一个点或下下个点
 把p_i的边擦除,连i->a_i的边
 会有4中种情况,分别讨论一下
 现在就是给定a_i的图还原成p_i的图
 */


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k) cout<<s<<endl;
else{
  rep(i,k) cout<<s[i];
cout<<"..."<<endl;
}
return 0;
}

Measured memory_bytes: 3624
n=int(input())
p=[]
for i in range(n):
	s,t=map(str,input().split())
	t=int(t)
	p.append([s,t])
x=input()
ans=0
f=0
for i in range(n):
	if p[i][0]==x:
		f=1
	elif f:
		ans+=p[i][1]
print(ans)

Measured memory_bytes: 3064
from sys import stdin
import math

def distance(x,y):
    xx = x * x
    yy = y * y

    xxyy = xx + yy
    d = math.sqrt(xxyy)
    return d

def main():
    n, dis = [int(x) for x in stdin.readline().rstrip().split()]

    cnt = 0
    for _ in range(n):
        x, y = [int(x) for x in stdin.readline().rstrip().split()]
        d = distance(x,y)
        if d <= dis:
            cnt += 1

    print(cnt)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
from collections import Counter
s = list(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

ans = 0
for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
        ans += 1
print(ans)

Measured memory_bytes: 49392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string a,b;
    cin >>a>>b;
    string S=a+b;
    ll N=stoi(S);
    ll sn = sqrt(N);
    if(sn*sn==N){
        cout<<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }
    
    


    return 0;
    

}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

int main() {
	ll x, y;
	cin >> x >> y;

	ll ans = INF;
	if (x <= y) ans = min(ans, y - x);
	if (x * y <= 0) ans = min(ans, abs(abs(y) - abs(x)) + 1);
	if (y < x) ans = min(ans, abs(abs(y) - abs(x)) + 2);
	cout << ans;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>


using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()
int F[110][10];
ll P[110][11];
int n;
ll ans = -1000000000;
int a[10];
int check[10] = { 0,0,0,0,0,0,0,0,0,0 };

void func()
{
	if (equal(begin(a),end(a),begin(check)))return;

	ll score = 0;
	rep(i, 0, n - 1)
	{
		int count = 0;
		rep(j, 0, 9)
		{
			if (a[j] == 1 && F[i][j] == 1)
			{
				++count;
			}
		}
		score += P[i][count];
	}
	ans = max(ans, score);
}

void dfs(int pos)
{
	if (pos == 10)
	{
		func();
		return;
	}
	a[pos] = 0; dfs(pos + 1);
	a[pos] = 1; dfs(pos + 1);
}

int main()
{
	cin >> n;
	rep(i, 0, n - 1)rep(j, 0, 9)cin >> F[i][j];
	rep(i, 0, n - 1)rep(j, 0, 10)cin >> P[i][j];
	dfs(0);
	cout << ans << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
num=[]
for i in range(n):
    a,b=map(int,input().split())
    num.append([a,b])
str1= lambda val: val[0]
num.sort(key=str1)
numa=0
numb=0
for i in range(n):
    numa+=(num[i][1])*(num[i][0])
    numb+=num[i][1]
    if numb>=m:
        numa-=(numb-m)*num[i][0]
        break
print(numa)


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

int main() {
    long long N;
    cin >> N;
    map<long long,long long> A;
    long long s = 0;
    for (int i = 0; i < N; i++) {
        long long a;
        cin >> a;
        A[a]++;
        s += a;
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        long long b, c;
        cin >> b >> c;
        s -= b * A[b];
        s += c * A[b];
        A[c] += A[b];
        A[b] = 0;
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 9516
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, D = MAP()

X = [LIST() for _ in range(N)]
ans = 0
for i, j in combinations(X, 2):
	tmp = 0
	for k in range(D):
		tmp += (i[k]-j[k])**2
	if tmp**(1/2) == ceil(tmp**(1/2)):
		ans += 1
print(ans)

Measured memory_bytes: 5708
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;
    cin >> n;
    set<string> alpha;
    for (int i=0;i<=n-1;i++)
    {
        string a;
        cin >> a;
        alpha.insert(a);
    }

    cout << alpha.size() << endl;
    return 0;
}

Measured memory_bytes: 19240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

using I = ll;
template <class F>
I lower_bound(I i0, I i1, F f) {
    while (i0 < i1) {
        I i = (i0 + i1) / 2;
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

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

    int x[3], k;
    for (int h = 0; h < 3; h++) {
        cin >> x[h];
    }
    cin >> k;

    ll s = 0;

    vector<ll> a[3];
    for (int h = 0; h < 3; h++) {
        a[h] = vector<ll>(x[h]);
        for (int i = 0; i < x[h]; i++) {
            cin >> a[h][i];
        }
        sort(a[h].begin(), a[h].end(), greater<>());
        ll t = a[h][0];
        s += t;
        for (int i = 0; i < x[h]; i++) {
            a[h][i] = t - a[h][i];
        }
    }

    //合計がl以下になる選び方がk通り以上あるか lが大きくなるほど満たされやすくなる
    ll l = lower_bound(0, s, [&](ll l) {
        int c = 0;
        for (int i0 = 0; i0 < x[0]; i0++) {
            ll s0 = a[0][i0];
            if (s0 > l) break;
            for (int i1 = 0; i1 < x[1]; i1++) {
                ll s1 = s0 + a[1][i1];
                if (s1 > l) break;
                for (int i2 = 0; i2 < x[2]; i2++) {
                    ll s2 = s1 + a[2][i2];
                    if (s2 > l) break;
                    c++;
                    if (c >= k) return true;
                }
            }
        }
        return false;
    });

    //k通り以上ある最小ののl
    vector<ll> r;
    r.reserve(k);
    for (int i0 = 0; i0 < x[0]; i0++) {
        ll s0 = a[0][i0];
        if (s0 >= l) break;
        for (int i1 = 0; i1 < x[1]; i1++) {
            ll s1 = s0 + a[1][i1];
            if (s1 >= l) break;
            for (int i2 = 0; i2 < x[2]; i2++) {
                ll s2 = s1 + a[2][i2];
                if (s2 >= l) break;
                r.push_back(s2);
            }
        }
    }
    sort(r.begin(), r.end());
    while (r.size() < k) r.push_back(l);

    for (int i = 0; i < k; i++) {
        cout << s - r[i] << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 string s;
 cin >> s;
 int n=s.size();
 rep(i,n){
     if(i%2==0)cout << s.at(i);
 }
 cout << endl;
}

Measured memory_bytes: 512
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rnk = [0] * (n + 1)

    def get_root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.get_root(self.root[x])
            return self.root[x]

    def is_same_group(self, x, y):
        return self.get_root(x) == self.get_root(y)

    def count(self, x):
        return -self.root[self.get_root(x)]

    def unite(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)

        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1


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

f = UnionFind(N + 1)

friends = {}
for _ in range(M):
    a, b = map(int, input().split())
    if friends.get(a) is None:
        friends[a] = set([b])
    else:
        friends[a].add(b)
    if friends.get(b) is None:
        friends[b] = set([a])
    else:
        friends[b].add(a)
    f.unite(a, b)

blocks = {}
for _ in range(K):
    c, d = map(int, input().split())
    if blocks.get(c) is None:
        blocks[c] = set([d])
    else:
        blocks[c].add(d)
    if blocks.get(d) is None:
        blocks[d] = set([c])
    else:
        blocks[d].add(c)


def get_number_of_blocks_in_same_group(i):
    block = blocks.get(i, [])
    return len([j for j in block if f.is_same_group(i, j)])


for i in range(1, N + 1):
    count = f.count(i)
    friend = friends.get(i, [])
    num_friends = len(friend)
    num_blocks = get_number_of_blocks_in_same_group(i)
    ans = count - num_friends - num_blocks - 1
    # print('count', count, friend, num_friends, num_blocks)
    print(ans)


Measured memory_bytes: 75732
#include <iostream>
#include <string>
using namespace std;
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(){
	string s;
	cin >> s;
	int a = s[0] - '0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] - '0';
	Rep(i, 2) Rep(j, 2) Rep(k, 2){
		int ans = a;
		ans += b * (1 - 2 * i);
		ans += c * (1 - 2 * j);
		ans += d * (1 - 2 * k);
		if(ans == 7){
			cout << a << "+-"[i]
				 << b << "+-"[j]
				 << c << "+-"[k]
				 << d << "=7" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int firs[200010];
int seco[200010];

int main() {
    int n;
    int m;
    cin >> n >> m;
    imfor(i, m) {
        int a, b;
        cin >> a >> b;
        if (a == 1) {
            firs[b] = 1;
        }
        else if (b == n) {
            seco[a] = 1;
        }
    }
    imfor(i, n + 1) {
        if (firs[i] == 1 && seco[i] == 1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


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

int N, M, I, J, num;
VII mp;

int solve(int x, int y, int cnt) {
	if (cnt == 0) {
		if (x == I || y == J) return 1;
	}

	int res = 0;
	rep(i, 4) {
		int nx = x, ny = y;
		while (true)
		{
			nx += dx[i], ny += dy[i];
			if (mp[nx][ny] == -1) break;
			if (mp[nx][ny] == 1) {
				mp[nx][ny] = 0;
				res += solve(nx, ny, cnt-1);
				mp[nx][ny] = 1;
				break;
			}
		}
	}

	return res;
}

int main() {
	while (cin >> M >> N, M)
	{
		mp = VII(N + 2, VI(M + 2, -1));
		num = 0;
		for(int i=1; i<=N; i++) {
			for(int j=1; j<=M; j++) {
				cin >> mp[i][j];
				if (mp[i][j] == 1) num++;
				else if (mp[i][j] == 2) {
					I = i; J = j;
				}
			}
		}

		cout << solve(I, J, num) << endl;
	}

	return 0;
}



Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p 998244353

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int A, B, C, D, i, j;
	scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
	vector<vector<int>> dp(C + 1, vector<int>(D + 1, 0));
	dp[A][B] = 1;
	for(i = A + 1; i <= C; i++){
		dp[i][B] = MOD(B * dp[i - 1][B]);
	}
	for(j = B + 1; j <= D; j++){
		dp[A][j] = MOD(A * dp[A][j - 1]);
	}
	for(i = A + 1; i <= C; i++){
		for(j = B + 1; j <= D; j++){
//			printf("(i, j) = (%lld, %lld)\n", i, j);
			dp[i][j] = MOD(j * dp[i - 1][j] + i * dp[i][j - 1] - (i - 1) * (j - 1) * dp[i - 1][j - 1]);
		}
	}
	printf("%lld\n", dp[C][D]);
	return 0;
}

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

const int MOD=1000000007;

int main(){
    long long n,m;
    cin>>n>>m;
    long long ans=1;
    if(abs(n-m)>1)ans=0;
    else{
        for(int i=1;i<=n;i++){
            ans*=i;
            ans%=MOD;
        }
        for(int i=1;i<=m;i++){
            ans*=i;
            ans%=MOD;
        }
        if(n==m){
            ans*=2;
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int m;
    cin >> m;
    vvi G(n);
    int k, kl;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
        k = a; 
        kl = b;
    }

    UnionFind uft(n);

    deque<int> dq;
    dq.push_front(k);
    dq.push_back(kl);
    uft.unite(k, kl);
    int cnt = 2;
    while(true) {
        bool plus = false;
        int now = dq.front();
        for(int i = G[now].size()-1; i >= 0; i--) {
            if(uft.same(G[now][i], k)) {
                G[now].pop_back();
            } else {
                dq.push_front(G[now][i]);
                plus = true;
                cnt++;
                uft.unite(k, G[now][i]);
                break;
            }
        }
        now = dq.back();
        for(int i = G[now].size()-1; i >= 0; i--) {
            if(uft.same(G[now][i], k)) {
                G[now].pop_back();
            } else {
                dq.push_back(G[now][i]);
                plus = true;
                cnt++;
                uft.unite(k, G[now][i]);
                break;
            }
        }
        if(!plus) break;
    }

    cout << cnt << endl;
    while(!dq.empty()) {
        cout << dq.front()+1 << (dq.front() == dq.back()?'\n':' ');
        dq.pop_front();
    }
}

Measured memory_bytes: 9668
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        while(true) {
            int height = scan.nextInt();
            int width = scan.nextInt();

            if(height == 0 && width == 0) {
                break;
            }
 
            for(int i = 0; i < height; i++) {
                for(int j = 0; j < width; j++) {
                    if((0 < i && i < height - 1) && (0 < j && j < width - 1)) {
                        System.out.print(".");
                    } else {
                        System.out.print("#");
                    }
                }
                System.out.println("");
            }

            System.out.println("");
        }
    }
}



Measured memory_bytes: 32660
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    
    int n;
    cin>>n;
    
    bool bb=false;
    while(n>=0){
        if(n%4==0){
            bb=true;
            break;
        }
        
        n-=7;
    }
    
    cout<<(bb?"Yes":"No")<<endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>)
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)a.size()
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl
#define debgp(a) cout<<#a<<" "<<a.fi<<" "<<a,se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(const auto&y:a){for(const auto&x:y)cout<<x<<" ";cout<<endl;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define PQ priority_queue
typedef long long ll;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<PL> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<class T>T gcd(T a,T b){return (b==0?a:gcd(b,a%b));}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*a;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  VL a(n);
  rep(i,n)cin>>a[i];
  SORT(a);
  int mx=*(a.end()-1);
  a.erase(a.end()-1);
  int center=(mx+1)/2;
  auto itr=upper_bound(all(a),center);
  int ans;
  if(itr==a.end())ans=*(itr-1);
  else if(itr==a.begin())ans=*itr;
  else{
    int dif=*itr-center;
    if(center-*(itr-1)<dif)ans=*(itr-1);
    else ans=*itr;
  }
  cout<<mx<<" "<<ans<<endl;
  
  
  
  return 0;
}


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

int main()
{
	int H, N, sum=0; cin >> H >> N;
	vector<int> A(N); rep(i, N) cin >> A[i]; 
	string ans = "No";
	rep(i, N) sum += A[i];
	if (sum >= H) ans = "Yes";
	cout << ans << endl;
}


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

using namespace std;

#define ll  long long
#define ld  double

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

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 4005;
const int   mod = 998244353;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

typedef pair<int,int>   ii;

int Fac[N];
int Inv[N];

int Ckn(int n,int k)    {
    if (n < k)  return  0;
    if (k < 0)  return  0;

    return  mul(Fac[n],mul(Inv[k],Inv[n - k]));
}

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

    Fac[0] = Inv[0] = 1;

    for(int i = 1 ; i < N ; ++i)    Fac[i] = mul(Fac[i - 1],i);     Inv[N - 1] = inv(Fac[N - 1],mod);
    for(int i = N - 2 ; i ; --i)    Inv[i] = mul(Inv[i + 1],i + 1);

    int k;  cin >> k;
    int n;  cin >> n;

    for(int i = 2 ; i <= k + k ; ++i)   {
        int cnt = min(k,i - 1) - max(1,i - k) + 1;
        int ans = 0;

        for(int j = 0 ; j <=  cnt / 2 ; ++j) {
            int val = mul(Ckn(cnt / 2,j),Pow(2,j));

            add(ans,mul(Ckn(n - 1 + k - cnt,j + k - cnt - 1),val));

            if (i & 1)  continue;

            add(ans,mul(Ckn(n - 2 + k - cnt,j + k - cnt - 1),val));
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int ans = n / (2 * d + 1);
  if (n % (2 * d + 1) == 0) {
    cout << ans << endl;
  } else {
    cout << ans + 1 << endl;
  }
  return 0;
}

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

int main() {
  int A,B,C,D;
  cin >>A >>B >>C >>D;
  if((A + B) > (C + D)){
    cout << "Left";
  }else if((A + B) == (C + D)){
    cout << "Balanced";
  }else{
    cout << "Right";
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int PN[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

int main(){
  int N;
  cin >> N;
  vector<int> NPN(15);
  int ans=0;
  for(int i=1; i<=N; i++){
    int temp=i;
    for(int j=0; j<15; j++){
        while(temp%PN[j]==0){
            temp=temp/PN[j];
            NPN.at(j)++;
        }
    }
  }
  vector<int> cnt(5);
  for(int i=0; i<15; i++){
      if(NPN.at(i)>=2) cnt.at(0)++;
      if(NPN.at(i)>=4) cnt.at(1)++;
      if(NPN.at(i)>=14) cnt.at(2)++;
      if(NPN.at(i)>=24) cnt.at(3)++;
      if(NPN.at(i)>=74) cnt.at(4)++;
  }
  ans+=cnt.at(1)*(cnt.at(1)-1)*(cnt.at(0)-2)/2;
  
  ans+=cnt.at(2)*(cnt.at(1)-1);
  
  ans+=cnt.at(3)*(cnt.at(0)-1);
  
  ans+=cnt.at(4);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int maxn=110;
int map[maxn][maxn];
int h,w,n;
int a[maxn*maxn];
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
void dfs(int x,int y,int k){
	if(a[k]==0)k++;
	if(k>n)return;
	map[x][y]=k;
	a[k]--;
	for(int i=0;i<4;i++){
		int lx=x+dir[i][0],ly=y+dir[i][1];
		if(lx<0||lx>=h||ly<0||ly>=w)continue;
		if(map[lx][ly])continue;
		dfs(lx,ly,k);
	}
}

int main(){
	cin>>h>>w;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dfs(0,0,1);
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++){
		if(j==0)cout<<map[i][j];
		else cout<<' '<<map[i][j];
		if(j==w-1)cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <stdlib.h>
using namespace std;


int main() {
	string s;
	cin >> s;
	int x;
	int y;
	cin >> x >> y;
	int* xMove = new int[8001];
	int* yMove = new int[8001];
	int xIdx = 0;
	int yIdx = 0;
	bool xDir = true;
	int MAX_LENGTH = 10000;
	
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'T') {
			xDir = !xDir;
			if (xDir) {
				++xIdx;
			} else {
				++yIdx;
			}
		}
		else {
			if (xDir) {
				++xMove[xIdx];
			} else {
				++yMove[yIdx];
			}
		} 
	}

	bool** xSum = new bool*[xIdx + 1];
	bool** ySum = new bool*[yIdx + 1];
	
	for (int i = 0; i < xIdx + 1; ++i) {
		xSum[i] = new bool[2 * MAX_LENGTH + 1];
		for (int j = 0; j < 2 * MAX_LENGTH + 1; ++j) {
			xSum[i][j] = false;
		}
	}
	for (int i = 0; i < yIdx + 1; ++i) {
		ySum[i] = new bool[2 * MAX_LENGTH + 1];
		for (int j = 0; j < 2 * MAX_LENGTH + 1; ++j) {
			ySum[i][j] = false;
		}
	}

	if (s.length() > 0 && s[0] == 'F') {
		xSum[0][MAX_LENGTH + xMove[0]] = true;
	} else {
		xSum[0][MAX_LENGTH + xMove[0]] = true;
		xSum[0][MAX_LENGTH - xMove[0]] = true;
	}
	
	for (int i = 1; i <= xIdx; ++i) {
		for (int sum = -MAX_LENGTH; sum <= MAX_LENGTH; ++sum) {
			xSum[i][MAX_LENGTH + sum] = xSum[i - 1][MAX_LENGTH + sum - xMove[i]] ||
			xSum[i - 1][MAX_LENGTH + sum + xMove[i]];
		}
	}
	if (!xSum[xIdx][MAX_LENGTH + x]) {
		cout << "No" << endl;
		return 0;
	}
	
	ySum[0][MAX_LENGTH - yMove[0]] = true;
	ySum[0][MAX_LENGTH + yMove[0]] = true;
	
	for (int i = 1; i <= yIdx; ++i) {
		for (int sum = -MAX_LENGTH; sum <= MAX_LENGTH; ++sum) {
			ySum[i][MAX_LENGTH + sum] = ySum[i - 1][MAX_LENGTH + sum - yMove[i]] ||
			ySum[i - 1][MAX_LENGTH + sum + yMove[i]];
		}
	}
	if (!ySum[yIdx][MAX_LENGTH + y]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 155392
// ABC166E.cpp 

#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<ll>a(n);
    vector<ll>rs(n);
    vector<ll>ls(n);
    rep(i, n) {
        cin >> a[i];
        if (i + a[i] < n) rs[i + a[i]]++;
        if (i - a[i] >= 0) ls[i - a[i]]++;
    }
    ll ans = 0;
    rep(i, n) {
        ans += (rs[i] * ls[i]);
    }
    cout << ans;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  cout << A * B << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(100);
  for (int i = 0; i < 100; i++) {
    cin >> a.at(i);
    if((i+1)%2 != 0 && a[i]%2 != 0){
      ans ++;
    }
  }
 
  cout << ans << endl;
}


Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

def main():
    S = input()
    pre = int(S[0:2])
    suf = int(S[2:4])

    if pre >= 1 and pre <= 12 and suf >= 1 and suf <= 12:
        print('AMBIGUOUS')
        exit()
    elif pre >= 1 and pre <= 12:
        print('MMYY')
        exit()
    elif suf >= 1 and suf <= 12:
        print('YYMM')
        exit()
    else:
        print('NA')



if __name__ == '__main__':
    main()



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

int		main(void)
{
	vector<int> a(3);
	int		d;
	for (int i = 0; i < 3; i++)
		cin >> a.at(i);
	cin >> d;
	if (abs(a.at(0) - a.at(2)) <= d)
		cout << "Yes" << endl;
	else
		cout << (abs(a.at(0) - a.at(1)) <= d && abs(a.at(1) - a.at(2)) <= d ? "Yes" : "No") << endl;
}

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

int main() {
	int count, i;
	long long int k;
	char a[105];
	while(scanf("%s",a)!=-1) {
		scanf("%lld",&k);
		for(i=0;i<strlen(a);i++) {
			if(a[i]!='1') {
				count = i;
				break;
			}
		}
		if(i<strlen(a)) {
			if(count<k) {
				printf("%c\n",a[i]);
			}
			else printf("1\n");
		}
		else printf("1\n");
	}
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  if (n == 1) {
    out("Hello World");
    return 0;
  }
  in(int, a, b);
  out(a + b);
}


Measured memory_bytes: 3600