akhauriyash/Code-Regression huggingface dataset:
//IGNORANCE IS BLISS

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio

    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int k;
    cin >> k;
    cout << arr[k-1] << endl;

	return 0;
    
}

Measured memory_bytes: 8832
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int cnt = 0;
        int kind = 0;
        int max = 0;

        for(int i = 0;i < n;i++){
            String s1 = s.substring(0,i+1);
            String s2 = s.substring(i+1, n);
            kind = 0;
            for(char j = 'a';j <= 'z';j++){
                String k = String.valueOf(j);
                if(s1.contains(k) && s2.contains(k))
                kind++;
            }
            max = Math.max(kind,max);
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 23892
def solve():
    n, m = map(int, input().split())
    u = [0] * n
    for _ in range(m):
        a, b = map(int, input().split())
        u[a - 1] += 1
        u[b - 1] += 1
    for i in range(n):
        print(u[i])


if __name__ == '__main__':
    solve()

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

int n;
priority_queue<double> pq;

int main() {
	cin>>n;
	for(int i = 0;i<n;i++){
		int t;
		cin>>t;
		pq.push(-t*1.0);
	}
	while(pq.size()>1){
		double a = -pq.top();
		pq.pop();
		double b = -pq.top();
		pq.pop();
		pq.push(-(a+b)/2);
	}
	cout<<fixed<<setprecision(10)<<-pq.top();
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
pfa={}
m=a
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfa[i]=pfa.get(i,0)+1
        m//=i
if m>1:pfa[m]=1
pfb={}
m=b
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfb[i]=pfb.get(i,0)+1
        m//=i
if m>1:pfb[m]=1
aa=set()
bb=set()
for i in pfa.keys():
    aa.add(i)
for i in pfb.keys():
    bb.add(i)
print(len(aa&bb)+1)

Measured memory_bytes: 9480
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
d = 0
for i in range(n):
    ans = 0
    a = list(map(int, input().split()))
    for j in range(m):
        ans += a[j]*b[j]
    ans += c
    if ans > 0:
        d+=1
print(d) 

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);		
		int n=in.nextInt();
		int l=in.nextInt();
		int ans=(l-1)*n+n*(n+1)/2;
		int q=Math.min(Math.abs(l),Math.abs(l+n-1));
		if(l<0&&l+n-1>0)
		{
			ans=ans;
		}
		else if(Math.abs(l)<Math.abs(l+n-1))
		{
			ans=ans-l;
		}
		else
		{
			ans=ans-l-n+1;
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 21972
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		a[i]--
	}
	answer := finalTown(n, k, a) + 1
	fmt.Println(answer)
}

func finalTown(n, k int, a []int) int {
	beforeLoop := 1
	loopStart := 0
	loopLength := 1
	next := 0
	visited := make([]bool, n)
	visited[0] = true
	for {
		next = a[next]
		if visited[next] {
			// loop start
			loopStart = next
			for t, length := a[next], 2; t != loopStart; t, length = a[t], length+1 {
				loopLength = length
			}
			break
		}
		visited[next] = true
		beforeLoop++
	}
	beforeLoop = beforeLoop - loopLength
	if beforeLoop < 0 {
		panic("beforeLoop must be equal or greather than 0")
	}
	// fmt.Println("k-beforeLoop", k-beforeLoop)
	if k-beforeLoop < 0 {
		town := a[0]
		if k == 1 {
			return town
		}
		for i := 0; i < k-1; i++ {
			// fmt.Println("town", town)
			town = a[town]
		}
		return town
	}
	m := (k - beforeLoop) % loopLength
	town := loopStart
	for i := 0; i < m; i++ {
		town = a[town]
	}
	// fmt.Println(beforeLoop, loopStart, loopLength)
	return town
}


Measured memory_bytes: 6628
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
 
int main(void) {
    int a,b,t;
    int count=0;

    cin>>a>>b>>t;

    for(int i=a;i<=t;i+=a){
        count+=b;
    }

    cout<<count<<endl;
    
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
M = max(a)
ok = [0]*(M+1)
a.sort()

for i in range(n):
    ok[a[i]] += 1

for i in range(n):
    if ok[a[i]] != 0:
        for g in range(a[i], M+1, a[i]):
            if g != a[i]:
                ok[g] = 0

print(ok.count(1))

Measured memory_bytes: 32248
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    A=list(map(int,input().split()))
    print(A[0]*A[1]//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
from collections import deque

H,W=map(int,input().split())
maze=[list(input()) for i in range(H)]

sx,sy=0,0
gx,gy=H-1,W-1

def bfs():
    d=[[float('inf')]*W for i in range(H)]
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]

    que=deque([])
    que.append((sx,sy))
    d[sx][sy]=0

    while que:
        p=que.popleft()
        if p[0]==gx and p[1]==gy:
            break
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            if 0<=nx<H and 0<=ny<W and maze[nx][ny]!="#" and d[nx][ny]==float("inf"):
                que.append((nx,ny))
                d[nx][ny]=d[p[0]][p[1]]+1
        
    return d[gx][gy]

ans=0
cnt=0
res=bfs()
for i in range(H):
    for j in range(W):
        if maze[i][j]=='.':
            cnt+=1
if res==float('inf'):
    ans=-1
else:
    ans=cnt-res-1
print(ans)

Measured memory_bytes: 9420
#include<stdio.h>

int main(){
  int n,m,l,i,j,s;
  scanf("%d",&n);
  int A[n][n];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&l,&m);
    for(j=0;j<m;j++){
      scanf("%d",&s);
      A[l-1][s-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0)printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
  
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

double fact(int n){
    if(n==1)return 1;
    return n*fact(n-1);
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n);
    rep(i,0,n-1){
        cin >> x[i] >> y[i];
    }
    double ans = 0.0;

    rep(i,0,n-1){
        rep(j,0,n-1){
            if(i!=j)ans += sqrt((double)(x[i]-x[j])*(x[i]-x[j])+(double)(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    ans *= (double)fact(n-1);
    ans /= (double)fact(n);

    //cout << ans << endl;
  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=2e5+5;
const int M=1e9+7;
int h,w;
char X[1001][1001];
int ans[1001][1001];
bool val(int x,int y)
{
	if(ans[x][y]!=-1) return false;
	if(x>=1 && x<=h && y>=1 && y<=w)
	return true;
	return false;
}
void solve()
{
	cin>>h>>w;
	memset(ans,-1,sizeof(ans));
	queue<pair<int,int>> q;
	f(i,1,h){
		f(j,1,w) {
		cin>>X[i][j];
		if(X[i][j]=='#')
		{
			ans[i][j]=0;
			q.push(mp(i,j));
		}
	}
	} 
	int res=0;
	while(!q.empty())
	{
		pair<int,int> p=q.front();
		q.pop();
		int x=p.ff;
		int y=p.ss;
		if(val(x+1,y)){
			q.push(mp(x+1,y));
			ans[x+1][y]=ans[x][y]+1;
			res=max(res,ans[x+1][y]);
		}
		if(val(x-1,y))
		{
			q.push(mp(x-1,y));
			ans[x-1][y]=ans[x][y]+1;
			res=max(res,ans[x-1][y]);
		}
		if(val(x,y+1))
		{
			q.push(mp(x,y+1));
			ans[x][y+1]=ans[x][y]+1;
			res=max(res,ans[x][y+1]);
		}
		if(val(x,y-1))
		{
			q.push(mp(x,y-1));
			ans[x][y-1]=ans[x][y]+1;
			res=max(res,ans[x][y-1]);
		}
	}
	cout<<res;
	
	
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}



Measured memory_bytes: 25396
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	long long int n, a[200];
	cin >> n;
	n = n * 2;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a +n);
	long long int ans = 0;
	for (int i = 0; i <= n - 2; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int>  A(N);
  vector<int> ans(N);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    ans.at(i) = A.at(i);
  }
  
  sort(ans.begin(), ans.end());
  
  for( int i = 0; i < N; i++ ){
    if( A.at(i) == ans.at(N-1) ){
      cout << ans.at(N-2) << endl;
    }else{
      cout << ans.at(N-1) << endl;
    }
  }
}


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

//#include <cstdio>

using namespace std;

static int inputArray(int A[], int num) {
  int max = 0;
  for (int i = 0; i < num; i++) {
    cin >> A[i];
    if (A[i] > max) {
      max = A[i];
    } 
  }
  return max;
}

static inline int f(int A[], int num, uint64_t P, int k) {
    int i = 0, v = 0;
    for (uint64_t total = 0; (v < k) && (i < num); i++) {
      total += A[i];
      if (total > P) {
        total = 0;
        i--;
        v++;
      }
    }
    return i;
}

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

  vector<int> w(n);
  uint64_t P = inputArray(&w[0], n);

  uint64_t left = 0;
  uint64_t right = 100000 * 10000;
  uint64_t mid;
  int v = 0;
  while (1 < right - left) {
    mid = (left + right) / 2;
    v = f(&w[0], n, mid, k);
    if (v < n) {
      left = mid;
    } else {
      right = mid;
    }
  }

  cout << right << endl;

  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sq = (int)sqrt(n);
    cout << sq * sq << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int n;

void countingsort(int a[], int b[], int k){
    int c[10001];
    rep(i, 0, k+1) c[i] = 0;
    rep(j, 1, n+1) c[a[j]]++;
    rep(i, 1, k+1) c[i] += c[i-1];
    rrep(j, n, 0) {
        b[c[a[j]]] = a[j];
        c[a[j]]--;
    }

}

int main(void){
    int *a, *b;
    cin >> n;
    a = new int[n+1];
    b = new int[n+1];
    rep(i, 1, n+1) cin >> a[i];
    countingsort(a, b, 10000);
    rep(i, 1, n+1) {
        if(i-1) cout << ' ';
        cout << b[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18764
#include<stdio.h>
 
#define MAX 100005
#define NIL -1
    
struct Node{
  int p, l, r;
};
 
struct Node N[MAX];
int n;
 
void Preorder(int u){
  if(u != NIL){
    printf(" %d", u); 
    Preorder(N[u].l);
    Preorder(N[u].r);
  }
}
 
void Inorder(int u){
  if(u != NIL){
    Inorder(N[u].l);
    printf(" %d", u);
    Inorder(N[u].r);
  }
}
 
void Postorder(int u){
  if(u != NIL){
    Postorder(N[u].l);
    Postorder(N[u].r);
    printf(" %d", u);
  }
}

int main(){
  int i, j, d, v, c, l;
  int first;
  scanf("%d", &n);
   
  for(i = 0; i < n; i++){
    N[i].p = N[i].l = N[i].r = NIL;
  }
   
  for (i = 0; i < n; i++){
    scanf("%d %d %d", &v, &d, &c);
    if(i == 0) first = v;
    N[d].p = v;
    N[c].p = v;
    N[v].l = d;
    N[v].r = c;
  }

  for(i = 0; i < n; i++){
    if(N[i].p == NIL){
      first = i;
      break;
    }
  }
   
  printf("Preorder\n");
  Preorder(first);
   
  printf("\n");
  printf("Inorder\n");
  Inorder(first);
   
  printf("\n");
  printf("Postorder\n");
  Postorder(first);
   
  printf("\n");
  return 0;
}

Measured memory_bytes: 620
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
    vector<int> vc;
    int x;
    for(int i=0;i<5;i++){
        cin >> x;
        vc.push_back(x);
    }
    sort(vc.rbegin(),vc.rend());
    for(int i=0;i<vc.size();i++){
        if(i)   cout << " " << vc[i];
        else    cout << vc[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>

int main()
{
	int i, a, b, c, count = 0;
	while (1)
	{
		scanf("%d %d %d", &a, &b, &c);
		if (1 <= a, b, c&&a, b, c <= 10000 && a <= b)
			break;
	}
	for (i = a; i <= b; i++){
		if (c%i == 0)
			count++;
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 596
//#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int n,x,y;
int ans[2005];
bool vis[2005];

vector<vector<int>>g;
void bfs(int at){
    for(int i=0;i<n;i++)
        vis[i]=false;
    queue<pair<int,int>>q;
    q.push({at,0});
    vis[at]=true;
    while(!q.empty()){
        int v=q.front().first;
        for(int i=0;i<g[v].size();i++){
            if(!vis[g[v][i]]){
                q.push({g[v][i],q.front().second+1});
                ans[q.front().second+1]++;
                vis[g[v][i]]=true;
            }
        }
        q.pop();
    }
}
int main(){
    cin>>n>>x>>y;
    g.resize(n+1);
    for(int i=0;i<n-1;i++){
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x-1].push_back(y-1);
    g[y-1].push_back(x-1);
    for(int i=0;i<n;i++){
        bfs(i);
    }
    for(int i=1;i<=n-1;i++){
        printf("%d\n",ans[i]/2);
    }
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int n, f, s, t;
	cin >> n;
	t = n % 10;
	s = (n / 10) % 10;
	f = (n / 10) / 10;
	if (f == t)
		cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
int main() {
    int N;
    cin>>N;
    int A[2][N];
    for(int i=0;i<2;i++){
      for(int j=0;j<N;j++){
        cin>>A[i][j];
      }
    }
    int ans=0;
    for(int i=0;i<N;i++){
      int sumj=0;int sumk=0;
      for(int j=0;j<=i;j++){sumj+=A[0][j];}
      for(int k=i;k<N;k++){sumk+=A[1][k];}
      int sum=sumj+sumk;
      ans=max(ans,sum);
    }
    cout<<ans<<endl;

return 0;}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int x = b-a-1;
      int sum = 0;
      for(int i = 0;i <= x;i++){
      	sum += i;
      }
      System.out.println(sum-a);
    }
}

Measured memory_bytes: 21204
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))




int main(){
	string str;
	vector< pair<string,int> >sp;
	int num;
	while(cin>>str>>num){
		sp.PB(MP(str,num));
	}
	bool c=false;
	SORT(sp);
	REP(i,SZ(sp)){
		if(!c)cout<<sp[i].first<<endl;
		if(i!=SZ(sp)-1&&sp[i].first==sp[i+1].first){
			cout<<sp[i].second<<" ";
			c=true;
		}else{
			c=false;
			cout<<sp[i].second<<endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val A = sc.nextInt()
    val B = sc.nextInt()

    val train = N * A
    if(train >= B){
        println(B)
    }else{
        println(train)
    }
}

Measured memory_bytes: 31136
//Begin Template
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
// define
const int INF = 1<<24;
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET cin.tie(0);ios::sync_with_stdio(false);
// Inspired by: https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a) - 1, n, d, >=)

#define repc(...) GET_MACRO(__VA_ARGS__, repc4, repc3, repc2, repc1) (__VA_ARGS__)
#define repc1(n) repc2(_, n)
#define repc2(i, n) repc3(i, 0, n)
#define repc3(i, a, n) repc4(i, a, n, 1)
#define repc4(i, a, n, d) rep5(i, a, n, d, <=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int,int> pii;
typedef pair<lint,lint> pll;
// func
template <class C> inline void vcin(C &c);
template <class C,class D> inline void vcin(C &c,D &d);
template <class C> inline void vcout(const C &c,const string separate="\n");
template <class T=int> inline T in();
template <class T> inline bool chmin(T &a, T b);
template <class T> inline bool chmax(T &a, T b);
//http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}


void solve()
{
  const int n = in();
  vector<string> s(n);
  vcin(s);

  vector<map<char, lint>> vmp(n);
  rep(i, n)
  {
    for (char c : s[i])
    {
      vmp[i][c]++;
    }
  }

  map<map<char, lint>,lint> mmp;
  for (auto mp : vmp)
  {
    mmp[mp]++;
  }

  lint ans = 0;
  for (auto mpl : mmp)
  {
    lint cnt = mpl.second;
    ans += cnt * (cnt - 1) / 2;
  }

  cout << ans << endl;
}
signed main(){
  AMULET
  solve();
  return 0;
}

template <class C>inline void vcin(C &c){for(auto &a:c){cin>>a;}}
template <class C,class D> inline void vcin(C &c,D &d){for(auto it1=c.begin(),it2=d.begin();it1!=c.end()&&it2!=d.end();it1++,it2++){cin>>*it1>>*it2;}}
template <class C> inline void vcout(const C &c,const string separate){for(auto it=c.begin();it!=c.end();it++){if(it!=c.begin())cout<<separate;cout<<*it;}}
template <class T=int> inline T in(){T x;cin>>x;return (x);}
template<class T> inline bool chmin(T& a, T b){if(a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b) {a = b;return true;}return false;}
//End Template


Measured memory_bytes: 125184
# 貰うDP
N = int(input())

INF = 10 ** 5 + 1

dp = [INF for _ in range(N + 1)]
dp[0] = 0

for n in range(N + 1):
    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n - power] + 1)
        power *= 6

    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n - power] + 1)
        power *= 9

print(dp[N])


Measured memory_bytes: 3864
#include <iostream>
#include <map>
#include <cstdio>
#include <set>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

const int N = 2010;

using i64 = uint64_t;

int n, m, a[N], b[N];
map<int, int> ra, rb;
i64 ans = 1, modp = 1e9 + 7;

void fail() {
	puts("0");
	exit(0);
}

i64 fac(int x) {
	i64 ans = 1;
	for (i64 i = 2; i <= x; i++) ans = (ans * i) % modp;
	return ans;
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		if (ra.count(a[i])) fail();
		ra[a[i]] = i;
	}
	for (int i = 1; i <= m; i++) {
		scanf("%d", b + i);
		if (rb.count(b[i])) fail();
		rb[b[i]] = i;
	}

	int tot_x = 0, tot_y = 0;
	int ele = n * m, cnt = 0;
	while (tot_x < n || tot_y < m) {
		int x = ra.count(ele) ? ra[ele] : 0;
		int y = rb.count(ele) ? rb[ele] : 0;
		if (x && y) {
			tot_x++;
			tot_y++;
		} else if (x > 0) {
			tot_x ++;
			ans = (ans * tot_y) % modp;
		} else if (y > 0) {
			tot_y ++;
			ans = (ans * tot_x) % modp;
		} else {
			ans = (ans * (tot_x * tot_y - cnt)) % modp;
		}
		ele--;
		cnt++;
	}
	cout << (ans * fac(n * m - cnt)) % modp << endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		List<string> str = new List<string>();
		str.AddRange(input);

		for(int i=0; i<str.Count; i++)
		{
			int n;
			if(!int.TryParse(str[i], out n))
			{
				int a = int.Parse(str[i-2]);
				int b = int.Parse(str[i-1]);
				int c = 0;
				switch(str[i])
				{
					case "+":
						c = a + b;
						break;
					case "-":
						c = a - b;
						break;
					case "*":
						c = a * b;
						break;
				}
				str[i-2] = c.ToString();
				str.RemoveAt(i);
				str.RemoveAt(i-1);
				i = 0;
			}

			if(str.Count == 1)
			{
				break;
			}
		}

		Console.WriteLine(str[0]);
	}
}

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
int main () {
  ios::sync_with_stdio(false);
  unordered_map<int, int> mt;
  mt[0] = 4;
  cin >> N;
  for(int i = 0; i < N; ++i) {
    int c;
    cin >> c;
    mt[c]++;
  }

  vector<pair<int,int>> v;
  for(auto it = mt.begin(); it != mt.end(); ++it) {
    if (it->second >= 2) v.push_back({it->first, it->second});
  }

  sort(v.rbegin(), v.rend());

  if (v[0].second >= 4) {
    cout << ll(v[0].first) * v[0].first << endl;
    return 0;
  }

  cout << ll(v[0].first) * v[1].first<< endl;
}

Measured memory_bytes: 4388
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int SZ = 1e6;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        // trueで初期化
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
// SZ = 1e6 だと10ms
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        // 同じ数が重複するケースを考慮
        D[x]++;
    }
    // trueなら "pairwise coprime"
    bool pc = true;

    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            for (int now = i; now <= SZ && cnt <= 1; now += i) {
                cnt += D[now];
            }
            // 共通の素数を含むのでgcd(ALL) >= i
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 19040
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	ll N, K;
  	cin >> N >> K;
  	vector<ll> a(N), b(N);
  	rep(i,N) cin >> a[i] >> b[i];
  
  	vector<pair<ll,ll>> data(N);
  	rep(i,N){	
      	data[i].first = a[i];
  		data[i].second = b[i];
    }
  	sort(data.begin(),data.end());

  	// K 番目に小さいもの = data[i].second の累積が K-1 に到達したときの data[i].first
  	ll temp = 0;
  	ll i = 0;	
  	while(1){
		temp += data[i].second;
      	if( temp >= K ) { break;}
  		i++;
    }
  	cout << data[i].first << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

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

	//string s;
	int a,b;

	cin >> a >> b;
	
	int ans=a+b;
	
	if(ans%2) cout << "IMPOSSIBLE" << "\n";
	else cout << ans/2 << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 256
/*
 * Created by Dipta Das on 29-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

vector<ll> adj[100005];
ll ans[100005];
ll mini;

ll dfs (ll curr) {
    ll &now = ans[curr];
    if (now != -1) return now;
    now = 0;
    for (int i = 0; i < (int) adj[curr].size(); ++i) {
        now = max (now, dfs(adj[curr][i]) + 1);
    }
    
    return now;
}


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

    int n, m;
    cin >> n >> m;
    for (int i = 0, x, y; i < m; ++i) {
        cin >> x >> y;
        adj[x].push_back(y);
    }

    memset(ans, -1, sizeof(ans));

    ll mn = 0;
    for (int i = 1; i <= n; ++i) {
        mn = max (mn, dfs(i));
    }

    cout << mn << endl;


    


    return 0;
}



Measured memory_bytes: 8576
from collections import defaultdict
import sys

input = lambda: sys.stdin.readline().rstrip()

def mod_inv(a):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, M
  while z1 != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1%M

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
  return g

def sum_grundy(grundy):
  sum_g = [defaultdict(int, {0:B_sum}) for i in range(3)]
  W = 1
  for i in range(1, N+1):
    W = W * B % M
    for s, g in zip(sum_g, grundy):
      if i in g:
        s[g[i]] =  (s[g[i]] + W) % M
        s[0] =  (s[0] - W) % M
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

N = int(input())
M = 998244353
B = pow(10, 18, M)
B_sum = (pow(B, N+1, M) - B) * mod_inv(B-1) % M

edge = [read_edge() for i in range(3)]
grundy = list(map(calc_grundy, edge))
sum_g = sum_grundy(grundy)
ans = 0
for gx, sx in sum_g[0].items():
  for gy, sy in sum_g[1].items():
    gz = gx^gy
    sz = sum_g[2][gz]
    if sz:
      ans = (ans + sx*sy*sz) % M
print(ans)


Measured memory_bytes: 70316
n,c,k=map(int,input().split())
t=[]
for _ in range(n):
  t.append(int(input()))
t.sort()
renow=0
cun=0
for i in range(n):
  if t[i]-t[renow]>k or i-renow+1>c:
    cun+=1
    renow=i
print(cun+1)
  

Measured memory_bytes: 13208
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
vector<int>A;


int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		A.push_back(a);
	}
	int now = 1;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (now == A[i]) {
			now++;
		}
		else {
			ans++;
		}
	}
	if (ans == N) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

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

string yaki = "YAKI";

int main(){
    string s;
    cin >> s;
    bool flag = true;
    for(int i=0;i<4;++i){
        if(s.size() < 4 || s[i] != yaki[i])
            flag = false;
    }

    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
# B
# 2020/03/03 0:12-
s = list(input())

l = []
for i in range(len(s)):
    if s[i] == '0':
        l.append('0')
    elif s[i] == '1':
        l.append('1')
    elif s[i] == 'B':
        if len(l) > 0:
            l.pop()
            
for v in l:
    print(v, end='')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<vector<int>> c;
    c.resize(n);
    vector<int> ar(m,0);
    vector<int> cost(n);
    rep(i,n){
        cin >> cost[i];
        rep(j,m){
            int a;
            cin >> a;
            c[i].emplace_back(a);
        }
    }
    int mini=INF;
    rep(i,1<<n){
        int cos=0;
        rep(j,n){
            if(i>>j&1){
                rep(k,m){
                    ar[k] += c[j][k];
                }
                cos += cost[j];
            }
            
        }
        rep(j,m){
            if(ar[j]<x){
                cos += INF;
                break;
            }
        }
        mini = min(mini,cos);
        ar = vector<int> (m);
    }
    if(mini==INF) cout << -1 << endl;
    else cout << mini << endl;
	return 0;
}



Measured memory_bytes: 3628
#pragma GCC optimize ("O2") // "Ofast" for REAL FAST
// #pragma GCC optimization ("unroll-loops")

// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#include <bits/stdc++.h>
#define DEBUG 1

using namespace std;

#define rep(i, a, b) for (i = (a); i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) (x).begin (), (x).end ()
#define rall(x) (x).rbegin (), (x).rend ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair <int, int> pii;
#define f first
#define s second
#define mp(x, y) make_pair (x, y)

typedef vector <int> vi;
#define pb(x) push_back (x)

#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7; // UPDATE

int main ()
{
    FASTIO;
    ll i, j;
    scanf ("%lld %lld", &i, &j);
    printf ("%lld\n", (i/__gcd(i, j))*j);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int* a=new int [n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int count=0;
    for(int i=0;i<k;i++)
        count+=a[i];
    cout<<count<<endl;
} 

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(void){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" ";
	if(n>=a+b)cout<<"0"<<endl;
	else cout<<a+b-n<<endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
)

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

func answer(reader io.Reader, writer io.Writer) {
	var n int
	_, _ = fmt.Fscan(reader, &n)
	a := make([]int, n)
	a1 := make([]int, n-1)
	a2 := make([]int, n-1)
	for i := 0; i < n; i++ {
		var v int
		_, _ = fmt.Fscan(reader, &v)
		a[i] = v
	}

	if n == 2 {
		if a[0] < a[1] {
			_, _ = fmt.Fprintf(writer, "%d", a[1])
		} else {
			_, _ = fmt.Fprintf(writer, "%d", a[0])
		}
		return
	}
	a1[0] = a[0]
	a2[n-2] = a[n-1]
	for i := 1; i < n-1; i++ {
		a1[i] = gcd(a1[i-1], a[i])
		a2[n-2-i] = gcd(a2[n-1-i], a[n-1-i])
	}
	//fmt.Printf("%v\n", a)
	//fmt.Printf("%v\n", a1)
	//fmt.Printf("%v\n", a2)
	m := a2[0]
	for i := 0; i < n-1; i++ {
		var c int
		if i < n-2 {
			c = gcd(a1[i], a2[i+1])
		} else {
			c = a1[i]
		}
		if m < c {
			m = c
		}
	}
	_, _ = fmt.Fprintf(writer, "%d", m)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


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

using namespace std;

int main()
{
    int k, s;   cin >> k >> s;

    int ans = 0;

    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            int z = s - (x + y);
            if (z >= 0 && z <= k)
                ++ans;
        }
    }

    cout << ans << endl;
}

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

int n;
int k[101];
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%d",&k[i]);
		}
		string str;
		cin >> str;
		for(int i=0;i<str.size();i++){
			int d=k[i%n];
			for(int j=0;j<d;j++){
				if(str[i]=='A')str[i]='z';
				else if(str[i]=='a')str[i]='Z';
				else str[i]--;
			}
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

int n, s;
int memo[11][1024][400];

int solve( int t, int state, int sum ) {
    if ( sum < 0 ) return 0;
    if ( t == n + 1 ) return sum == 0;
    if ( memo[t][state][sum] != -1 ) return memo[t][state][sum];
    int answer = 0;
    for ( int i = 0; i < 10; ++ i ) {
        if ( state & ( 1 << i ) ) continue;
        answer += solve( t + 1, state | ( 1 << i ), sum - i * t );
    }
    return memo[t][state][sum] = answer;
}

int main() {
    int prev = -1;
    while ( scanf( "%d%d", &n, &s ) != EOF ) {
        if ( n <= prev ) {
            goto output;
        }
        for ( int i = 0; i < 11; ++ i ) {
            for ( int j = 0; j < 1024; ++ j ) {
                for ( int k = 0; k < 400; ++ k ) {
                    memo[i][j][k] = -1;
                }
            }
        }
    output:;
        prev = n;
        printf( "%d\n", s > 340 ? 0 : solve( 1, 0, s ) );
    }

    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
void func(int,int);
int cnt,a,b,n,kouzi[17][17];
int main(void)
{
	int i,j,x,y;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		scanf("%d",&n);
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++){
			kouzi[i][j]=0;
			}
		}
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			kouzi[x][y]=1;
		}
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
	}
	return 0;
}
void func(int y1,int x1){
	if(y1==a&&x1==b){
		cnt++;
	}
	else{
		if(x1+1<=b&&kouzi[y1][x1+1]==0){
			func(y1,x1+1);
		}
		if(y1+1<=a&&kouzi[y1+1][x1]==0){
			func(y1+1,x1);
		}
	}
}


Measured memory_bytes: 2020
N, K = map(int, input().split())
a = list(map(int, input().split()))
s = [0]
for i in range(N):
    s.append(s[-1] + a[i])
d = []
for i in range(N + 1):
    for j in range(i + 1, N + 1):
        d.append(s[j] - s[i])

x = 0
for t in range(40, -1, -1):
    tmp = 0
    for j in d:
        if (x + 2 ** t) & j == x + 2 ** t:
            tmp += 1
    if tmp >= K:
        x += 2 ** t

print(x)


Measured memory_bytes: 65916
def main():
    N, M = map(int, input().split())
    m = [None, None] * M
    i = 0
    while i < M * 2:
        a, b = map(int, input().split())
        m[i] = a
        m[i+1] = b
        i += 2

    for s in range(1, N + 1):
        ans = m.count(s)
        print(ans)

main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int c=0;
  char S[17],T[17]="CODEFESTIVAL2016";
  scanf("%s",S);
  for(int i=0;i<16;i++){
    if(S[i]!=T[i]) c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 1676
#include<cstdio>
#include<cmath>
#include<algorithm>
#define ll long long

using namespace std;

void my_swap(ll a,ll b){
	if(a<b){
		ll t=a;
		a=b;
		b=t;
	}
	
}

int main(){
     ll x,y,t;
     scanf("%lld %lld",&x,&y);
     if(abs(x-y)<=1){
	 	printf("Brown");
	 }
	 else printf("Alice");
    return 0 ;
}

Measured memory_bytes: 128
import java.util.*;
import java.math.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = sc.nextInt();
	    if(n == 0) break;
	    BigInteger s = new BigInteger("0");
	    for(int i = 0; i < n; i++) s = s.add(new BigInteger(sc.next()));

	    System.out.println(s.divide(new BigInteger(Integer.toString(n))).toString());
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  

  
  ll n,d;
  cin>>n>>d;
  cout<<ceil(1.0*n/(2*d+1));

    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
 
 
int main(){
 
  int n,i,s;
  scanf("%d",&n);
  int l[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
 s=0;
 qsort(l, n, sizeof(int), compare_int);
  
    for(i=1;i<n;i++){
    s=s+l[i];
  }
  
  if(l[0]>=s)
    printf("No");
  else printf("Yes");
           
  
}

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

int main()
{
    vector<ll> x(5);
    rep(i, 5) cin >> x[i];
    rep(i, 5) if (x[i] == 0) cout << i + 1 << endl;
    return 0;
}


Measured memory_bytes: 3620
a=[]
N = int(input())
for i in range(N):
    a.append(int(input().strip()))


def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

if N!=1:
    for i in range(len(a)-1):
        pr=a[i]*a[i+1]
        lcm=pr//gcd(a[i],a[i+1])
        a[i+1]=lcm
else:
    lcm=a[0]

print(lcm)

Measured memory_bytes: 3064
n,m = map(int,input().split())

big = max(n,m)
small = min(n,m)

mod = 10**9+7
if big > small+1:
    print(0)
else:
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    for i in range(1,m+1):
        ans *= i
        ans %= mod
    if n== m:
        ans *= 2
    print(ans%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll n;
	cin >> n;
	string s="";
	while(n>0){
		n--;
		char z='a'+n%26;
		s=z+s;
		n/=26;
	}
	cout << s << endl;
 	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll res=0,A[100001],N,sum=0,bsum=0,t;
  cin >> N;
  REP(i,N)cin >> A[i];
  REP(i,N){
    bsum = sum;
    sum += A[i];
    if(bsum*sum > 0 || sum == 0){
      res += abs(sum)+1;
      if(sum < 0)
        sum = 1;
      else
        sum = -1;
    }
  }
  t = res;
  res = abs(A[0])+1;
  if(A[0] > 0)
    A[0] = -1;
  else
    A[0] = 1;
  sum = 0;
  REP(i,N){
    bsum = sum;
    sum += A[i];
    if(bsum*sum > 0 || sum == 0){
      res += abs(sum)+1;
      if(sum < 0)
        sum = 1;
      else
        sum = -1;
    }
  }
  cout << min(res,t) << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 1024