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

public class Main{

    public static void main(String[] args) throws Exception{

        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(in,out);
        out.close();
    }

    static class Task{

        public void solve(InputReader in ,PrintWriter out){

            long a = in.nextLong();
            long b = in.nextLong();
            long mid = (a+b)/2;
            if(Math.abs(a - mid) == Math.abs(b - mid))
              out.println(mid);
            else 
              out.println("IMPOSSIBLE");
        }
    }

    static class InputReader{

        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream){
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tokenizer = null;
        }

        public String next(){
            while(tokenizer == null || !tokenizer.hasMoreTokens()){
                try{
                    tokenizer = new StringTokenizer(reader.readLine());
                }
                catch(IOException e){
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

table = [0] * (a[n - 1] + 1)
#table
for i in range(n):
    p = a[i]
    for j in range(2 * p, a[n - 1] + 1, p):
        #print(j)
        table[j] = 1
        
from collections import Counter
cnt = Counter(a)
ans = 0
for i in range(n):
    
    if cnt[a[i]] != 1:
        continue
    
    if table[a[i]] != 1:
        ans += 1
print(ans)

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

int main(){
    int n, a, b;
    multiset<int> m;
    vector<int> v[32];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        v[a].push_back(b);
    }
    int ans = 0;
    for(int i = 1; i <= 31; i++){
        for(int x : v[i])   m.insert(x);
        while(!m.empty() && *(m.begin()) < i)  m.erase(m.begin());
        if(m.empty())   ans++;
        else            ans += 2, m.erase(m.begin());
    }
    cout << ans*50 << endl;
    return 0;
}


Measured memory_bytes: 3176
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

int main(){
  ll N, M;
  cin >> N >> M;
  if(N > M) swap(N, M);
  if(N == 1){
    if(M == 1){
      cout << 1 << endl;
      return 0;
    }
    cout << (M - 2) << endl;
    return 0;
  }
  ll ans = N * M - 2 * N - 2 * M + 4;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main(){
   int n;
   char s[n];
   int count = 0;
   scanf("%d", &n);
   scanf("%s", s);
   
   for(int i = 0; i < n-2; i++) {
      if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
         count++;
      }
   }
   printf("%d\n", count);
   return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100000 + 7;
int n;
string s[N];

int go(int& x, int& y)
{
	int mn = min(x, y);
	x -= mn;
	y -= mn;
	return mn;
}

int st1(int ba, int bx, int xa)
{
	if (xa == 0 && bx == 0)
		return max(0, ba - 1);
	return ba + min(xa, bx);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	cin >> n;
	FOR(i, 0, n)
		cin >> s[i];
	
	int ans = 0;
	FOR(i, 0, n)
		FOR(j, 0, SZ(s[i]) - 1)
			ans += s[i][j] == 'A' && s[i][j + 1] == 'B';
	
	int ba = 0, bx = 0, xa = 0;
	FOR(i, 0, n)
	{
		if (s[i].back() == 'A')
		{
			if (s[i][0] == 'B')
				++ba;
			else
				++xa;
		}
		else
		{
			if (s[i][0] == 'B')
				++bx;
		}
	}
	
	int lol = st1(ba, bx, xa);

	ans += lol;	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


Measured memory_bytes: 1536
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [input().split() for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    h,w=map(int,input().split())
    if h == 1 or w == 1:
        print(1)
        return 0
    res = h*w//2
    if (h*w)%2 != 0:
        res += 1
    print(res)

if __name__ == '__main__':
    main()



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

void bubleSort(pair<char,int> t[],int n)
{
	pair<char,int> a;
	for(int i=0;i<n-1;i++)
		for(int j=0;j<n-1;j++)
		{
			if(t[j].second>t[j+1].second)
			{
				a=t[j];
				t[j]=t[j+1];
				t[j+1]=a;
			}
		}
		
}
void selectSort(pair<char,int> t[],int n)
{
	for(int i=0;i<n;i++)
	{
		int min=i;
		
		for(int j=i;j<n;j++)
		if(t[j].second<t[min].second) min=j;
		
		pair<char,int> a=t[i];
		t[i]=t[min];
		t[min]=a;
	}
	
}
void print(pair<char,int> t[],int n)
{
	for(int i=0;i<n;i++)
	{
		if(i>0) printf(" ");
		printf("%c%d",t[i].first,t[i].second);
	}
	printf("\n");
}
void compa(pair<char,int> a[],pair<char,int> b[],int n)
{
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i]) 
		{
			printf("Not stable\n");
			return ;
		}
	}
	printf("Stable\n");
}
int main()
{
	int n;
	scanf("%d",&n);
	
	pair<char,int> card[n];
	pair<char,int> sort_card1[n];
	pair<char,int> sort_card2[n];
	for(int i=0;i<n;i++)
	{
		cin>>card[i].first>>card[i].second;
		sort_card1[i]=card[i];
		sort_card2[i]=card[i];
	}
	bubleSort(sort_card1,n);
	print(sort_card1,n);
	printf("Stable\n");
	
	selectSort(sort_card2,n);
	print(sort_card2,n);
	compa(sort_card1,sort_card2,n);
	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define int long long
int q[100000000];
int w[100000000];
signed main(){
  int b=0,c=0,d=0,e,f,a;
  cin>>a;
  for(int i=0;i<=a;i++) cin>>q[i];
  for(int i=0;i<a;i++) cin>>w[i];
  if(q[0]<=w[0]) b+=q[0],w[0]=w[0]-q[0],q[0]=0;
  else b+=w[0],q[0]=q[0]-w[0],w[0]=0;
  for(int i=0;i<a;i++){
    if(w[i]!=0){
      if(q[i]<=w[i]) b+=q[i],w[i]=w[i]-q[i],q[i]=0;
      else b+=w[i],q[i]=q[i]-w[i],w[i]=0;
    }
    if(w[i]!=0){
      if(q[i+1]<=w[i]) b+=q[i+1],w[i]=w[i]-q[i+1],q[i+1]=0;
      else b+=w[i],q[i+1]=q[i+1]-w[i],w[i]=0;
    }
  }
  cout<<b<<"\n";}


Measured memory_bytes: 3072
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,c,b[110],a[110][110],ans=0;

int main()
{
	cin>>n>>m>>c;
	rep(i,m) cin>>b[i];
	rep(i,n)
	{
		int res=0;
		rep(j,m)
		{
			cin>>a[i][j];
			res+=a[i][j]*b[j];
		}
		if(res+c>0) ans++;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	for(unsigned int i = 0; i < s.size(); i++){
		if(s[i] == t[0]){
			for(unsigned int j = i, k = 0; ; j++, k++){
				if(j == s.size()) j = 0;
				if(k == s.size()){
					cout << "Yes" << endl;
					return 0;
				}
				if(s[j] != t[k]) break;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;
std::vector<P>v[100010];

int main() {
	int n;
	std::cin >> n;
	std::cout << n * 800 - 200 * (n / 15) << std::endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define int long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int32_t main()
    {
        std::ios::sync_with_stdio(false);
       string s;
       cin>>s;
       int n=s.length();
       int x=s[n-1]-'0';
       if(x==3)
        cout<<"bon"<<endl;
       else if(x==0 || x==1 || x==6|| x==8)
        cout<<"pon"<<endl;
       else
        cout<<"hon"<<endl;
        return 0;
    }


Measured memory_bytes: 3652
A, B, C, X = [int(input()) for _ in range(4)]

combi = 0

for ai in range(A+1):
  for bi in range(B+1):
    for ci in range(C+1):
      if X == 500 * ai + 100 * bi + 50 * ci:
        combi += 1
print(combi)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 51;

int main()
{
    while(1){
        int n,m;
    	scanf("%d",&n);
        if(n == 0){
            break;
        }
        if(n == 1){
            printf("0\n");
            return 0;
        }
        int emp[51][31];
        rep(i,n){
            rep(j,31){
                emp[i][j] = 0;
            }
        }
    	rep(i,n){
    		scanf("%d",&m);
            rep(j,m){
                int bf;
                scanf("%d",&bf);
                emp[i][bf-1] = 1;
            }
    	}
        int res = -1;
        ll mp[MAX_N];
        rep(i,n){
            mp[i] = (1LL << i);
        }
        rep(i,30){
            vector<int> vec;
            rep(j,n){
                if(emp[j][i] == 1){
                    vec.push_back(j);
                }
            }
            ll hoge = 0;
            rep(j,vec.size()){
                hoge |= mp[vec[j]];
            }
            if(hoge == (1LL << n) - 1LL){
                res = i+1;
                break;
            }
            rep(j,vec.size()){
                mp[vec[j]] = hoge;
            }
        }
        if(res){
            printf("%d\n",res);
        }
    }
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    int count = 0;
    int ans = 0;
    for(int i = 0; i < N - 1; i++)
    {
        if(H[i] >= H[i+1]) count++;
        else
        {
            ans = max(ans,count);
            count = 0;
        }
    }
    if(count != 0) ans = max(ans,count);
    cout << ans << endl;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!
N=int(input())
A=[0]
A=A+list(map(int,input().split()))
A.append(0)
A.append(0)
dis=[]
sum_dis=[0]
skip=[]
sum_skip=[0]

for i in range(N+1):
    dis.append(abs(A[i+1]-A[i]))
    sum_dis.append(dis[-1]+sum_dis[i])
    skip.append(abs(A[i+2]-A[i]))

for i in range(len(sum_dis)-2):
    print(skip[i]+sum_dis[len(sum_dis)-1]-sum_dis[i+2]+sum_dis[i])
#なぜかめちゃくちゃ苦労した
#台風19号記念パピコ

Measured memory_bytes: 20724
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			if (x == 0 && y == 0) break;
			if (x < y) {
				System.out.printf("%d %d\n", x, y);
			} else System.out.printf("%d %d\n", y, x);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 40052
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=max(x,y)*2*c;
    ans=min(ans,min(x,y)*2*c+(y>x?(y-x)*b:(x-y)*a));
    ans=min(ans,a*x+b*y);
    cout<<ans;
    return 0;
}

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

int main(){
    int a, b;
    //char op;
    while( cin >> a >> b, a ){
        for( int i = 0; i < a; i++ ){
            for( int j = 0; j < b; j++ ){
                if( (i+j)%2 == 0 ){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int w,h;
string s[77];

string mem[77][77];

string bigger(string s1,string s2){
	if(s1.length()>s2.length())return s1;
	else if(s1.length()<s2.length())return s2;
	else if(s1>s2)return s1;
	else return s2;
}

string dfs(int i,int j){
	if(mem[i][j]!="")return mem[i][j];
	string res="";
	if(i+1<h&&isdigit(s[i+1][j]))res=bigger(res,dfs(i+1,j));
	if(j+1<w&&isdigit(s[i][j+1]))res=bigger(res,dfs(i,j+1));
	return mem[i][j]=s[i][j]+res;
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>w>>h;
		if(w==0)break;
		rep(i,h)cin>>s[i];
		string res="";
		rep(i,h+1)rep(j,w+1)mem[i][j]="";
		rep(i,h)rep(j,w){
			if(isdigit(s[i][j])&&s[i][j]!='0')res=bigger(res,dfs(i,j));
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3416
from itertools import combinations
n, m = map(int, input().split(" "))
if n >= m:
  print(0)
else:
  ls = list(sorted(map(int, input().split(" "))))
  total = ls[-1] - ls[0]
  sections = sorted([ls[i+1]-ls[i] for i in range(m-1)], reverse=True)
  print(total-sum(sections[:n-1]))
  


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


inline void transpose(vector<string> &a) {

    int n = a.size();
    if (n == 0) return;
    int m = a[0].size();
    vector<string> b(m, string(n, ' '));
    fori (i, n) fori (j, m) b[j][i] = a[i][j];
    a = b;
}


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

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


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}


const int N = 1e5 + 9;
const int L = 1e4 + 9;
const ll oo = 1e18;


void smain() {


    int n;
    cin >> n;
    vl h(n + 1, 0);
    vvl dp(n + 1, vl(3, -oo));
    vvl a(n + 1, vl(3, -oo));
    fori (i, n) cin >> a[i + 1][0] >> a[i + 1][1] >> a[i + 1][2];
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int z : {0, 1, 2}) {
            for (int step : {1}) {
                if (i - step < 0) continue;
                ll cur = a[i][z] + (step == 2 ? a[i - 1][z] : 0);
                inmax(dp[i][z], dp[i - step][(z + 1) % 3] + cur);
                inmax(dp[i][z], dp[i - step][(z + 2) % 3] + cur);
            }
        }
    }
    cout << *max_element(ALL(dp[n]));
}

Measured memory_bytes: 12032
MOD = 10**9+7

n = int(input())
a=list(map(int,input().split()))

sum_a=sum(a)%MOD
total=0
for i in range(len(a)):
    sum_a=(sum_a-a[i])%MOD
    total = (total+sum_a*a[i])%MOD

print(total%MOD)

Measured memory_bytes: 104932
#include <stdio.h>

int main(){
    int a, b, sum, t=0;
    while (scanf("%d %d",&a,&b) != EOF) {
        sum=a+b;
        while (sum>0) {
            sum /=10;
            t++;
        }
        printf("%d\n",t);
        t=0;
    }
    
    return 0;
}

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

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

    vector<int> vec(N);
    for (int i = 0; i < M; i++){
        int j,k;
        cin >> j >> k;
        vec.at(j-1) += 1;
        vec.at(k-1) += 1;
    }
    for (int l = 0; l < N; l++){
        cout << vec.at(l) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  int dp[s.size()+1][2];
  rep(i,s.size()+1)rep(j,2)dp[i][j]=MAX;
  dp[s.size()][0]=0;
  rrep(i,s.size()) {
    int x=s[i]-'0';
    dp[i][0]=min(dp[i][0],dp[i+1][0]+x);
    dp[i][1]=min(dp[i][1],dp[i+1][0]+10-x);
    x=x+1;
    dp[i][0]=min(dp[i][0],dp[i+1][1]+x);
    dp[i][1]=min(dp[i][1],dp[i+1][1]+(10-x)%10);
  }
  pr(min(dp[0][0],dp[0][1]+1));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n;
int a[2][100];
int dp[2][105];

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

	cin>>n;
	REP(i,2) REP(j,n) cin>>a[i][j];
	REP(i,2) {
		REP(j,n) {
			if(i==0&&j==0) dp[i][j]=a[i][j];
			if(i!=0) dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i][j]);
			if(j!=0) dp[i][j]=max(dp[i][j],dp[i][j-1]+a[i][j]);
		}
	}
	cout<<dp[1][n-1]<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
long long int a,b,c;
long long int x,y;
long long int solve(void){
  if(c*2-a-b>=0) return a*x+b*y;
  if(x>y) return fmin(2*c*x,2*c*y+a*(x-y));
  return fmin(2*c*y,2*c*x+b*(y-x));
}
main(){
  cin>>a>>b>>c>>x>>y;
  cout<<solve()<<endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll n, x, s, a[55]={1}, b[55]={1};

void f(ll p, ll q) {
	if(p==0) {s++; return;}
	ll md = (a[p]+1)/2;
	if(q==1) return;
	else if(q < md) f(p-1, q-1);
	else if(q==md) {s += b[p-1] + 1; return;}
	else {
		s += b[p-1] + 1;
		f(p-1, q-md);
	}
}

int main() {
	int i;
	cin>>n>>x;
	for(i=1; i<=n; i++) {
		a[i] = a[i-1]*2 + 3;
		b[i] = b[i-1]*2 + 1;
	}
	f(n, x);
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

ans = 0
left = M
for i in range(len(A)):
    if A[i] > K:
        break

    while A[i] + B[left] > K:
        left -= 1

    ans = max(ans, left + i)

print(ans)

Measured memory_bytes: 76056
# coding: utf-8
# Your code here!

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
tmp = 0
ctr = 0

for i in range(N):
    A = list(map(int, input().split()))
    for j in range(len(B)):
        tmp += A[j] * B[j]
    tmp += C
    if tmp > 0:
        ctr += 1
    tmp = 0
print(ctr)

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val nodes = Array(n) { Node() }
    for (i in 0 until n - 1) {
        val u = sc.nextInt() - 1
        val v = sc.nextInt() - 1
        val w = sc.nextInt()
        if (w % 2 == 0) {
            nodes[u].even.add(nodes[v])
            nodes[v].even.add(nodes[u])
        } else {
            nodes[u].odd.add(nodes[v])
            nodes[v].odd.add(nodes[u])
        }
    }
    nodes[0].dfs(0)
    nodes.map { it.color }.forEach(::println)
}

class Node {
    var color = 0
    var decided = false
    val even = ArrayList<Node>()
    val odd = ArrayList<Node>()
    fun dfs(color: Int) {
        this.color = color
        this.decided = true
        even.forEach {
            if (!it.decided) it.dfs(color)
        }
        odd.forEach {
            if (!it.decided) it.dfs(1 - color)
        }
    }
}


Measured memory_bytes: 130860
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<pl, ll>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	ll  i, j,n, a[mx];
	cin>>n;
	rep(i, 1, n+1)
	cin>>a[i];

    ll ans= 0;

    rep(i, 0, 64){

        ll kk[]= {0, 0};
        rep(j, 1, n+1){
            kk[a[j]&1]++;
           // a[j]/=2;
           a[j]>>=1;
        }

       // ans= (ans + ((kk[0]*kk[1])%mod)*(1<<i)%mod)%mod;
       ans= (ans + ((kk[0]*kk[1])%mod*(powr(2, i))%mod))%mod;
    }
	
    cout<<ans;
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 3968
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
	var num = int.Parse(ReadLine());
    var list = new Dictionary<string,int>();
    var lists = new List<string>();
    var keys = "";
    var count = 0;
	
    for(var i = 0;i < num;i++){
      keys = ReadLine();
      if(list.ContainsKey(keys)){
        list[keys]++;
        count = Math.Max(count,list[keys]);
      }else{
        list[keys] = 0;
      }
    }
    foreach(var i in list){
    	if(i.Value == count){
        	lists.Add(i.Key);
        }
    }
    
    lists.Sort(StringComparer.Ordinal);
    
    foreach(var i in lists){
    
    WriteLine(i);
    }
    

    
  }
}


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

int h, w;
string a[8];
bool ok = false;
int num_sharp = 0;

void dfs(int i, int j, int cnt) {
  if (i == h - 1 && j == w - 1 && num_sharp == cnt) {
    ok = true;
    return;
  }
  if (i < h - 1 && a[i+1][j] == '#') {
    dfs(i+1, j, cnt+1);
  }
  if (j < w - 1 && a[i][j+1] == '#') {
    dfs(i, j+1, cnt+1);
  }
}
int main() {
  cin>>h>>w;
  for (int i=0; i<h; i++) cin>>a[i];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (a[i][j] == '#') {
        ++num_sharp;
      }
    }
  }
  dfs(0, 0, 1);
  if (ok) {
    cout<<"Possible"<<endl;
  } else {
    cout<<"Impossible"<<endl;
  }
}

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


//=============ford_fulkerson============================
ll MAX_V = 202;
struct edge {ll to, cap, rev;};
vector<vector<edge>> G(MAX_V);
vector<bool> used(MAX_V, false);

void add_edge(ll from, ll to, ll cap) {
  G.at(from).push_back((edge){to, cap, (ll)G.at(to).size()});
  G.at(to).push_back((edge){from, 0ll, (ll)G.at(from).size() - 1});
}

ll dfs(ll v, ll t, ll f) {
  if (v == t) {
    return f;
  }
  used.at(v) = true;
  for (ll i = 0; i < G.at(v).size(); ++i) {
    edge &e = G.at(v).at(i);
    if (!used.at(e.to) && e.cap > 0) {
      ll d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G.at(e.to).at(e.rev).cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(ll s, ll t) {
  ll flow = 0;
  while (true) {
    used = vector<bool>(MAX_V, false);
    ll f = dfs(s, t, INF);
    if (f == 0) {
      return flow;
    }
    flow += f;
  }
}
//=================================================

int main() {
  ll X, Y, E;
  cin >> X >> Y >> E;
  for (ll i = 1; i <= X; ++i) {
    add_edge(0, i, 1);
  }
  for (ll i = 1; i <= Y; ++i) {
    add_edge(i + 100, 201, 1);
  }
  for (ll i = 0; i < E; ++i) {
    ll x, y;
    cin >> x >> y;
    x += 1;
    y += 1;
    add_edge(x, y + 100, 1);
  }
  cout << max_flow(0, 201) << "\n";
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  ll ans;
  bool judge=false;
  for(int i=1;i<=N;i++){
    ll yen=i*1.08;
    if(yen==N){
      judge=true;
      ans=i;
      break;
    }
  }
  if(judge) cout<<ans<<endl;
  else cout<<":("<<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    long long N;
    cin >> N;
    vector<long long> nums(N);
    for(int i = 0; i < N; i++) cin >> nums[i];
    
    long long mcnt = 0;
    for(int i = 0; i < N; i++)
    {
        if (nums[i] < 0) mcnt++;
    }
    
    long long ans = 0;
    if (mcnt % 2 == 0)
    {
        for(int i = 0; i < N; i++)
        {
            if (nums[i] < 0) nums[i] *= -1;
            ans += nums[i];
        }
    }
    else
    {
        long long mnum = 100000000000;
        for(int i = 0; i < N; i++)
        {
            long long num = abs(nums[i]);
            mnum = min(mnum, num);
        }
        
        for(int i = 0; i < N; i++)
        {
            if (abs(nums[i]) == mnum)
            {
                ans -= mnum;
            }
            else
            {
                ans += abs(nums[i]);
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		string S; cin >> S;
		reverse(S.begin(), S.end());
		ULL ans = 0;
		ULL buf = 0;
		for (UL i = 0; i < S.size(); i++) {
			if (S[i] == 'A') ans += buf;
			else if (S[i] == 'C') {
				if (i == S.size() - 1) continue;
				if (S[i + 1] == 'B') { buf++; i++; }
				else buf = 0;
			}
			else if (S[i] == 'B') { buf = 0; }
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

signed main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
}



Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int a[100], b[100];

int main() {

	int i;

	for (i = 0; i < 100 ; i++)
	{
		cin >> a[i] >> b[i];
		if (a[i] == 0 && b[i] == 0) break;
	}

	//iは要素数

	for (int j = 0; j < i; j++)
	{
		if (a[j] == 0 && b[j] == 0) break;

		bool ans = false;

		for (int k = a[j]; k <= b[j]; k++)
		{
			if (k % 4 == 0)
			{
				if (k % 400 == 0)
				{
					ans = true;
					cout << k << endl;
					continue;
				}
				if (k % 100 == 0)
					continue;
				ans = true;
				cout << k << endl;
			}
		}
		if (ans == false) cout << "NA" << endl;
		if (j != i - 1) cout << endl;
	}
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
  cin>>a>>b>>n;
  if(n>=b) n = b-1;
  ll ans = (a*n)/b;
  cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 1000000
int main() {
    int e;
    vector<int> y, z;
    for (int i=0;;i++) {
        if (i*i>INF) break;
        y.push_back(i*i);
    }
    for (int i=0;;i++) {
        if (i*i*i>INF) break;
        z.push_back(i*i*i);
    }
    while (scanf("%d",&e)) {
        if (e==0) break;
        int m=INF+1;
        for (int i=0; i<y.size(); i++) {
            if (y[i]>e) break;
            for (int j=0; j<z.size(); j++) {
                if (z[j]>e) break;
                if (y[i]+z[j]>e) break;
                m = min(m, e-y[i]-z[j]+i+j);
            }
        }
        printf("%d\n",m);
    }
}

Measured memory_bytes: 1064
//#pragma warning(disable:4996)
#include <stdio.h>

int main() {
	int n;
	int w[110];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &w[i]);
	}
	int a = 0, b = 0;
	int ada = 0, adb = n - 1;
	for (int i = 0; i < n; i++) {
		if (a >= b) {
			b += w[adb];
			adb--;
		}
		else {
			a += w[ada];
			ada++;
		}
	}
	if (a > b) {
		printf("%d\n", a - b);
	}
	else {
		printf("%d\n", b - a);
	}

}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

PI tasks[200200];
li n;

inline bool check() {
    li now = 0;
    rin{
        now += tasks[i].S;
        if (now > tasks[i].F) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> n;
    rin{
        // tasks : {deadline, process_time}
        // input : {process_time, deadline}
        cin >> tasks[i].S >> tasks[i].F;
    }
    sort(tasks, tasks + n);

    cout << (check() ? "Yes" : "No") << endl;

    return 0;
}

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

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

int n, k;

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k;
    vi a(n), inc(n);
    inc[0] = 1;

    rep(i, 0, n) {
        cin >> a[i];
        if (i) {
            if (a[i] > a[i - 1]) inc[i] = inc[i - 1] + 1;
            else inc[i] = 1;
        }
    }    

    // if (k == 1) {
        // cout << 1;
        // return 0;
    // }

    set<int> cur;

    rep(i, 0, k)
        cur.insert(a[i]);
    
    int noc = 0, identical = 0;
    if (inc[k - 1] >= k) ++identical;
    
    rep(i, k, n) {
        if (a[i] > *cur.rbegin() && *cur.begin() == a[i - k]) {
            ++noc;
        } else if (inc[i] >= k) {
            ++identical;
        } 

        cur.erase(cur.find(a[i - k]));
        cur.insert(a[i]);
    }
    
    identical = max(identical, 1);
    cout << n - k + 1 - noc - identical + 1;
}


Measured memory_bytes: 14268
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
bool prime[1000010];
void furui() {
    prime[0]=true;
    prime[1]=true;
	int i = 2;
	while (i < 1000010) {
		int j = 2;
		while (j <= sqrt(i) && !prime[i]) {
			if (i%j == 0) {
				prime[i] = true;
				break;
			}
			else j++;
		}
		int z = 2;
		while (!prime[i]) {
			if (i*z <= 1000010) {
				prime[i*z] = true;
				z++;
			}
			else break;
		}
		i++;
	}
}

int main(void){
    int n,p;
    furui();
    while(true){
        cin>>n>>p;
        if(n==-1&&p==-1)break;
        vector<int>P,ans;
        int num=0;
        for(int i=n+1;;i++){
            if(num>=100)break;
            if(!prime[i]){
                P.push_back(i);
                num++;
            }
        }
        for(int i=0;i<P.size();i++){
            for(int j=i;j<P.size();j++){
                ans.push_back(P[i]+P[j]);
            }
        }
        sort(ans.begin(),ans.end());
        cout<<ans[p-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4152
#include<stdio.h>
#define X 1
#define Y 1000000000

int main()
{
  int x,y,num,div=0;

  while(1)
    {
      scanf("%d %d",&x,&y);
      /*if((x >= X && x <= Y) && (y >= X && y <= Y))*/ break;
    }

  if(x<y)
    {
      num = x;
      x = y;
      y = num;
    }
 
  while(1)
    {
      div = x % y;
      if(div == 0) break;
      x = y;
      y = div;
     }

  printf("%d\n",y);
  
  return 0;
}



Measured memory_bytes: 2140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		int[] A = new int[N];
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
		{
			A[i] = GetInt();
			B[i] = GetLong();
		}

		long ans = 0;
		for(int i = 0; i < 30; i++)
		{
			if(!contains(K, i))
				continue;

			int X = K;
			X |= (1 << i) - 1;
			X ^= (1 << i);
			
			long sum = 0;
			for(int j = 0; j < N; j++)
				if((A[j] | X) == X)
					sum += B[j];

			chmax(ref ans, sum);
		}
		{
			long sum = 0;
			for(int j = 0; j < N; j++)
				if((A[j] | K) == K)
					sum += B[j];

			chmax(ref ans, sum);
		}

		Console.WriteLine(ans);
	}

	private bool contains(int s, int x) => ((s >> x) & 1) == 1;
	private void chmax(ref long x, long y) => x = Math.Max(x, y);
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 17292
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	int x=0;
	char s[100001];
	cin >> s;
	for(int i=1;i<strlen(s);i++)
	{
		if(s[i] != s[i-1])
		{
			x++;
		}
	}
	cout << x;
}

Measured memory_bytes: 384
class Board
  def initialize(board)
    @board = board
  end

  def point_symmetry?
    done = Array.new($w, false)
    ($w-1).times do |i|
      next if done[i]
      (i+1..$w-1).each do |j|
        next if done[i] || done[j]
        if symmetry?(i, j)
          done[i], done[j] = true, true
        end
      end
    end
    if $w.odd? && done.count(false) == 1
      i = done.index(false)
      return symmetry?(i, i)
    end
    done.all?
  end

  def symmetry?(i, j)
    $h.times do |k|
      return false if @board[k][i] != @board[$h-k-1][j]
    end
    true
  end
end

def permutation(pairs, remains)
  pairs.permutation do |_pairs|
    a = []
    b = []
    _pairs.each do |pair|
      a << $g[pair[0]]
      b << $g[pair[1]]
    end
    board = Board.new(a + remains + b.reverse)
    if board.point_symmetry?
      puts 'YES'
      exit 0
    end
  end
end

def dfs(p, done, pairs)
  if done.count(true) == $h - ($h.odd? ? 1 : 0)
    remain = done.find_index(false)
    remains = remain ? [$g[remain]] : []
    permutation(pairs, remains)
    return
  end
  s = pairs.empty? ? 0 : pairs[p-1][0] + 1
  (s..($h-1)).each do |i|
    next if done[i]
    (i+1..$h).each do |j|
      next if done[i] || done[j]
      next unless $is_pair[i][j]
      done[i], done[j] = true, true
      pairs << [i, j]
      dfs(p + 1, done, pairs)
      done[i], done[j] = false, false
      pairs.pop
    end
  end
end

def create_is_pair
  same_chars = $g.map.with_index { |s,i| [s.split('').sort.join, i] }.reduce(Hash.new { |k,v| k[v] = [] }) { |z, x| z[x[0]] << x[1]; z }
  ps = same_chars.map { |k,v| v }
  $is_pair = Hash.new { |k,v| k[v] = Hash.new(false) }
  ps.each do |a|
    n = a.size
    n.times do |i|
      n.times do |j|
        $is_pair[a[i]][a[j]] = true if i != j
      end
    end
  end
end

$h, $w = gets.split.map(&:to_i)
$g = []

$h.times do
  $g << gets.chomp
end

create_is_pair
dfs(0, Array.new($h, false), [])
puts 'NO'


Measured memory_bytes: 3836
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    cout<<fixed<<setprecision(20);
    cout<<2*in()*3.14159265358979<<endl;
}


Measured memory_bytes: 3768
def resolve():
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))
    sub = []
    ans = []
    for i in range(N):
        sub.append(T-H[i]*0.006)
    for j in range(N):
        ans.append(abs(A-sub[j]))
    print(ans.index(min(ans))+1)
resolve()

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	v := -a + b
	if k%2 == 0 {
		v = a - b
	}
	if v < -1000000000000000000 || 1000000000000000000 < v {
		fmt.Println("Unfair")
	}
	fmt.Println(v)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,c; cin >> a >> b >> c;
	if(a+b+c>=22){
		cout << "bust" << endl;
	}
	else{
		cout << "win" << endl; 
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll a,b,ans=0;
  cin>>a>>b;
  a--;
  ll t=1;
  for(int i=0;i<42;i++){
    ll as=0,bs=0;
    ll k=a/t;
    as+=k/2*t;
    if(k%2==1){
      as+=a%t+1;
    }
    k=b/t;
    bs+=k/2*t;
    if(k%2==1){
      bs+=b%t+1;
    }
    //cout<<as<<' '<<bs<<endl;
    if((bs-as)%2==1){
      ans+=(1LL<<i);
    }
    t*=2;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    string t;
    cin>>s>>t;
    for(int i=0;i<s.size()+t.size();i++){
        if(i%2==0){
            cout<<s[i/2];
        }
        else{
            cout<<t[i/2];
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256