akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
  long long x,y;
  cin >> x >> y;
  if(x>y && x%y!=0)cout << x*(y+1) << endl;
  else if(y>x) cout << x*(y+1) << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
p = 998244353
max = 2 * (10**5)
fact = [1,1]
facti = [1,1]
inv = [0,1]
for i in range(2, max + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    facti.append((facti[-1] * inv[-1]) % p)

def comb(n,r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * facti[r] * facti[n-r] % p

n,m,k = map(int, input().split())
ans = 0
for i in range(k+1):
    a = comb(n-1,i)
    b = m * pow(m-1,n-1-i,998244353)
    ans += (a * b)% 998244353
print(ans%998244353)

Measured memory_bytes: 32732
N = int(input())
ans = 0
l=[]
r=[]
for i in range(N):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)

for i in range(N):
    ans += (abs(r[i]-l[i])+1)

if ans<=10**5:
    print(ans)
else:
    print(10**5)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int time = A+B;
    if(time >= 24) cout << time - 24 << endl;
    else cout << A+B << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    double max;

    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];

    sort(v.begin(), v.end());

    max = v[0];
    for(int i = 1; i < n; ++i)
        max = (max + v[i]) / 2;

    cout << max << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

using ll = long long;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	string ans[4];
	ans[0] = "SS";
	ans[1] = "SW";
	ans[2] = "WS";
	ans[3] = "WW";
	for (int i = 0; i < 4; i++) {
		ans[i].resize(n + 2);
		for (int j = 1; j < n + 1; j++) {
			char next;
			if ((ans[i][j - 1] == ans[i][j%n]) == (s[j%n] == 'o')) {
				next = 'S';
			}
			else next = 'W';
			ans[i][j + 1] = next;
		}
		if (ans[i][0] == ans[i][n] && ans[i][1] == ans[i][n + 1]) {
			ans[i].resize(n);
			cout << ans[i] << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 896
import sys
import bisect

inf = float('inf')

def solve():
    n = int(input())
    A = [int(input()) for i in range(n)]
    dp = [inf] * n
    # max_ = 1

    for a in A:
        j = bisect.bisect_left(dp, a)
        # max_ = max(max_, j + 1)
        dp[j] = a

    # print(dp)

    ans = 1
    for i, v in enumerate(dp):
        if v == inf:
            ans = i
            break
    else:
        ans = n
        
    print(ans)


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

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

int N;
std::vector<int> a;
int main(void){
    std::cin >> N;
    a.resize(N);
    for(int i=0; i<N; ++i){
        std::cin >> a[i];
        --a[i];
    }
    int b = 0;
    int ans = -1;
    for(int i=0; i<N;++i){
        b = a[b];
        if(b == 1){
            ans = i+1;
            break;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 640
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop, std.typetuple, std.typecons;

immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;

void main(){
    double r = readln.chomp.to!double;
    auto area = r^^2 * PI;
    auto circum = 2 * r * PI;

    writefln("%.7f %.7f", area, circum);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    str ans = "";
    for (; n > 0; n /= 26) {
        char c = 'a' + --n % 26;
        ans.insert(ans.begin(), c);
    }

    std::cout << ans << '\n';
}


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

const int N = 100233;
int n, u, v, p, dep[N], vis[N], size[N];
vector<int> G[N], t(1, 1);
void dfs(int x, int pre) {
  dep[x] = dep[pre] + 1;
  for (auto y : G[x]) if (y != pre) {
    dfs(y, x);
  }
}
bool dfs(int x, int pre, int g) {
  vis[x] = ++p;
  if (x == g) return true;
  for (auto y : G[x]) if (y != pre) {
    if (dfs(y, x, g)) return true;
  }
  vis[x] = 0;
  --p;
  return false;
}
void get() {
  vector<int> f(1, 0);
  for (int i = 1, a = 0; i <= p; i++) {
    for (int j = 1; j <= size[i]; j++) f.push_back(a + j + 1);
    f.push_back(a + 1);
    a += size[i] + 1;
  }
  t = min(t, f);
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) if (dep[i] > dep[u]) {
    u = i;
  }
  dfs(u, 0);
  for (int i = 1; i <= n; i++) if (dep[i] > dep[v]) {
    v = i;
  }
  dfs(u, 0, v);
  for (int i = 1; i <= n; i++) if (!vis[i]) {
    if (G[i].size() > 1) return puts("-1"), 0;
    size[vis[G[i][0]]]++;
  }
  get();
  reverse(size + 1, size + 1 + p);
  get();
  for (int i = 1; i <= n; i++) {
    printf("%d%c", t[i], i == n ? '\n' : ' ');
  }
}


Measured memory_bytes: 14448
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if(b > n * a) cout << n * a<< endl;
    else cout << b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define INF (2e9)
const int maxv=10000+10;
const int maxe=100000+10;
int V,E;
int d[maxv];
struct Edge
{
    int from,to,cost;
};
Edge es[maxe];

int p[maxv];
int rank[maxv];

bool cmp(const Edge& a,const Edge& b)
{
    return a.cost<b.cost;
}


void init(int n)
{
    for(int i=0; i<n; i++)
    {
        p[i]=i;
        rank[i]=0;
    }
}
int fnd(int x)
{
    if(x==p[x]) return x;
    return fnd(p[x]);

}
bool is_same(int x,int y)
{
    return fnd(x)==fnd(y);

}
void unite(int x,int y)
{
    x=fnd(x);
    y=fnd(y);
    if(x==y) return;
    if(rank[x]>rank[y])
    {
        p[y]=x;
    }
    else
    {
        p[x]=y;
        if(rank[x]==rank[y]) rank[y]++;
    }
}
void kruskal()
{
    sort(es,es+E,cmp);
    init(V);
    int res=0;
    for(int i=0; i<E; i++)
    {
        Edge &e=es[i];
        if(!is_same(e.from,e.to))
        {
            unite(e.from,e.to);
            res+=e.cost;
        }
    }
    printf("%d\n",res);
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&V,&E);
    int u,v,cost;
    for(int i=0; i<E; i++)
    {
        scanf("%d%d%d",&u,&v,&cost);
        es[i].from=u;
        es[i].to=v;
        es[i].cost=cost;
    }
    kruskal();
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  Graph G(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int cnt = 0;
  rep(v,n){
    bool OK = true;
    for (auto nv : G[v]) {
      if (h[v]<=h[nv]) OK = false;
    }
    if(OK) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 8796
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  in(a),in(b)
#define in3(a,b,c)  in2(a,b),in(c)
#define in4(a,b,c,d)  in2(a,b),in2(c,d)
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
bool check(int x){
	FOR(i,2,sqrt(x))
		if(x%i==0)return 0;
	return 1;
}
int main(){
	int num=0;
	int n;in(n);
	FOR(i,2,55555){
		if(i%10==1&&check(i))
			cout<<i<<endl,num++;
		if(num==n)break;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
long long n;	
cin>>n;
long long s=0;
for (long long d = 1; d*d <= n; ++d) {
  if (n % d == 0) {
  if(n/d-1>d)s+=n/d-1;
}}
	cout<<s<<'\n';
}

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

using namespace std;

int f[30];
int c[30];
int sum[30];
int tmp[30];
int a[30][1005];
int n,m,ans, k;

void check()
{
    int res = 0;
    int N = 1;
    for (int i = 1; i <= n; i++)
    {
        if (f[i]) N++, res++;
        c[i] = N;
    }
    for (int i = 1; i <= N; i++)
    {
        sum[i] = 0;
        tmp[i] = 0;
    }
    for (int j = 1; j <= m; j++)
    {
        for (int i = 1; i <= n; i++)
        {
            tmp[c[i]] += a[i][j];
            if (tmp[c[i]] > k) return;
        }
        bool ok = true;
        for (int i = 1; i <= N; i++)
        {
            if (sum[i] + tmp[i] > k) ok = false;
        }
        if (!ok)
        {
            res++;
            for (int i = 1; i <= N; i++)
            {
                sum[i] = tmp[i];
                tmp[i] = 0;
            }
        } else {
            for (int i = 1; i <= N; i++)
            {
                sum[i] += tmp[i];
                tmp[i] = 0;
            }
        }
    }
    ans = min(ans, res);
}

void binary_gen(int i)
{
    for (int j = 0; j <= 1; j++)
    {
        f[i] = j;
        if (i == n) check();
        else binary_gen(i + 1);
    }
}

int main()
{
    //freopen("file.inp","r",stdin);
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        char c;
        cin >> c;
        a[i][j] = c - '0';
    }
    ans = 1e9;
    binary_gen(2);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

const int maxn = 100 + 10;

int main()
{
    int A[maxn];
    int n ;
    cin >> n;
    for (int i = 1 ; i <= n ; i ++){
        cin >> A[i];
    }
    for (int i = 1 ; i <= n ; i ++){
            cout << A[i];
            if (i != n){
                 cout << " ";
            }
        }
        cout << endl;
    for (int i = 2 ; i <= n ; i ++){
        int j = i - 1;
        int key = A[i];
        while (j >= 1 && A[j] > key){
            A[j + 1] = A[j];
            j --;
            A[j + 1] = key;
        }
        for (int i = 1 ; i <= n ; i ++){
            cout << A[i];
            if (i != n){
                 cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>                                                                                                               
using namespace std;                                                           
                                                                               
                                                                               
int main() {                                                                   
    int K; cin >> K;                                                           
    if (K%2==0) cout << K/2 * K/2 << endl;                                  
    else cout << (K/2+1) * (K/2) << endl;                                            
}                                                                              

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x, a, b int64
	fmt.Scan(&x)

	for a = -118; a <= 119; a++ {
		for b = -119; b <= 118; b++ {
			if a == b || x%(a-b) != 0 {
				continue
			} else if (a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b) == x/(a-b) {
				fmt.Println(a, b)
				return
			}
		}
	}
}


Measured memory_bytes: 1752
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;
int main(){
	int N,M,sum=0,s=0;
	long long int a[50],b[50],c[50],d[50],ans[50],t[50];
	
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>a[i]>>b[i];
		 t[i]=10000000000;
	}
	for(int j=0;j<M;j++){
		cin>>c[j]>>d[j];
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			s=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(s<t[i]){
				t[i]=s;
				
				ans[i]=j+1;
			}
		}
		cout<<ans[i]<<endl;
	}
	


	return 0;
}


Measured memory_bytes: 256
// 274
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;

int N;
int G[110][110] = {}; // 隣接リスト表現
int d[101] = {};
int f[101] = {};

int main(void) {

    cin >> N;

    for (int i = 1; i <= N; ++i) {
        int v;
        cin >> v;
        cin >> G[v][0];
        for (int k = 1; k <= G[v][0]; ++k) {
            cin >> G[i][k];
        }
    }

    int time = 0;
    for (int n = 1; n <= N; ++n) {
        if (d[n] == 0) {
            stack<int> S;

            S.push(n);
            
            d[n] = ++time;
            while (!S.empty()) {
                int u = S.top();

                bool found = false;
                // 未探索の奴をスタックに積む
                for (int i = 0; i < G[u][0]; ++i) {
                    if (d[G[u][i + 1]] != 0) continue;
                    S.push(G[u][i + 1]);
                    found = true;
                    d[G[u][i + 1]] = ++time;
                    break;
                }

                if (!found) {
                    f[u] = ++time;
                    S.pop();
                } 
            }
        }
    }


    for (int i = 1; i <= N; ++i) {
        cout << i << ' ' << d[i]  << ' ' << f[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n;cin >> n;vector<int> a(n);
	ll sum = 0;int b[100001];
	rep(i, 100001) b[i] = 0;
	rep(i, n) {
		cin >> a[i];
		if (a[i] > 100000) sum++;
		else b[a[i]]++;
	}
	for (int i = 1;i < 100001;i++) {
		if (b[i] != i) {
			if(b[i] > i){
				sum += b[i] - i;
			}
			else {
				sum += b[i];
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();
		
		int input[] = new int[n];
		
		for(int i = 0; i < n; i++) {
			input[i] = sc.nextInt();
		}
		
		long total = 0;
		
		for(int i = 1; i < n; i++) {
			if(input[i] + input[i - 1] > x) {
				int remain = input[i] + input[i - 1] - x;
				
				if(input[i] >= remain) {
					input[i] -= remain;
				}
				else {
					input[i] = 0;
				}
				
				total += remain;
			}
		}
		
		System.out.println(total);
	}

}


Measured memory_bytes: 50632
program sequential_operations_on_sequence
  implicit none
  integer :: n, q, i, j, u = 1, l, r, m, x
  integer(8) :: p(0:100000) = 0_8, k, t(100000) = 0_8, a(100001) = 0_8, ans = 0_8
  read(*,*) n, q
  p(1) = int(n,8)
  do i = 1, q
    read(*,*) k
    do while (k <= p(u))
      u = u-1
    end do
    u = u+1
    p(u) = k
  end do
  t(u) = 1_8
  do i = u, 1, -1
    k = p(i)
    j = idx(k,i-1)
    do while (j > 0)
      t(j) = t(j)+t(i)*(k/p(j))
      k = mod(k,p(j))
      j = idx(k,j-1)
    end do
    x = int(k,4)
    a(1) = a(1)+t(i)
    a(x+1) = a(x+1)-t(i)
  end do
  do i = 1, n
    ans = ans+a(i)
    write(*,'(i0)') ans
  end do
contains
  integer function idx(v,i)
    integer(8), intent(in) :: v
    integer, intent(in) :: i
    integer :: l, r, m
    l = 1
    r = i
    idx = 0
    do while (l <= r)
      m = (l+r)/2
      if (p(m) <= v) then
        idx = m
        l = m+1
      else
        r = m-1
      end if
    end do
  end
end program sequential_operations_on_sequence

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
int main(){
	int H,W,i,j,a,b;

	while(1){
		std::cin >> H >> W;
		if(H==0 && W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				a=i%2;
				b=j%2;
				if(a==0){
					if(b==0)
						std::cout<< "#";
					else
						std::cout<< ".";
					}
				if(a==1){
					if(b==0)
						std::cout<< ".";
					else
						std::cout<< "#";
					}	
				if(j==W-1)
				std::cout<<"\n";						
				}
			if(i==H-1)
			std::cout<<"\n";	
			}
		
		}
	return 0;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N), B(M);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  for (ll i = 0; i < M; ++i) {
    cin >> B.at(i);
  }
  vector<ll> C = convolution<998244353>(A, B);
  for (ll i = 0; i < C.size(); ++i) {
    cout << C.at(i) << " ";
  }
  cout << "\n";
}


Measured memory_bytes: 27276
object Main extends App {
  val Array(n, t) = readLine.split(" ").map(_.toInt)
  val cts = for (_ <- 1 to n) yield {
    val Array(c, t) = readLine.split(" ").map(_.toInt)
    (c, t)
  }

  val filteredCts = cts.filter(ct => {
    val c_ = ct._1
    val t_ = ct._2
    t_ <= t
  })
  val ans =
    if (filteredCts.isEmpty) "TLE"
    else filteredCts.minBy(ct => ct._1)._1

  println(ans)
}

Measured memory_bytes: 27468
#include<cstdio>
#include<algorithm>
using namespace std;
 
int main()
{	
	int N,M,X,Y;
	scanf("%d %d %d %d",&N,&M,&X,&Y);
	int x[N];
	int y[M];
	for(int i=0;i<N;i++)
	{
		scanf("%d", &x[i]);
	}
	for(int i=0;i<M;i++)
	{
		scanf("%d", &y[i]);
	}
	
	int xmax, ymin;
	xmax=X;
	ymin=Y; 
	for(int i=0;i<N;i++)
	{
		xmax=max(xmax, x[i]);
	}
	
	for(int i=0;i<M;i++)
	{
		ymin=min(ymin, y[i]);
	}
 
	if(xmax<ymin)
	{	printf("No War");}
	else
	{	printf("War");}
	
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ',')
		{
			s[i] = ' ';
		}
	}
	cout << s << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
map <int, int> cnt;
int get(int c) {
  int r = -1 + sqrt(1 + 8*c);
  r /= 2;
  return r;
}
void primeFac(int n) {
  while (n % 2 == 0)  
  {  
    cnt[2]++;
    n = n/2;  
  }  
  for (int i = 3; i <= sqrt(n); i = i + 2)  
  {  
    while (n % i == 0)  
    {  
      cnt[i]++;
      n = n/i;  
    }  
  } 
  if (n > 2)  
    cnt[n]++;
}
void sol() {
  int ans = 0;
  int n;
  cin >> n;
  if(n == 1) {
    cout << 0 << '\n';
    return;
  }
  primeFac(n);
  for(auto it : cnt) {
    int c = it.S;
    int k = get(c);
    ans += k;
  }
  cout << ans << '\n';
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; 
  for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
    sol();
  }
  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,d,e,i,j,k=0,l=0;
    vector<long long>v;
 cin>>a>>c;
    for(i=1;i<=a;i++)
    {
   cin>>b;
v.push_back(abs(b-c));
        }
    if(a>1){
l=__gcd(v[0],v[1]);
 for(i=2;i<a;i++)
  {
  l=__gcd(l,v[i]);
  }
cout<<l<<endl;}
else
{
cout<<abs(b-c)<<endl;}
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

int N = 0;
double p[110] = {};
int m[110] = {};
vector<int> know[110];
vector<int> beKnown[110];
bool waked[110] = {};

double ans = 1;
void SetWake(int n) {
	for (int i = 0; i < know[n].size();i++) {
		if (!waked[know[n][i]] ) {
			waked[know[n][i]] = true;
			SetWake(know[n][i]);
		}
	}
}

double semiAns=1;
void CheckSameGroup(int n) {
	for (int i = 0; i < beKnown[n].size(); i++) {
		if (!waked[beKnown[n][i]]) {
			semiAns *= p[beKnown[n][i]];
			waked[beKnown[n][i]] = true;
			CheckSameGroup(beKnown[n][i]);
		}
	}
}

int main() {

	while (scanf("%d", &N), N != 0) {
		ans = 1;
		for (int i = 1; i <= N; i++) {
			know[i].clear();
			beKnown[i].clear();
			waked[i] = false;
		}
		for (int i = 1; i <= N; i++) {
			scanf("%lf", p + i);
			scanf("%d", m + i);
			for (int j = 0; j < m[i]; j++) {
				int c;
				scanf("%d", &c);
				know[i].push_back(c);
				beKnown[c].push_back(i);
			}
		}

		for (int i = 1; i <= N; i++) {
			if (beKnown[i].size()==0) {
				waked[i] = true;
				SetWake(i);
				ans *= (1 - p[i]);
			}
		}

		for (int i = 1; i <= N; i++) {
			if (!waked[i] && know[i].size()!=0) {
				waked[i] = true;
				semiAns = p[i];
				CheckSameGroup(i);
				ans *= (1 - semiAns);
			}
		}
		printf("%.8lf\n", ans);
	}
	return 0;
}




Measured memory_bytes: 2860
n,k=list(map(int,input().split()))
data=[int(x) for x in input().split()]
ans=[0]*n
for q in range(1,n):
    min=abs(data[q]-data[q-1])+ans[q-1]
    for w in range(q-2,q-k-1,-1):
        if(w>=0):
            val=abs(data[q]-data[w])+ans[w]
            #print(val)
            if(val<min):
                min=val
        else:
            break
    #print(min)
    ans[q]=min
print(ans[-1])

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

using namespace std;
int main(){
  int N;
  string str;
  
  cin >> N;
  cin.ignore();
  
  getline(cin,str);
  
  if(str.find("Y") != string::npos){
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
  return 0;
}
    
  
  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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


  vector<vector<int>> v(10, vector<int>(10, 0));
  FOR(i, 1, N+1){
    if(i%10 == 0) continue;
    v[to_string(i)[0]-'0'][i%10]++;
  }

  int ans = 0;
  FOR(i, 1, N+1){
    ans += v[i%10][to_string(i)[0]-'0'];
  }

  cout << ans << "\n";

  return 0;
}

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

int main(){
	int N;
  	cin>>N;
  	string s;
  	cin>>s;
  	int k;
  	cin>>k;
  	k--;
  	char t=s[k];
  	for(int i=0;i<s.size();++i){
    	if(s[i]!=t)s[i]='*';
    }
	cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 3e5+5;

int main(){
	string s; cin >> s;
	int ok = 0;
	for(int i = 0; i < 3; i++) if(s[i] == '7') ok = 1;
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D,E,K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  ll nums[5];
  cin >> N;
  ll h[N];
  ans = 1;
  ll count =0;
  rep(i, N){
    cin >> h[i];
    if (i==0) continue;
    rep(j, i){
      if (h[j]>h[i]) goto Idle;
    }
    //cout <<"i: " << i << endl;
    ans++;
    Idle:
    count = 0;
  }
  cout << ans << endl;
}


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

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        if (n <= k)
        {
            Console.WriteLine(x * n);
        }
        else
        {
            Console.WriteLine(x * k + y * (n - k));
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void){
    int num,i,min,max=0,n;
    long sum=0;
    scanf("%d",&num);
    scanf("%d",&n);
    min=max=sum=n;
    for(i=0;i<num-1;i++){
        scanf("%d",&n);
        sum+=n;
        if(min > n)
            min=n;
        if(max < n)
            max=n;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int A[81][81], B[81][81];
bool dp[81][81][10000];

int main(){
  int h, w;
  cin >> h >>w;
  rep(i, h){
    rep(j, w){
      cin >> A[i][j];
    }
  }
  rep(i, h){
    rep(j, w){
      cin >> B[i][j];
    }
  }
  dp[0][0][(int)abs( A[0][0]- B[0][0])]=true;
  rep(i, h){
    rep(j, w){
      rep(k, 10000){
        if(dp[i][j][k]){
          if(i+1<h){
            if(k+(int)abs(A[i+1][j]-B[i+1][j])<10000){
              dp[i+1][j][k+(int)abs(A[i+1][j]-B[i+1][j])]=true;
            }
            dp[i+1][j][(int)abs(k-(int)abs(A[i+1][j]-B[i+1][j]))]=true;
          }

          if(j+1<w){
            if(k+(int)abs(A[i][j+1]-B[i][j+1])<10000){
              dp[i][j+1][k+(int)abs(A[i][j+1]-B[i][j+1])]=true;
            }
            dp[i][j+1][(int)abs(k-(int)abs(A[i][j+1]-B[i][j+1]))]=true;
          }

        }
      }
    }
  }
  int ans;
  rep(k, 10000){
    if(dp[h-1][w-1][k]){
      ans=k;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 61084
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int k;
  	string s, r;
  	cin >> k >> s;
  	if(s.size()<=k) cout << s << endl;
  	else{
    	for(int i=0;i<k;i++){
        	r += s.at(i);
        }
      	cout << r << "..." << endl;
    }
 
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e3 + 5;
const ll LINF = 1e18 + 5;
int h, w;
char a[N][N];
constexpr int mod = 1e9 + 7;
int dp[N][N];
inline void add(int &x, int y) { x += y; if(x>=mod) x -= mod; }
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> h >> w;
 	for(int i=1; i<=h; i++)
 		cin >> (a[i]+1);
 	dp[1][1] = 1;
 	for(int i=1; i<=h; i++)
 		for(int j=1; j<=w; j++)
 		{
 			if(i==1&&j==1) continue;
		 	if(i-1>=1 && a[i-1][j]=='.') add(dp[i][j], dp[i-1][j]);
		 	if(j-1>=1 && a[i][j-1]=='.') add(dp[i][j], dp[i][j-1]);
		}
 	int ans = dp[h][w];
 	cout << ans;
	return 0;
}


Measured memory_bytes: 5248
n = int(input())
lis=[]
for _ in range(n):
    m = int(input())
    l = []
    for i in range(m):
        tmp = list(map(int,input().split()))
        l.append(tmp)
    lis.append(l)

ans_l=[]
for i in range(2 ** n):
    people=[]
    for j in range(n):
        if (i >> j) & 1:
            people.append(1)
        else:
            people.append(0)

    fail=False
    for num in range(len(people)):
        if people[num] == 1: # check testimony
            testi=lis[num]
            for t in testi:
                if people[t[0]-1] != t[1]: # contradict
                    fail=True
    if not fail:
        ans_l.append(sum(people))
print(max(ans_l))

Measured memory_bytes: 43244
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n):
        a = LI()
        l = len(a)
        s = set()
        r = 0
        for i in range(l-1):
            if abs(a[i] - a[i+1]) < 2:
                s.add((i,i+1))
        for i in range(4, l+1):
            for j in range(l-i+1):
                k = j + i - 1
                if (j+1, k-1) in s and abs(a[j] - a[k]) < 2:
                    s.add((j,k))
                    continue
                for m in range(j+2,k,2):
                    if (j,m-1) in s and (m,k) in s:
                        s.add((j,k))
                        break

        m = {}
        m[l] = 0
        def _f(i):
            if i in m:
                return m[i]
            r = 0
            for j in range(i,l+1):
                t = _f(j+1)
                if (i,j) in s:
                    t += j - i + 1
                if r < t:
                    r = t
            m[i] = r
            return r
        return _f(0)

    while True:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 39632
H,W = map(int,input().split())
Gd = [list(input()) for _ in range(H)]
L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]

for h in range(H):
  for w in range(W):
    if Gd[h][w]=='#':
      R[h][w]=0
    else:
      if w==0:
        R[h][w]=1
      else:
        R[h][w]=R[h][w-1]+1
    wr=W-w-1
    if Gd[h][wr]=='#':
      L[h][wr]=0
    else:
      if w==0:
        L[h][wr]=1
      else:
        L[h][wr]=L[h][wr+1]+1

for w in range(W):
  for h in range(H):
    if Gd[h][w]=='#':
      D[h][w]=0
    else:
      if h==0:
        D[h][w]=1
      else:
        D[h][w]=D[h-1][w]+1
    hr=H-h-1
    if Gd[hr][w]=='#':
      U[hr][w]=0
    else:
      if h==0:
        U[hr][w]=1
      else:
        U[hr][w]=U[hr+1][w]+1
ret = 0
for w in range(W):
  for h in range(H):
    ret = max(ret, D[h][w]+U[h][w]+R[h][w]+L[h][w]-3)
print(ret)


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

using namespace std;
string s;
bool solve(int st,int en)
{
    //cout<<st<<" "<<en<<endl;
    while(st<=en&&s[st]==s[en])
    {
        st++;
        en--;
    }
    return st>en;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>s;
    int n=(int)s.size();
    s="#"+s;
    if(solve(1,n)&&solve(1,(n-1)/2)&&solve((n+3)/2,n)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = 0

for i in range(3,n+1,2):
    y = 1
    cnt = 0
    for j in range(3,int((i**0.5)//1)+1,2):
        while i%j == 0:
            i //= j
            cnt += 1
        y *= cnt+1
        cnt = 0
    if i != 1: y *= 2
    if y == 8: ans += 1
print(ans)


Measured memory_bytes: 3188
a=2,3,5
def f(n):
 if(m:=s.get(n))is None:s[n]=m=min([d*n]+[abs(p*k-n)*d+c+f(k)for p,c in zip(a,b)for k in(n//p,0--n//p)])
 return m
for _ in[0]*int(input()):n,*b,d=map(int,input().split());s={0:0,1:d};print(f(n))

Measured memory_bytes: 11124
#include <iostream>
#include <stack>

int main() {
	std::stack<int> istack;
	int n;
	while (std::cin >> n) {
		if (n > 0) {
			istack.push(n);
		} else {
			std::cout << istack.top() << std::endl;
			istack.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,l,r) for (ll i = (ll)l; i < (ll)(r); i++)
using Edge = pair<int,int>;
using Graph  = vector<vector<Edge> >;

ll N;
Graph G;

void dfs(int v, int p, int pc, vector<int> &res){
    int color = 1;
    if(color == pc) color++;
    for(auto &nv : G[v]){
        if(nv.first == p) continue;
        res[nv.second] = color;
        dfs(nv.first, v, color, res);
        color++;
        if(color == pc) color++;
    }
}

int main(){
    cin >> N;
    G.assign(N, vector<Edge>());
    rep(i,0,N-1){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(make_pair(b,i));
        G[b].push_back(make_pair(a,i));
    }
    int ma = 0;
    for(auto &v : G){
        ma = max(ma, (int)v.size());
    }
    vector<int> res(N-1,-1);
    dfs(0,-1,-1,res);

    cout << ma << endl;
    rep(i,0,N-1){
        cout << res[i] << endl;
    }
}

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

using namespace std;

const int MX = 2000;

bitset<MX> mask[MX * MX / 2];

bitset<MX>& getMask(int u, int v) {
	assert(u != v);
	if (u < v) swap(u, v);
	return mask[u * (u - 1) / 2 + v];
}

vector<int> T[MX];

bitset<MX> active, subtree[MX];
void dfs(int root, int v, int p = -1) {
	if (root != v) getMask(root, v) |= active;
	
	subtree[v].reset();
	subtree[v].set(v);
	active.set(v);
	
	for (int u : T[v]) {
		if (u == p) continue;
		dfs(root, u, v);
		subtree[v] |= subtree[u];
	}
	
	active.reset(v);
	
	if (root != v) getMask(root, v) |= subtree[v];
}

bitset<MX> G[MX];

int main() {
	int n, m;
	ignore = scanf("%d %d", &n, &m);
	for (int i = 1, u, v; i < n; i++) {
		ignore = scanf("%d %d", &u, &v);
		u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}
	
	vector<pair<int, int>> queue;
	for (int i = 0, u, v; i < m; i++) {
		ignore = scanf("%d %d", &u, &v);
		u--; v--;
		queue.emplace_back(u, v);
		G[u][v] = G[v][u] = 1;
	}
	
	for (int i = 0; i < n; i++) dfs(i, i);
	
	auto process = [&](int u, int v) {
		static bitset<MX> tmp;
		tmp = G[v];
		tmp &= ~G[u];
		tmp &= getMask(u, v);
		tmp[u] = tmp[v] = 0;
		
		for (int w = tmp._Find_first(); w < MX; w = tmp._Find_next(w)) {
			queue.emplace_back(u, w);
			G[u][w] = G[w][u] = 1;
		}
	};
	
	for (size_t i = 0; i < queue.size(); i++) {
		int u, v;
		tie(u, v) = queue[i];
		
		process(u, v);
		process(v, u);
	}
	
	printf("%d\n", (int)queue.size());
	
	return 0;
}


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

int main() {
	long long x;
	long long y;
	int n;

	cin >> x;

	y=100;
	n=0;

	while (y < x) {
		n++;
		y=y+(y/100);
	}
	cout << n << endl;
}

Measured memory_bytes: 3620
S = input()

if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	int N, M;
	cin >> N >> M;
	
	vector<int> a(M);
	vector<int> b(M);
	vector<int> c(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}

	vector<ll> d(N, -LINF);
	d[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
	}

	ll ans1 = d[N-1];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
	}

	ll ans2 = d[N-1];

	if (ans1 == ans2) cout << d[N-1] << endl;
	else cout << "inf" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

vector<ll> A;

void Primefactor(ll n){
  ll a = n;
  for(ll i = 2;i * i <= n;i++){
    while(a % i == 0){
      A.push_back(i);
      a /= i;
    }
    if(a == 1){
      break;
    }
  }
  if(a != 1){
    A.push_back(a);
  }
  return;
}

int main(){
   ll N,P;cin >> N >> P;
   Primefactor(P);
   sort(ALL(A));
   ll ans = 1,cnt = 1;
   if(N == 1){
       cout << P << endl;
       return 0;
   }
   rep(i,A.size()-1){
       if(A[i] == A[i+1]){
           cnt++;
           if(i == A.size()-2){
               if(cnt >= N){
                   ans *= (ll)pow(A[i],(ll)cnt / (ll)N);
               }
           }
       }else{
           if(cnt >= N){
               ans *= (ll)pow(A[i],(ll)cnt / (ll)N);
           }
           cnt = 1;
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
  int n; cin>>n;
  string s; cin>>s;
  bool res=false;
  if(n%2==0){
  string t=s.substr(0,(n/2));
   
  string r=t+t;
  if(r==s)res=true;
 
  }
 if(res==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

const int maxn = 1e5 + 10;
long long a[maxn], b[maxn], s = 0;

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

    for (int i = 0; i <= n; i++)
        cin >> a[i], s += a[i];
    
    for (int i = 0; i < n; i++)
        cin >> b[i];
    
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (b[i] >= a[i])
            a[i + 1] -= (b[i] - a[i]), a[i + 1] = max(0ll, a[i + 1]);
        else
            ans += a[i] - b[i];
    }

    cout << s - ans - a[n];

    return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<String> color = new HashSet<>();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if(tmp < 400) color.add("gray");
            else if(tmp < 800) color.add("brown");
            else if(tmp < 1200) color.add("green");
            else if(tmp < 1600) color.add("lightbrue");
            else if(tmp < 2000) color.add("brue");
            else if(tmp < 2400) color.add("yellow");
            else if(tmp < 2800) color.add("orange");
            else if(tmp < 3200) color.add("red");
            else list.add(tmp);
        }
        int min = Math.max(1, color.size());
        int max = color.size() + list.size();
        System.out.println(min + " " + max);
    }
}


Measured memory_bytes: 38904
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int max(int x, int y)
{
    if (x>=y) return x;
    else return y;
}

int main()
{
    int a, b, c, k;
    scanf("%d%d%d", &a, &b, &c);
    scanf("%d", &k);
    int maxm = 0;
    maxm = max(a, max(b,c));
    int ans = a + b + c + maxm*pow(2, k) - maxm;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var d int
	fmt.Scan(&d)

	ans := n / ((2 * d) + 1)
	if ans*((2*d)+1) != n {
		ans++
	}
	fmt.Print(ans)
}


Measured memory_bytes: 512