akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        String s = sc.nextLine();
        int len = s.length();

        int[][] dp = new int[len+1][13];
        dp[0][0] = 1;
        int place = 1;

        for(int i=1;i<=len;i++) {
            int n = len - i;
            char c = s.charAt(n);
            if(c == '?') {
                for(int j=0;j<10;j++) {
                    for(int k=0;k<13;k++) {
                        dp[i][(j*place+k)%13] += dp[i-1][k];
                        dp[i][(j*place+k)%13] %= MOD;
                    }
                }
            }
            else {
                int j = (c - '0');
                for(int k=0;k<13;k++) {
                    dp[i][(j*place+k)%13] += dp[i-1][k];
                    dp[i][(j*place+k)%13] %= MOD;
                }
            }
            place *= 10;
            place %= 13;
        }

        pw.println(dp[len][5]);
        pw.close();
    }
}


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

int main() {
  vector<int> a(3);
  
  for(int i=0;i<3;i++){
  cin>>a.at(i);
  }
   
  sort(a.begin(),a.end());
  
  cout<<a.at(2)*10+a.at(1)+a.at(0)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
#define coa cout << ans << endl
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    long long x;
    cin >> x;

    long long ans = 0;
    ans = (x / 11);
    x -= ans * 11;
    ans *= 2;
    if(x > 0){
        x -= 6;
        ans++;
        if(x > 0){
            ans++;
        }
    }

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


Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
	int i, N, H[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(H[i]));
	
	int j, max = 0;
	for (i = 1; i <= N; ) {
		for (j = i + 1; j <= N; j++) {
			if (H[j] > H[j-1]) break;
		}
		if (j - i - 1 > max) max = j - i - 1;
		i = j;
	}
	
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner input = new Scanner(System.in);

        int a,b,c;
        a = input.nextInt();
        b = input.nextInt();
        c = input.nextInt();

        System.out.printf("%d %d %d",c,a,b);
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i,0,tx-sx){
    cout << "R";
  }
  rep(i,0,ty-sy){
    cout << "U";
  }
  rep(i,0,tx-sx){
    cout << "L";
  }
  rep(i,0,ty-sy){
    cout << "D";
  }
  cout << "D";
  rep(i,0,tx-sx+1){
    cout << "R";
  }
  rep(i,0,ty-sy+1){
    cout << "U";
  }
  cout << "L";
  cout << "U";
  rep(i,0,tx-sx+1){
    cout << "L";
  }
  rep(i,0,ty-sy+1){
    cout << "D";
  }
  cout << "R" << endl;
  return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	ll X, Y;
	cin >> X >> Y;
	if (X%Y==0) {
		ce(-1)
	}
	else {
		ll k = 1;
		ll maxi = 10E18/X;
		while (k<=maxi&&(X*k)%Y==0) {
			k++;
		}
		if ((X*k) % Y != 0) {
			ce(X*k)
		}
		else {
			ce(-1)
		}

	}
    return 0;
}



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

int main()
{

  string s;
  cin >> s;
  
  if(s[0] >= 'a' && s[0] <= 'z')
  {
  cout << "a" << endl;
  }else
  {
  cout << "A" << endl;  
  }
  
  return 0;
}

Measured memory_bytes: 3624
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;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

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

void main()
{
    long N, M;
    scan(N, M);
    auto T = new bool[long][](N);
    foreach (_; 0 .. M)
    {
        long a, b;
        scan(a, b);
        T[a - 1][b - 1] = T[b - 1][a - 1] = true;
    }
    foreach (i; 0 .. N)
        if (0 in T[i] && N - 1 in T[i])
        {
            writeln("POSSIBLE");
            return;
        }
    writeln("IMPOSSIBLE");
}


Measured memory_bytes: 64252
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> ans(2, 0);
	for (int i = 0; i < n; i++) {
		string taro, hanako;
		cin >> taro >> hanako;
		if (taro > hanako) {
			ans.at(0) += 3;
		}
		else if (taro == hanako) {
			ans.at(0) += 1;
			ans.at(1) += 1;
		}
		else {
			ans.at(1) += 3;
		}
	}
	cout << ans.at(0) << " " << ans.at(1) << endl;
}


Measured memory_bytes: 3144
# -*- coding: utf-8 -*-

def main():
    h, w = map(int, input().split())
    lines = [l for l in [input() for _ in range(h)] if l != '.' * w]
    lines2 = [''] * len(lines)
    for i in range(w):
        f = False
        for l in lines:
            if l[i] != '.':
                f = True
                break
        if f:
            for j, l in enumerate(lines):
                lines2[j] = lines2[j] + l[i]

    for l in lines2:
        print(l)


if __name__ == '__main__':
    main()


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

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

	vector<pair<char,int>> sn;
	int i = 0;
	while(i<n){
		int count = 0;
		int j;
		for (j = i; j < n; j++) {
			if (s[i] == s[j]) {
				count++;
			}
			else {
				break;
			}
		}
		sn.push_back(make_pair(s[i], count));
		i = j;
	}

	int ans = 0;
	int sum = 0;
	int left = 0;
	int right = 0;
	int count0 = 0;
	while (right < sn.size()) {
		if (sn[right].first == '0') {
			count0++;
			if (count0 > k) {
				break;
			}
		}
		sum += sn[right].second;
		right++;
	}
	ans = sum;

	while (right < sn.size()) {
		sum -= sn[left].second;
		if (sn[left].first == '0') {
			sum += sn[right++].second;
			if (right < sn.size()) {
				sum += sn[right++].second;
			}
		}
		left++;
		ans = max(ans, sum);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1528
using System;


namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            int x = int.Parse(str);
            int i = 0;
            while (x != 0)
            {
                i++;
                Console.WriteLine("Case " + i + ": " + x);
                str = Console.ReadLine();
                x = int.Parse(str);


            }

            }
        }
}

Measured memory_bytes: 9220
#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;
    int a[n];rep(i,n)cin>>a[i];
    int sum=abs(a[0]);rep(i,n-1)sum+=abs(a[i+1]-a[i]);
    sum+=abs(a[n-1]);
    
    rep(i,n){
        int ans = sum;
        if(i==0)ans = ans - abs(a[i]) - abs(a[i+1]-a[i]) + abs(a[i+1]);
        else if(i==n-1)ans =  ans - abs(a[i]) - abs(a[i]-a[i-1]) + abs(a[i-1]);
        else ans = ans - abs(a[i+1]-a[i])- abs(a[i]-a[i-1]) + abs(a[i+1] - a[i-1]);
        
        cout<<ans<<endl;
    }
	return 0;
}

Measured memory_bytes: 4024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
#define INF (200000001)
#define F first
#define S second
int W[2],H[2],X[2],Y[2];
int L[2][501][501];
int R;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vector<int> E[2];
void dijk(int id){
  priority_queue<PP,vector<PP>,greater<PP> > q;
  int h[501][501];
  memset(h,-1,sizeof(h));
  q.push( PP( 1, P(X[id], Y[id]) ) );
  h[X[id]][Y[id]]=1;
  while( !q.empty() ){
    PP p = q.top(); q.pop();
    int x=p.S.F, y=p.S.S;
    for(int i=0;i<4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if( nx < 0 || nx >= W[id] || ny < 0 || ny >= H[id] ) continue;
      if( h[nx][ny] == -1 ){
	int c = max(L[id][nx][ny],p.F);
	q.push(PP(c,P(nx,ny)));
	h[nx][ny]=c;
      }
    }
  }
  E[id].clear();
  for(int y=0;y<H[id];y++){
    for(int x=0;x<W[id];x++){
      //      printf("%d ",h[x][y]);
      E[id].push_back( h[x][y] );
    }
    //    puts("");
  }
  sort(E[id].begin(),E[id].end());
}
int search(int id){
  int res = INF;
  int id2 = (id+1)%2;
  for(int i=0;i<(int)E[id].size();i++){
    int r = R-i-2;
    if( i+1 >= R ){
      res = min(res,E[id][i]);
      break;
    }
    if( r >= E[id2].size() ) continue;
    res = min(res,E[id][i]+E[id2][r]);
  }
  return res;
}
int main(){
  while(1){
    scanf("%d",&R);
    if(!R) break;
    for(int i=0;i<2;i++){
      scanf("%d %d %d %d",&W[i],&H[i],&X[i],&Y[i]);
      X[i]--; Y[i]--;
      for(int y=0;y<H[i];y++)
	for(int x=0;x<W[i];x++)
	  scanf("%d",&L[i][x][y]);
      dijk(i);
    }
    printf("%d\n",min(search(0),search(1)));
  }
}

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

int main()
{
 int N,M; cin >> N >> M;
 long H[N];
 for(int i=0;i<N;i++){
     long h; cin >> h;
     H[i]=h;
 }
 vector<bool> check;
 check.assign(N,false);
 for(int i=0;i<M;i++){
     int a,b; cin >> a >> b;
     a-=1;
     b-=1;
     if(H[a]<H[b]){
         check[a]=true;
     }
     else if(H[a]>H[b]){
         check[b]=true;
     }
     else{
         check[a]=true;
         check[b]=true;
     }
 }
 int ans=0;
 for(int i=0;i<N;i++){
     if(check[i]==false) ans++;
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 4424
fun main(args: Array<String>) {
    abc126B()
}

fun abc126B() {
    val s = readLine()!!
    val left = s.substring(0..1).toInt()
    val right = s.substring(2..3).toInt()
    val answer = if (left in 1..12) {
        if (right in 1..12) {
            "AMBIGUOUS"
        } else {
            "MMYY"
        }
    } else {
        if (right in 1..12) {
            "YYMM"
        } else {
            "NA"
        }
    }
    
    println(answer)
}


Measured memory_bytes: 31900
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int N; cin >> N;
	int x[110], y[110], h[110];
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i] >> h[i];
	}
	REP(i, 101) {
		REP(j, 101) {
			int X = i;
			int Y = j;
			int H;
			for (int k = 0; k < N; ++k) {
				if (h[k] != 0) {
					H = h[k] + abs(x[k] - X) + abs(y[k] - Y);
					break;
				}
			}
			bool ok = true;
			REP(n, N) {
				if (h[n] != max(0, H - abs(x[n] - X) - abs(y[n] - Y))) {
					ok = false;
				}
			}
			if (ok) {
				cout << X << " " << Y << " " << H << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, a: "List[int]"):
    res = 0
    c = -1
    if a[0] == a[1]:
        a[1] = c
        c -= 1
        res += 1
    for i in range(1, N-1):
        if a[i+1] == a[i]:
            a[i+1] = c
            c -= 1
            res += 1
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  ll n,m;
  cin >> n >> m;
  ll ans = 0;
  if(n*2 <= m){
    ans += n;
    m -= n*2;
  }
  else{
    ans += m/2;
    m %= 2;
  }
  if(m >= 4){
    ans += m/4;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <functional>
#include <numeric>
#include <cstring>

using namespace std;

string A, B;

long long cnt[26];
int main()
{
    cin >> A;
    long long N = A.length();
    for (int i = 0; i < N;i++)
    {
        cnt[A[i] - 'a']++;
    }
    long long palindrome_cnt = 0;
    long long canditate_cnt = (N * (N + 1)) / 2;
    for (int i = 0; i < 26;i++)
    {
        palindrome_cnt += (cnt[i] * (cnt[i] + 1)) / 2;
    }
    long long ans = canditate_cnt - palindrome_cnt;
    cout << ans + 1LL << endl;

    return 0;
}

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

#define maxn 10000+10
#define maxe maxn*maxn/2+1
int pa[maxn],ran[maxn];

void init(int n){
	for(int i=0; i<n; i++){
		pa[i] = i;
		ran[i] = 0;
	}
}

int find(int x){
	if(pa[x]==x) return x;
	else return pa[x] = find(pa[x]);
}

void unite(int x,int y){
	x = find(x); y = find(y);

	if(x==y) return;
	if(ran[x] < ran[y]){
		pa[x] = y;
	}else{
		pa[y] = x;
		if(ran[x] == ran[y])
			++ran[x];
	}
}

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

struct edge{
	int u,v;
	double cost;
	edge(int u=0,int v=0,double cost=0) : u(u),v(v),cost(cost){}
	bool operator<(const edge& rhs) const{
		return cost > rhs.cost;
	}
};
edge es[maxe];
int V,E;

pair<int,int> pile[maxn];

double kruskal(){
	sort(es,es+E);
	init(V);
	double res = 0;
	for(int i=0; i<E; i++){
		edge e = es[i];
		if(!same(e.u,e.v))
			unite(e.u,e.v);
		else
			res += e.cost;
	}

	return res;
}


int main(){
	scanf("%d%d",&V,&E);
	for(int i=0; i<V; i++)
		scanf("%d%d",&pile[i].first,&pile[i].second);

	for(int i=0; i<E; i++){
		scanf("%d%d",&es[i].u,&es[i].v);
		--es[i].u,--es[i].v;
		int dx = pile[es[i].u].first - pile[es[i].v].first;
		int dy = pile[es[i].u].second - pile[es[i].v].second;
		es[i].cost = sqrt(dx*dx+dy*dy);	
	}

	printf("%.3lf\n",kruskal());
}

Measured memory_bytes: 5080
#include <iostream>

using namespace std;


int main()
{
    int squares[100], squares_num, answer = 0;
    cin >> squares_num;
    for (int i = 0; i < squares_num; i++)
    {
        cin >> squares[i];
    }
    for (int z = 0; z < squares_num; z+=2)
    {
        if (squares[z] % 2 == 1)
            answer++;
    }
    cout << answer;
}

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

int main(int argc, const char * argv[]) {
    string s;
    string str;
    int num=0;
    int i;
    
    cin >> s;
    
    while(cin >> str){
        if(str=="END_OF_TEXT"){
            break;
        }else{
            for(i=0;i<str.size();i++){
                if('A'<=str[i] && str[i]<='Z'){
                    str[i]+=('a'-'A');
                }
            }
            if(s==str){
                    num++;
            }
        }
    }
    
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	unordered_multiset<string> ms;
	for (int i = 0; i < n; i++)
	{
		string test;
		cin >> test;
		ms.insert(test);
	}
	for (auto r : {"AC", "WA", "TLE", "RE"})
		printf("%s x %lu\n", r, ms.count(r));
	return 0;
}


Measured memory_bytes: 10752
// abc111_c (arc103_a)
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut vv = vec![0usize; n];
    for i in 0..n - 1 {
        vv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    vv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut me = vec![(0usize, 0i32); 100_000 + 1];
    let mut mo = vec![(0usize, 0i32); 100_000 + 1];
    for i in 0..n {
        if i % 2 == 0 {
            me[vv[i]].0 = vv[i];
            me[vv[i]].1 += 1;
        } else {
            mo[vv[i]].0 = vv[i];
            mo[vv[i]].1 += 1;
        }
    }

    me.sort_by(|&(_, v1), &(_, v2)| v2.cmp(&v1));
    mo.sort_by(|&(_, v1), &(_, v2)| v2.cmp(&v1));

    let ans = n as i32
        - if me[0].0 != mo[0].0 {
            me[0].1 + mo[0].1
        } else {
            max(me[0].1 + mo[1].1, me[1].1 + mo[0].1)
        };
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 150;
int n, m, cnt, fa[N], f[N], head[N], to[N << 1], nxt[N << 1], sum, ans, res;
inline void add(int a, int b){
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
struct Edge {
	int a, b, c;
	inline bool operator < (const Edge &o) const {return c > o.c;}
} e[N];
inline int getfa(int x){
	return x == fa[x] ? x : fa[x] = getfa(fa[x]);
}
bool in[N], vis[N], flag;
int col[N];
inline void dfs(int x){
	if(!flag) vis[x] = true;
	if(x == n) flag = true;
	for(Rint i = head[x];i;i = nxt[i])
		if(to[i] != f[x]){f[to[i]] = x; dfs(to[i]);}
	if(!flag) vis[x] = false;
}
inline void dfs2(int x, int c){
	col[x] = c;
	for(Rint i = head[x];i;i = nxt[i])
		if(to[i] != f[x] && !vis[to[i]] && !col[to[i]]) dfs2(to[i], c);
}
inline int rnd(){return rand() << 15 | rand();}
clock_t st = clock();
int main(){
	srand(20050915);
	scanf("%d%d", &n, &m);
	for(Rint i = 1;i <= m;i ++) scanf("%d%d%d", &e[i].a, &e[i].b, &e[i].c), sum += e[i].c;
	sort(e + 1, e + m + 1);
	while(true){
		res = flag = cnt = 0;
		memset(head, 0, sizeof head);
		memset(vis, 0, sizeof vis);
		memset(in, 0, sizeof in);
		memset(f, 0, sizeof f);
		memset(col, 0, sizeof col);
		for(Rint i = 1;i <= n;i ++) fa[i] = i;
		for(Rint i = 1, j = 1;i <= m && j < n;i ++){
			int fa1 = getfa(e[i].a), fa2 = getfa(e[i].b);
			in[i] = false;
			if(fa1 != fa2){
				in[i] = true; fa[fa1] = fa2;
				add(e[i].a, e[i].b); add(e[i].b, e[i].a); res += e[i].c; ++ j;
			}
		}
		dfs(1);
		for(Rint i = 1, j = 0;i <= m;i ++)
			if(vis[i]) dfs2(i, ++ j);
		for(Rint i = 1;i <= m;i ++) if(!in[i] && col[e[i].a] == col[e[i].b]) res += e[i].c;
		ans = max(ans, res);
		random_shuffle(e + 1, e + m + 1);
		if(clock() - st >= CLOCKS_PER_SEC * 3.9) break;
	}
	printf("%d", sum - ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n
 string s;
 cin>>s;
 if(s=="ABC")
    cout << "ARC"  << endl;
 else 
    cout << "ABC" << endl;
    return 0;

}


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

int main()
{
	int n;
	cin >> n;
	int t,A;
	cin >> t >> A;
	double a[n + 1];
	for(int i = 1;i <=n ;i++){
		scanf("%lf",&a[i]);
		a[i] = t - 0.006 * a[i];
	}
	double INF = 10000000;
	double minn = INF;
	int tmp;
	for(int i = 1;i <= n;i++){
		if(abs(A - a[i]) < minn){
			minn = abs(A - a[i]);
			tmp = i;
		}
	}
	cout << tmp << endl;
	return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", (c / a) * b);
	
	Please AC;
}


Measured memory_bytes: 632
#![allow(non_snake_case)]

fn knapsack(items: &[(usize, u64)], capacity: usize) -> u64 {
    let mut dp = vec![0; capacity + 1];
    for i in 1..capacity + 1 {
        for &(weight, value) in items {
            if weight <= i {
                dp[i] = std::cmp::max(dp[i], dp[i - weight] + value);
            }
        }
    }
    dp[capacity]
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());

    let N: usize = stdin.read();
    let A: Vec<u64> = (0..3).map(|_| stdin.read()).collect();
    let B: Vec<u64> = (0..3).map(|_| stdin.read()).collect();
    let items1: Vec<_> = (0..3).filter(|&i| A[i] <= B[i]).map(|i| (A[i] as usize, B[i] - A[i])).collect();
    let M = N + knapsack(&items1, N) as usize;
    let items2: Vec<_> = (0..3).filter(|&i| B[i] <= A[i]).map(|i| (B[i] as usize, A[i] - B[i])).collect();
    let result = M + knapsack(&items2, M as usize) as usize;
    println!("{}", result);
}

#[allow(unused_must_use)]
mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}

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

namespace abc091_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(x[0] + x[1] >= x[2] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n,m;
    cin >> n >> m;
    int sum = 0;
    rep(i,m){
        int in;
        cin >> in;
        sum += in;
    }   
    int ans = n - sum;
    if(ans >= 0){
        cout << ans << endl;
    } else{
        cout << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  bool ok = false;
  rep(x,k+1)rep(y,k+1)rep(z,k+1){
    int na=a*(1<<x),nb=b*(1<<y),nc=c*(1<<z);
    if(x+y+z<=k && na<nb && nb<nc)ok=true;
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define int long long

using namespace std;

map <int, int> used;

 main () {   
 	int n;
 	cin >> n;
 	used[0] = 1;
 	int asd = 0;
 	int ans = 0;
 	for (int i = 1;i <= n;i ++) {
 		int x;
 		cin >> x;
 		asd += x;
		ans += used[asd];
		used[asd] ++;
 	}
 	cout << ans;
    return 0;           		
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll h,w;
char a[200][200];
ll cou[26];
int main(){
	cin >> h >> w;
	REP(i,h) 
		cin >> a[i];

	REP(i,h) {
		REP(j,w) {
			cou[a[i][j] - 'a']++;
		}
	}

	bool f = true;
	if(h % 2 == 0 && w % 2 == 0) {
		REP(i,26) {
			if(cou[i] % 4 != 0) {
				f = false;
			}
		}
	}else if(h % 2 == 1 && w % 2 == 1) {
		ll c = 0;
		REP(i,26) {
			if(cou[i] % 2 == 1)
				c++;
		}
		if(c != 1) f = false;
		c = 0;
		REP(i,26) {
			if(cou[i] % 4 == 0);
			else if(cou[i] % 4 == 2) {
				c++;
				if(c > (h - 1) / 2 + (w - 1) / 2) {
					f = false;
				}
			}
		}
	}else{
		if(h % 2 == 1) {
			swap(h,w);
		}
		ll c = 0;
		REP(i,26) {
			if(cou[i] % 4 ==  0);
			else if(cou[i] % 4 == 2) {
				c++;
				if(c > h / 2) 
					f = false;
			}else 
				f = false;
		}
	}

	if(f) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}


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

int h, w, n, l[200005];

int main() {
	scanf("%d%d%d", &h, &w, &n);
	fill(l + 1, l + 1 + h, w + 1);
	for (int i = 0, x, y; i < n; ++i) {
		scanf("%d%d", &x, &y);
		l[x] = min(l[x], y);
	}
	int r = 1;
	for (int i = 2; i <= h; ++i) {
		if (l[i] <= r) {
			printf("%d\n", i - 1);
			return 0;
		}
		r = min(r + 1, l[i] - 1);
	}
	printf("%d\n", h);
}


Measured memory_bytes: 1024
[x,y]=list(map(int,input().split()))
ans=0
if x==1:
	ans+=300000
if x==2:
	ans+=200000
if x==3:
	ans+=100000
if y==1:
	ans+=300000
if y==2:
	ans+=200000
if y==3:
	ans+=100000
if x==1 and y==1:
	ans+=400000
print(ans)

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n, a[N];

int main() {

	File();

	n = read();

	For (i, 1, n) a[i] = read();

	for (int i = n; i > 0; i -= 2)
		printf ("%d ", a[i]);

	for (int i = 1 + (n & 1); i <= n; i += 2)
		printf ("%d ", a[i]);

	return 0;

}

Measured memory_bytes: 2944
#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];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3632
s = str(input())
if s[0] == 'A' and s[2:len(s)-1].count('C') == 1:
    j = s.index('C')
    w = s[1:j] + s[j+1:]
    if w.lower() == w:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 8936
// Problem : B - Count Balls
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define REP(i,n) for (ll i = 0; i < n; i++)
#define REPR(i,n) for(ll i = n-1; i >= 0; i--)
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define FORR(i,a,b) for(ll i = a-1; i>= b; i--)
#define ff first
#define ss second
#define MAXN (ll)1000002
#define MODN (ll)1000000007
#define mp make_pair
#define pb push_back
#define LN(x) (ll)x.length()
#define SZ(x) (ll)x.size()
#define bg(x) (x.begin())
#define rbg(x) (x.rbegin())
#define ENDL cout<<endl
ll n,t=1,tmp;
ll arr[MAXN];
int main() {
   ll n,a,b;
cin>>n>>a>>b;
if(a == 0 && b == 0) {
	cout<<0;
} else {
	ll x = n/(a+b);
	ll ans=x*a;
	x = n - x*(a+b);
	ans+=min(x,a);
	cout<<ans;
}
}

Measured memory_bytes: 256
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    start = n if n < x else x
    for a in range(start, 0, -1):
        if a >= x:
            continue
        for b in range(a - 1, 0, -1):
            if a + b >= x:
                continue
            for c in range(b - 1, 0, -1):
                total = a + b + c
                if total == x:
                    count += 1
                elif total < x:
                    break
    print(count)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int a,b,m,c[maxn],d[maxn],e[maxn],f[maxn],g[maxn],minn1=2e9,minn2=2e9,ans=2e9;
 
signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b >> m;
	rep(a) cin >> c[i];
	rep(b) cin >> d[i];
	rep(m) cin >> e[i] >> f[i] >> g[i];
	rep(a) minn1=min(minn1,c[i]);
	rep(b) minn2=min(minn2,d[i]);
	ans=minn1+minn2;
	rep(m) ans=min(ans,c[e[i]-1]+d[f[i]-1]-g[i]);
	print1(ans);
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string s;
	int num, i, a = 0, b = 0;
	cin >> num >> s;
	for (i = 0; i < num; i++) {
		if (s[i] == '(')
			b++;
		else if (b > 0)
			b--;
	}
	for (i = num - 1; i >= 0; i--) {
		if (s[i] == ')')
			a++;
		else if (a > 0)
			a--;
	}
	for (i = 0; i < a; i++)
		printf("(");
	cout << s;
	for (i = 0; i < b; i++)
		printf(")");
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m,a[105],i,l=0,c=0;
  scanf("%d",&n);
  scanf("%d",&m);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    l+=a[i];
  }
  for(i=0;i<n;i++){
    if(a[i]*4*m>=l) c++;
  }
  if(c>=m){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}

Measured memory_bytes: 128
//
//  main.cpp
//  APG4b
//
//  Created by 安藤光希 on 2020/03/21.
//  Copyright © 2020 安藤光希. All rights reserved.
//


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


int main() {
    
    int N, M; //N個の都市、M本の道路
    cin >> N >> M;
    
    vector<int> src(M), dst(M);
    
    for (int i = 0; i<M; i++){
        cin >> src.at(i) >> dst.at(i);
    }
    
    
    
    for (int i = 0; i < N; i++){
        int cnt = 0;
        
        for (int j = 0; j < M; j++){
            if (src.at(j) == i + 1 || dst.at(j) == i + 1){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    
    
    
    //N個の都市、M本の道路
    /*
     4 3 # 4都市、3道路
     1 2
     2 3
     1 4
     
     ----
     2
     2
     1
     1
     
     */
    
    
    
}

// cin >> N;
// cout << N << endl;

/*
https://atcoder.jp/contests/apg4b/tasks/APG4b_n
 https://atcoder.jp/contests/apg4b/tasks/APG4b_cq
 https://atcoder.jp/contests/practice
 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,m,k;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m >> k;
    for(int i=0;i<m;i++){
        if(m-2*i && !((k-n*i)%(m-2*i)) && (k-n*i)/(m-2*i)>=0 && (k-n*i)/(m-2*i)<=n){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<pair<int, string> > cand;

void dfs(int n, string s) {
  if (n > 11) return;
  cand.push_back(make_pair(n, s));
  int last = s[s.size() - 1] - '0';
  if (0 <= last - 1) {
    dfs(n + 1, s + (char)(last - 1 + '0'));
  }
  dfs(n + 1, s + (char)(last + '0'));
  if (last + 1 <= 9) {
    dfs(n + 1, s + (char)(last + 1 + '0'));
  }
}

int main() {
  int k;
  cin >> k;
  for (int i = 1; i <= 9; ++i) {
    dfs(1, to_string(i));
  }
  sort(cand.begin(), cand.end());
  cout << cand[k - 1].second << endl;
  return 0;
}

Measured memory_bytes: 51048
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  k=n-1;
  rep(i,a-k, a+k+1) cout<<i<<" ";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3584
# Quick Sort #
def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for k in range(p, r):
        if A[k][1] <= x:
            i += 1
            A[i], A[k] = A[k], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)

def bubble_sort(c, n):
    x = c[:]
    for i in range(n):
        for k in range(n-1, i, -1):
            if x[k][1] < x[k-1][1]:
                x[k], x[k-1] = x[k-1], x[k]
    return x

def is_stable(_in, out):
    n = len(_in)
    for i in range(n):
        for k in range(i+1, n):
            for a in range(n):
                for b in range(a+1, n):
                    if _in[i][1] == _in[k][1] and _in[i] == out[b] and _in[k] == out[a]:
                        return False
    return True

n = int(input())
a = []
for i in range(n):
    mrk, num = input().split()
    num = int(num)
    a.append((mrk, num))
b = a[:]
quick_sort(b, 0, n-1)
if n > 10000:
    print("Not stable")
else:
    c = bubble_sort(a[:], n)
    if b == c:
        print("Stable")
    else:
        print("Not stable")
for i in b:
    print(*i)


Measured memory_bytes: 17268
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll dp[51][2501];

int main() {
	int N, A; cin >> N >> A;
	vector<int> a(N);
	for (int& x: a) cin >> x;
	dp[0][0] = 1;
	for (int x: a) {
		for (int k = 50; k >= 0; k--)
			for (int y = 0; y <= 2500; y++) {
				if (!dp[k][y]) continue;
				dp[k + 1][y + x] += dp[k][y];
			}
	}
	ll ans = 0;
	for (int k = 1; k <= 50; k++)
		for (int y = 0; y <= 2500; y++)
			if (k * A == y)
				ans += dp[k][y];
	cout << ans << endl;
}


Measured memory_bytes: 640
edges = [[] for _ in range(7)]
"""
A:0, B:1, X:2, Y:3, Z:4, W:5, NA:61
"""
edges[0] = [2, 3]
edges[1] = [3, 2]
edges[2] = [6, 4]
edges[3] = [2, 6]
edges[4] = [5, 1]
edges[5] = [1, 3]
edges[6] = [6, 6]

while True:
  s = input()
  if s == "#":
    break
  node = 0
  for c in s:
    node = edges[node][int(c)]
  if node == 1:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 5616
<?php
 

 
      
     $chaine = trim(fgets(STDIN));
     $newchaine = "";	
     for($j=strlen($chaine);$j>0;$j--){
 
         $newchaine .= $chaine[$j-1];
     
 
     }
     echo $newchaine;
 

 
 
 
?>

Measured memory_bytes: 15028
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,K;
int h[100000];

int main(){
    cin>>N>>K;
    rep(i,N) cin>>h[i];

    sort(h,h+N);

    int ans=1001001001;
    rep(i,N-K+1){
        ans=min(ans,h[i+K-1]-h[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    scanf("%d",&n);
    if(n==2) return cout<<-1<<endl,0;
    if(n==3) return puts("aa.\n..a\n..a"),0;
    vector<string> q={"aabc","ddbc","bcaa","bcdd"},
            p={"aabbc","cdd.c","c..ba","a..ba","accdd"},
            h={".llkkj","iihh.j","ggfe..","..fedd","c...ba","c...ba"},
            s={".nnmmll","kkjji..","hhggi..","f....ed","f....ed","....cba","....cba"};
    vector<string> ans(n,string(n,'.'));
    fr(i,n/4){
        fr(I,4) fr(J,4){
            ans[4*i+I][4*i+J]=q[I][J];
        }
    }
    if(n%4==1) fr(i,5) fr(j,5) ans[n-5+i][n-5+j]=p[i][j];
    if(n%4==2) fr(i,6) fr(j,6) ans[n-6+i][n-6+j]=h[i][j];
    if(n%4==3) fr(i,7) fr(j,7) ans[n-7+i][n-7+j]=s[i][j];
    fr(i,n) printf("%s\n",ans[i].c_str());
}

Measured memory_bytes: 2304
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b,n=map(int,input().split())
cnt=0

if n//b>0:
	print(a*(b-1)//b-a*((b-1)//b))
else:
	print(a*(n)//b-a*((n)//b))

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

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

    int64_t t=1,a=1;

    for(int i=0;i<N;i++){
        int64_t T,A;
        cin>>T>>A;
        int64_t mul=max((t+T-1)/T,(a+A-1)/A);
        t=T*mul; a=A*mul;
        // cout<<t<<' '<<a<<endl;
    }
    cout<<t+a<<endl;

    return 0;
}

Measured memory_bytes: 256