akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}

	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<wData> book = new ArrayList<wData>();
		String line;

		while((line = in.readLine()) != null){
			String[] dst = line.split(" ");
			String word = dst[0];
			int page = Integer.parseInt(dst[1]);

			if(page == 0){
				break;
			}

			boolean isOverlap = false;
			for(int i=0; i<book.size(); i++){
				if(word.equals(book.get(i).word)){
					book.get(i).addPage(page);
					isOverlap = true;
					break;
				}
			}

			if(!isOverlap){
				wData data = new wData(word, page);
				book.add(data);
			}
		}

		book = BookSort(book);

		for(int i=0; i<book.size(); i++){
			String word = book.get(i).word;
			List<Integer> pages = book.get(i).pages;
			System.out.println(word);
			for(int j=0; j<pages.size(); j++){
				System.out.print(pages.get(j));

				if(j != pages.size()-1){
					System.out.print(" ");
				}else{
					System.out.println();
				}
			}
		}
	}

	public List<wData> BookSort(List<wData> book){
		String[] words = new String[book.size()];
		List<wData> ans = new ArrayList<wData>();

		for(int i=0; i<book.size(); i++){
			words[i] = book.get(i).word;
		}

		Arrays.sort(words);
		for(int i=0; i<words.length; i++){
			for(int j=0; j<book.size(); j++){
				if(words[i].equals(book.get(j).word)){
					ans.add(book.get(j));
				}
			}
		}

		return ans;
	}
}

class wData{
	String word;
	List<Integer> pages;

	public wData(String word, int page){
		this.word = word;
		this.pages = new ArrayList<Integer>();
		this.pages.add(page);
	}

	public void addPage(int page){
		for(int i=0; i<pages.size(); i++){
			if(page < pages.get(i)){
				pages.add(i, page);
				break;
			}
			else if(i == pages.size()-1){
				pages.add(page);
				break;
			}
		}
	}
}

Measured memory_bytes: 10000
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Lsn (x<<1)
#define Rsn (x<<1|1)
#define Mid (L+R>>1)

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;
const ll oo=1ll<<50;

ll f[N];
int d[N],E,T,n,l,r,res;

ll Qv;
int Ql,Qr,Qx;

struct SegTree{
	ll mn[N*4];
	SegTree(){
		For(i,0,N*4) mn[i]=oo;
	}
	void Modify(int x,int L,int R){
		mn[x]=min(mn[x],Qv);
		if (L==R) return;
		if (Qx<=Mid) Modify(Lsn,L,Mid);else Modify(Rsn,Mid+1,R);
	}
	ll Query(int x,int L,int R){
		if (Ql<=L&&R<=Qr) return mn[x];
		ll res=oo;
		if (Ql<=Mid) res=min(res,Query(Lsn,L,Mid));
		if (Qr>Mid) res=min(res,Query(Rsn,Mid+1,R));
		return res;
	}
} S1,S2;

int main(){
	n=IN(),E=IN(),T=IN();
	For(i,1,n+1) d[i]=IN();
	For(i,0,N) f[i]=oo;
	f[0]=0;
	For(i,1,n+1){
		Qx=i,Qv=f[i-1]+d[i]-d[i-1]-3ll*d[i];
		S1.Modify(1,1,n);
		Qx=i,Qv=f[i-1]+d[i]-d[i-1]-d[i];
		S2.Modify(1,1,n);
		
		l=1,r=i;res=0;
		while (l<=r){
			int mid=(l+r>>1);
			if (2*(d[i]-d[mid])>T) res=mid,l=mid+1;else r=mid-1;
		}
		Ql=1,Qr=res;
		if (Ql<=Qr) f[i]=min(f[i],S1.Query(1,1,n)+3ll*d[i]);
		Ql=res+1,Qr=i;
		if (Ql<=Qr) f[i]=min(f[i],S2.Query(1,1,n)+T+d[i]);
		/*
		For(j,1,i+1){
			f[i]=min(f[i],f[j-1]+d[j]-d[j-1]+max(2*(d[i]-d[j]),T)+d[i]-d[j]);
		}
		*/
	}
	cout<<f[n]+E-d[n]<<endl;
}

Measured memory_bytes: 7808
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 200010;
ll p[N + N];
double preb[N], s[N], bakb[N], ans;
int b[N + N], n, st[N], top;

double query(int x, int y, int i){
	int dx = i - x, dy = y - i;
	double final = 1.0 * p[x] * dy / (dx + dy) + 1.0 * p[y] * dx / (dx + dy);
	double k = ((dx - 1.0) / dx + (dy - 1.0) / dy) / 2;
	k = 1 / (1 - k);
	final = final - b[i] * k;
	double now = bakb[i + 1] - bakb[y] - (s[y - 1] - s[i]) * (n - y + 1), t = k / dy;
	final = final - now * t;
	now = preb[i - 1] - preb[x] - (s[i - 1] - s[x]) * x, t = k / dx;
	final = final - now * t;
	return final;
}
int main(){
	read(n);
	ll mx = 0;
	int mxi = 1;
	for (int i = 1; i <= n; i++){
		read(p[i]);
		if (p[i] > mx) mx = p[i], mxi = i;
	}
	for (int i = 1; i <= n; i++) read(b[i]);
	for (int i = 1; i <= n; i++) p[i + n] = p[i], b[i + n] = b[i];
	for (int i = 1; i <= n; i++){
		p[i] = p[mxi + i - 1], b[i] = b[mxi + i - 1];
		preb[i] = i * b[i] + preb[i - 1];
		s[i] = b[i] + s[i - 1];
	}
	for (int i = n; i >= 1; i--){
		bakb[i] = bakb[i + 1] + (n - i + 1) * b[i];  
	}
	p[n + 1] = p[1], b[n + 1] = b[1];
	st[top = 1] = 1;
	for (int i = 2; i <= n + 1; i++){
		while (top > 1 && query(st[top - 1], i, st[top]) > p[st[top]]) top--;
		st[++top] = i;
	}
	
	for (int i = 1; i < top; i++){
		ans = ans + p[st[i]];
		for (int j = st[i] + 1; j < st[i + 1]; j++)
			ans = ans + query(st[i], st[i + 1], j);
	}
	ans = ans / n;
	printf("%.10lf\n", ans);
	return 0;
}



Measured memory_bytes: 13756
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A1,A2,A3,sum;
    cin>>A1;
    cin>>A2; 
    cin>>A3;
    sum=A1+A2+A3;
    if(sum>=22)
        cout<<"bust";
    else
        cout<<"win";
    return 0;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		for (int i = 0; i < n -1; i++) {
			a[scan.nextInt() - 1]++;
		}
		for (int i : a) {
			System.out.println(i);
		}
	}

}


Measured memory_bytes: 62028
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int dp[101][100001],n,k;
int pre[101][100001];

signed main(){
    FASTER;
    cin>>n>>k;
    
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        int can;cin>>can;
        for(int sum=0;sum<=k;sum++){
            dp[i][sum]=(dp[i][sum]+dp[i-1][sum])%MOD;
            if(sum+can+1<=k)dp[i][sum+can+1]=(dp[i][sum+can+1]-dp[i-1][sum]+MOD)%MOD;
        }
        for(int j=0;j<=k;j++){
            if(j)dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
        }
    }
    cout<<dp[n][k];
    
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector<int> ve[N];
priority_queue<int> qe;
int main()
{
	int n,m,sum=0;
	cin>>n>>m;
	int a,b;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		if(m-a+1>0)ve[m-a+1].push_back(b);
	}
	for(int i=m;i>0;i--)
	{
		for(int j=0;j<ve[i].size();j++)qe.push(ve[i][j]);
		if(qe.size())
		{
			sum+=qe.top();qe.pop();
		}
	}cout<<sum;
}

Measured memory_bytes: 8988
import sys
from collections import Counter

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    c = Counter(A)
    # All caps are 0.
    if 0 in c and len(c) == 1:
        return 'Yes'

    # N/3 '0', and 2N/3 'non-zero'.
    if 0 in c and len(c) == 2:
        v0 = c[0]
        for k, v in c.items():
            if k != 0 and v == 2 * v0:
                return 'Yes'

    # Three caps.
    if len(c) == 3:
        x, y, z = tuple(c.keys())
        if (x ^ y) == z and c[x] == c[y] == c[z]:
            return 'Yes'

    return 'No'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 14468
#include <stdio.h>
#include <stdlib.h>

#define HASH 5000011

typedef struct List {
	struct List *next;
	char *s;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = ((x << 5) + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, m, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 32, HASH);
	for (k = 1, pow[0] = 32; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (S[i][1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1, m = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (p = hash[h[i]]; p != NULL; p = p->next) {
				if (dp[p->s[0] - 'a'] == 1 && lex_smaller(&(p->s[1]), &(S[i][j+1])) == 0) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (S[i][j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 53112
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    int ans = 0;
    for(int i=0; i<n; i++){
      p[i] = sc.nextInt();
    }
    Arrays.sort(p);
    p[n-1] = p[n-1]/2;
    for(int i=0; i<n; i++){
      ans += p[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<vector>
#define N 100005
using namespace std;
vector<int> G[N];
int n,m,q,dp[11][N],c[N];
int main()
{
	int i,j,k,x,y;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	  }
	scanf("%d",&q);
	for(i=1;i<=q;i++){
		scanf("%d %d %d",&x,&y,&c[i]);
		dp[y][x]=i;
	  }
	for(i=10;i>=1;i--)
		for(j=1;j<=n;j++){
			dp[i-1][j]=max(dp[i-1][j],dp[i][j]);
			for(k=0;k<G[j].size();k++)
				dp[i-1][G[j][k]]=max(dp[i-1][G[j][k]],dp[i][j]);
		  }
	for(i=1;i<=n;i++)
		printf("%d\n",c[dp[0][i]]);
	return 0;
}


Measured memory_bytes: 11128
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    double n;
    cin >> n;
    	dcout << ((int)(n - 1) / 2 + 1) / n;
    return 0;
}

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

int main()
{
    int N, K;
    int a, b;
    int c = 1;
    double ans = 0.0;
    double S = 1.0;

    scanf("%d %d", &N, &K);

    for (a = 1; a < N + 1; a++)
    {
        c = a;
        for (b = 0; c < K; b++)
        {
            c *= 2;
        }
        S = pow(0.5, b);
        ans += (S / N);
    }
    printf("%.12f", ans);

    return 0;
}

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

# input
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]

# solve & output
for i in range(N):
    min_diff = 10 ** 9
    for j in range(M):
        diff = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if min_diff > diff:
            min_diff = diff
            ans = j + 1
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll N, D,count=0;	cin>>N>>D;
	while(N--){
	ll x, y;	cin>>x>>y;
	if(x*x+y*y<=D*D)	count++;
	}

	cout<<count<<endl;


    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<cstring>
#define For(i,j,k)	for(ll i=j;i<=k;++i)
#define Dow(i,j,k)	for(ll i=k;i>=j;--i)
#define maxm 10011
#define maxn 511
#define pb push_back
#define ll unsigned long long
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{c=getchar();}
	while(c<='9'&&c>='0')	t=t*10+c-48,c=getchar();
	return t*f;
}
string s,ch;
int len,len2,len3,len4;
int ans,mid,num[200001];
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
		if(s[i]!='x')ch+=s[i]; else num[ch.length()]++;
	for(int i=0;i<ch.length()/2;i++)if(ch[i]!=ch[ch.length()-i-1]){
		puts("-1"); return 0;
	}
	for(int i=0;i<(ch.length()+1)/2;i++){
		ans+=abs(num[i]-num[ch.length()-i]);
	}
	printf("%d\n",ans);
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();
const int mod = 1000000000 + 7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int n, k; cin >> n >> k;
  int a[2005]; rep(i, n) cin >> a[i];
  ll ans = 0;
  ll sub1 = 0, sub2 = 0;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j)
        continue;

      if(a[i] > a[j]){
        if(i < j){
          sub1++;
          sub2++;
        }else
        {
          sub2++;
        }
      }
    }
  }
  int t = k, u = k-1;
  if(t % 2 == 0) t /= 2;
  if(u % 2 == 0) u /= 2;

  ans = (k * sub1 % mod + (sub2 * t % mod) * u % mod) % mod;

  cout << ans << endl;
}

int main(){
// FastIO
  //ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

const int N=305; 
int P; 
int mul(int a,int b){ return 1ll*a*b%P; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int mul(int a,int b,int c){ return mul(mul(a,b),c); }

int n,k,f[N][N],C[N][N],s[N][N]; 

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	cin>>n>>k>>P; 
	C[0][0]=1;
	rep(i,1,n){
		C[i][0]=1;
		rep(j,1,i)C[i][j]=add(C[i-1][j],C[i-1][j-1]); 
	}	
	rep(j,0,k){
		f[1][j]=1;
		s[1][j]=add(1,j); 
	}
	rep(i,2,n+1){
		dec(j,k-1,0){
			int res=0;
			rep(l,1,i-1){
				res=add(res,mul(sub(s[l][k],s[l][j]),f[i-l][j],C[i-2][l-1]));
			}
			f[i][j]=res;
		}
		s[i][0]=f[i][0];
		rep(j,1,k)s[i][j]=add(s[i][j-1],f[i][j]); 
	}
	//rep(i,1,n+1)rep(j,0,k)if(f[i][j])Pr("f[%d][%d]=%d\n",i,j,f[i][j]); 
	printf("%d\n",f[n+1][0]); 
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

void zikkou(void){
	int i,data;
	int max1=0,max2=0,max3=0;
	for(i=0; i<=9; i++){
	   scanf("%d",&data);
	   if(max3<=data){
	     if(max2<=data){
		if(max1<=data){
		  max3=max2;
		  max2=max1;
		  max1=data;
		}
		else{
		 max3=max2;
		 max2=data;
		}
	  }
	else{
	max3=data;
 	}
      }
   }

 printf("%d\n",max1);
 printf("%d\n",max2);
 printf("%d\n",max3);
}

int main(void){
  zikkou();
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
int main(){
    ll sum=0,k;
    cin>>k;
    for(ll i=1;i<=k;i++)
        for(ll j=1;j<=k;j++)
            for(ll q=1;q<=k;q++)
                sum+=(ll)gcd(i,gcd(j,q));
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3560
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

const int mod=1000000007;

int a[3010],x[3010],y[3010],pw2[3010];
int g[3010][3010],dp[3010][3010];

int main()
{
	int n,q;scanf("%d%d",&n,&q);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=q;i++) scanf("%d%d",&x[i],&y[i]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
		{
			g[i][j]=q;
			dp[i][j]=i<j ? 1 : 0;
		}
	pw2[0]=1;for (int i=1;i<=q;i++) pw2[i]=pw2[i-1]*2%mod;
	for (int i=q;i;i--)
	{
		for (int j=1;j<=n;j++)
			if (j!=x[i]&&j!=y[i])
			{
				int t=(ll(dp[x[i]][j])*pw2[g[x[i]][j]-i]+ll(dp[y[i]][j])*pw2[g[y[i]][j]-i])%mod;
				dp[x[i]][j]=dp[y[i]][j]=t;
				g[x[i]][j]=g[y[i]][j]=i-1;
			}
		for (int j=1;j<=n;j++)
			if (j!=x[i]&&j!=y[i])
			{
				int t=(ll(dp[j][x[i]])*pw2[g[j][x[i]]-i]+ll(dp[j][y[i]])*pw2[g[j][y[i]]-i])%mod;
				dp[j][x[i]]=dp[j][y[i]]=t;
				g[j][x[i]]=g[j][y[i]]=i-1;
			}
		int t=(ll(dp[x[i]][y[i]])*pw2[g[x[i]][y[i]]-i]+ll(dp[y[i]][x[i]])*pw2[g[y[i]][x[i]]-i])%mod;
		dp[x[i]][y[i]]=dp[y[i]][x[i]]=t;
		//printf("%d\n",t);
		g[x[i]][y[i]]=g[y[i]][x[i]]=i-1;
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			if (a[i]<a[j]) ans=(ll(dp[j][i])*pw2[g[j][i]]+ans)%mod; else if (a[i]>a[j]) ans=(ll(dp[i][j])*pw2[g[i][j]]+ans)%mod;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 71040
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, K;
    string S;
    char k;
    cin >> N >> S >> K;
    k = S[K - 1];
    for (int i = 0; i < N; i++) {
        if (S[i] != k) {
            S[i] = '*';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
hands = {'r':r, 's':s, 'p':p}
win = {'r':p, 's':r , 'p':s}
t = input()

ans = []
for i in range(n):
    c = t[i]
    if i - k >= 0 and t[i-k] == c and ans[i-k]:
        ans.append(0)
    else:
        ans.append(win[c])
print(sum(ans))

Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
         
using namespace std;
         
int main() {
int a,b;
cin >> a >> b;
while(a+b>0) {
int min2 = min(a,b);
int max2 = a+b-min2;
cout << min2 << " " << max2 << endl;
cin >> a >> b;
}
}


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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  ll a, sum;
  cin >> a;
  A[0] = a;
  sum += a;
  for (int i = 1; i < N; i++){
    ll k;
    cin >> k;
    sum += k;
    A[i] = A[i-1] + k;
  }
  
  vector<ll> B(N);
  rep(i, N){
    B[i] = sum - A[i];
  }
  
  ll min_count = INF;
  rep(i, N-1){
    ll m = abs(A[i] - B[i]);
    min_count = min(min_count, m);
  }
  
  cout << min_count << endl;
    
}

Measured memory_bytes: 3328
n = int(input())
blis = list(map(int,input().split()))
alis = []
for i in range(n):
    if i == n-1:
        alis.append(blis[n-2])
    elif i == 0:
        alis.append(blis[0])
    else:
        if blis[i]>blis[i-1]:
            alis.append(blis[i-1])
        else:
            alis.append(blis[i])
print(sum(alis))


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

#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j,k;
    //cin>>t;
    while(t--)
    {
        int n,count=0,sum=0,flag=0,maxi=-1,mini=1e18;
        cin>>n;
    
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                for(k=1;k<=n;k++)
                {
                    sum+=__gcd(__gcd(i,j),k);
                }
            }
        }
        cout<<sum;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  
  if (b - a <= k * 2 - 2) {
    FOR(i, a, b)
      cout << i << endl;
  }
  else {
    FOR(i, a, a + k - 1)
      cout << i << endl;
    FOR(i, b - k + 1, b)
      cout << i << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
using namespace std;

typedef long long lint;

const int M = 300000000;

int main(){
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> visit(r);
    for(int i = 0 ; i < r ; i++){
        cin >> visit[i];
        visit[i]--;
    }
    sort(visit.begin(), visit.end());
    vector< vector<int> > dis(n);
    for(int i = 0 ; i < n ; i++){
        dis[i].resize(n, M);
        dis[i][i] = 0;
    }
    for(int i = 0 ; i < m ; i++){
        int a, b, c;
        cin >> a >> b >> c;
        dis[a-1][b-1] = c;
        dis[b-1][a-1] = c;
    }
    for(int k = 0 ; k < n ; k++){
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < n ; j++){
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    int ans = M;
    do{
        int cnt = 0;
        for(int i = 0 ; i < r - 1 ; i++){
            cnt += dis[visit[i]][visit[i+1]];
        }
        ans = min(ans, cnt);
    }while(next_permutation(visit.begin(), visit.end()));
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    
int main(){
    ll a,b,v,w,t;

    cin>>a>>v>>b>>w>>t;

    if(w>=v){
        cout<<"NO";
    }
    else if (abs(a-b)<=((v-w)*t)){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    int a =0, b=0, c=0, keta = 1, kijun = 10;
    while(cin >>a >>b){
        c= a+b;
        while(c >= kijun){
            kijun = kijun*10;
            ++keta;
        }
        cout<<keta<<endl;
        keta = 1;
        kijun = 10;
    }
}



Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {

            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");

            int N = Integer.parseInt(inputsArrays[0]);
            int X = Integer.parseInt(inputsArrays[1]);
            int T = Integer.parseInt(inputsArrays[2]);

            int timeTaken = 0;
            while (N>0){
                timeTaken += T;
                N -=  X;
            }
            System.out.println(timeTaken);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 25308
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include <numeric>
using namespace std;
int main() {
	int a, b, c, d, ans;
	cin >> a >> b >> c;
	d = a - b;
	ans = c - d;
	if (c - d < 0)ans = 0;
	cout << ans << endl;
	return 0;
}

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

def main():
  #偶数+ 偶数
  ans1 = ans12(N)
  #奇数+ 奇数
  ans2 = ans12(M)
  ans = int(ans1 + ans2)
  print(ans)

def ans12(x):
  if x > 1:
    return (x * (x - 1)) / 2
  else:
    return 0

if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
n, a, b = map(int, input().split())
h = [int(input()) for i in range(n)]
l, r = 0, max(h)
while l + 1 < r:
    m = (l + r) // 2
    cnt = 0
    for i in range(n):
        cnt += max(0, h[i] - b * m + a - b - 1) // (a - b)
    if cnt <= m:
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 13000
#include <stdio.h>

int main() {
  int a, b, x;
  scanf("%d %d %d", &a, &b, &x);
  if (x == a || (x > a && x <= (a+b))) {
    printf("YES\n");
  }
  else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
vector<ll> dis;
ll gcd(ll a,ll b)
{
	if(a%b == 0)
		return b;
	else
		return gcd(b,a%b);
}
int main()
{
	int n,i;
	ll x;
	scanf("%d%lld",&n,&x);
	for(i=0;i<n;i++)
	{
		ll ni;
		scanf("%lld",&ni);
		dis.push_back(abs(ni-x));
	}
	ll ans=dis[0];
	for(i=1;i<dis.size();i++)
		ans = gcd(ans,dis[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

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

  int n;
  cin >> n;

  vector<double> vec;
  
  for(int i=0;i<n;i++){
    double a;
    cin >> a;
    vec.push_back(a);
  }

  long double ans = 0;
  long double sum = 1;
  long double divi = vec[0];

  for(int i=1;i<sz(vec);i++){
    sum = (sum*vec[i]) + divi;
    divi *= vec[i];
  }

  cout << divi/sum << endl;

  return 0;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	ll n; cin >> n;
	n--;

	string ans;
	while(true){
		ans += 'a' + n%26;
		if(n<26) break;
		n /= 26;
		n--;
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define endl        "\n"
#define ff          first
#define ss          second
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define CC(x)       for(auto xx: x) cout<<xx<<" ";
#define ee          cout<<"\n";
#define ll          long long
#define ull         unsigned long long
#define pii         pair<ll,ll>
#define mp          make_pair
#define all(x)      x.begin(),x.end()
#define ps(x)       push(x)
#define psb(x)      push_back(x)
#define psf(x)      push_front(x)
#define pp          pop()
#define ppb         pop_back()
#define ppf         pop_front()
#define OK          cout<<"Ok"<<"\n";
#define TESTS       ll test;cin>>test;for(ll   tcase=1;tcase<=test;tcase++)
/*------------------------*/
#define MAX int(1e5)
int dp[2][10000+9];
int value[1000+9],weight[1000+9];


int main()
{
    FAST
    int n,k;
    cin>>n>>k;
    vector <int> H(n);
    for(int i=0;i<n;i++)
    {
        cin>>H[i];
    }
    sort(all(H));
    int x;
    ll s=0;
    for(int i=0;i<n-k;i++)
    {
       s+=H[i];

    }
    cout<<s<<endl;


    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
using namespace std;
#define maxn 100010
int n,m;
long long a[maxn];
int main()
{
	priority_queue<long long>q;
	 
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		q.push(a[i]);
	 } 
	while(m)
	{
		m--;
		long long tmp=q.top();
		q.pop();
		tmp/=2;
		
		q.push(tmp);
	}
	long long sum=0;
    while(!q.empty())
    {
    	sum+=q.top();
    	q.pop();
	}
	long long ans=sum;
	cout<<ans;
	return 0;
}
 

Measured memory_bytes: 1912
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    h, a = map(int, input().split())
    print((h + a - 1) // a)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
#define ll long long int

using namespace std;

int main(void){
  const double interest = 0.01;
  double deposit = 100;
  ll X ,year = 0;

  cin >> X;

  while(floor(deposit) < X){
      deposit += floor(deposit*interest);
    year++;
  }

  cout << year << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
using namespace std;



int main(){
    int n ;
    cin >> n ;
    vector<int64_t> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int64_t ans = 0 ;
    ans += a.at(0) / 2 ;
    a.at(0) %= 2 ;
    for (size_t i = 0; i < n-1; i++)
    {
        if (a.at(i) == 1 && a.at(i+1) > 0)
        {
            ans ++ ;
            a.at(i) -= 1 ;
            a.at(i+1) -= 1 ;
        }
        ans += a.at(i+1) /2 ;
        a.at(i+1) %= 2 ;
        
    }
    cout << ans << endl ;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,b,a) for(int i=b;i>a;i--)
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define cps CLOCKS_PER_SEC
#define complex cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
  }
  return r;
}

//think recursively also

void solve()
{  

int n,k;
cin>>n>>k;
int sk[n+1]={0};
for(int i=1;i<=k;i++)
{ int d;
  cin>>d;
  for(int j=1;j<=d;j++)
  { int x;
    cin>>x;
    sk[x]+=1;
  }
}
int c=0;
for(int i=1;i<=n;i++)
{
  if(sk[i]==0)
    c++;
}
cout<<c;
  
}
int main()
{
   fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  { //cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#define N 8
void PutQueens(int ,int *c,int *,int *, int *);
int main(){
 
  int *row;
  int *col;
  int *dpos;
  int *dneg;
  int i,j,n,a,b;

  
  row=malloc(N*sizeof(int));
  col=malloc(N*sizeof(int));
  dpos=malloc(N*sizeof(int)*2);
  dneg=malloc(N*sizeof(int)*2);
 
  for(i=0;i<N;i++)
    {
      row[i]=-1;
      col[i]=-1;
    }
   for(i=0;i<N*2;i++)
    {
      dpos[i]=-1;
      dneg[i]=-1;
      
    }
    scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&a,&b);
      
      row[a]=b;      
      col[b]=1;     
      dpos[a+b]=1;      
      dneg[a-b+(N-1)]=1;
      }
  
  
  PutQueens(0,col,dpos,dneg,row);
  
  return 0;
}
void PutQueens(int i,int *col,int *dpos, int *dneg, int *row){
  int j,k;
  
    if(i == N)
      {
	for(k=0;k<N;k++)
	  {
	    for(j=0;j<N;j++)
	      {
		if(j==row[k]) printf("Q");
		else
		  {
		    printf(".");
		  }
	      }
	    printf("\n");
	  }
      }
    else {
      if(row[i]!=-1)
	{
	  PutQueens(i+1,col,dpos,dneg,row);
	  return;
	}
      for(j=0;j<N;j++)
	{
	  if(col[j] == 1 || dpos[i+j] == 1 || dneg[i-j+(N-1)] == 1)
	    {
	      continue;
	    }
	  else{
	    row[i] = j;
	    col[j] = 1;
	    dpos[i+j] = 1;
	    dneg[i-j+N-1] = 1;
	    PutQueens(i+1,col,dpos,dneg,row);
	    col[j] = -1;
	    dpos[i+j] = -1;
	    dneg[i-j+N-1] = -1;
	    row[i]=-1;
	  }
	}
      return;
    }
    
  
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
/*  Writen by : AS7
 *  "JUST KEEP GOING..."
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
const int N = 2e5+5;
map<int ,bool> vis;
int ans;
void solve(){
   int n,k;
   cin>>n;
   int arr[n];
   lp(i,n){
       cin>>arr[i];
       if(i%2==0&&arr[i]%2)ans++;
   }
   cout<<ans<<endl;
}
int main() {
    int t = 1;
   //cin>>t;
    while (t--)solve();
}

Measured memory_bytes: 3608
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
	static long getLong(){return Long.parseLong(s.next());}

	public static void main(String[]$){
		long N=getLong();
		for(long h=0;h<=3500;++h) {
			for(long n=0;n<=3500;++n) {
				long Nhn=N*h*n;
				long v=4*h*n-N*n-N*h;
				if(v>0&&Nhn%v==0) {
					System.out.println(h+" "+n+" "+(Nhn/v));
					return;
				}
			}
		}
	}
}

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

int main()
{
  //a青 b赤 ans青いボールの個数
  ll n, a, b, ans=0;
  cin >> n >> a >> b;

  ans += (n / (a + b)) * a;
  ll rem = n % (a + b);
  ans += min(rem, a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
vector<int> list[100000];
int N, M, E;
int match[100000];
bool used[100000];
int x, y;

bool DFS(int V) {
	used[V] = true;
	for (int i = 0; i < list[V].size(); i++) {
		int u = list[V][i]; int w = match[u];
		if (w < 0 || !used[w] && DFS(w)) {
			match[V] = u;
			match[u] = V;
			return true;
		}
	}
	return false;
}

int supermatching() {
	int r = 0;
	memset(match, -1, sizeof(match));
	for (int j = 0; j < N + M; j++) {
		if (match[j] < 0) {
			memset(used, 0, sizeof(used));
			if (DFS(j)) { r++; }
		}
	}
	return r;
}

int main() {
	cin >> N >> M >> E;
	for (int i = 0; i < E; i++) {
		cin >> x >> y;
		y += N;
		list[y].push_back(x);
		list[x].push_back(y);
	}
	cout << supermatching() << endl;
	return 0;
}

Measured memory_bytes: 4176
/*================= *\
|  ID : aman__guta__ |
|      LANG: C++     |
\*==================*/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define ll long long int
#define ld long double 
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mk make_pair
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fs first
#define sc second 
#define mod 998244353
#define sp <<" "<<
#define JOKER ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// typedef tree<lli, null_type, less_equal<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
int spf[10000001];
ll fac[200005];
ll comb[1010][1010];
const ll MAXN=1e6+5;
ll tree[MAXN];
void inc(ll pos);
ll get(ll pos);
ll get_kth(ll k);
void combfun();
void sieve(int n);
int expo(int base,int exponent);
ll power(ll x, ll y, ll p);
ll modInverse(ll n, ll p);
ll nCrModPFormat(ll n, ll r, ll p);
int main()  
{
    JOKER
    int t=1;
    // cin>>t;
    Forn(tc,t)
    {
        ld r;
        cin>>r;
        ld ans=3.14159;
        cout<<ans*r*2<<endl;
    }
    cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
    return 0;
}

void combfun()
{
    for(int i=1; i<1010; i++)
    {
        for(int j=0; j<=i; j++)
        {
            if(j==0 or i==j)
            {
                comb[i][j]=1;
            }
            else 
            {
                comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
                comb[i][j]%=mod;
            }
        }
    }
}

int expo(int base,int exponent)
{
    ll ans=1;
    while(exponent!=0){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

void sieve(int n)
{
    spf[1]=1;
    for(int i=2;i<=n;i++) spf[i]=i;
    for(int i=4;i<=n;i+=2) spf[i]=2;
    for(int i=3;i*i<=n;i++)
    {
        if(spf[i]==i)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}

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

void inc(ll pos) {
    for (; pos < MAXN; pos |= (pos + 1)) {
        tree[pos] += 1;
    }
}
 
ll get(ll pos) {
    ll ans = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
        ans += tree[pos];
    }
    return ans;
}

ll get_kth(ll k) {
    ll l = -1, r = MAXN;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (get(mid) < k) {
            l = mid;
        } else {
            r = mid;
        }
    }
    return r;
}

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

ll nCrModPFormat(ll n, ll r, ll p) 
{ 
    fac[0]=1;
    for(int i=1; i<200005; i++)
    {
        fac[i]=(fac[i-1]*i)%mod;
    }
    if (r==0) 
        return 1; 
    return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p; 
}


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

int main(){
  string S;
  cin >> S;
  if(S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3)){
    cout << "Bad" << endl;
  }
  else
    cout << "Good" << endl;
}


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

int main() {
    int a ; cin >> a ; int c = 0;
    while (a >0){
        if ((a % 10) == 7) c++;
        
        a /= 10;
    }
    if (c != 0) cout << "Yes";
    else cout << "No";
    
	return 0;
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(2147483647)

n,k=map(int,input().split())
#n個の中からk個選んだ時の最大と最小

a=list(map(int,input().split()))
"""
seta=set([])
dic={}

for v in a:
    if v in seta:
        dic[v]+=1
    else:
        dic[v]=1
        seta.add(v)

a=list(seta)
"""

a.sort()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10**9+7 #割る数
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


result=0
for i,v in enumerate(a):
    if i>=k-1:
        result+=v*cmb(i, k-1, p)
    
    if k-1<=n-i-1:
        result-=v*cmb(n-i-1, k-1, p)

print(result%p)
        




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

//const int INF = 1001001001;
const ll INF = 1000000000000000000;

int main() {
	int n;
	cin >> n;
	vector<vector<pair<int,int>>> testim(n);
	rep(i,n) {
		int a;
		cin >> a;
		rep(j,a) {
			int x, y;
			cin >> x >> y; x--;
			testim[i].push_back(make_pair(x,y));
		}
	}
	int ans = 0;
	repbit(bit,n) {
		bitset<15> bs(bit);
		//cout << bs << endl;
		int honest = 0;
		rep(i,n) {
			bool consistent = true;
			honest += bs[i];
			if (bs[i]) {
				for (auto x : testim[i]) {
					if (bs[x.first] != x.second) {
						//cout << " " << x.first;
						consistent = false;
						break;
					} 
				}
			}
			//cout << endl;
			if (!consistent) {
				honest = 0;
				break;
			}
		}
		//cout << "honest= " << honest << endl;
		ans = max(ans, honest);
	}
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
// const ll INF = 1LL << 30;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

int main() {
    ll a; cin >> a;
    cout << a + a*a + a*a*a << endl;

    return 0;
}



Measured memory_bytes: 3600