akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string S, T, Sm;

  std::cin >> S >> T;

  int size1 = S.size(), size2 = T.size();

  for (int i = 0; i < size1; i ++) {
    bool match = true;

    std::string s(S);

    for (int j = 0; j < size2; j ++) {
      int ii = i + j;

      if (ii >= size1) {
        match = false;

        break;
      }
      else if (S[ii] == '?') {
      }
      else if (S[ii] != T[j]) {
        match = false;

        break;
      }

      s[ii] = T[j];
    }

    if (match) {
      for (auto& c : s)
        if (c == '?')
          c = 'a';
      
      if (Sm.empty()) {
        Sm = s;
      }
      else if (s < Sm) {
        Sm = s;
      }
    }
  }

  std::cout << (Sm.empty() ? "UNRESTORABLE" : Sm) << std::endl;

  return 0;
}


Measured memory_bytes: 256
fn check(s: &str) -> bool {
    let len = s.len();
    if len == 0 {
        return true;
    }

    if len >= 6 && &s[0..6] == "eraser" {
        return check(&s[5..]) || check(&s[6..]);
    } else if len >= 5 && &s[0..5] == "erase" {
        return check(&s[5..]);
    } else if len >= 7 && &s[0..7] == "dreamer" {
        return check(&s[5..]) || check(&s[7..]);
    } else if len >= 5 && &s[0..5] == "dream" {
        return check(&s[5..]);
    }
    false
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let s = buf.trim();
    if check(s) {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4476
import sys
import math
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
N=int(input())
a=0
if N==1:
  print(0)
  sys.exit()
c = collections.Counter(prime_factorize(N))
L=c.values()
L=list(map(int,L))
for i in range(len(L)):
  q=int(math.sqrt(L[i]))
  for j in range(q,N+1):
    if j*(j+1)//2>L[i]:
      t=(j-1)
      break
    elif j*(j+1)//2==L[i]:
      t=j
      break
  a+=t
print(a)

Measured memory_bytes: 9492
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#define INF 1000000000
#define INF_L 1000000000000
using namespace std;
typedef long long LL;
typedef pair<LL,int> Pa;

vector<int> paths[100010];
int disz[100010];
bool isdang[100010],iszomb[100010];
LL dis[100010];

int main(){
	int N,K,M,S,P,Q;
	cin>>N>>M>>K>>S>>P>>Q;
	int a,b;
	vector<int> zomb;
	for(int i=1;i<=K;i++){
		cin>>a;
		zomb.push_back(a);
		iszomb[a]=true;
	}
	for(int i=1;i<=M;i++){
		cin>>a>>b;
		paths[a].push_back(b);
		paths[b].push_back(a);
	}

	fill(disz,disz+100010,INF);
	queue<Pa > que;
	for(vector<int>::iterator it=zomb.begin();it!=zomb.end();it++){
		que.push(Pa(0,*it));
	}
	Pa tmp;
	while(!que.empty()){
		tmp=que.front();que.pop();
		if(disz[tmp.second]==INF){
			disz[tmp.second]=tmp.first;
			for(vector<int>::iterator it=paths[tmp.second].begin();it!=paths[tmp.second].end();it++){
				que.push(Pa(tmp.first+1,(*it)));
			}
		}
	}

	for(int i=1;i<=N;i++){
		if(disz[i]<=S) isdang[i]=true;
	}

	fill(dis,dis+100010,INF_L);
	priority_queue<Pa ,vector<Pa >,greater<Pa > > pque;
	pque.push(Pa(0,1));
	while(!pque.empty()){
		tmp=pque.top();pque.pop();
		if(dis[tmp.second]!=INF_L||iszomb[tmp.second]) continue;
		dis[tmp.second]=tmp.first;
		for(vector<int>::iterator it=paths[tmp.second].begin();it!=paths[tmp.second].end();it++){
			if(dis[*it]==INF_L){
				if(tmp.second==1){
					pque.push(Pa(0,(*it)));
				}
				else if(isdang[tmp.second]){
					pque.push(Pa(tmp.first+Q,(*it)));
				}
				else{
					pque.push(Pa(tmp.first+P,(*it)));
				}
			}
		}
	}
	cout<<dis[N]<<endl;
	return 0;
}

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

using namespace std;

#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define endl '\n'
#define int long long

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

	int a, b, cnt = 1;
	cin >> a >> b;
	int g = __gcd(a, b);
	int temp = g;
	for (int i = 2; i * i <= temp; ++i)
	{
		if (g % i == 0) ++cnt;
		while (g % i == 0) g /= i;
	}

	if (g > 1) ++cnt;
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


int main(){
    int rate;
    cin >> rate;
    if (rate < 1200) {
        cout << "ABC" << endl;
    }else if (rate < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    
    return 0;
}


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}



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

using namespace std;


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 1; i < N; ++i){
        cin >> A[i];
    }

    vector<int> table(N);
    for(int i = 1; i < N; ++i){
        table[A[i]-1]++;
    }
    for(int i = 0; i < N; ++i){
        cout << table[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4792
import java.util.*;
import java.io.*;

public class Main extends Template{
	public void solve() throws IOException{
		int n = nextInt();
		int k = nextInt();
		int[] rabbit = new int[n+1];
		for(int i = 0; i < k; i++){
			int num = nextInt();
			for(int j = 0; j < num; j++){
				rabbit[nextInt()]= i;
			}
		}
		int count = 0;
		int r = nextInt();
		boolean[] check = new boolean[n+1];
		for(int i = 0; i < r; i++){
			int x = nextInt();
			int y = nextInt();
			if( rabbit[x] == rabbit[y] ){
				check[x] = true;
				check[y] = true;
			}
		}
		for(int i = 1; i <= n; i++){
			if( check[i] ){
				count++;
			}
		}
		System.out.println(count);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
}

abstract class Template implements Runnable{
	public abstract void solve() throws IOException;
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run(){
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	
	public double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	public long nextLong() throws IOException{
		return Long.parseLong(nextToken());
	}
	
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}
		

Measured memory_bytes: 9800
#include<bits/stdc++.h>
int main()
{

  char s[200];
  scanf ("%s",s);


  int len=0;
  for (int i=0; s[i] !=0 ; i++)
  len++;

  int cnt =0;
  for (int i=0, j=len-1; i<=j; i++, j--)
  {
     if(s[i]!=s[j])


    {
    cnt++;
    }
}
 printf ("%d",cnt);
 return 0;
  }


Measured memory_bytes: 256
import sys
#import numpy as np
from collections import Counter

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A = list(rs())
answer = 1
c = Counter(A)
for i in range(len(A)):
    answer += len(A) - i - c[A[i]]
    c[A[i]] -= 1

print(answer)
# 53

Measured memory_bytes: 5212
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

const int MAX_N=200000;
int n,m,a,b;
int list[MAX_N]={};

int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		if(a==1){
			if(list[b]==2){
				cout << "POSSIBLE" << endl;
				return 0;
			}else{
				list[b]=1;
			}
		}if(b==n){
			if(list[a]==1){
				cout << "POSSIBLE" << endl;
				return 0;
			}else{
				list[a]=2;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int n,num;
  cin >> n;
  vi d(n);
  rep(i,0,n){
    cin >> d[i];
  }

  sort(all(d));
  num= d[n/2]- d[n/2-1];
  cout << num << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        scanner.nextLine();
        List<Integer> array = new ArrayList<>();
        for(int i=0; i<givenNumber; i++) {
            array.add(scanner.nextInt());
        }
        long size = array.stream().distinct().count();
        System.out.println(size);
    }
}


Measured memory_bytes: 27220
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

int hoge[MAXN];

signed main(){
    int A, B;
    cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
      cout << "Possible";
    }else{
      cout << "Impossible";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  static int N, M, X;
  static int ans;
  static int[] prices;
  static int[][] books;

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

    N = in.nextInt();
    M = in.nextInt();
    X = in.nextInt();
    ans = -1;

    prices = new int[N];
    books = new int[N][M];

    for (int i = 0; i < N; i++) {
      prices[i] = in.nextInt();
      for (int j = 0; j < M; j++) {
        books[i][j] = in.nextInt();
      }
    }

    boolean[] use = new boolean[N];
    sol(use, 0);
    System.out.println(ans);
  }

  public static void sol(boolean[] use, int index) {
    if (index == N) {
      // Compute the understanding score.
      int[] understandings = new int[M];
      int p = 0;

      for (int i = 0; i < N; i++) {
        if (use[i]) {
          p += prices[i];
          for (int j = 0; j < M; j++) {
            understandings[j] += books[i][j];
          }
        }
      }

      for (int i = 0; i < M; i++) {
        if (understandings[i] < X) {
          return;
        }
      }

      if (ans == -1) {
        ans = p;
      } else {
        ans = Math.min(ans, p);
      }
    } else {
      sol(use, index + 1);
      use[index] = true;
      sol(use, index + 1);
      use[index] = false;
    }
  }
}


Measured memory_bytes: 38584
# -*- coding: utf-8 -*-
import math


n = int(input())

p = n / 1.08

if p.is_integer():
    print(int(p))
elif math.floor(math.ceil(p)*1.08) == n:
    print(math.ceil(p))
elif math.floor(math.floor(p)*1.08) == n:
    print(math.floor(p))
else:
    print(':(')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int num=0;
    for(int i=1;i<n;i++){
        string tmp1,tmp2;
        int j;
        for(j=0;j<i;j++){
            tmp1.push_back(s[j]);
            sort(tmp1.begin(),tmp1.end());
            tmp1.erase(unique(tmp1.begin(), tmp1.end()),tmp1.end());
        }
        for(;j<n;j++){
            tmp2.push_back(s[j]);
            sort(tmp2.begin(),tmp2.end()); 
            tmp2.erase(unique(tmp2.begin(), tmp2.end()),tmp2.end());
            
        }
        int m=min(tmp1.size(),tmp2.size());
        int cnt=0;
        for(int ii=0;ii<tmp1.size();ii++){
            for(int jj=0;jj<tmp2.size();jj++){
                if(tmp1[ii]==tmp2[jj]){
                    cnt++;
                    break;
                }
            }

        }
        num=max(num,cnt);



    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double 
#define foi(a,n) for(int i = a; i < n; i++)
#define ee 1000000007
#define pb push_back
 
using namespace std;

void solve() {
    ll a, b, c , d;
    cin >> a >> b >> c >> d;
    if(a <= 0 && b>=0 && d <= 0) {
		cout << a*c;
		return;
	}
	if(c<=0 && d >= 0 && b <= 0){
		cout << a*c;
		return;
	}
	
    cout << max(a*c, max(b*c, max(a*d, b*d)));
}

int main() {
    int t = 1;
    //~ cin >> t;
    while(t--){
		solve();
		cout << '\n';
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	
	int x, y;
	cin>>x>>y;
	
	rep(i,0, x)
	{
		if(i * 2 + (x - i)*4 == y){
			cout<<"Yes";
			return 0;
		}

	}
	cout<<"No";
		



}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s;
  cin >> s;

  if (s[0] == 'S') cout << "Cloudy" << endl;
  if (s[0] == 'C') cout << "Rainy" << endl;
  if (s[0] == 'R') cout << "Sunny" << endl;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int x,y,t;
	while(1)
	{
		cin>>x>>y;
		if(x==0&&y==0) break;
		if(x>y)
		{
			t=x;
			x=y;
			y=t;
		}
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 3052
//与えられた英文に含まれる、各アルファベットの数を数えるプログラムを作成して下さい。 なお、小文字と大文字は区別しません。
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    int [] count = new int[128];
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()){
      String str = sc.nextLine().toLowerCase();
      for(int i=0;i<str.length();i++){
        count[str.charAt(i)]++;
      }
    }
    for(char c='a';c<='z';c++){
      System.out.printf("%c : %d\n",c,count[c]);
    }

  }
}



Measured memory_bytes: 26388
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if ( x-r >=0 && x+r<=W && y-r>=0 && y+r<=H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    string s;
    cin >> n >> s;
    int w = 0;
    rep(i, n) if (s[i] == '.') w++;
    int ans = w, b = 0;
    rep(i, n)
    {
        if (s[i] == '#')
            b++;
        else
            w--;
        ans = min(ans, b + w);
    }
    cout << ans << endl;
}


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

ll N;
ll a=0, b=0, c=0, d=0;

void input () {
    int temp;
    for(ll i=0;i<6;i++){
        cin >> temp;
        if(temp==1){
            a++;
        }else if(temp==2){
            b++;
        }else if(temp==3){
            c++;
        }else if(temp==4){
            d++;
        }
    }
}

void solve() {
    
}

int main(void){
    // Your code here!
    input();
    solve();
    cout << ((a*b*c*d==4)?"YES":"NO") << endl;
}


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

using ll = long long;

#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_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int m, f, r;

int main(){
	cin.tie(0);
	
	while(cin>>m>>f>>r,m!=-1||f!=-1||r!=-1) {
	    if(m<0||f<0) {
	        cout<<'F'<<endl;
	        continue;
	    }
	    if(m+f>=80) {
	        cout<<'A'<<endl;
	        continue;
	    }
	    if(m+f>=65) {
	        cout<<'B'<<endl;
	        continue;
	    }
	    if(m+f>=50) {
	        cout<<'C'<<endl;
	        continue;
	    }
	    if(m+f>=30) {
	        if(r>=50)cout<<'C'<<endl;
	        else cout<<'D'<<endl;
	        continue;
	    }
	    cout<<'F'<<endl;
	}

	return 0;
}



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

s = list(input())
line = []
for w in s:
    if w == '0':
        line.append(w)
    elif w == '1':
        line.append(w)
    elif w == 'B' and line:
        line.pop()

for n in line:
    print('{0}'.format(n), end='')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
int main(void) {
	int N;
	std::cin >> N;
	std::vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> A[i];
	}
	int NumberChange = 0;
	for (int i=0; i < N; ++i) {
		int Minj = i;
		for (int j = i+1; j< N; ++j) {
			if (A[j] < A[Minj]) { Minj = j;
				}
			
		}if (Minj != i) {
			std::swap(A[i], A[Minj]);
			++NumberChange;
		}
	}
		for (int i = 0; i < N ; ++i) {
		if(i==N-1){ std::cout << A[i] << std::endl; }
		else { std::cout << A[i] << " "; }
	}
	std::cout  << NumberChange << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll N,M;cin>>N>>M;
    vector<vector<ll>>poly(N,vector<ll>(2));
    for(ll i=0;i<N;i++)cin>>poly[i][0]>>poly[i][1];
    sort(poly.begin(),poly.end());
    ll count=0;//本数
    ll sum=0;//値段
    for(ll i=0;i<N;i++){
        ll s=poly[i][0];ll c=poly[i][1];
        if(M>count+c){sum+=s*c;count+=c;}
        else {sum+=s*(M-count);break;}
    }
    cout<<sum<<endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    
    if (x < K - x){
      sum += 2*x;
    }
    else {
      sum += 2*(K - x);
    }
  }
  cout << sum << endl;
}



Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        string S = ReadLine();
        if(S == "ABC")
        {
            WriteLine("ARC");
        }
        else
        {
            WriteLine("ABC");
        }
        //ReadLine();
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
    
    public static int[] intArrayReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static long[] longArrayReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static List<int> intListReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToList();
    }

    public static List<long> longListReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToList();
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 25788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int n;
    cin >> n;
    map<string, int> paper;
    rep(i,n){
        string s;
        cin >> s;
        paper[s]++;
    }
    //cout << "----------------" << endl;
    int ax = 0;
    for(auto p : paper) ax = max(ax, p.second);
    for(auto p : paper){
        if(p.second == ax) cout << p.first << endl;
    }
}
/*



*/

Measured memory_bytes: 19224
fun main(args: Array<String>) {
    val (N, A, B, C, D) = readLine()!!.split(" ").map{it.toLong()}

    val L = Math.abs(B - A)

    if (L > N * D) {
        println("NO")
        return
    }

    val M = C + D

    var l = C + D - (C * 2 - 1)
    for (i in 1 .. N - 2) {
        l = Math.min(M, l + D - C)
    }

    val t = (L + D * (N - 1)) % M

    if (t < l) {
        println("YES")
    } else {
        println("NO")
    }
}


Measured memory_bytes: 37924
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

int dp(int n) {
    if (memo[n] != -1) {
        return memo[n];
    }
    if (n == 0) {
        return 0;
    }
    if (n == 1) {
        return abs(h[1] - h[0]);
    }
    memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
    return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
}

int main() {
    long long n;
    cin >> n;
    h.resize(n);
    memo.resize(n, -1);
    REP(i, n) { cin >> h[i]; }
    cout << dp(n - 1) << endl;
}

Measured memory_bytes: 4224
N = int(input())
a = list(map(int, input().split()))

a_min, a_max = float('inf'), -float('inf')
a_min_idx, a_max_idx = -1, -1

if min(a) == max(a):
    print(0)
    exit()

ascend = True
for i in range(N - 1):
    if a[i] < a_min:
        a_min = a[i]
        a_min_idx = i + 1
    elif a_max < a[i]:
        a_max = a[i]
        a_max_idx = i + 1
    if a[i+1] < a[i]:
        ascend = False
if ascend:
    print(0)
    exit()

count = 0
message = ''
if a_min < 0 and 0 < a_max:
    if abs(a_min) < abs(a_max):
        for i in range(N):
            if a[i] < a_max:
                a[i] += a_max
                count += 1
                message += '{} {}\n'.format(a_max_idx, i + 1)
    else:
        for i in range(N):
            if a_min < a[i]:
                a[i] += a_min
                count += 1
                message += '{} {}\n'.format(a_min_idx, i + 1)

if min(a) >= 0:
    for i in range(1, N+1):
        count += 1
        message += '{} {}\n'.format(i, min(i+1, N))
else:
    for i in range(N, 1, -1):
        count += 1
        message += '{} {}\n'.format(i, max(i-1, 1))
print(count)
print(message, end='')


Measured memory_bytes: 3064
_sum = _num =  0
cnt = 0
try:
    while True:
        tmp = map(int, raw_input().split(","))
        _sum = _sum + (tmp[0] * tmp[1])
        _num += tmp[1]
        cnt+=1 
except:
    print _sum
    print int(round(_num*1.0/cnt, 0))


Measured memory_bytes: 4672
readline()
A,B=map(x->parse(Int,x),split(readline()))
a=b=c=0
for x=map(x->parse(Int,x),split(readline()))
  if x<=A
    a+=1
  elseif x<=B
    b+=1
  else
    c+=1
  end
end
println(min(a,b,c))

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

int main(){
  string S;
  cin>>S;
  if(S=="SUN"){
    cout<<7<<endl;
  }
  else if(S=="MON"){
    cout<<6<<endl;
  }
  else if(S=="TUE"){
    cout<<5<<endl;
  }
  else if(S=="WED"){
    cout<<4<<endl;
  }
  else if(S=="THU"){
    cout<<3<<endl;
  }
  else if(S=="FRI"){
    cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }
}

Measured memory_bytes: 3548
#include <iostream>
#include <cstdint>
#include <cmath>

const int MOD = 1000000007;

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
    cout << "A" << endl;
  } else {
    cout << "B" << endl;
  }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;
const int  M = 1e4 ;

void solve(){
    ll n , d , a;
    cin>>n>>d>>a;
    vector<pair < ll , ll > > v(n);
    for(int i = 0 ; i < n ; i++){
        cin>>v[i].F>>v[i].S;
    }
    sort(v.begin(), v.end());
    queue< pair< ll , ll > > q;
    ll sum = 0;
    ll res = 0;
    for(int i = 0 ; i < n; i++){
        while(q.size() > 0 && q.front().F < v[i].F){
            sum -= q.front().S;
            q.pop();
        }
        v[i].S -= a * sum;
        if(v[i].S <= 0) continue;

        ll tmp = (v[i].S + a - 1) / a;
        res += tmp;
        q.push({v[i].F + 2 * d, tmp});
        sum += tmp;
    }
    cout<<res<<endl;
}	
 
int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 7860
#include <stdio.h>

int count=0;
int check(int A[ ],int n,int key){
  int i=0;
  A[n]=key;
  while(i < n){
    if(A[i] == key){
      count++;
      break;
    }
    i++;
  }
}

int main(){
  int i,j,n,s[10000],q,key;

  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0;i < q;i++){
    scanf("%d",&key);
    check(s,n,key);
  }

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

  return 0;
}





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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int A, B; cin >> A >> B;
	cout << ((max(A, B) <= 8) ? "Yay!" : ":(") << '\n';


	return 0;
}

Measured memory_bytes: 256
from collections import deque
N, M = [int(x) for x in input().split()]
fst_to = deque([])
sec_from = deque([])
for a, b in [[int(x) for x in input().split()] for _ in range(M)]:
  if a == 1:
    fst_to.append(b)
  elif b == N:
    sec_from.append(a)
ret = 'IMPOSSIBLE'
if set(fst_to) & set(sec_from):
  ret = 'POSSIBLE'
print(ret)

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int h, w;
string s[50];

bool isRange(int y, int x) {
    if (y < 0 || h <= y || x < 0 || w <= x || s[y][x] == '#') {
        return false;
    }

    return true;
}

int main(void) {
    const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
    int cnt[50][50] = {{0}};

    cin >> h >> w;
    REP(i, h) {
        cin >> s[i];
    }

    REP(i, h) {
        REP(j, w) {
            if (s[i][j] == '#') {
                cnt[i][j] = -1;
                REP(k, 8) {
                    if (isRange(i + dy[k], j + dx[k])) {
                        cnt[i + dy[k]][j + dx[k]]++;
                    }
                }
            }
        }
    }

    REP(i, h) {
        REP(j, w) {
            if (s[i][j] == '#') {
                cout << s[i][j];
            } else {
                cout << cnt[i][j];
            }
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX_LEN 100001

typedef struct pp{
  char name[11];
  int t;
}P;

P Q[MAX_LEN];
int head = 1, tail = 0, n;

void enqueue(P x){
	Q[tail] = x;
	if(tail == n){
		tail = 0;
	}else{
	tail++;
	}
}

P dequeue(){
	P x;
	x = Q[head];
	if(head == n){
		head = 0;
	}else{
		head++;
	}
	return x;
}

int main(void){
  int i, q,elaps = 0;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
	
	while(head != tail){
		u = dequeue();
		if(u.t > q){
			u.t = u.t - q;
			elaps =  elaps + q;
			enqueue(u);
		}else{
			elaps = elaps + u.t;
			printf("%s %d\n",u.name, elaps);
		}
	}
  return 0;
}


Measured memory_bytes: 2488
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#ifndef SOLUTION_COMMON_H

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using PI = pair<int, int>;
template<class T> using V = vector<T>;
using VI = V<int>;
#define _1 first
#define _2 second

#ifdef MY_DEBUG
# define DEBUG(x) x
#else
# define DEBUG(x)
#endif

template<class A, class B>
std::ostream & operator <<(ostream &os, const pair<A, B> &p) {
  os << "(" << p._1 << "," << p._2 << ")";
  return os;
}

template<class T>
inline void debug(T &A) {
  DEBUG(
      for (const auto &a : A) {
        cerr << a << " ";
      }
      cerr << '\n';
  )
}

template<class T, class Func>
inline void debug_with_format(T &A, Func f) {
  DEBUG(
      for (const auto &a : A) {
        cerr << f(a) << " ";
      }
      cerr << '\n';
  )
}

template<class T>
inline void debug_dim2(T &A) {
  DEBUG(
      for (const auto &as : A) {
        debug(as);
      }
  )
}

template<typename ... Args>
inline void debug(const char *format, Args const &... args) {
  DEBUG(
      fprintf(stderr, format, args ...);
      cerr << '\n';
  )
}

template<typename ... Args>
string format(const string &fmt, Args ... args) {
  size_t len = snprintf(nullptr, 0, fmt.c_str(), args ...);
  vector<char> buf(len + 1);
  snprintf(&buf[0], len + 1, fmt.c_str(), args ...);
  return string(&buf[0], &buf[0] + len);
}

template<class T1, class T2>
string fmtP(pair<T1, T2> a) {
  stringstream ss;
  ss << "(" << a._1 << "," << a._2 << ")";
  return ss.str();
}

#define SOLUTION_COMMON_H

#endif //SOLUTION_COMMON_H

const int MOD = 1000000007;

class EAlmostEverywhereZero {
public:
  void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S;
    int K;
    in >> S >> K;

    V<V<VI>> memo(S.length(), V<VI>(2, VI(K + 1, -1)));
    function<int(int, int, int)> dfs = [&](int i, int less, int k) {
      if (k > K) return 0;
      if (i == S.size()) {
        return k == K ? 1 : 0;
      }

      if (memo[i][less][k] != -1) {
        return memo[i][less][k];
      }

      int res = 0;
      int len = less ? 10 : S[i] - '0' + 1;
      for (int j = 0; j < len; ++j) {
        int nless = less | (j < S[i]-'0');
        int nk = j != 0 ? k + 1 : k;
        res += dfs(i + 1, nless, nk);
      }
      memo[i][less][k] = res;
      return res;
    };

    out << dfs(0, 0, 0);
  }
};


int main() {
	EAlmostEverywhereZero solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	//freopen("in","r",stdin);
	while(1) {
		int median, final, make_up;
		cin>>median>>final>>make_up;
		if(median==-1&&final==-1&&make_up==-1) break;
		
		if(median==-1||final==-1) cout<<"F";
		else if(median+final>=80) cout<<"A";
		else if(median+final>=65) cout<<"B";
		else if(median+final>=50) cout<<"C";
		else if(median+final>=30) {
			if(make_up>=50) cout<<"C";
			else cout<<"D";
		}
		else if(median+final<30) cout<<"F";
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using Series = vector<int>;

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

  Series s0 = {0};
  vector<Series> prev;

  prev.push_back(s0);

  REP(n, 1, N) {
    vector<Series> curr;

    for (Series & s : prev) {
      int max_d = *max_element(s.begin(), s.end());

      REP(d, 0, max_d + 2) {
        Series t(s.size());

        copy(s.begin(), s.end(), t.begin());
        t.push_back(d);
        curr.push_back(t);
      }
    }

    prev = curr;
  }

  for (Series & s : prev) {
    for (int d : s) {
      printf("%c", 'a' + d);
    }
    printf("\n");
  }
}


Measured memory_bytes: 18340
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (a, b): (i32, i32) = read();
    if a <= 8 && b <= 8 {
        println!("Yay!");
    } else {
        println!(":(");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,x;
cin >> N >> x;
vector<int> vec(N);
for (int i = 0;i < N;i++){
cin >> vec.at(i);
}

sort(vec.begin(),vec.end());
int count = 0;
int a = 0;

 
 for (int i = 0;i < N;i++) {
  a += vec.at(i);
  if (a > x) {
    break;
  }
  count++;
}
if (a < x) cout << count-1 << endl;
else cout << count  << endl;
return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int g1[303][303];
int g2[303][303];
int res[100000];
signed main() {
	int n, m, l; cin >> n >> m >> l;
	rep(i, n)rep(j, n)g1[i][j] = inf;
	rep(i, n)g1[i][i] = 0;
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c;
		if (c > l)continue;
		a--; b--;
		g1[a][b] = c; g1[b][a] = c;
	}
	rep(k, n)rep(i, n)rep(j, n)g1[i][j] = min(g1[i][j], g1[i][k] + g1[k][j]);
	
	rep(i, n)rep(j, n)g2[i][j] = inf;
	rep(i, n) {
		rep(j, n) {
			if (g1[i][j] <= l)g2[i][j] = 1;
		}
	}
	rep(k, n)rep(i, n)rep(j, n)g2[i][j] = min(g2[i][j], g2[i][k] + g2[k][j]);
	int q; cin >> q;
	rep(i, q) {
		int s, t; cin >> s >> t;
		s--; t--;
		res[i] = g2[s][t];
		if (res[i] == inf)res[i] = 0;
	}
	rep(i, q)cout << res[i]-1 << endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		cout << (b / c) - ((a - 1) / c) << endl;
	}
	return 0;
}


Measured memory_bytes: 3664
N,Q = map(int,input().split())
BIT = [0]*(N+1)

def BIT_query(idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

def BIT_update(idx,x):
    while idx <= N:
        BIT[idx] += x
        idx += idx&(-idx)
    return

a = list(map(int,input().split()))
for i in range(N):
    BIT_update(i+1,a[i])

for i in range(Q):
    a,b,c = map(int,input().split())
    if a == 0:
        BIT_update(b+1,c)
    else:
        print(BIT_query(c)-BIT_query(b))


Measured memory_bytes: 69036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1<<30;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[8]={1,0,-1,0,1,1,-1,-1} , dy[8]={0,1,0,-1,1,-1,1,-1} ;


int main(){
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    vector<int> a(n);
    rep(i,m){
        scanf("%d%d",&x,&y);
        a[y-1]=max(x,a[y-1]);
    }
    int cnt=0;
    int pos=0;
    rep(i,n){
        if(a[i]>pos){
            cnt++;
            pos=i;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
unsigned long long a[114514], b[114514];
int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	unsigned long long ans = 0;
	for (int i = n; i > 0; i--) {
		a[i] += ans;
		if (a[i] % b[i] != 0) {
			ans += b[i] - (a[i] % b[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // メインプログラムここから
    ll a, b, c;
    string s;
    
    cin >> a >> b >> c;
    
    ll x = max(a,b);
    ll y = max(x,c);
    ll z = min(a,b);
    ll w = min(x,c);
    
    if(y==z+w){
        s = "Yes";
    }else{
        s = "No";
    }
    
    cout << s << endl;
    // ここまで
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #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 pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            ll ar[n+1];
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
            }
            ll ct,ct2,x,ans=0;
            for(j=0;j<60;++j)
            {
                ct=ct2=0;
                x=(1ll<<j);
                for(i=1;i<=n;++i)
                {
                    if((ar[i]&x)==0)
                        ++ct;
                    else
                        ++ct2;
                }
                x=x%mod;
                ans=(ans+(x*ct)%mod*ct2)%mod;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 2560
io = STDIN
n=io.gets.to_i
f=Array.new(10001,0)
(100..9999).each do |i|
  break if (sum=6*i**2)>10000
  f[sum]+=1
end

(1..99).each do |x|
  ((x)..99).each do |y|
    ((y)..99).each do |z|
     sum= x**2+y**2+z**2+x*y+y*z+z*x
     break if sum>10000
     if x==y&&y==z
      f[sum]+=1
    elsif  x!=y&&y!=z
      f[sum]+=6
    else
      f[sum]+=3
     end
    end
  end
end
(1..n).each {|i|puts f[i]}


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define ll long long
#define REP(i,a,n) for(ll i=a;i<(n);i++)
#define REP_sz(i,s) for(ll i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(ll i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
ll _min(int a,ll b){
	return a<b?a:b;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	V<ll>a,b,c,ab,abc;
	ll x,y,z,K;
	cin>>x>>y>>z>>K;
	REP(i,0,x){
		ll x;
		cin>>x;
		a.pb(x);
	}
	REP(i,0,y){
		ll x;
		cin>>x;
		b.pb(x);
	}
	REP(i,0,z){
		ll x;
		cin>>x;
		c.pb(x);
	}
	SO(a);SO(b);SO(c);
	REP(i,0,x)
	REP(j,0,y)
	ab.pb(a[i]+b[j]);
	sort(all(ab),greater<ll>());
	//cout<<ab[0]<<endl;
	for(ll i=0;i<_min(ab.size(),K);i++)
	REP(j,0,z)
	abc.pb(ab[i]+c[j]);
	sort(all(abc),greater<ll>());
	for(int i=0;i<K;i++)cout<<abc[i]<<endl;
    return 0;
}


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

using namespace std;

vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

vector<int> num;

int calculate(){
	int sum=0;
	for(int i=0; i<a.size(); i++){
		if(num[b[i]]-num[a[i]]==c[i])
			sum+=d[i];
	}
	return sum;
}
int ans=0;

void dfs(int n, int m, int curr){
	if(num.size()==n){
		ans=max(ans,calculate());
		return;	
	}
	for(int i=curr; i<=m; i++){
		num.push_back(i);
		dfs(n,m,i);
		num.pop_back();
	}
}

int main(){
	int n, m, q;
	cin>>n>>m>>q;
	int ta,tb,tc,td;

	for(int i=0; i<q; i++){
		cin>>ta>>tb>>tc>>td;
		a.push_back(ta-1);
		b.push_back(tb-1);
		c.push_back(tc);
		d.push_back(td);	
	}
	dfs(n,m,1);
	cout<<ans<<"\n";

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
long long i[3000000];
lol u[111111];
lol ii[121111];
bool o;
bool ans[5];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0,j=0;
  string s;
  cin >>a>>b;
  for(int n=0;n<a;n++){
    cin >>c>>i[n];
    if(d<c) d=c;
  }
  sort(i,i+a,greater<lol>());
  for(int n=0;n<a;n++){
    if(d<i[n]) f++,b-=i[n];
    if(b<=0) break;
  }
  if(b<=0) cout <<f<<'\n';
  else{
    g=b/d;
    if(b%d!=0) g++;
    cout <<g+f<<'\n';
  }
  return (0);
}


Measured memory_bytes: 2560
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m = ns()
    d = []
    for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
    dp = [INF for _ in range(2 ** n)]
    dp[0] = 0

    for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

    tmp = dp[2 ** n - 1]
    print(tmp if tmp != INF else -1)


if __name__ == '__main__':
    main()


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

//Coding below.
int main (){
   int M[2],D[2];
   cin >> M[0] >> D[0] >> M[1] >> D[1];
   if(M[0] != M[1]){
       cout << '1' << endl;
   }else{
       cout << '0' << endl;
   }
}

Measured memory_bytes: 256