akhauriyash/Code-Regression huggingface dataset:
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    long ans = long.max;

    foreach (x; -100 .. 100 + 1)
    {
        long cost;
        foreach (a; A)
            cost += (x - a) ^^ 2;
        ans = ans.min(cost);
    }
    writeln(ans);
}


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

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

	int n;
	cin >> n;
	
	vector <int> v(2 * n);
	
	for(int i = 0; i < 2 * n; i++)
	{
		cin >> v[i];
	}
		
	if((int) v.size() >= 6)
	{
		for(int i = 0; i <= 2 * n - 6; i++)
		{
			if(v[i] == v[i + 1] && v[i + 2] == v[i + 3] && v[i + 4] == v[i + 5])
			{
				cout << "Yes\n";
				return 0;
			}
		}
	}
	
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[][] map = new int[100][1000];
		for(int i=1;i<100;i++){
			for(int j=0;j<1000;j++){
				int p = j*(100+i)/100;
				if(p>=1000) map[i][j] = Integer.MIN_VALUE; 
				else map[i][j] = p;
			}
		}
		
		while(true){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int s = sc.nextInt();
			if(x==0 && y==0 && s==0) break;
			
			int max = 0;
			for(int i=1;i<1000;i++){
				for(int j=i;j<1000;j++){
					if(map[x][i]+map[x][j]==s) max = Math.max(max, map[y][i]+map[y][j]);
				}
			}
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 23256
#
#   max I + J
#     with
#       \sum_{i <= I} Ai + \sum_{j <= J} Bi <= K
#
def solve(ls1, ls2, k):
    n, m = len(ls1), len(ls2)

    # Make cumsum
    for i in range(n - 1):
        ls1[i + 1] += ls1[i]

    for i in range(m - 1):
        ls2[i + 1] += ls2[i]
    ls1 = [0] + ls1
    ls2 = [0] + ls2

    # Find maximum by
    #   1. Initially (I, J) = (0, maxJ)
    #   2. Increase I and decrease J

    # Initialize
    for j in range(m + 1)[::-1]:
        if ls2[j] <= k:
            J = j
            break
    ij_max = J

    # Increase/decrease
    I = 0
    while I <= n and J >= 0:
        while I <= n and ls1[I] + ls2[J] <= k:
            I += 1
        ij_max = max(ij_max, I + J - 1)
        J -= 1

    return ij_max


def main(istr, ostr):
    n, m, k = list(map(int, istr.readline().strip().split()))
    ls1 = list(map(int, istr.readline().strip().split()))
    ls2 = list(map(int, istr.readline().strip().split()))
    result = solve(ls1, ls2, k)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


Measured memory_bytes: 40520
def main():
    H, W, N = list(map(int, input().split()))
    sr, sc = list(map(lambda x: int(x) - 1, input().split()))
    S = input()
    T = input()
    # 後手が勝つ領域を後ろから順にさかのぼっていく
    ok_left, ok_right = 0, W - 1
    ok_up, ok_down = 0, H - 1
    for n in range(N - 1, -1, -1):
        s = S[n]
        if s == 'L':
            ok_left += 1
        if s == 'R':
            ok_right -= 1
        if s == 'U':
            ok_up += 1
        if s == 'D':
            ok_down -= 1
        if ok_left > ok_right or ok_up > ok_down:
            print('NO')
            return
        if n > 0:
            t = T[n - 1]
            if t == 'L':
                ok_right = min(ok_right + 1, W - 1)
            if t == 'R':
                ok_left = max(ok_left - 1, 0)
            if t == 'U':
                ok_down = min(ok_down + 1, H - 1)
            if t == 'D':
                ok_up = max(ok_up - 1, 0)
    if ok_left <= sc <= ok_right and ok_up <= sr <= ok_down:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LNF = __LONG_LONG_MAX__;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    ll sum=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
        sum = sum%MOD;
    }
    ll out=0;
    for(int i=0;i<N;i++){
        sum -= A[i]; if(sum<0) sum += MOD;
        out += A[i]*sum;
        out = out%MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3968
//AtCoder Beginner Contest 176
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e5 + 5;
const ll INF = 1e9 + 5;
const ll mxN = 1000000007;
const double E = 1e-9;

//------------------------------------------------------------------------------
int n, x, t;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	cin >> n >> x >> t;
	if (n % x)
		cout << ((n / x) + 1)*t;
	else
		cout << (n / x)*t;
	return 0;
}
//22-08-2020 17:31:42
//------------------------------------------------------------------------------

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
	int a[5], count;
	for(int i=0; i<5;i++){
		cin>>a[i];
	}
	for(int i=0; i<5;i++){
		if(a[i]==0){
			count=i;
			break;
		}
	}
	cout<<count+1<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int H, W, N, num;
    cin >> H >> W >> N;
    int a[10000] = {}, b[10000] = {};
    vector< vector<int> > grid;
    grid.resize(H);
    for(int i=0;i<H;i++)
        grid[i].resize(W);
    
    for(int i=0;i<N;i++)
        cin >> a[i];

    int count = 0;
    for(int i=0;i<N;i++){
        num = a[i];
        for(int j=0;j<num;j++){
            b[count + j] = i+1;
        }
        count += num;
    }

    count = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            grid[i][j] = b[count];
            count++;
        }
    }


    for(int i=0;i<H;i++){
        if(i%2 == 0){
            cout << grid[i][0];
            for(int j=1;j<W;j++){
                cout << ' ' << grid[i][j];
            }
        }else{
            cout << grid[i][W-1];
            for(int j=W-2;-1<j;j--){
                cout << ' ' << grid[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,d; cin >> m >> d;
    int ans = 0;
    REPP(i,m) {
        REPP(j,d) {
            if(j/10>=2 && j%10>=2) ans += ((j/10) * (j%10) == i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<bool> done(n+1,false);
    done[0]=true;
    done[1]=true;
    long long ans=0;
    //みんなiを約数にもつ
    for(int i=1;i<n+1;i++){
        ans+=i;
    }
    for(int i=2;i<=n;i++){
        if(done[i]) continue;
        int x=i;
        while(1){
            for(int j=x;j<n+1;j+=x){
                ans+=j;
            }
            done[x]=true;
            if(n/i<x)break;
            x*=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

void point(char ji,char ten,int n);
void zenbu(char ji);

int main(void){
    int a,b;
    cin >> a >> b;
    a--; b--;

    int h;
    if(a>b)
    h=a/25*2+2;
    else
    h=b/25*2+2;
    cout << h << " 100\n";

    for(int i=0; i<h; i++){
        if(i%2==0){
            if(a-25>0){
                point('#','.',25);
                a-=25;
            }
            else if(a>0){
                point('#','.',a);
                a=0;
            }
            else{
                zenbu('#');
            }
            if(b-25>0){
                point('.','#',25);
                b-=25;
            }
            else if(b>0){
                point('.','#',b);
                b=0;
            }
            else{
                zenbu('.');
            }
        }
        else{
            zenbu('#');
            zenbu('.');
        }
        cout << "\n";
    }

    return 0;
}

void point(char ji,char ten,int n){
    if(ji=='.')
    cout << ji;

    int count=0;
    for(int i=0; i<49; i++){
        if(i%2==0 && count<n){
            cout << ten;
            count++;
        }
        else
        cout << ji;
    }

    if(ji=='#')
    cout << ji;

    return;
}

void zenbu(char ji){
    for(int i=0; i<50; i++)
    cout << ji;
    return;
}

Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Mon, 13th Jan 2020                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

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

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n;
	cin >> n;

	vi a(n,0);
	rep(i,0,n) cin >> a[i];

	vi dp(n,0);
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);

	rep(i,2,n){
		dp[i] = min(abs(a[i]-a[i-1]) + dp[i-1], abs(a[i]-a[i-2]) + dp[i-2]);
	}

	ret(dp[n-1]);
}


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

int main(){
    cout<<fixed<<setprecision(12);

    while(1){
        int n;
        double sum = 0;

        cin >> n;
        if(n == 0){
        break;
        }
        
        double s[n];
        
        for(int i = 0; i < n; i++){
            cin >> s[i];
        }
        for(int i = 0; i < n; i++){
            sum += s[i];
        }
        double avg = sum / n;
        double ans = 0;
  
        for(int i = 0; i < n; i++){
            ans += pow(s[i] - avg, 2);
        }
        ans=sqrt(ans / n);
  
        cout << ans << endl;
    }
  return 0;  
}




Measured memory_bytes: 3284
#include<iostream>

using namespace std;
typedef long long ll;
#define INF (1LL<<59)


int main(){
    ll a,b;
    int n;
    cin>>a>>b>>n;
    
    
    
    ll ans = INF;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(b%j==0){
                ll t = b/j;
                ans = min(ans,abs(a-t*i));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3080
// 解き直し.
// http://agc005.contest.atcoder.jp/data/agc/005/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
int A[111];

int main(){
    
    // 1. 入力情報.
    int N, a, K = 0;
    scanf("%d", &N);
    rep(i, N){
        scanf("%d", &a);
        A[a]++;
        K = max(K, a); // 直径を取得.
    }
    
    // 2. パスの構築(※解説参照).
    bool f = (K & 1); // 偶奇フラグ.
    bool ok = true;   // 条件を満たす木が構築できるか？
    repr(i, K, K / 2 + 1){
        if(A[i] >= 2) A[i] -= 2;
        else          ok = false;
    }
    // 偶数の場合は, K / 2 も 見る.
    if(!f){
        if(A[K / 2]) A[K / 2]--;
        else         ok = false;
    }
    
    // 3. 最大距離をチェックしながら, 残りの辺を繋げる.
    vector<int> v;
    rep(i, N) rep(j, A[i]) v.pb(i);
    for(auto &k : v){
        // 最大距離を, 偶奇に分けて比較.
        if(f  && (k <= (K + 1) / 2)) ok = false;
        if(!f && (k <= K / 2))       ok = false;
    }
    
    // 4. 出力.
    printf("%s\n", ok ? "Possible" : "Impossible");
    return 0;
    
}

Measured memory_bytes: 3688
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
 
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}

 
 
int main() {
    #ifdef sharma
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);      
    #endif
    fastio;
    int n;
    cin >> n;
    int a[n];
    int v[n] = {0};
    rep(i, n)
    {
        cin >> a[i];
    }
    
    for(int i=n-1;i>=0;i--)
    {
        if(a[i] % 2 == 1)
        {
            v[i] = 1;
            for(int j=1;j*j<=i+1;j++)
            {
                if((i+1) % j == 0)
                {    a[j-1]++;
                if((i+1)/j != j)
                {
                    int x = (i+1) / j;
                    a[x-1]++;
                }}
            }
        }
    }
    int sum = 0;
    rep(i, n)
    if(v[i])
        sum++;
    cout << sum << endl;
    rep(i, n)
    if(v[i])
        cout << i+1 << " ";

    return 0; 
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; cin >> n >> k;
    set<int> se;
    rep(i,k){
        int d; cin >> d;
        rep(j,d){
            int a; cin >> a;
            se.insert(a);
        }
    }
    cout << n - se.size() << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N, K;
	cin >> N >> K;

	vector<long long>x(N);
	vector<long long>y(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}
	
   long long ans = 9223372036854775807;
	for (int x1 = 0; x1 < N;++x1) {
		for (int x2 = 0; x2 < N;++x2) {
			for (int y1 = 0; y1 < N; ++y1) {
				for (int y2 = 0; y2 < N; ++y2) {
					long long minX = min(x[x1],x[x2]);
					long long maxX = minX == x[x1] ? x[x2] : x[x1];
					long long minY = min(y[y1], y[y2]);
					long long maxY = minX == y[y1] ? y[y2] : y[y1];

					int count = 0;
					for (int k = 0; k < N; ++k) {
						if (minX <= x[k] && x[k] <= maxX && minY <= y[k] && y[k] <= maxY) {
							count++;
						}
					}

					if (K <= count)ans = min(ans, (maxX - minX)*(maxY - minY));
				}
			}
		 }
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define M_MAX         10000
#define N_MAX         1000
#define r_MAX         1000
#define q_MAX         50
#define DATASET_MAX   10
#define TS_MIN        540
#define TE_MAX        1260
#define USETIME_MAX   TE_MAX-TS_MIN

struct LogInfo{
    int PCNum;
    int LogInTime;
    int LogOutTime;
};

int LogInCnt[M_MAX];
struct LogInfo LogInfoData[M_MAX][r_MAX];
int UsePCTime[DATASET_MAX];

void VarInit( void ){
    int i;
    int j;
    
    for( i=0; i<M_MAX; i++ ){
        LogInCnt[i] = 0;
        for( j=0; j<r_MAX; j++ ){
            LogInfoData[i][j].PCNum = 0;
            LogInfoData[i][j].LogInTime = 0;
            LogInfoData[i][j].LogOutTime = 0;
        }
    }
}


void RecLogInInfo( int t, int n, int m ){
    LogInfoData[m][LogInCnt[m]].PCNum = n;
    LogInfoData[m][LogInCnt[m]].LogInTime = t;
    LogInCnt[m]++;
}

void RecLogOutInfo( int t, int n, int m ){
    int i;
    
    for( i=0; i<LogInCnt[m]; i++ ){
        if( (LogInfoData[m][i].PCNum == n) && (LogInfoData[m][i].LogOutTime == 0)){
            LogInfoData[m][i].LogOutTime = t;
        }
    }
}

int CalcUsePCTime( int ts, int te, int m ){
    int i,j,t1,t2,Time;
    int Work[USETIME_MAX+1];
    Time = 0;
    
    for( i=0; i<USETIME_MAX+1; i++){
        Work[i] = 0;
    }
    
    for( i=0; i<LogInCnt[m]; i++ ){
        t1 = LogInfoData[m][i].LogInTime-TS_MIN;
        t2 = LogInfoData[m][i].LogOutTime-TS_MIN;
        for( j=t1; j<t2; j++){
            Work[j] = 1;
        }
    }
    
    for( i=ts; i<te; i++){
        if(Work[i-TS_MIN] == 1){
        Time++;
        }
    }
    
    return Time;
}


int main( void ){
    int i,N,M,r,q,t,n,m,s,ts,te;
    int qNum;
    int UseTime;
    
    qNum = 0;
    for( i=0; i<DATASET_MAX; i++ ){
        UsePCTime[i] = 0;
    }
    while( 1 ){
        scanf( " %d %d", &N, &M );
        if( N == 0 ){
            break;
        }
        VarInit();
        scanf( " %d", &r );
        for( i=0; i<r; i++ ){
            scanf( " %d %d %d %d", &t, &n, &m, &s );
            if( s == 1 ){
                RecLogInInfo( t, n, m );
            }else{
                RecLogOutInfo( t, n, m );
            }
        }
        
        scanf( " %d", &q );
        for( i=0; i<q; i++ ){
            scanf( " %d %d %d", &ts, &te, &m );
            UseTime = CalcUsePCTime( ts, te, m );
            printf("%d\n",UseTime);
        }
    }
}




Measured memory_bytes: 119796
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int main() {
	string s,t;
	cin >> s>>t;
	int count=0;
	rep(i,3) if(s[i]==t[i]) count++;
	cout << count << endl;


  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    sort(all(v));

    cout << v[v.size()-1]-v[0] << endl;
    return (0);
}


Measured memory_bytes: 3608
from functools import reduce
# input
dev     = pow(10, 9) + 7
n, a, b = map( int, input().split() )

# calc
def nCr( n, r ):
    x = reduce( lambda a, b: a*b%dev, range(n, n-r, -1) )
    y = reduce( lambda a, b: a*b%dev, range(1, r+1,  1) )
    # mod gyakugen
    y = pow( y, dev-2, dev)
    return x * y % dev
ans  = pow(2, n, dev) - 1 - nCr(n,a) - nCr(n,b)
ans %= dev

# out
print(ans)

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n,m;cin>>n>>m;
	ll a[n+2]={0};
	rep(i,0,m){
		ll l,r;cin>>l>>r;
		a[l]++;a[r+1]--;
	}
	rep(i,1,n+2)a[i]+=a[i-1];
	ll ans=0;
	rep(i,1,n+1)if(a[i]==m)ans++;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 1024
from collections import defaultdict

input()
d_list = input().split(" ")
input()
t_list = input().split(" ")

d_dict = defaultdict(lambda: 0)
for d in d_list:
    d_dict[d] += 1

t_dict = defaultdict(lambda: 0)
for t in t_list:
    t_dict[t] += 1

yes = True
for k, v in t_dict.items():
    if v > d_dict[k]:
        print("NO")
        yes = False
        break
if yes:
    print("YES")

Measured memory_bytes: 69344
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;

using namespace std;

const int MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    set<int> a;
    rep(i, m) {
        int t;
        cin >> t;
        a.insert(t);
    }
    vector<int> dp(n+1, 0);
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        if(a.count(i))
            dp[i] = 0;
        else {
            dp[i] = (dp[i-1] + (i >= 2 ? dp[i-2] : 0)) % MOD;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a>=1&&b>=1&&c>=1&&a<=13&&b<=13&&c<=13){
    if((a+b+c)>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
}


return 0;}


Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(10**7)
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    a = II()
    print(3*a*a)
    pass
solve()

Measured memory_bytes: 3064
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextInt();
      long d = sc.nextInt();
      long lcm = lcm(c, d);
      long cnt1 = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm;
      long cnt2 = b - b / c - b / d + b / lcm;

      System.out.println(cnt2 - cnt1);
  }

  private static long gcd(long a, long b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }

  private static long lcm(long a, long b) {
    return a / gcd(a, b) * b;
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define MOD 1000000007
#define PSET(x,y) fixed<<setprecision(y)<<x
#define ll long long
#define ld long double
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define lopr(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define pi pair<int,int>
#define pll pair<ll, ll>
#define si set<int>
#define sll set<ll>
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define state tuple<int,int,int>
#define graph map<ll,list<ll>>

inline int sbt(int x){return __builtin_popcount(x);} //returns number of set bits

using namespace std;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    fast_io()
    
    int a,b;
    cin>>a>>b;

    if(b%a==0)
    	cout<<a+b;
    else
    	cout<<b-a;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	bool can = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			can = true;
			break;
		}
	}
	cout << (can ? "OK" : "NG") << endl;
	return 0;
}

Measured memory_bytes: 3624
s=input()
def iskaibun(s):
  n=len(s)
  for i in range(n):
    if s[i]==s[-i-1]:
      continue
    else:
      return False
  return True
n=len(s)
if iskaibun(s) and iskaibun(s[:(n-1)//2]) and iskaibun(s[(n+3)//2-1:]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


int d;
int s[365][26];
int c[26];


int calc(vector<int>& v) {
	int sum = 0;
	int las[26]; rep(i, 26)las[i] = 0;


	int dec = 0;
	rep(j, 26)dec += c[j];

	int aldec = 0;

	rep(i, d) {
		aldec -= c[v[i]] * (i - las[v[i]]);

		sum += s[i][v[i]];
		las[v[i]] = i;

		sum -= aldec;
		aldec += dec;
	}
	return max(sum, 0);
}

void query(vector<int> v) {
	rep(i, d) {
		cout << v[i] + 1 << "\n";
	}
}
void solve() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d)rep(j, 26)cin >> s[i][j];

	//init_answer
	vector<int> v;
	int las[26]; rep(j, 26)las[j] = 0;
	int sum = 0;

	rep(i, d) {
		int ma = -mod;
		int chk = -1;
		rep(j, 26) {
			int ad = s[i][j];
			ad += c[j] * (i - las[j]);
			if (ma < ad) {
				ma = ad;
				chk = j;
			}
		}
		v.push_back(chk);
		las[chk] = i;

		sum += s[i][chk];
		rep(j, 26) {
			sum -= c[j] * (i - las[j]);
		}
	}

	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> ud(0, d - 1);
	uniform_real_distribution<> rd(0.0, 1.0);
	vector<int> alt = v;


	int cur = sum;

	int ans = cur;
	vector<int> out = v;

	const int tm = 30000;
	double arfa = 0.1;
	rep(i, tm) {
		int id = ud(mt);
		rep(j, 26) {
			if (j == v[id])continue;
			alt[id] = j;
			int val = calc(alt);
			if (ans < val) {
				v = alt;
				cur = val;

				out = alt;
				ans = val;
				break;
			}
			continue;
			double d = rd(mt);
			double d1;
			if (cur < val)d1 = 1;
			else d1 = exp((val - cur) / (double)pow(arfa, i / (double)tm));
			if (d <= d1) {
				v = alt;
				cur = val;
				//break;
			}
		}
		alt = v;
	}

	//cout << ans << "\n";
	query(out);
}


signed main() {
	solve();
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 2 * 1e5;


template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

string s;

bool isPalindrome(int lo, int hi) {

	while (lo < hi) {
		if (s[lo] != s[hi])
			return false;
		++lo;
		--hi;
	}

	return true;
}

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

	int n;
	cin >> s;
	n = s.length();
	if (isPalindrome(0, n - 1) &&
		isPalindrome(0, (n - 1) / 2 - 1) && 
		isPalindrome((n + 3) / 2 - 1, n - 1) )
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';

}


Measured memory_bytes: 3652
def bingo(marked):
    for i in range(3):
        all_marked = True
        for j in range(3):
            if not marked[i][j]:
                all_marked = False
        if all_marked:
            return True
    
    for i in range(3):
        all_marked = True
        for j in range(3):
            if not marked[j][i]:
                all_marked = False
        if all_marked:
            return True
    
    all_marked = True
    for i in range(3):
        if not marked[i][i]:
            all_marked = False
    if all_marked:
        return True
    
    all_marked = True
    for i in range(3):
        if not marked[2 - i][i]:
            all_marked = False
    if all_marked:
        return True

    return False
            
A = [[] for i in range(3)]
marked=  [[False for i in range(3)] for j in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                marked[i][j] = True
                
if bingo(marked):
    print("Yes")
else:
    print("No")

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


li=[0]*(n+1)
ans=[]
for i in range(n,0,-1):
    if a[i-1]==1:
        if sum(li[i::i])%2==0:
            li[i]=1
            ans.append(i)
    else:
        if sum(li[i::i])%2==1:
            li[i]=1
            ans.append(i)

print(len(ans))
print(*ans)

Measured memory_bytes: 77916
import collections
import itertools
N = int(input())
#cnt[URLD][x y y+x y-x][value]=set()
cnt = [[collections.defaultdict(set) for _ in range(4)] for _ in range(4)]
for _ in range(N):
    x, y, u = input().split()
    x = int(x)
    y = int(y)
    p = y + x
    q = y - x
    i = 'URLD'.index(u)
    cnt[i][0][x].add(y)
    cnt[i][1][y].add(x)
    cnt[i][2][p].add(q)
    cnt[i][3][q].add(p)

INF = float('inf')


def calc(up, down):
    ret = [INF]
    for c in up.keys() & down.keys():
        ua = sorted(up[c])
        da = sorted(down[c])
        i = j = 0
        for i in range(len(ua)):
            for j in range(j, len(da)):
                if ua[i] < da[j]:
                    ret += [da[j] - ua[i]]
                    break
            i += 1
    return min(ret)


#U(0)とD(3)がx(0)が一緒:d-u(>=0)の最小値
#R(1)とL(2)がy(1)が一緒:l-r(>=0)の最小値
#U(0)とR(1)がx+y(2)が一緒:(y-x)のr-u(>=0)の最小値
#L(2)とD(3)がx+y(2)が一緒:(y-x)のd-l(>=0)の最小値
#U(0)とL(2)がy-x(3)が一緒:(y+x)のl-u(>=0)の最小値
#R(1)とD(3)がy-x(3)が一緒:(y+x)のd-r(>=0)の最小値
ans = min(
    calc(cnt[0][0], cnt[3][0]), calc(cnt[1][1], cnt[2][1]),
    calc(cnt[0][2], cnt[1][2]), calc(cnt[2][2], cnt[3][2]),
    calc(cnt[0][3], cnt[2][3]), calc(cnt[1][3], cnt[3][3]))
print('SAFE' if ans == INF else ans * 5)


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int temp = 0;
	if ((B + C) <= A) {
		cout << 0;
	}
	if ((B + C) > A) {
		temp = B + C;
		int temp1 = temp - A;
		cout << temp1;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:51 on 2020-04-04.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll k;
    cin >> k;
    vl a;
    for (ll i = 1; i <= 9; ++i) {
        a.eb(i);
    }

    while (k > a.size()) {
        k -= a.size();
        vl old;
        old = a;
        a = vl();
        each(x, old) {
            for (ll i = -1; i <= 1; ++i) {
                ll d = x % 10 + i;
                if (d < 0 || 9 < d) continue;
                ll nx = x * 10 + d;
                a.eb(nx);
            }
        }
    }
    cout << a[k - 1] << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 2164
import fileinput
import string

alphabetArray = list(string.ascii_lowercase)

for data in fileinput.input():
    for n in range(-26, 27):
        replacedStrAry = list(data.replace('\n', '').replace('\r', ''))
        for index in range(0, len(replacedStrAry)):
            if not replacedStrAry[index] in alphabetArray:
                continue
            if n >= 0:
                replacedStrAry[index] = alphabetArray[(alphabetArray.index(replacedStrAry[index]) + n) % 26]
            else:
                replacedStrAry[index] = replacedStrAry[index] = alphabetArray[alphabetArray.index(replacedStrAry[index]) + n]
        replacedStr = "".join(replacedStrAry)
        replacedStrSplitedBySpace = replacedStr.split(' ')
        if "the" in replacedStrSplitedBySpace or "this" in replacedStrSplitedBySpace or "that" in replacedStrSplitedBySpace:
            print(replacedStr)
            break

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

vector<int> v(pow(2,18)+1,0),w(pow(2,18)+1,0);
vector<vector<int>> dp(512,vector<int>(1e5+1,0));

int dfs(int V,int W,int C){
  if(W<0){
    return 0;
  }
  if(V<512){
    return dp[V][W]+C;
  }
  int s=dfs(V/2,W-w[V],C+v[V]),t=dfs(V/2,W,C);
  return max(s,t);
}

int main() {
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> v[i+1] >> w[i+1];
  }
  dp[1][w[1]]=v[1];
  for(int i=1;i<512;i++){
    for(int j=1;j<1e5+1;j++){
      if((i==1&&j==w[1])||i>N){
        continue;
      }
      if(j>=w[i]){
        dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i]]+v[i]);
      }
      else{
        dp[i][j]=dp[i/2][j];
      }
    }
  }
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int V,W;
    cin >> V >> W;
    cout << dfs(V,W,0) << endl;
  }
}


Measured memory_bytes: 206352
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 3; i <= n; i++)
            if (i % 3 == 0 || i.ToString().Contains("3")) Console.Write(" " + i);
        Console.WriteLine();
    }
}



Measured memory_bytes: 9956
#include<stdio.h>
int main(){
  char s[102],c;
  int i,w,r;
  while(scanf("%s %c",s,&c),c-'X'){
    char d[102][102]={0};
    d[w=0][0]=s[0];
    for(i=r=1;s[i];i++){
      if(s[i]=='_')i++;
      if(s[i]<'a'||'z'<s[i]||s[i-1]=='_')d[++w][r=0]=s[i];
      else d[w][r]=s[i];
      r++;
    }
    if(c=='D'){
      for(i=0;i<=w;i++){
	if(i)printf("_");
	printf("%c%s",tolower(d[i][0]),d[i]+1);
      }
    }
    else{
      if(c=='U')printf("%c%s",toupper(d[0][0]),d[0]+1);
      else      printf("%c%s",tolower(d[0][0]),d[0]+1);
      for(i=1;i<=w;i++)printf("%c%s",toupper(d[i][0]),d[i]+1);
    }
    printf("\n");
  }
  return 0;
}
	
	  

Measured memory_bytes: 564
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x=I()
print(10-x//200)

Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll a[2005];
void pre(){
    a[0]=a[1]=a[2]=1;
    for(int i=3;i<=2000;i++) a[i]=(a[i-3]+a[i-1])%mod;
}
int main()
{
    pre();
    int n;
    cin>>n;
    if(n<3) cout<<0;
    else cout<<a[n-3];
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    int q;
    cin >> q;
    while (q--) {
        int k;
        cin >> k;
        cout << lower_bound(as.begin(), as.end(), k) - as.begin() << " " << upper_bound(as.begin(), as.end(), k) - as.begin() << endl;
    }
}


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

int main() {
  int a, b;
  cin >> a >> b;

  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,m,i;
  scanf("%d %d",&n, &m);
  int a[n];
  for(i=0;i<n;i++){
    a[i]=0;
  }
  int x,y;
  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    a[x-1]=a[x-1]+1;
    a[y-1]=a[y-1]+1;
  }
  for(i=0;i<n;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
//ll dp[100001];
void knapsack(int n,ll* w,ll* v,int W)
{
  ll dp[n][W+1];
  for(int i=0;i<=W;i++)
  {
    if(i>=w[0])
    {
      dp[0][i]=v[0];
    }
    else
    dp[0][i]=0;
//    cout<<i<<dp[0][i]<<endl;
  }
  for(int i=1;i<n;i++)
  {

    for(int j=0;j<=W;j++)
    {
    //  int max=0;
      if(j>=w[i])
      {
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      }
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  /*for(int i=0;i<n;i++)
  {
    for(int j=0;j<=W;j++)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }*/
  cout<<dp[n-1][W]<<endl;
}
int main()
{
  int n,W;
  cin>>n>>W;
  ll w[n],v[n];
  for(int i=0;i<n;i++)
  {
    cin>>w[i]>>v[i];
  }
  knapsack(n,w,v,W);
}


Measured memory_bytes: 78336
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $m);
$freezers = fgets(STDIN);
$exploded_freezers = explode(' ', trim($freezers));
$microwaves = fgets(STDIN);
$exploded_microwaves = explode(' ', trim($microwaves));
for ($i=0; $i<$m; $i++) {
  fscanf(STDIN, '%d %d %d', $coupons[$i]['a'], $coupons[$i]['b'], $coupons[$i]['discount']);
}

// まず割引券を使わない最小の金額
$sorted_freezers = $exploded_freezers;
$sorted_microwaves = $exploded_microwaves;
sort($sorted_freezers);
sort($sorted_microwaves);
$default_sum = $sorted_freezers[0] + $sorted_microwaves[0];

// 割引券を使った金額
foreach ($coupons as $coupon) {
  $coupon_sums[] = $exploded_freezers[($coupon['a']-1)] + $exploded_microwaves[($coupon['b']-1)] - $coupon['discount'];
}
sort($coupon_sums);
if ($coupon_sums[0] < $default_sum) {
  echo $coupon_sums[0];
} else {
  echo $default_sum;
}

Measured memory_bytes: 82796
n,k = map(int, input().split())
t = []
for i in range(n):
	ti = tuple(map(int, input().split()))
	t.append(ti)

t = sorted(t, key=lambda x: x[0])

res = 0
x = 0
for i in range(n):
	res = t[i][0]
	inc = t[i][1]
	x += inc
	if x >= k:
		break

print(res)

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

unsigned long long gcd(unsigned long long a, unsigned long long b, unsigned long long r) {
  if (r == 0) {
    return b;
  }
  else {
    return gcd(b, r, b%r);
  }
}

/*unsigned long long lcm(unsigned long long a, unsigned long long b, unsigned long long g) {
  return a*b/g;
}*/

int main() {
  unsigned long long n, ans = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    unsigned long long t;
    cin >> t;
    ans = (ans/gcd(ans, t, ans%t))*t;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void) {
    int a[4][13];
    int n,c,d,f;
    char e;
    for(int b=0;b<4;b++){
      for(int c=0;c<14;c++){
        a[b][c] = 0;
      }
    }
    scanf("%d\n",&n);
    for(int d=0;d<n;d++){
      scanf("%c %d\n",&e,&f);
      if(e == 'S') a[0][f-1] = 1;
      else if(e == 'H') a[1][f-1] = 1;
      else if(e == 'C') a[2][f-1] = 1;
      else if(e == 'D') a[3][f-1] = 1;
    }
    

    for(int i=0;i<4;i++){
      for(int j=0;j<13;j++){
        if(a[i][j] != 1){
          if(i == 0) printf("S %d\n",j+1);
          if(i == 1) printf("H %d\n",j+1);
          if(i == 2) printf("C %d\n",j+1);
          if(i == 3) printf("D %d\n",j+1);
        }
      }
    }
return 0;
}


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

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 100000 + 10;

int a[N], n;

void run(int case_id = 0) {
  std::cin >> n;
  for (int i = 1; i <= n; ++ i) std::cin >> a[i];
  int result = 0;
  for (int i = 1; i <= n; ) {
    int j = i + 1;
    while (j <= n && a[j] <= a[j - 1]) j ++;
    update_max(result, j - i);
    i = j;
  }
  std::cout << result - 1 << "\n";
}

void multi_cases_main() {
  int num_tests;
  std::cin >> num_tests;
  for (int t = 1; t <= num_tests; ++ t) {
    run(t);
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  run();
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int ret[101][101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	if(N==2) return _P("-1\n");
	if(N%2==1) {
		FOR(y,N) FOR(x,N-1) _P("%d%c",(x+y+1)%N+1,(x==N-2)?'\n':' ');
	}
	else {
		FOR(y,N) FOR(x,N-1) {
			if(y>=N/2 && x==N/2-1) _P("%d%c",(x+y+2)%N+1,(x==N-2)?'\n':' ');
			else if(y>=N/2 && x==N/2) _P("%d%c",(x+y)%N+1,(x==N-2)?'\n':' ');
			else _P("%d%c",(x+y+1)%N+1,(x==N-2)?'\n':' ');
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
/** Programming problem solution 3.
 *  Copyright (c) 2020 Peter Winchester. All rights reserved.
 *  
 *  This program is written by Peter Winchester.
 *  Peter use this program to solve a programming problem.
 *  If you are not allowed to copy the code, don't copy the
 *  following code.
 */

// code:
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int n, x, t;

int main()
{
	cin >> n >> x >> t;
	printf("%.0lf\n", ceil(n * 1.0 / x) * t);
	return 0;
}

Measured memory_bytes: 3664
s = input()
x = int(input())
a = set()
l = len(s)
q = ''
for i in range(l):
    q = s[i]
    a.add(q)
q = ''
for i in range(l):
    if (i <= 1):
        q += s[i]
    else:
        q = q[1:]
        q += s[i]
    a.add(q)
q = ''
for i in range(l):
    if (i <= 2):
        q += s[i]
    else:
        q = q[1:]
        q += s[i]
    a.add(q)
q = ''
for i in range(l):
    if (i <= 3):
        q += s[i]
    else:
        q = q[1:]
        q += s[i]
    a.add(q)
q = ''
for i in range(l):
    if (i <= 4):
        q += s[i]
    else:
        q = q[1:]
        q += s[i]
    a.add(q)
a = list(a)
a = sorted(a)
print(a[x-1])


Measured memory_bytes: 4464