akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG //GCC環境での[]デバッグ
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
using namespace std;
using ll = long long;
int sumVector (const std::vector<int>& v){ //int配列計算
    int sum = 0;
    rep(i, v.size()) sum += v.at(i);
    return sum; 
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    bool takahashi =false;
    cin >> A >>B >> C >>D;
    while(1){
        C -= B;
        if(C <= 0){
            takahashi = true;
            break;
        }
        A -= D;
        if(A <= 0){
            takahashi = false;
            break;
        }
    }
    
    if(takahashi) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

## BFS

#入力受け取り
N, Q = mi()
x = li2(N-1)

cnt = [0]*(N+1)
for i in range(Q):
    p0, p1 = mi()
    cnt[p0] += p1

#隣接リスト作成
adj = [[] for i in range(N+1)]
for i in range(N-1):
    #x[i][0] -= 1
    #x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])
    adj[x[i][1]].append(x[i][0])

global ans
ans = [0]*(N+1)

def dfs(fr, nx):
    ans[nx] += ans[fr] + cnt[nx]
    for v in adj[nx]:
        if v != fr:
            dfs(nx, v)

dfs(1, 1)

for i in range(1, N+1):
    print(ans[i], '', end='')

Measured memory_bytes: 260708
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private string S;
        private void Scan()
        {
            var sc = new Scanner();
            S = sc.Next();
        }

        public void Solve()
        {
            Scan();
            Console.WriteLine(S.Select(c => (int)c).Sum() == ('a' + 'b' + 'c') ? "Yes" : "No");
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    d=a;
    a=b;
    b=d;
  }
  if(b>c){
    d=b;
    b=c;
    c=d;
  }
if(a>b){
    d=a;
    a=b;
    b=d;
  }
  printf("%d %d %d\n",a,b,c);
 
  
  return 0;
  }

Measured memory_bytes: 596
import kotlin.math.*

fun read(d:String = " ") = readLine()!!.split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun main() {
	val (n,k) = list()
	val p = list().map {it-1}
	val c = list {toLong()}

	val a = Array(n+1) {LongArray(n)}
	val t = Array(n+1){IntArray(n) {it}}

	for(d in 0 until n) {
		for(i in 0 until n) {
			t[d+1][i] = p[t[d][i]]
			a[d+1][i] = a[d][i]+c[t[d+1][i]]
		}
	}

	var r = Long.MIN_VALUE
	for(d in 1..min(n,k))
		r = max(r,a[d].max()!!)
	if(k>n) {
		for(i in 0 until n) {
			val m=(1..n).first {t[it][i]==i}
			for(d in k-m..k)
				r = max(r,a[d%m][i]+a[m][i]*(d/m))
		}
	}
	println(r)
}


Measured memory_bytes: 338836
#!/usr/bin/env ruby
require 'set'

H, W, K = gets.chomp.split.map(&:to_i)

C = []
H.times do |i|
  C[i] = gets.chomp.codepoints
end

BLACK = '#'.ord
WHITE = '.'.ord

result = 0

0.upto(H) do |h|
  hcomb = (0...H).to_a.combination(h)

  0.upto(W) do |w|
    wcomb = (0...W).to_a.combination(w)

    hcomb.each do |hc|
      wcomb.each do |wc|
        count = 0

        hc.each do |hi|
          wc.each do |wi|
            count += 1 if C[hi][wi] == BLACK
          end
        end

        result += 1 if count == K
      end
    end
  end
end

puts result


Measured memory_bytes: 14524
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using P = pair<int, int>;

vector<vector<P>> E;

int main(){
    int n;
    cin >> n;
    E.resize(n);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            x--;
            E[i].emplace_back(x, y);
        }
    }
    int ans = 0;
    for(int S = 0; S != 1 << n; S++){
        bool ok = true;
        for(int i = 0; i < n; i++){
            if (!(S & 1 << i))continue;
            for(int j = 0; j < E[i].size(); j++){
                int x = E[i][j].first;
                int y = E[i][j].second;
                if (y == 0){
                    if (S & 1 << x){
                        ok = false;
                        break;
                    }
                }
                else{
                    if (!(S & 1 << x)){
                        ok = false;
                        break;
                    }
                }
            }
            if (!ok)break;
        }
        if (!ok)continue;
        int nans = 0;
        int Sd = S;
        while(Sd != 0){
            if (Sd & 1)nans++;
            Sd >>= 1;
        }
        ans = max(ans, nans);
    }

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

int main(void)
{

    int N, reader_num, change_person, min;
    string str;

    cin >> N;
    cin >> str;

    change_person = 0;

    // 先頭の人をリーダーにした場合について、まず考える
    for(int i = 1; i < N; i++)
    {
        if( str[i] == 'E' )
        {
            // リーダーより東で, 東を向いている人は西を向いてもらう
            change_person++;
        }
    }

    // 最小値の初期値
    min = change_person;
    reader_num = 1;
    //change_person = 0;

    // リーダーになる人を東方向に総当りで求める
    while( reader_num < N )
    {

        if( str[reader_num - 1] == 'W' )
        {
            // リーダーより西で, 西を向いている人は東を向いてもらう
            change_person++;
        }

        if( str[reader_num] == 'E' )
        {
            // リーダー自身が東を向いていたら, 方向を変える人が一人減る
            change_person--;
        }

        // 東側は最初に考慮しているので、検討不要
        /*
        if( str[reader_num + 1] == 'E' )
        {
            // リーダーより東で, 東を向いている人は西を向いてもらう
            change_person++;
        }
        */

        if( change_person < min )
        {
            min = change_person;
        }

        reader_num++;
    }

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

    return 0;
}


Measured memory_bytes: 900
import sys
input = sys.stdin.readline
import math


def read():
    N = int(input().strip())
    return N,


def solve(N):
    # (m+1)p=N, 0 < p < mを満たすmを列挙する
    ans = 0
    p = 1
    while p * p <= N:
        if N % p == 0:
            m = N // p - 1
            if p < m:
                ans += m
            else:
                break
        p += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 9056
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    cin>>n>>k;
    i = pow(k-1,n-1);
    i *= k;
    cout<<i<<endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
#define N 1000005
int n,m,ans[N];
int main()
{
	scanf("%d %d",&n,&m);
	if(n&1) for(int i=1;i<=m;++i) printf("%d %d\n",i,n-i);
	else
	{
		for(int i=1;i<=((n>>1)>>1);++i) ans[i]=n-i+1;
		for(int i=((n>>1)>>1)+1;i<=(n>>1);++i) ans[i]=n-i;
		for(int i=1;i<=m;++i) printf("%d %d\n",i,ans[i]);
	}return 0;
}

Measured memory_bytes: 3944
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
 int a,b,c,d,n,x,y,z;
 cin>>n>>a>>b>>c>>d;
 if(n%a==0){
     x=n/a;
 }
 else  if(n%a>0){
     x=n/a+1;
 }
 if(n%c==0){
     y=n/c;
 }
 else if(n%c>0)
{
    y=n/c+1;
}
 z=min(x*b,y*d);
 cout<<z<<endl;
  }



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if (s.size() == 2)
    {
        cout << s << endl;
    }
    else
    {
        reverse(ALL(s));
        cout << s << endl;
    }
}

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};



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

    
    cout << N*(N-1)/2 <<endl;
    
    return 0;
    

}


Measured memory_bytes: 3608
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(S[K-1])

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int MAXN = 1e4 + 5;

int main() {
  //
  int N, M;
  int f[MAXN] = {0};
  cin >> N;
  M = sqrt(N) + 1;
  for (int i = 1; i <= M; i++)
    for (int j = 1; j <= M; j++)
      for (int k = 1; k <= M; k++) {
        int x;
        x = (i + j + k) * (i + j + k) - i * j - j * k - k * i;
        if (x <= N) f[x]++;
      }
  for (int i = 1; i <= N; i++) cout << f[i] << endl;
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=2;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            ans+=j;
        }
    }
    cout <<ans+(n*(n+1)/2)<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3624
unittest
{
	assert( [ "3 2" ].parse.expand.solve == 10 );
	assert( [ "200000 1000000000" ].parse.expand.solve == 607923868 );
	assert( [ "15 6" ].parse.expand.solve == 22583772 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	// 移動を 0,1,2 -> 1,0,2 のようにすれば k-1 のときと同じパターンを作れる
	// つまり、0 ~ k のパターンを全部考慮する必要がある
	
	// 0人部屋の数を決め打ちする
	auto ans = ModWorld!()( 0 );
	foreach( i; 0L .. min( n, k + 1 ) )
	{
		// 0人部屋のパターン数を計算
		auto a = n.combination( i );
		
		// 0人部屋に居た人の移動先のパターン数を計算
		auto p = n - i - 1;
		auto b = ( p + i ).combination( p );
		
		ans += a * b;
	}
	return ans;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M = 10L ^^ 9 + 7 )
{
	long n;
	
	// 演算子オーバーロード
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = this.n * a % M;
			a = a ^^ 2 % M;
		}
	}
	auto opBinary( string OP )( ModWorld r )
	{
		auto t = this;
		t.opOpAssign!OP( r );
		return t;
	}
	
	// long型対応
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	// format用出力
	string toString()
	{
		return this.n.to!string;
	}
}

// 階乗
auto factorial( long M = 10L ^^ 9 + 7 )( long x )
{
	static memo = [ ModWorld!M( 1L ) ];
	if( memo.length <= x )
	{
		auto i = memo.length.signed;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combination( long M = 10L ^^ 9 + 7 )( long x, long y )
{
	if( x < y ) return ModWorld!M( 0L );
	else        return x.factorial!M / ( y.factorial!M * ( x - y ).factorial!M );
}


Measured memory_bytes: 3836
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N;

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

  cin >> N;

  cout << 3*pow(N, 2) << endl;
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n), dp(n);
  rep(i, n) cin >> h[i];
  rep(i, n) dp[i] = 999999999;
  dp[0] = 0;

  for (int i = 1; i < n; ++i) {
    for (int j = max(i - k, 0); j < i; ++j) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){
  int N,C;
  cin >> N >> C;
  if (N==1){
    cout << 0;
    return 0;
  }
  int D[C+1][C+1];
  int i,j;
  for (i=1;i<=C;i++){
    for(j=1;j<=C;j++){
      cin >> D[i][j];
    }
  }
  int cell[N][N];
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      cin>>cell[i][j];
    }
  }
  int col[3];
  int flag;
  int tmp;
  long long ans = 500000000;
  long long pre[3][C+1];
  int color;
  for(color=1;color<=C;color++){
    for(i=0;i<3;i++){
      pre[i][color]=0;
    }
  }
  for(color=1;color<=C;color++){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        if((i+j)%3==0) pre[0][color]+=D[cell[i][j]][color];
        if((i+j)%3==1) pre[1][color]+=D[cell[i][j]][color];
        if((i+j)%3==2) pre[2][color]+=D[cell[i][j]][color];
      }
    }
  }

  for(col[0]=1;col[0]<=C;col[0]++){
    for(col[1]=1;col[1]<=C;col[1]++){
      for(col[2]=1;col[2]<=C;col[2]++){
        flag=0;
        if(col[0]==col[1]) flag=1;
        if(col[2]==col[1]) flag=1;
        if(col[0]==col[2]) flag=1;
        if(flag==0){
          tmp=pre[0][col[0]]+pre[1][col[1]]+pre[2][col[2]];
          if(tmp<ans)ans=tmp;
        }
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1280
n = int(input())
A = [int(i) for i in input().split()]

l = -1
r = 2 * 10 ** 9 + 2

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return n % 2 == 0
    
while abs(r - l) > 1:
    # if r % 2 == 1:
    #     r -= 1
    # if l % 2 == 1:
    #     l += 1
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)    


Measured memory_bytes: 84580
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll findDivisors(ll n) 
{ 
  
    ll div[n + 1]; 
    memset(div, 0, sizeof div);  
    for (ll i = 1; i <= n; i++) {  
        for (ll j = 1; j * i <= n; j++) 
            div[i * j]++; 
    } 
	ll sum=0;
    for (ll i = 1; i <= n; i++) 
         sum+=(i*div[i]);
	return sum;
} 
int main()
{
	ll n;
	cin>>n;
	cout<<findDivisors(n)<<endl;

}


Measured memory_bytes: 81756
n=int(input())
tree=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  tree[u-1].append((v-1,w))
  tree[v-1].append((u-1,w))
color=[-1]*n
color[0]=0
q=[0]
while q:
  x=q.pop()
  for t,cost in tree[x]:
    if color[t]>=0:
      continue
    if cost%2==0:
      color[t]=color[x]
    else:
      color[t]=1-color[x]
    q.append(t)
print(*color,sep='\n')

Measured memory_bytes: 40364
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;
const ll infll=1e15;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<ll>v(n),pref(n,0),suff(n,0);

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

    pref[0]=v[0];
    suff[n-1]=v[n-1];

    for(int i=1;i<n;i++)
        pref[i]=pref[i-1]+v[i];
    for(int i=n-2;i>=0;i--)
        suff[i]=suff[i+1]+v[i];

    ll ans=infll;

    for(int i=0;i<n-1;i++)
        ans=min(ans,abs(pref[i]-suff[i+1]));

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n, w; cin >> n >> w;
	mk(wt, n + 1, int);
	mk(v, n + 1, int);
	for (int i = 1; i <= n; i++)
		cin >> wt[i] >> v[i];

	int dp[n + 1][w + 1];

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= w; j++) {
			if (i == 0 || j == 0)
				dp[i][j] = 0;

			else if (wt[i] > j)
				dp[i][j] = dp[i - 1][j];

			else {
				dp[i][j] = max(dp[i - 1][j], v[i] + dp[i - 1][j - wt[i]]);
			}
		}
	}

	cout << dp[n][w] << endl;

	return 0;
}

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

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

  vector<int> flag(101);
  for(int i=0; i<N; i++){
    flag[d[i]] = 1;
  }

  int count = 0;
  for(int i: flag){
    if(i>0)  count++;
  }
  cout<<count<<endl;

  return 0;
}


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

int main(){
  int n, u, k, v, a[101][101] = {0};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u;
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> v;
      a[u][v] = 1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(j-1) cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3136
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */

int main(void) {
  int n, m;
  char s[101][11];
  char t[101][11];
  scanf("%d", &n);
  rep(i, 0, n) scanf("%s", s[i]);
  scanf("%d", &m);
  rep(i, 0, m) scanf("%s", t[i]);

  int ans = 0;
  int cnt = 0;
  rep(i, 0, n) {
    int cnt = 0;
    rep(si, i, n) {
      if (strcmp(s[i], s[si]) == 0) cnt++;
    }
    rep(ti, 0, m) {
      if (strcmp(s[i], t[ti]) == 0) cnt--;
    }
    ans = max(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
   int x, y;
   cin >> x >> y;
   int mx = max(x, y);
   int mn = min(x, y);
   for (int i = 0; i < mx; i++)
   {
      cout << mn;
   }
}
int main()
{
	int t = 1;
//	cin >> t;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
#include <cstdlib>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int main(){
  const int n = getInt();
  int x = 0;
  int y = 0;
  int t = 0;
  REP(i,n){
    const int tt = getInt();
    const int xx = getInt();
    const int yy = getInt();

    const int dx = std::abs(x - xx);
    const int dy = std::abs(y - yy);
    const int dt = tt - t;

    const int r = dt - dx - dy;

    if(r < 0 || r % 2 != 0){
      puts("No");
      return 0;
    }

    x = xx;
    y = yy;
    t = tt;
  }

  puts("Yes");
  return 0;
}


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

using namespace std;

int main() {
    
    char c; cin >> c;
    
    if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ){
        cout << "vowel\n";
    }
    else
    {
        cout << "consonant\n";
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
typedef long long ll;
#define mod 1000000007
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 1e15
const int N=5e5+5;

int main()
{
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s)
		cout<<a-1<<" "<<b;
	else
		cout<<a<<" "<<b-1;
}




Measured memory_bytes: 256
#include <stdio.h>

int min (int a, int b){
  if ( a > b ){
    return b;
  } else {
    return a;
  }
}

int max (int a, int b){
  if ( a < b ){
    return b;
  } else {
    return a;
  }
}

int main ()
{
 int a[200000];
 int ans, small, diff, x;

 scanf("%d", &x);

 for ( int i = 0; i < x; i++){
  scanf("%d", &a[i]);
 }

 small = a[0];
 diff  = a[1] - a[0];
 ans   = diff;

 for ( int j = 1; j < x; ++j){
   diff  = a[j] - small;
   ans   = max( ans,   diff );
   small = min( small, a[j] );
 }

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

 return 0;
}



Measured memory_bytes: 2528
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
//#define debug1 cout<<"?"<<endl;
//#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=2e6+9;
const double pi=acos(-1);
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	char s[2];
	scanf("%s",s);
	printf("%c\n",s[0]+1); 
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn = 1e5 + 7;

int n, res[maxn];
string s;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	cin >> s;
	n = sz(s);

	vi left, right;
	rep(i, 0, n) {
		if (s[i] == 'L') {
			left.push_back(i);
		} else {
			right.push_back(i);
		}
	}

	rep(i, 0, n) {
		if (s[i] == 'L') {
			auto it = lower_bound(right.begin(), right.end(), i);
			it--;
			int idx = *it;
			if ((i - idx) % 2 == 1) {
				res[idx + 1]++;
			} else {
				res[idx]++;
			}
		} else {
			auto it = lower_bound(left.begin(), left.end(), i);
			int idx = *it;
			if ((idx - i) % 2 == 1) {
				res[idx- 1]++;
			} else {
				res[idx]++;
			}
		}
	}
	rep(i, 0, n) {
		cout << res[i] << " ";
	}
	cout << endl;
}


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


int main() {
    string s;
    cin >> s;
    rep(i,3){
        if(s[i] == '1')s[i] = '9';
        else if(s[i] == '9')s[i] = '1';
    }
    cout << s << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>

int main() {
	int x, a;

	std::cin >> x >> a;

	if (x < a) {
		std::cout << 0 << std::endl;
	}
	else {
		std::cout << 10 << std::endl;
	}

	return 0;
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i)
        ans += s[i] == t[i];

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
nearest_temper = 10000
ans_i = 0
for i in range(n):
    cur = t - h[i] * 0.006
    if abs(a - cur) < nearest_temper:
        nearest_temper = abs(a - cur)
        ans_i = i + 1
print(ans_i)

Measured memory_bytes: 38256
#include <iostream>
#include <map>

using namespace std;

map <string, int> m;
string s;
int n, dist;

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    m[s]++;
    if (m[s] == 1)
      dist++;
  }
  cout << dist;
  return 0;
}


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

template<class T>bool chmax(T &a,const T &b){
    if(a>b)return false;
    a=b;
    return true;
}
template<class T>bool chmin(T &a,const T &b){
    if(a<b)return false;
    a=b;
    return true;
}

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

int n;
int h[200];

int main(){
    cin>>n;
    rep(i,n)cin>>h[i];
    int ans=0;
    rep(i,200){
        int x=0;
        while(x<n){
            bool ok=false;
            while(x<n&&h[x]){
                h[x]--;
                ok=1;
                x++;
            }
            if(ok)ans++;
            x++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, XY):
    g = defaultdict(dict)
    V = [(i, x, y) for i, (x, y) in enumerate(XY)]
    V.sort(key=lambda x: x[1])
    for i in range(1, N):
        v = V[i][0]
        u = V[i-1][0]
        d = min(abs(XY[v][0] - XY[u][0]), abs(XY[v][1] - XY[u][1]))
        g[v][u] = d
        g[u][v] = d

    V.sort(key=lambda x: x[2])
    for i in range(1, N):
        v = V[i][0]
        u = V[i-1][0]
        d = min(abs(XY[v][0] - XY[u][0]), abs(XY[v][1] - XY[u][1]))
        g[v][u] = d
        g[u][v] = d

    return Prim(g)


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]

    print(slv(N, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 104560
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    string n, ans="";
    cin >> n;
    rep(i, 0, n.length()){
      if(n[i] == '1') ans += '9';
      if(n[i] == '9') ans += '1';
    }
    print(ans);
   
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll N;
	cin>>N;
	cout<<180+(N-3)*180<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = readInputLine().toCharArray()

    for ((i, s) in S.withIndex()) {
        if (i % 2 == 0 && s == 'L') {
            println("No")
            return
        } else if (i % 2 == 1 && s == 'R') {
            println("No")
            return
        }
    }
    
    println("Yes")
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void AGC011A()
{
	int N, C, K;
	cin >> N >> C >> K;
	int b = 0;
	int ct = 0;
	int start = 0;
	vi T(N);
	for (auto& x : T)
		cin >> x;

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

	for (int i = 0; i < N; ++i)
	{
		int X = T[i];
		cin >> X;
		if(ct == 0)
		{
			start = X;
		}
		++ct;

		if (X > start + K)
		{
			++b;
			ct = 1;
			start = X;
			continue;
		}

		if (ct == C)
		{
			ct = 0;
			++b;
			continue;
		}
	}
	if (ct > 0)
		++b;

	cout << b << endl;
}
int main()
{
	AGC011A();
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    rep(i, N) cin >> s[i] >> t[i];
    string X;
    cin >> X;
    int tmp;
    rep(i, N) {
        if (s[i] == X) tmp = i+1;
    }
    int ans = 0;
    for (int i = tmp; i < N; ++i) {
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
  public static void main(String[] args)
  {
    try (Scanner scanner = new Scanner(System.in))
    {
      while (scanner.hasNextLine())
      {
        double a = Double.valueOf(scanner.nextLine());
        System.out.printf("%.8f\n", solver(a));
      }
    }
  }

  private static double solver(double a)
  {
    double ans = a;
    for (int i = 2; i <= 10; i++)
    {
      if (i % 2 == 0)
      {
        a *= 2.0;
      }
      else
      {
        a /= 3.0;
      }
      ans += a;
    }
    return ans;
  }
}



Measured memory_bytes: 26308
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
const ll maxn = 2010;
ll a,b,ans,c[maxn][maxn],sum[maxn][maxn],f[maxn][maxn];

void pre()
{
    for (ll i = 0; i < maxn; i++)
    {
        c[i][0] = sum[i][0] = f[i][0] = 1;
        for (ll j = 1; j <= i; j++)
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
        for (ll j = 1; j < maxn; j++)
            sum[i][j] = (sum[i][j - 1] + c[i][j]) % mod;
        for (ll j = 1; j < maxn; j++)
            f[i][j] = (f[i][j - 1] + sum[i][j]) % mod;
    }
}

ll solve(ll t,ll b)
{
    ll res = 1;
    for (ll i = 1; i <= min(t - 1,b); i++)
        res = (res + c[b][i] * f[i - 1][t - i - 1] % mod) % mod;
    return res;
}

int main()
{
    pre();
    scanf("%lld%lld",&a,&b);
    if (!a || !b)
        puts("1");
    else
    {
        for (ll i = 1; i <= a + 1; i++)
            ans = (ans + solve(i,b - 1)) % mod;
        printf("%lld\n",ans);
    }

    return 0;
}


Measured memory_bytes: 95104
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

a,b,c = readints()

if 4*a*b < (c-a-b)**2 and c-a-b>0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 61996
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;
int N,a[1000];
vector<pair<ll,ll>>e[1001][1001];
ll num[1001][1001],d[1001][1001],ans,cnt;

int main(){
  cin>>N;
  FOR(i,1,N+1){
    REP(j,N-1){
      cin>>a[j];
      if(j){
        e[min(i,a[j-1])][max(i,a[j-1])].push_back({min(i,a[j]),max(i,a[j])});
        num[min(i,a[j])][max(i,a[j])]++;
      }
    }
  }

  queue<pair<ll,ll>> que;
  cnt=0;
  FOR(i,1,N+1)FOR(j,i+1,N+1)if(num[i][j]==0){
    que.push({i,j});
    //頂点iからjまでのパスに含まれる頂点の数
    d[i][j]=1;
  }

  while(!que.empty()){
    ll x=que.front().first,y=que.front().second,nx,ny;
    que.pop();
    cnt++;
    REP(i,e[x][y].size()){
      nx=e[x][y][i].first;
      ny=e[x][y][i].second;
      num[nx][ny]--;
      if(num[nx][ny]==0){
        que.push({nx,ny});
        d[nx][ny]=d[x][y]+1;
        ans=max(ans,d[nx][ny]);
      }
    }
  }
  //全ての頂点が入次数0になったか？
  cout<<(cnt==N*(N-1)/2?ans:-1)<<endl;
}


Measured memory_bytes: 64640
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        long n = sc.nextLong();

        long ans = 0;

        for (int i=1; i<=n; i++) {
            if (i%3!=0 && i%5!=0) ans += i;
        }

        System.out.println(ans);


    }
}


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

int N, M;
vector<vector<int>> G;
int ans = 0;

void dfs(int now, int result) {
  int flag = false;
    result |= (1 << now);
    for (auto e : G[now]) {
      if(!(result&(1<<e))){
        dfs(e, result);
        flag = true;
      }
    }
    if(!flag && bitset<8>(result).count() == N){
      ans += 1;
    }
}

int main() {
    cin >> N >> M;
    G.resize(N);

    rep(i, M) {
        int from, to;
        cin >> from >> to;
        from--;
        to--;

        G[from].push_back(to);
        G[to].push_back(from);
    }

    dfs(0, 0);
    cout << ans << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  int N;cin>>N;
  vector<int> as(N);
  REP(i,N) cin>>as[i];

  // 達成できるとは何か
  // 奇数の数==0
  // 奇数の数<=4を因数に持つ数
  // .o.o.o
  // 奇数の数-1==4を因数に持つ数で、その二つだけの場合
  // .o.o.o.

  int odd_cnt = count_if(ALL(as),[](int a){return a%2==1;});
  int four_cnt = count_if(ALL(as),[](int a){return a%4==0;});

  if (odd_cnt==0) {
    OUT("Yes");
  } else if (odd_cnt<=four_cnt) {
    OUT("Yes");
  } else if (odd_cnt-1==four_cnt && odd_cnt+four_cnt==N) {
    OUT("Yes");
  } else {
    OUT("No");
  }

  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.TreeMap;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int student = sc.nextInt();
		TreeMap<Integer, Integer> studentMap = new TreeMap<>();

		//キーと値を追加する(.put())
		for (int studentNum = 1 ; studentNum <= student ; studentNum++) {
			studentMap.put(sc.nextInt(), studentNum);
		}

		//すべてのキーを取得する(.keySet())
		for (int key : studentMap.keySet()) {

			//keyを指定してvalueを取得(.get())
			System.out.print(studentMap.get(key) + " ");
		}
		sc.close();
	}
}

Measured memory_bytes: 61812
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer,Integer> nums = new HashMap<Integer,Integer>();
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			add(nums, num);
			add(nums, num + 1);
			add(nums, num - 1);
		}
		Collection<Integer> list = nums.values();
		int ans = 0;
		for(Integer i : list) {
			if(i > ans) ans = i;
		}
		System.out.println(ans);
	}
	static void add(Map<Integer, Integer> map, Integer num) {
		if(map.containsKey(num)) {
			map.put(num, map.get(num) + 1);
		} else {
			map.put(num, 1);
		}
	}
}

Measured memory_bytes: 60804
#include<cstdio>
long long int ans = 1, oth = 1;
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++)
        ans *= 3;
    
    for(int i = 1; i <= n; i ++){
        int x;
        scanf("%d", &x);
        if(x & 1)
            continue;
        oth *= 2;
    }
    printf("%lld", ans - oth);
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+7, LINF = 1e18;


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=105;
int a[maxn];
int main(){
	ll x;
	cin>>x;
	for(int i=0;i<233;++i)
		for(int j=-233;j<233;++j)
			if((i*i*i*i*i-j*j*j*j*j)==x) {
				cout<<i<<" "<<j<<"\n";
				return 0;
			}
	return 0;
} 

Measured memory_bytes: 3596
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    // Your code here!
    Scanner sc = new Scanner(System.in);
    int sx = sc.nextInt();
    int sy = sc.nextInt();
    int tx = sc.nextInt();
    int ty = sc.nextInt();
    sc.close();

    int dx = tx - sx;
    int dy = ty - sy;
    
    outputLoopStr("R", dx);
    outputLoopStr("U", dy);
    outputLoopStr("L", dx);
    outputLoopStr("D", dy);

    System.out.print("D");
    outputLoopStr("R", dx+1);
    outputLoopStr("U", dy+1);
    System.out.print("L");
    System.out.print("U");
    outputLoopStr("L", dx+1);
    outputLoopStr("D", dy+1);
    System.out.print("R");
    
  }
  private static void outputLoopStr(String s, int n){
    for(int i = 0; i < n; i++){
      System.out.print(s);
    }
  }
}


Measured memory_bytes: 24260
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	ll a, b; cin >> a >> b;
	ll g = (a*b)/__gcd(a,b);
	cout << g << endl;
	return 0;
}


Measured memory_bytes: 256
primeN=[]
for i in range(2,3000):
    for j in range(2,i+1):
        if i%j==0:
            if i==j:
                primeN.append(i)
            else:
                break
primeN_5=[]
for i in primeN:
    if i%5==2:
        primeN_5.append(i)
n=int(input())
c=[]
for i in range(n):
    c.append(str(primeN_5[i]))
print(" ".join(c))
        

Measured memory_bytes: 3060
$L=<>;
$s=<>;chop$s;$a=length$s;
$t=<>;chop$t;$b=length$t;
for(1..2){
	$x=$y=0;
	$y+=$b while($L-$y)%$a;
	$x=$L-$y;
	push@_,$s x($x/$a).$t x($y/$b),$t x($y/$b).$s x($x/$a);
	($s,$t,$a,$b)=($t,$s,$b,$a)
}
printf sort@_


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

using namespace std;
int main() {
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int res = 1e9;
	int l = 1, r = 1e9 + 1;
	while (l <= r) {
		int m = l + (r - l)/2;
		int cnt = 0;
		for (int log : a) {
			cnt += max(0, (log + m - 1) / m - 1);
		}
		if (cnt > k) {
			l = m + 1;
		}
		else {
			res = min(res, m);
			r = m - 1;
		}
	}
	cout << res;
}

Measured memory_bytes: 3984