akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main() {
int N;
cin >> N;
vector<ll>T(N);
REP(i, N) cin >> T.at(i);
ll ans;
	if(N == 1) {
		cout << T[0] << endl;
		return 0;
	}else {
    ans = T.at(0);
    REP(i, N - 1){
      ans = lcm(ans, T.at(i + 1));
    }
  }
print(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  int x[N];
  for(int i=0;i<N;i++) cin >> x[i];

  vector<int> pos;
  pos.push_back(X);
  for(int i=0;i<N;i++) pos.push_back(x[i]);
  sort(pos.begin(),pos.end());
  vector<int> dist;
  for(int i=0;i<N;i++) dist.push_back(pos[i+1]-pos[i]);
  sort(dist.begin(),dist.end());

  int mn = dist[0];

  while(mn!=1){
    bool isok=true;
    for(int i=0;i<N;i++){
      if(dist[i]%mn != 0){
        isok = false;
        break;
      }
    }

    if(isok){
      break;
    }else{
      mn--;
    }
  }

  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(){
    ll k;
    cin>>k;
    int l=0;
    ll s=0;
    while(1){
        l++;
        s+=pow(26,l);
        if(s>=k){
            k-=s-pow(26,l);
            break;
        }
    }
    k--;
    vector<int> ret(l);
    for(int i=0;i<l;i++){
        ret[i]=k%26;
        k/=26;
    }
    reverse(ret.begin(),ret.end());
    for(int i=0;i<l;i++){
        cout<<(char)('a'+ret[i]);
    }
    cout<<endl;
}

Measured memory_bytes: 4112
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int a, n;
	cin >> a >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	cout << (sum >= a ? "Yes" : "No");
}


Measured memory_bytes: 3544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		if(n==0){
			System.out.println(x);
			System.exit(0);
		}
		int ans1=0;
		int ans2=0;
		List<Integer> l = new ArrayList<Integer>();
		for(int i = 0;i<n;i++){
			l.add(sc.nextInt());
		}
		int count = 0;
		boolean flg1 = false;
		boolean flg2 = false;
		while(!flg1&&!flg2){

			if(!l.contains(x+count)){
				flg1 = true;
				ans1 = x+count;
			}
			if(!l.contains(x-count)){
				flg2 = true;
				ans2 = x-count;
			}
          count++;
		}
		if(flg2){
			System.out.println(ans2);
		}else{
			System.out.println(ans1);
		}		
	}
}


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

int main(void){
    vector<vector<int> > a(3, vector<int>(3));
    vector<vector<int> > flag(3, vector<int>(3));
    rep(i, 3)rep(j, 3){
        cin>>a[i][j];
    }
    int n;
    cin>>n;
    vector<int>b(n);
    rep(i, n) cin>>b[i];
    rep(num, n){
        rep(i, 3)rep(j, 3){
            if(b[num]==a[i][j]){
                flag[i][j]=1;
            }
        }
    }

    rep(i, 3){
        if(flag[i][0]==1&flag[i][1]==1&&flag[i][2]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    rep(j, 3){
        if(flag[0][j]==1&flag[1][j]==1&&flag[2][j]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(flag[0][0]==1&flag[1][1]==1&flag[2][2]==1){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(flag[0][2]==1&flag[1][1]==1&flag[2][0]==1){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

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

const int mod=924844033;
const int N=2010;
int sz,dp[N],f[2][N][2][2],T,jc[N];
typedef long long ll;
inline void reduce(int&x){x+=x>>31&mod;}
void init(){
	jc[0]=1;
	for(int i=1;i<N;++i)jc[i]=(ll)jc[i-1]*i%mod;
}
int last_n=-1;
void calc(int n){
	if(n!=last_n){
		memset(f,0,sizeof f);
		f[0][0][1][0]=1;T=0;
		for(int i=1;i<=n;++i){
			T^=1;memset(f[T],0,sizeof f[T]);
			for(int j=0;j<i;++j)
				for(int k=0;k<2;++k)
					for(int l=0;l<2;++l)if(f[!T][j][k][l]){
						int v=f[!T][j][k][l];
						reduce(f[T][j][l][0]+=v-mod);
						reduce(f[T][j+1][l][1]+=v-mod);
						if(!k)reduce(f[T][j+1][l][0]+=v-mod);
					}
		}
		last_n=n;
	}
	for(int i=sz+n;i>=0;--i){
		int v=0;
		for(int j=0;j<=i&&j<=n;++j)
			v=(v+(ll)dp[i-j]*(f[T][j][0][0]+f[T][j][1][0]))%mod;
		dp[i]=v;
	}
	sz+=n;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,K;cin>>n>>K;init();
	dp[0]=1;sz=0;
	for(int i=1;i<=K;++i)calc((n-i)/K+1);
	int ans=0;
	for(int i=0;i<=n;++i){
		int v=(ll)dp[i]*jc[n-i]%mod;
		if(i&1)reduce(ans-=v);
		else reduce(ans+=v-mod);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,h,w,a,b,c,d;
string str;

signed main(){

  char gl;
  cin >> a >> gl >> b; 
  cout << (gl=='+' ? a+b : a-b) fin;
                         
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	vector<int> yama;
	int j;
	for (int i = 0; i < 10; i++) {
		cin >> j;
		yama.emplace_back(j);
	}
	sort(yama.begin(), yama.end());
	for (int i = 0; i < 3; i++) {
		cout << yama[9 - i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

using namespace std;

int main() {
  
  int n; cin >> n;
  int odd = (n + 1) / 2;
  printf("%.10lf", 1.0 * odd / n);

  return 0;
}

// created by Daniel yuan


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

int aa(int x){
    int a=1;
    x=x-1;
    while(x>0){
        a=a*10;
        x-=1;
    }
    return a;
}

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/



int main(){
    int N,M;
    cin>>N>>M;
    if(M>0){
    vector<pair<int,int>> sc(M);
    for(int i=0;i<M;i++){
        cin>>sc.at(i).first;
        cin>>sc.at(i).second;
    }
    sort(sc.begin(),sc.end());
    int tmp=0;
    for(int i=0;i<M-1;i++){
        if(sc.at(i).first==sc.at(i+1).first){
            if(sc.at(i).second!=sc.at(i+1).second){
                tmp=-1;
            }
        }
    }
    int tmpp=0;
    if(sc.at(0).first!=1){
        tmpp=1;
    }
    reverse(sc.begin(),sc.end());
    int m=sc.at(0).first;
    
    
    if(N!=1){
        for(int i=0;i<M;i++){
            if(sc.at(i).first==1 && sc.at(i).second==0){
                tmp=-1;
            }
        }
    }

    sort(sc.begin(), sc.end());
    sc.erase( unique(sc.begin(), sc.end()), sc.end() );
    
    if(tmp==0){
    for(int i=0;i<sc.size();i++){
        tmp+=sc.at(i).second*(int)(pow(10,(float)(N-sc.at(i).first)));
        if(tmpp==1){
            tmp+=1*(int)(pow(10,(float)(N-1)));
        }
    }
    }
    cout<<tmp<<endl;
    }
    else{
    if(N!=1){
    int p=1*(int)(pow(10,(float)(N-1)));
    cout<<p<<endl;
    }
    else{
        cout<<0<<endl;
    }
    }
}

Measured memory_bytes: 256
n , y = map(int,input().split())
y = y//1000
for i in range(y//10+1):
    y1 = y-10*i - n +i
    if y1 >=0 and y1%4 == 0 and n-i-y1//4>=0:
        print(i,y1//4,n-i-y1//4)
        exit()
print('-1 -1 -1')

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

public static class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        for (int i = 1; i < 10; i++)
        {
            for (int j = 1; j < 10; j++)
            {
                if (i * j == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }
}

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

using namespace std;

template<class T>
int popcount(T n)
{
    int c = 0;
    for (; n>0; n>>=1)
        c += int(n&1);
    return c;
}

int main()
{
    int N;
    cin>>N;
    vector<vector<int>> a(N, vector<int>(N));
    for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
        cin>>a[i][j];

    vector<int> T(1<<N);
    T[0] = 1;
    for (int i=0; i<N; i++)
        for (int b=0; b<1<<N; b++)
        if (popcount(b) == i)
            for (int j=0; j<N; j++)
            if (!(b>>j&1) && a[i][j])
                T[b|1<<j] += T[b],
                T[b|1<<j] %= 1000000007;
    cout<<T[(1<<N)-1]<<endl;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int main()
{
    fastIO
    int k;
    string s;
    
    cin >> k >> s;
    
    int n = s.size();
    if(n <= k)
        cout << s;
    else
    {
        for(int i = 0; i < k; ++i)
            cout << s[i];
        cout << "...";
    }

    return 0;
}

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

int main(){
	int N,K=0;
	cin >> N;
	vector <int> L(2*N);
	for(int i=0;i<2*N;i++){
		cin >> L[i];
	}
	sort(L.begin(),L.end());
	for(int i=0;i<2*N;i+=2){
		K+=L[i];
	}
	cout << K << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int t_size = t.size();
    if (s == t.erase(t_size-1)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;

int par[MAX_N];
int rk[MAX_N];

void init(int n){
  REP(i,n){
    par[i] = i;
    rk[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(rk[x] < rk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rk[x] == rk[y]) rk[x]++;
  }
}

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


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

  init(n);

  int p[n], x[m], y[m];
  REP(i,n) cin >> p[i];
  REP(i,m){
    cin >> x[i] >> y[i];
    unite(x[i]-1, y[i]-1);
  }

  ll ans = 0;
  REP(i,n){
    if(same(i,p[i]-1) || i == p[i]-1) ans++;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>                                                                             
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {
    int k, s;
    int ans = 0;
    cin >> k >> s;
    REP(i,k+1) {
        REP(j,k+1) {
            if(0 <= s-i-j && s-i-j <=k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)

Measured memory_bytes: 3268
//============================================================================
// Name        : abc145_d.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : test program
//============================================================================

/*
D - Knight

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 400 点

問題文
二次元グリッドの原点 (0, 0) にチェスのナイトの駒があります。
ナイトの駒はマス (i, j) にあるとき (i+1, j+2) か (i+2, j+1) のどちらかのマスにのみ動かすことができます。
ナイトの駒をマス (X, Y) まで移動させる方法は何通りありますか？
10^9+7 で割った余りを求めてください。

制約

・1 <= X <= 10^6
・1 <= Y <= 10^6
・入力中のすべての値は整数である。
 */

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

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

using ll = long long;
using ull = unsigned long long;

#define REP(i, m, n) for (ll i = (m); i < (ll)(n); ++(i))
#define REPM(i, m, n) for (ll i = (m); i <= (ll)(n); ++(i))
#define REPR(i, m, n) for (ll i = (m); i >= (ll)(n); --(i))
#define REPD(i, m, n, d) for (ll i = (m); i < (ll)(n); i += (d))
#define REPMD(i, m, n, d) for (ll i = (m); i <= (ll)(n); i += (d))
#define ALL(x) begin(x), end(x)

const ll MAX = 1000000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

/**
 * エントリポイント．
 * @return 0.
 */
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // const ll mod = 1e9 + 7;

    ll x, y;
    cin >> x >> y;

    // dp[i][j] == dp[j][i] が使える?
    // (x, y) に移動 => 右＋下に (x + y) 回移動，1回で 3 だけ移動する

    ll count = x + y;
    if (count % 3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    ll large = max({x, y});
    ll small = min({x, y});
    if (large > small * 2)
    {
        cout << 0 << endl;
        return 0;
    }
    count = count / 3; // 移動回数にする
    // count のうち何回を x に割り当てるか？
    // ずっと x を増やし続けて， (x の残り) * 2 == y の残り になるまでは x を増やし続けられる
    ll xc = 0;
    while ((x - 2 * xc) * 2 > y - xc)
    {
        xc++;
    }

    // ll yc = count - xc;
    // count のうち xc 回をどこで使うか? count C xc
    COMinit();
    // cerr << count << " " << xc << endl;
    cout << COM(count, xc) << endl;

    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
 
#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }
 
void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}
 
int main(){
    iostream_init();
    int m, n1, n2;
    while(cin >> m >> n1 >> n2 && m != 0) {
    vector<int> P(m);
    REP(i, m) cin >> P[i];
    int max_diff = -1;
    int ans = -1;
    for(int i = n1; i <= n2; i++) {
        int diff = P[i-1] - P[i];
        if(diff >= max_diff) {
            max_diff = diff;
            ans = i;
        }
    }
    cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
from itertools import product

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for now in product(range(2), repeat=N):
    res = 0
    An = [0 for _ in range(M)]
    for n in range(N):
        if now[n] == 1:
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9224
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	ll n;
	cin>>n;
	vector<ll> node(n);
	vector<vector<ll>> map(n);
	vector<pair<int ,int>> oder(n-1);
	std::map<ll, int> ans;
	rep(i,n-1)
	{
		ll foo,fooo;
		cin >> foo >> fooo;
		foo--;
		fooo--;
		node[foo]++;
		node[fooo]++;
		map[foo].push_back(fooo);
		oder[i]=make_pair(foo,fooo);
	}
	ll ma=0;
	rep(i,n)ma=max(ma,node[i]);
	cout<<ma<<endl;



	//rep(i,ans.size())cout<<ans[i].size()<<endl;

	rep(i,n)sort(ALL(map[i]));
	queue<ll> color;
	queue<ll> Q;
	color.push(0);
	Q.push(0);
	//cout<<color.front()<<endl;
	while(!Q.empty())
	{
		ll nowcolor = color.front();
		color.pop();
		ll nextcolor = 0;
		ll now=Q.front();
		Q.pop();
		for(ll i=0;i<map[now].size();i++)
		{
			Q.push(map[now][i]);
			if((nextcolor+1)==nowcolor)
			{
				nextcolor+=2;
				color.push(nextcolor);
			}
			else
			{
				nextcolor++;
				color.push(nextcolor);
			}
			ans[(1LL)*now*1000000+map[now][i]]=nextcolor;
		}
		//cout<<endl;
		//cout<<"a"<<endl;
	}
	rep(i,n-1)
	cout<<ans[(1LL)*oder[i].first*1000000+oder[i].second]<<endl;
	return 0;
}


Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main(){
    ll H,W;
    cin>>H>>W;
    char grid[H+1][W+1];
    
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>grid[i][j];
        }
    }
    
    ll dp[H+1][W+1];
    memset(dp,0,sizeof(dp));
    
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(grid[i][j]=='#')
            continue;
            
            if(i==1 && j==1)
            dp[i][j] = 1;
            
            else
            dp[i][j] = ((dp[i-1][j])%mod + (dp[i][j-1])%mod)%mod;
        }
    }
    cout<<dp[H][W]<<endl;
}

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

int main() {
  int N;
  cin >> N;

  string YES = "Yes";
  string NO = "No";

  int N1000 = N/1000;
  int simo3 = N - N1000*1000;

  int kami3 = N*0.1;

  if (N%1000 == 0 || N%1111 == 0 || simo3%111 == 0 || kami3%111 == 0) {
    cout << YES << endl;
  }else{
    cout << NO << endl;
  }

}


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

ll dfs(vector<vector<ll>> &adj, ll i, vector<ll> &dp)
{
    ll c=0;
    if(dp[i]!=-1)
        return dp[i]+1;
    for(auto j:adj[i])
    {
        c=max(c,dfs(adj,j,dp));
    }
    dp[i]=c;
    return c+1;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,m,u,v,i;
    cin>>n>>m;
    vector<vector<ll>> adj(n);
    
    for(i=0;i<m;i++)
    {
        cin>>u>>v;
        u--;
        v--;
        adj[u].push_back(v);
    }
    
    vector<ll> dp(n,-1);
    
    for(i=0;i<n;i++)
    {
        if(dp[i]==-1)
            dfs(adj,i,dp);
    }
    ll ans=0;
    for(i=0;i<n;i++)
    {
        // cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9216
/*
                            ---| APOORVA MITTAL |---
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl "\n"
#define nl   "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repD(i, a, b) for (int i = a; i >= b; i--)
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define init(i, k) memset(i, k, sizeof i)

#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define inp(a) rep(i,0,a.size()) cin>>a[i]; 
#define out(a) rep(i,0,a.size()) cout<<a[i]<<" "; \
                cout<<endl;
#define out2d(a)    \
    rep(i,0,a.size())\
    {rep(j,0,a[0].size())\
    cout<<a[i][j]<<" ";\
    cout<<endl;}       

#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define gcd(a,b)        __gcd(a,b)
#define deb(x) cout<<#x<<" "<<x<<endl;

int lcm(int a, int b) { return (a * (b / __gcd(a, b))); }
int ncr(int n,int r){int res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
#define Y				"YES"
#define N 				"NO"
const int mod = 1e9 + 7;
const int inf = 1e18;
const int maxn = 1e3 + 5;
// ====== Useful functions begin ======
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
// unordered_map<pair<int,int>,int,HASH>m;

inline int add(int a,int b) {return ((a%mod)+(b%mod))%mod;}
inline int sub(int a,int b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline int mul(int a,int b) {return ((a%mod)*(b%mod))%mod;}
int pwr(int x,int n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
int modinv(int n){ 
    return pwr(n,mod - 2); 
}

// ====== Useful functions end ======

//--------------------------------------------------------------------------------------------------------------------------------
void solve()
{
   string s;cin>>s;
   rep(i,0,s.size())
   {
       if(s[i]=='7')
       {
           cout<<"Yes"<<endl;
           return;
       }
   }
   cout<<"No"<<endl;

}
signed main()
{	
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

	speed;
	int t=1;
	// cin>>t;
	
	for(int tt=1;tt<=t;tt++)
	{
		// cout<<"Case #"<<tt<<": ";
		solve();
	}
}


Measured memory_bytes: 3644
a=[];b=[]
for i in range(5):
    a1 = int(input())
    a.append(a1)
    b.append(a1%10)
sum = 0
for i in range(5):
    if a[i]%10 ==0:
        sum += a[i]
    else:
        sum += a[i] +10 -a[i]%10
c = [i for i in b if not i ==0 ]
if c == []:
    print(sum)
else:
    print(sum-10+min(c))

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

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

    int a, b;
    cin >> a >> b;
    if (a >= 10 || b >= 10) {
        cout << -1 << endl;
    } else {
        cout << a * b << endl;
    }
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int A, B;
  char buf[100], *s = buf;
  bool flag = true;

  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%s", s);

  for (int i = 0; i < A; i++) flag &= isdigit(*s++);
  flag &= *s++ == '-';
  for (int i = 0; i < B; i++) flag &= isdigit(*s++);
  flag &= *s == '\0';

  printf("%s\n", flag ? "Yes" : "No");
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int N=1e5+7;
int n;
struct edge{
	int to,v,nx;
}e[N*2];
int ep=2,e0[N],sz[N],cg=0,bi=0;
i64 ans=0;
void f1(int w,int pa){
	bool is=1;
	sz[w]=1;
	for(int i=e0[w],u;i;i=e[i].nx){
		u=e[i].to;
		if(u!=pa){
			f1(u,w);
			sz[w]+=sz[u];
			ans+=i64(e[i].v)*2*std::min(sz[u],n-sz[u]);
			if(sz[u]*2>n)is=0;
			if(sz[u]*2==n)ans-=e[i].v,bi=1;
		}
	}
	if(sz[w]*2<n)is=0;
	if(is)cg=w;
}
int main(){
	scanf("%d",&n);
	for(int i=1,a,b,c;i<n;++i){
		scanf("%d%d%d",&a,&b,&c);
		e[ep]=(edge){b,c,e0[a]};e0[a]=ep++;
		e[ep]=(edge){a,c,e0[b]};e0[b]=ep++;
	}
	f1(1,0);
	if(!bi){
		int mv=INT_MAX;
		for(int i=e0[cg];i;i=e[i].nx)mv=std::min(mv,e[i].v);
		ans-=mv;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>

using namespace std;

int main(){
    double a,b;
    cin >> a >>b;
    double ans = 0;
    ans = (a+b)/2;
    if(ans >= (int)ans + 0.5)    cout << (int)ans + 1<< '\n';
    else    cout << (int)ans << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  string s;
  cin >> n >> s;
  stack<char> st;
  deque<char> res;
  for (char c : s) {
    if (c == ')') {
      if (st.empty()) {
        res.push_front('(');
        res.push_back(')');
      } else if (st.top() == '(') {
        st.pop();
        res.push_back(')');
      }
    } else if (c == '(') {
      st.push(c);
      res.push_back('(');
    }
  }
  while (!st.empty()) {
    res.push_back(')');
    st.pop();
  }
  for (char c : res) {
    cout << c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 7;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

ll x, ans;

int main(){
    Speedforce
    //fop("", "")
    cin >> x;
    cout << 1000 * (x / 500) + (x % 500) / 5 * 5;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
  int i,n,x;
  cin>>n;
 
  for(i=1;i<n+1;i++){
    x=i;
    if(x%3==0){
      cout<<" "<<i;
    }else{
      while(x>0){
        if(x%10==3){
          cout<<" "<<i;
          break;
        }else{
          x /= 10;
        }
      }
    }
  }
  cout<<endl;
 
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const int maxn = 5e5 + 5;

string s;
int N;
int a[maxn];

signed main(void){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin >> s;
	N = s.size();
	s = " " + s;
	for (int i=2; i<=N+1; ++i){
		if (s[i-1] == '<')
			a[i] = max(a[i], a[i-1] + 1);
	}
	for (int i=N+1; i>=2; --i)
		if (s[i-1] == '>')
			a[i-1] = max(a[i-1], a[i] + 1);
	ll res = 0;
	for (int i=1; i<=N+1; ++i)
		res += a[i];
	cout << res << '\n';
}


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

struct Point {double x,y;};

void Koch(int n,Point a, Point b){
    if(n==0) return;

    Point s,t,u;
    double th=M_PI*60.0/180.0;

    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

    Koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    Koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    Koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    Koch(n-1,t,b);
}
int main()
{
    Point a,b;
    int n;
    scanf("%d",&n);
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    printf("%.8f %.8f\n",a.x,a.y);
    Koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    return 0;
}



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

int main(){
  int n,k;
  cin >> n;
  cin >> k;
  vector<int> v(n);
  for(int i=0; i<n ; i++){
    cin >> v[i];
  }
  vector <int> dp(n, INT_MAX);
  dp[0] = 0;
  for(int i=0; i<n; i++){
    for(int j = i+1; j <= i+k ; j++ ){
        if(j < n){
            dp[j] = std::min(dp[j], dp[i]+abs(v[i]-v[j]));

        }
    }
  }
  cout << dp[n-1];
}


Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::pair<std::vector<ll>,ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    graph G(N);
    for (int i = 0; i < N - 1; ++i) {
        ll A,B;
        cin >> A >> B;
        A--; B--;
        G[A].first.push_back(B);
        G[B].first.push_back(A);
    }
    for (int j = 0; j < N; ++j) {
        G[j].second = -1;
    }
    queue<ll> q = queue<ll>();
    q.push(0);
    while(!q.empty()){
        ll current = q.front();q.pop();
        for (int i = 0; i < G[current].first.size(); ++i) {
            ll next = G[current].first[i];
            if(G[next].second != -1 || next == 0){
                continue;
            }
            q.push(next);
            G[next].second = current;
        }
    }
    ll current = N-1;
    vector<ll> route = vector<ll>(0);
    while(current!= -1){
        route.push_back(current);
        current = G[current].second;
    }
    for (int i = 0; i < route.size(); ++i) {
        //cout << route[i] << endl;
    }

    vector<int> col(N);
    fill(col.begin(),col.end(),-1);
    queue<ll> bQ = queue<ll>();
    queue<ll> wQ = queue<ll>();
    ll sumB = 0;
    ll sumW = 0;
    for (int i = 0; i < route.size(); ++i) {
        if(col[route[i]] == -1){
            col[route[route.size() - i - 1]] = 0;
            bQ.push(route[route.size() - i - 1]);
            sumB++;
        }

        if(col[route[i]] == -1){
            col[route[i]] = 1;
            wQ.push(route[i]);
            sumW++;
        }
    }
    while(!wQ.empty()){
        ll current = wQ.front();wQ.pop();
        for (int i = 0; i < G[current].first.size(); ++i) {
            ll next = G[current].first[i];
            if(col[next] != -1){
                continue;
            }
            wQ.push(next);
            col[next] = 1;
            sumW++;
        }
    }
    while(!bQ.empty()){
        ll current = bQ.front();bQ.pop();
        for (int i = 0; i < G[current].first.size(); ++i) {
            ll next = G[current].first[i];
            if(col[next] != -1){
                continue;
            }
            bQ.push(next);
            col[next] = 0;
            sumB++;
        }
    }
    for(int i = 0; i < N; i++){
        //cout <<i<<","<<col[i] << endl;
    }
    if(sumB > sumW){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }




}


Measured memory_bytes: 8564
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
int main()
{
  int a,b,ans=-1,i;
  cin>>a>>b;
  for(i=a;i<=1100;i++)
  {
    if((floor(0.08*i)==a)&&(floor(0.1*i)==b))
    {
      ans=i;
      break;
    }
  }
  cout<<ans;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define ld long double
#define MAX (int)(pow(10,6) + 10)
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7;
ld eps = 1e-9;


void deal(){
	ll n, k;
	cin>>n>>k;
	++n;
	ll sumbig = 0;
	ll sumsmall = 0;
	ll ans = 0;
	for(ll i = 1; i<=n; i++){
		sumbig+=n-i;
		sumsmall+=i-1;
	//	cout<<sumsmall<<" "<<sumbig<<endl;
		if(i >= k){
			ans+=sumbig-sumsmall+1;
			ans%=modulo;	
		}
	}
	cout<<ans;
}


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





























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

int gcd(int x,int y,int z){
  int tmp = z;
  while( x % y != 0 ){
     z = x % y;
     x = y;
     y = z;
  }
  x = tmp;

  while( x % y != 0 ){
     z = x % y;
     x = y;
     y = z;
  }
  return y;
}
int main(void){
  int N =0;
  long sum=0;
  scanf("%d\n",&N);
  for(int i=1;i < (N+1);i++){
    for(int j =1;j < (N+1);j++){
      for(int k =1;k< (N+1);k++){
        sum += gcd(i,j,k);
      }
    }
  }
  printf("%ld\n",sum);
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int N, M, Q, A[11];

int a[55], b[55], c[55], d[55];

int calc_bit(int K) {
	int ret = 0;
	while (K > 0) {
		if (K % 2 == 1) { ret++; }
		K /= 2;
	}

	return ret;
}

vector<int> V;

int CALC(void) {

	int ret = 0;
	for (int i = 1; i <= Q; i++) {
		if (V[b[i] - 1] - V[a[i] - 1] == c[i]) { ret += d[i]; }
	}
	return ret;
}

int main(void) {

	cin >> N >> M >> Q;

	int ans = 0;

	for (int i = 1; i <= Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	/*for (int k = 0; k < (1 << M); k++) {
		if (calc_bit(k) == N) {
			//cout << k << endl;

			V.clear();

			int m = k;
			for (int i = 1; i <= M; i++) {
				if ((k >> (i - 1)) & 1) { V.push_back(i); }
			}

			for (auto y : V) { cout << " " << y; }cout << endl;

			ans = max(ans, CALC());

		}
	}*/

	for (int i = 1; i <= N; i++) { V.push_back(1); }

	while (1) {

		//for (auto y : V) { cout << " " << y; }cout << endl;
		ans = max(ans, CALC());


		int I = 0;
		for (I = N - 1; I >= 0; I--) { 
			if (V[I] < M) {
				V[I]++;
				for (int j = N; j >= I + 1; j--) { V[j] = V[I]; }
				break; } }

		int sig = 0;
		for (int i = 0; i < N; i++) {
			if (V[i] != M) { sig = 1;  continue; }
		}
		if (sig == 0) { break; }
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#include<stdio.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;

#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int INF = 1<<29;

using namespace std;


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock();  
	int n;
	cin>>n;
	vector<int> stones(n);
	for(int& x:stones)
	{
		cin>>x;
	}
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i = 0 ; i< n ;i++)
	{
		for(int j:{i+1,i+2})
		{
			if(j<n) dp[j] = min(dp[j],dp[i]+abs(stones[i]-stones[j]));
		}
	}
	printf("%d",dp[n-1]);


	//time_req = clock()- time_req;cout << "Time Compexity:"<< (float)time_req/CLOCKS_PER_SEC << " seconds" << endl; 
	return 0;
}

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

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

const int inf = 1<<29;
int n;
int dp[2][2][5010];
int cut[10010];

/*
  dp[next][0][k+1] = min(dp[cur][0][k])
  dp[next][1][k+1] = min(dp[cur][0][k] + cut[i]);

  dp[next][1][k]   = min(dp[cur][1][k])
  dp[next][0][k]   = min(dp[cur][1][k] + cut[i])
 */
int main(){
    int i,j,k;

    scanf("%d",&n);
    // init
    rep(i,2)rep(j,2)rep(k,5010) dp[i][j][k] = inf;

    // input
    rep(i,n-1) scanf("%d",&cut[i]);

    dp[0][0][0] = 0;
    rep(i,n){
        int cur = i%2, next = (i+1)%2;
        rep(k,n/2+1){
            dp[next][0][k+1] = min(dp[next][0][k+1], dp[cur][0][k]);
            if( i < n-1 ) dp[next][1][k+1] = min(dp[next][1][k+1], dp[cur][0][k] + cut[i]);

            dp[next][1][k] = min(dp[next][1][k], dp[cur][1][k]);
            if( i < n-1 ) dp[next][0][k] = min(dp[next][0][k], dp[cur][1][k] + cut[i]);
        }
        rep(j,2)rep(k,n/2+1) dp[cur][j][k] = inf;
    }

    printf("%d\n",min(dp[n%2][0][n/2],dp[n%2][1][n/2]));

    return 0;
}

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


int main(){
  
  int N, X, A, s, S;
  cin >> N;
  s = 0;
  S = 0;
  vector<int> x(N);
  
  for(int i=0; i < N; i++){
    cin >> x.at(i);
    s += x.at(i);
  }
  A = s * 10 / N;
  //cout << A - A/10*10 << endl;
  
  
  if(A - A/10*10 >= 5 && A - A/10*10 != 10){
    A = A/10 + 1;
  }
  else{
    A = A/10;
  }
  //cout << A << endl;
  
  for(int i=0; i < N; i++){
    S += (x.at(i) - A) * (x.at(i) - A);
  }
  
  cout << S << endl;
  
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m;
	scanf("%d%d", &n, &m);

	string s(n, '?');
	while (m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		char c = '0' + b;
		if (s[a] == '?') s[a] = c;
		else if (s[a] != c) {
			puts("-1");
			return 0;
		}
	}

	for (int i = 0; i < n; i++) {
		if (s[i] != '?') continue;
		if (i == 0 && n > 1) s[i] = '1';
		else s[i] = '0';
	}
	if (s[0] == '0' && n > 1) {
		puts("-1");
		return 0;
	}
	cout << s << endl;
}


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

b.reverse()
ans = []
disable = False

for i in range(N):
  for j in range(len(b)):
    if b[j] == len(b) - j:
      ans.append(b.pop(j))
      break
    if j == len(b) - 1:
      disable = True
      ans = [-1]
      break
  if disable:
    break

ans.reverse()
for a in ans:
  print(a)

Measured memory_bytes: 3064
from copy import deepcopy


class Matrix:
    ZERO = 0
    ONE = 1

    def __init__(self, mat, copy: bool = True):
        assert(len(mat) and len(mat[0]))
        if copy:
            self.mat = deepcopy(mat)
        else:
            self.mat = mat

    def __matmul__(self, other):
        ret = [[self.ZERO] * len(other.mat[0]) for _ in range(len(self.mat))]
        for i in range(len(self.mat)):
            for k in range(len(self.mat[0])):
                for j in range(len(other.mat[0])):
                    ret[i][j] += self.mat[i][k] * other.mat[k][j]
        return Matrix(ret)

    def __pow__(self, k):
        ret = Matrix([[self.ZERO] * len(self.mat[0])
                      for _ in range(len(self.mat))])
        for i in range(len(self.mat)):
            ret.mat[i][i] = self.ONE
        n = Matrix(deepcopy(self.mat))

        while k:
            if k & 1:
                ret = ret.__matmul__(n)
            n = n.__matmul__(n)
            k >>= 1
        return ret

    @property
    def shape(self):
        return len(self.mat), len(self.mat[0])

    def __str__(self):
        return '[{}]\n'.format('\n'.join(str(row) for row in self.mat))


def det(mat: Matrix, mod: int = 998244353) -> int:
    # mat は変更されることに注意。
    ret = 1
    N = mat.shape[0]
    for i in range(N):
        pivot = i
        for j in range(i+1, N):
            if abs(mat.mat[j][i]) > abs(mat.mat[pivot][i]):
                pivot = j
        mat.mat[i], mat.mat[pivot] = mat.mat[pivot], mat.mat[i]
        ret *= mat.mat[i][i] * (-1 if i != pivot else 1)
        ret %= mod
        if not mat.mat[i][i]:
            break
        inv = pow(mat.mat[i][i], mod-2, mod)
        for j in range(i+1, N):
            for k in reversed(range(i, N)):
                mat.mat[j][k] += mod - mat.mat[i][k] * \
                    mat.mat[j][i] % mod * inv % mod
                mat.mat[j][k] %= mod
    return ret


def yosupo():
    # https://judge.yosupo.jp/problem/matrix_det
    N = int(input())
    mat = [[int(x) for x in input().split()] for _ in range(N)]
    print(det(Matrix(mat)))


def aoj_matmul():
    N, M, L = map(int, input().split())
    mat1, mat2 = [], []
    for _ in range(N):
        mat1.append([int(x) for x in input().split()])
    for _ in range(M):
        mat2.append([int(x) for x in input().split()])
    A, B = Matrix(mat1, False), Matrix(mat2, False)
    for row in (A @ B).mat:
        print(*row)


if __name__ == '__main__':
    # yosupo()
    aoj_matmul()



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

bool check(vl a){
  ll n = sz(a);
  for(int i = 1; i < n; i++){
    if(a[i] < a[i - 1]){
      return 0;
    }
  }
  return 1;
}

int main(){
  fastio

  ll n, i, j, k, t;
  string s;
  ll ans = 0;

  cin >> n;

  vl A(n);
  forn(0, n, i){
    cin >> A[i];
  }

  if(check(A)){
    cout << "YES\n"; return 0;
  }

  forn(0, n, i){
    forn(i + 1, n, j){
      swap(A[i], A[j]);
      if(check(A)){
        cout << "YES\n"; return 0;
      }
      swap(A[i], A[j]);
    }
  }

  cout << "NO\n";

  ktj();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <utility>

using namespace std;

char s1[4001], s2[4001];

int main(){
	while(true){
		memset(s1, 0, sizeof(char) * 4001);
		memset(s2, 0, sizeof(char) * 4001);
		if(!(cin >> s1 >> s2)){ break; }
		int l1 = strlen(s1), l2 = strlen(s2), answer = 0;
		for(int ofs = 1 - l2; ofs < l1; ofs++){
			int last = min(l1, ofs + l2), cur = 0;
			for(int i = max(0, ofs); i < last; i++){
				if(s1[i] != s2[i - ofs]){
					answer = max(answer, cur);
					cur = 0;
				}else{
					cur++;
				}
			}
			answer = max(answer, cur);
		}
		cout << answer << endl;
	}
	return 0;
}

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

long N;

int main(){
    cin>>N;

    if(N%2==1){
        cout<<0;
        return 0;
    }

    N/=2;

    //long count=1;
    long ans=0;
    do{
        ans+=N/=5;
    }while(N!=0);
    

    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll solve (string s) {
    ll cnt = 0, ret = 0;
    rep(i, (int)s.size()) {
        ++cnt;
        if (i == (int)s.size() - 1 || s[i] != s[i+1]) {
            ret += cnt / 2;
            cnt = 0;
        }
    }
    return ret;
}

int main() {
    string t;
    cin >> t;
    ll k;
    cin >> k;

    bool flag = true;
    ll n = t.size();
    rep(i, n-1) {
        if (t[i] != t[i+1]) {
            flag = false;
        }
    }
    if (flag) {
        cout << n * k / 2LL << endl;;
    }
    else {
        string v1 = t;
        string v2 = t + t;
        ll r1 = solve(v1);
        ll r2 = solve(v2);
        cout << r1 + (r2 - r1) * (k - 1LL) << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
n = int(input())
a = list(map(int, input().split()))

cnt = 0
while True:
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            break
    else:
        cnt += 1
        continue
    break

print(cnt)

Measured memory_bytes: 38896
main(){long n;scanf("%ld",&n);for(long i=1;i<=3500;++i)for(long j=1;j<=3500;++j)if(4*i*j-n*i-n*j>0&&n*i*j%(4*i*j-n*i-n*j)==0){printf("%ld %ld %ld",i,j,n*i*j/(4*i*j-n*i-n*j));return 0;}}

Measured memory_bytes: 128
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res
n = int(input())
data = list(map(int, input().split()))
cnt = count(data)
monsters = sorted(cnt.keys())
total = sum(data)
ans = n
idx = len(monsters)-2
while idx >= 0:
    prev = monsters[idx+1]
    total -= prev*cnt[prev]
    if total*2 < prev:
        break
    idx -= 1
out = 0
while idx >= 0:
    m = monsters[idx]
    out += cnt[m]
    idx -= 1

ans -= out 
print(ans)

Measured memory_bytes: 18752