akhauriyash/Code-Regression huggingface dataset:
//
//  main.c
//  AIZU_ONLINE
//
//  Created by 郷田将 on 2018/02/07.
//  Copyright © 2018年 郷田将. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...

    int a;
    int b;
    char* blank;
    
    scanf("%d",&a);
    scanf("%c",blank);
    scanf("%d",&b);
    
    if(a>b) printf("a > b\n");
    else if(a<b) printf("a < b\n");
    else printf("a == b\n");
    
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793

int main(int argc, char const *argv[])
{
    long a, b, h, m;
    cin >> a >> b >> h >> m;

    long d1 = h * 30 * 60 + 30 * m;
    long d2 = m * 6 * 60;
    long sa = abs(d1 - d2);

    double radian = sa * PI;
    radian /= 10800.0;

    double c = a * a + b * b - 2 * a * b * cos(radian);
    cout << std::fixed << std::setprecision(20) << sqrt(c) << endl;

    return 0;
}


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

using namespace std;

const int N=505,M=250005;
int n,m,l,r,x[N],a[M],id[N],num[N];
inline bool comp(const int&a,const int&b){return x[a]<x[b];}
inline void Assert(bool f){if(!f)puts("No"),exit(0);}

int main(){
	scanf("%d",&n),m=n*n;
	for(int i=1;i<=n;i++)scanf("%d",&x[i]),a[x[i]]=i,id[i]=i;
	for(l=1;a[l];l++);for(r=m;a[r];r--);sort(id+1,id+n+1,comp);
	for(int i=1;i<=n;i++){
		int k=id[i];
		for(int j=1;j<k;j++){
			Assert(l<x[k]);
			for(a[l]=k;a[l];l++);
		}
	}
	for(int i=n;i>=1;i--){
		int k=id[i];
		for(int j=k+1;j<=n;j++){
			Assert(r>x[k]);
			for(a[r]=k;a[r];r--);
		}
	}
	puts("Yes");
	for(int i=1;i<=m;i++)printf("%d%c",a[i]," \n"[i==m]);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932384626433832795028841971
using namespace std;

int main(){
    int w,h;
    
    while(true){
        cin >> h >> w;
        if(w == 0 && h == 0){
            break;
        }
        
        for(int hh = 0;hh<h;hh++){
            for(int ww = 0;ww<w;ww++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {

    public void main(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();

        if (h % 3 == 0 || w % 3 == 0) {
            System.out.println(0);
            return;
        }

        if (h == 2 && w == 2) {
            System.out.println(1);
            return;
        }

        // ooooo
        // .....
        // xxxxx
        // xxxxx
        int ans = Math.min(h, w);

        // oo...
        // oo...
        // ooxxx
        // ooxxx
        int ww = (w + 1) / 3;
        int hh = h / 2;
        ans = Math.min(ans, sa(h * ww, hh * (w - ww), (h - hh) * (w - ww)));

        // ooooo
        // ..xxx
        // ..xxx
        // ..xxx
        ww = w / 2;
        hh = (h + 1) / 3;
        ans = Math.min(ans, sa(hh * w, (h - hh) * ww, (h - hh) * (w - ww)));

        System.out.println(ans);
    }

    private int sa(int... nums) {
        Arrays.sort(nums);
        return nums[nums.length - 1] - nums[0];
    }

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


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int W, H;
int m1[2010][2010];
int m2[2010][2010];
int m3[2010][2010];
int m4[2010][2010];
int m = 1 << 30, M;

bool OK(int joi[2010][2010], int x){
	int end = W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < end; j++){
			if(x < M - joi[i][j]){
				end = j;
			}
		}
		for(int j = end; j < W; j++){
			if(x < joi[i][j] - m){
				return false;
			}
		}
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> m1[i][j];
			m = min(m, m1[i][j]);
			M = max(M, m1[i][j]);
			m2[H - i - 1][j] = m1[i][j];
			m3[i][W - j - 1] = m1[i][j];
			m4[H - i - 1][W - j - 1] = m1[i][j];
		}
	}
	int lb = 0;
	int ub = 1 << 30;
	while(ub - lb > 1){
		int mid = (ub + lb) / 2;
		bool flag = OK(m1, mid);
		flag = (flag | OK(m2, mid));
		flag = (flag | OK(m3, mid));
		flag = (flag | OK(m4, mid));
		if(flag)  ub = mid;
		else lb = mid;
	}
	cout << ub <<endl;
	return 0;
}


Measured memory_bytes: 65912
#pragma GCC optimize("Ofast")

#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#include <map>            //map(辞書)
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列
#include <list>           //双方向連結リスト

using namespace std;


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

	int n;
    cin >> n;
    string tmp;
    list<int> l;
    cin.ignore();
    for(int i = 0; i < n; ++i){
        getline(cin, tmp);
        istringstream iss(tmp);
        vector<string> operation;
        while(getline(iss, tmp, ' ')){
            operation.emplace_back(tmp);
        }
        if(operation[0] == "insert"){
            l.emplace_front(stoi(operation[1]));
        }else if(operation[0] == "delete"){
            auto itr = std::find(l.begin(), l.end(), stoi(operation[1]));
            if(itr != l.end()){
                l.erase(itr);
            }
        }else if(operation[0] == "deleteFirst"){
            l.pop_front();
        }else if(operation[0] == "deleteLast"){
            l.pop_back();
        }
    }
    for(auto begin = l.begin(), itr = begin, end = l.end(); itr != end; ++itr){
        if(itr != begin){
            cout << " ";
        }
        cout << *itr;
    }
    cout << "\n";

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

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

    map<string, ll> ma;

    rep(i, n){
        string s; cin >> s;
        sort(s.begin(), s.end());
        ma[s]++;
    }

    ll ans = 0;
    for(auto  m : ma){
        if(m.second == 1) continue;
        ll cnt = m.second;
        ans += cnt * (cnt - 1) / 2;
    }
    OP(ans);
}


Measured memory_bytes: 11136
#include <iostream>
#include<bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<fstream>
#include<typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j, a, b) for (ll j = a; j < b;j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >
#define mod 1000000007
#define lim 100001
 
using namespace std;
ll factorial(ll n){return (n==1 || n==0) ? 1: n * factorial(n - 1); }
int max3(int a,int b,int c){ return max(a, max(c, b));}
int gcd(int a,int b){if(a==0){return b;}else{return gcd(b % a, a);}}
ll power(ll a, ll n){if(n==1) return a; else if(n==0) return 1; else{ ll r = power(a, n / 2); if(n%2==0) return r * r; else return r * a * r;}}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector< vector<int > >& v,vi& check,int start){check[start - 1] = 1;repj(j, 0, v[start-1].size()){if(!check[v[start-1][j]-1]){dfs(v, check, v[start - 1][j]);}}}
bool isPrime(ll n) { if (n <= 1) return false;if (n <= 3)return true; if (n % 2 == 0 || n % 3 == 0)return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
//works under 2 till 1e12
 
//int i, j;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll num;
   cin>>num;
   int n;
   ll prev=0;
   for(int i=1;i<20;i++){
       ll sum = 26*((ll)pow(26,i)-1)/25;
       if(sum>=num){
           n = i;
           num = num - prev;
           break;
       }
       prev = sum;
    }
    string s;
    int po = n-1;
    for(int i=0;i<n;i++){
        ll di = (ll)pow(26,po);
        ll check = num/di;
        num = num%di;
        char in ;
        if(num>0){
            in = 'a'+check;
        }
        else{
            in = 'a' + check - 1;
        }
        s.pb(in);
        //num = num%di;
        if(num==0) num=di;
        po--;
    }
    //n = s.size()-1;
    //s[n] = s[n]-1;
    cout<<s;
    
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 100;
const int INF = 1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L

int main() {
	int x; cin >> x;
	ll ans = 0;
	ans += (x / 500) * 1000;
	x = x % 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
}

Measured memory_bytes: 3640
// D - Not Divisible
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vi A(N);
	int mx = 0;
	rep(i, N){
		cin>>A[i];
		mx = max(mx, A[i]);
	}
	vi c(mx+1, 0);
	for(int a:A){
		if(c[a]){ c[a] = 2; continue; }
		for(int i=a; i<=mx; i+=a) c[i]++;
	}
	int ans = 0;
	for(int a:A) if(c[a] == 1) ans++;
	cout<< ans <<endl;
}


Measured memory_bytes: 7920
from itertools import accumulate

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

max_point = []

points = sorted([a[i][0] + a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([a[i][0] + a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([a[i][0] - a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([a[i][0] - a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] + a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] + a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] - a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] - a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

print(max(max_point))

Measured memory_bytes: 3444
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;


main(){
    int n=in();
    int k=in();
    vec v(10);
    rep(i,k)v[in()]++;
    rep2(i,n,n*100-1){
        int now=i;
        bool flag=true;
        while(now){
            if(v[now%10])flag=false;
            now/=10;
        }
        if(flag){
            cout<<i;return 0;
        }
    }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
int main()
{
	read(n);
	if(n%10==9||n>=89)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define pi acos(-1)
#define double long double

using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    if (x / (a * a) == b) {
        cout << "0";
        return 0;
    }
    double determinant = (2 * x) / (a * a) - b;
    if (determinant <= 0) {
        double theta = atan((2 * x) / (a * b * b)) * 180 / pi;
        cout << setprecision(12) << 90 - theta;
        return 0;
    }
    else {
        double theta = atan(-(a / (determinant - b))) * 180 / pi;
        cout << setprecision(12) << 90 - theta;
        return 0;
    }
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K, Q;
int A[MAX_N], B[MAX_N];

void solve() {
	cin >> N >> K >> Q;
	rep(i, 0, N) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B, B + N);
	int res = inf;
	rep(q, 0, N) {
		int c = B[q];
		vi vec;
		vi tmp;
		rep(i, 0, N + 1) {
			if(A[i] < c) {
				sort(all(tmp));
				rep(i, 0, sz(tmp) - K + 1) {
					vec.pb(tmp[i]);
				}
				tmp.clear();
			}
			else tmp.pb(A[i]);
		}
		sort(all(vec));
		// debug(vec, c);
		if(sz(vec) >= Q) {
			MIN(res, vec[Q - 1] - vec[0]);
		}
	}
	cout << res << "\n";
}


int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
pi2 = Math::PI * 2

while true
  n = gets.chomp.to_i
  break if n == 0

  pts = []
  n.times do
    pts.push gets.chomp.split(",").map{|s| s.to_f}
  end
  pts.sort!{|a, b| b[0] <=> a[0] || b[1] <=> a[1]}
  #p pts

  used = pts.map{false}

  id0 = 0
  id1 = 0
  pt0 = [pts[id0][0], pts[id0][1] - 1]
  pt1 = pts[id1]
  used[id1] = true
  #p [id1, pts[id1]]

  while true
    v0x = pt1[0] - pt0[0]
    v0y = pt1[1] - pt0[1]
    th0 = Math.atan2(v0y, v0x)
    #p [v0x, v0y, th0]

    npt = (0...pts.length).select{|i| i != id1}.map{|i|
      vx = pts[i][0] - pt1[0]
      vy = pts[i][1] - pt1[1]
      th = Math.atan2(vy, vx) - th0

      while th < 0
        th += pi2
      end
      while th > pi2
        th -= pi2
      end

      #p [i, vx, vy, th]
      [i, th]
    }.min{|a, b| a[1] <=> b[1]}

    break if npt[0] == 0

    pt0 = pt1
    id0 = id1

    id1 = npt[0]
    pt1 = pts[id1]
    used[id1] = true

    #p [id1, pt1]
  end
  #p used

  puts used.select{|t| ! t}.length
end

Measured memory_bytes: 6216
N, *A = map(int, open(0).read().split())

def solve():
    A.sort()

    if A[-1] - A[0] >= 2:
        return False

    if A[-1] - A[0] == 0:
        return (A[0] == N - 1) or (2 * A[-1] <= N)

    M = A.count(A[0])
    return (M < A[-1]) and (2 * (A[-1] - M) <= N - M)

if solve():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14044
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])

for j in range(M):
    b.append(b[j] + B[j])

ans = 0
j = M

for i in range(N+1):
    if a[i] > K:
        break

    while b[j] > K - a[i]:
        j -= 1

    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n;
    cin >> n;
    ll rem = 0;
    ll gun = 1;
    for (i = 0; i <= 10000000;i++){
        if(i>0){
            gun = (gun * 10) % n;
        }
        ll temp = (gun * 7) % n;
        rem = (rem + temp) % n;
        if(rem==0){
            cout << i + 1 << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <bitset>
#include <climits>
#include <cassert>

using namespace std;
typedef long long ll;

int X,Y,E;
bool D[128][128] = {0};
int PY[110];
bool V[110];

bool match(int x){
    if(x<0)return true;
    if(V[x])return false;
    V[x]=true;
    for(int y=0;y<Y;++y){
        if(!D[x][y])continue;
        if(match(PY[y])){
            PY[y]=x;
            return true;
        }
    }
    return false;
}

int main(){

    
    cin >> X >> Y >> E;
    for(int i=0;i<E;++i){
        int x,y;
        cin >> x >> y;
        D[x][y]=true;
    }
    for(int y=0;y<Y;++y){
        PY[y]=-1;
    }
    int cnt=0;
    for(int x=0;x<X;++x){
        for(int i=0;i<X;++i){
            V[i]=false;
        }
        if(match(x))cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    ll cnt = 0;
    ll c;
    rep(i,min(a,b)){
        c = min(a,b)-i;
        if (a%c == 0 && b%c == 0){
            cnt++;
            if(cnt == k) {
                PRINT(c);
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

string s;
ll K;

// z=1;y=2;....b=25;a=0;

int main()
{
  cin >> s;
  cin >> K;
  ll i=0;
  while(K>0&&i<s.size())
  {
    ll m1=('z'-s[i]+1)%26;
    if(K>=m1)
    {
      ll m2=min(m1,K);
      s[i]=((s[i]-'a'+m2)%26)+'a';
      K-=m2;
    }
    i++;
  }
  ll l=s.size()-1;
  s[l]=((s[l]-'a'+K)%26)+'a';
  cout << s << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    SS(int,h,w)
    vector<vector<char>> a(h, vector<char>(w));
    vector<bool> d_h(h), d_w(w);
    rep(i, h){
        rep(j, w){
            cin >> a.at(i).at(j);
            if(a.at(i).at(j) == '#'){
                d_h.at(i) = true;
                d_w.at(j) = true;
            }
        }
    }

    rep(i, h){
        if(!d_h.at(i)) continue;
        rep(j, w){
            if(!d_w.at(j)) continue;
            cout << a.at(i).at(j);
        }
        p();
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node{
  int num;
  struct _Node *parent;
  struct _Node *left;
  struct _Node *right;
}Node;

void print_in_turn(Node *tree){
  if(tree != NULL){
    print_in_turn(tree->left);
    printf(" %d", tree->num);
    print_in_turn(tree->right);
  }
}

void print_on_node(Node *tree){
  if(tree != NULL){
    printf(" %d", tree->num);
    print_on_node(tree->left);
    if(tree->parent != NULL && tree->parent->right != tree){
      if(tree->right != NULL)
	print_on_node(tree->right);
    }
    else
      print_on_node(tree->right);
  }
}

int main(){
  Node *root = NULL;
  Node *tmp, *new;
  Node *node; 
  char o[6];
  int n,x,i;
  int *num;

  scanf("%d", &n);
  num = (int *)malloc(sizeof(int)*n);
  for(i=0; i<n; i++){
    new = NULL;
    scanf("%s", &o);
    /*insert*/
    if(strcmp(o,"insert")==0){
      scanf("%d", &x);
      if(root == NULL){//first insert
	root = (Node *)malloc(sizeof(Node));
	root->parent = NULL;
	root->right  = NULL;
	root->left   = NULL;
	root->num    = x;
      }
      else{//other insert
	tmp = root;
	while(1){
	  if(tmp->num < x){
	    if(tmp->right != NULL)
	      tmp = tmp->right;
	    else{
	      new = (Node *)malloc(sizeof(Node));
	      tmp->right = new;
	    }
	  }
	  else{
	    if(tmp->left != NULL)
	      tmp = tmp->left;
	    else{
	      new = (Node *)malloc(sizeof(Node));
	      tmp->left = new;
	    }
	  }
	  if(new != NULL){
	    new->num = x;
	    new->parent= tmp;
	    new->right = NULL;
	    new->left  = NULL;
	    break;
	  }
	}
      }
    }
    /*print*/
    else{
      print_in_turn(root); putchar('\n');
      print_on_node(root); putchar('\n');
    }
  }
  return 0;
}

Measured memory_bytes: 24044
//Shivam gupta (Codeforces handle : shivam_1999)

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

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef pair<long long, long long> pii;
typedef vector<pair<long long, long long>> vpii;
typedef map<long long, long long> mii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define sorta(x) sort(x.begin(),x.end())
#define sortd(v) sort(all(v), greater<ll>())
#define el cout << endl;
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define cpresent(container, element) (find(all(container), element) != container.end())
#define deb(x) cout << #x << x << endl;
#define fl(i,n) for(ll i=0;i<n;i++)
#define fls(i,x,n) for(ll i=x;i<n;i++)
#define flr(i,n)  for(ll i=n-1;i>=0;i--)
#define fla(i,v)  for(auto i:v)    
#define in(v) for(auto &i:v){cin>>i;}
#define INF 1e9+1
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define tt    \
    int T;    \
    cin >> T; \
    while (T--)

void dfs(int node,vi adj[],int dp[],bool visited[]){
    visited[node] = true;
    for (int i = 0; i < adj[node].size(); i++) { 
        if (!visited[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, visited); 
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
}

int lonpath(vi adj[], int n){
    int dp[n + 1];
    bool visited[n + 1];
    for (int i = 0; i <= n; i++){
        dp[i] = 0;
        visited[i] = 0;
    }
    fls(i,1,n+1){
        if(!visited[i]){
            dfs(i, adj, dp, visited);
        }
    }
    int ans = 0;
    fls(i, 1, n + 1)
        ans = max(ans, dp[i]);
    return ans;
}

int main()
{   fast
    int n,m,x,y;
    cin >> n >> m;

    vi adj[n + 1];
    while(m--){
        cin >> x >> y;
        adj[x].pb(y);
    }

    cout << lonpath(adj, n) << endl;

}


Measured memory_bytes: 12960
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()

if n >= m:
    print(0)
    exit()

#sub[i]:x[i+1]-x[i]
sub = [0]*(m-1)
for i in range(m-1):
    sub[i] = x[i+1]-x[i]
sub.sort()

ass = 0
for i in range(m-n):
    ass += sub[i]
print(ass)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

int main(){
    string s,t;
    cin >> s >> t;
    rep(i,(int)s.size()+1){
        rep(j,(int)t.size()+1){
            if (s[i]==t[j]){
                chmax(dp[i+1][j+1],dp[i][j]+1);
            }
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }

    //復元
    string res ="";
    int i=(int)s.size();
    int j = (int)t.size();
    while(i>0 && j > 0){
        if (dp[i][j]==dp[i-1][j])i--;
        else if(dp[i][j]==dp[i][j-1])j--;
        else{
            res = s[i-1] + res;
            i--;j--;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c << endl;
  } else if (b == c) {
    cout << a << endl;
  } else if (c == a) {
    cout << b << endl;
  }
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    vector<int> h(3);
    cin >> h[0] >> h[1];

    vector<int> dp(3);
    dp[0] = 0; dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; ++i) {
        cin >> h[2];
        dp[2] = min(dp[1] + abs(h[2] - h[1]), dp[0] + abs(h[2] - h[0]));
        h[0] = h[1]; h[1] = h[2];
        dp[0] = dp[1]; dp[1] = dp[2];
    }

    cout << dp[1 + (2 < n)] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, a[100], i, count = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", &a[i]);
  for(i = 1; i < n; ++i){
    if(a[i] == a[i - 1]){
      for(int j = 1; j <= 4; ++j){
        if(a[i - 1] != j && a[i + 1] != j){
          a[i] = j;
          count++;
          break;
        }
      }
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

string ToLower(string str){
    string rtn;
    for(char c : str){
        if(isalpha(c) && isupper(c)) rtn += tolower(c);
        else rtn += c;
    }
    return rtn;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s;
    int cnt = 0;
    while(cin >> t && t != "END_OF_TEXT"){
        if(s == ToLower(t)) cnt++;
    }
    cout << cnt << endl;
    
}


Measured memory_bytes: 3196
s=input()
t=input()
s_set={}
t_set={}
s_dash=[]
t_dash=[]
for i in range(len(s)):
    if s[i] not in s_set.keys():
        s_set.update({s[i]:i})
    s_dash.append(s_set[s[i]])
    if t[i] not in t_set.keys():
        t_set.update({t[i]:i})
    t_dash.append(t_set[t[i]])

if s_dash==t_dash:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 66620
INF=10**9
N,M=map(int,input().split())
L=[]
for i in range(M):
  a,b=map(int,input().split())
  l=[]
  l.append(a)
  l.append(b)
  c=list(map(int,input().split()))
  c_=0
  for j in c:
    c_+=2**(j-1)
  l.append(c_)
  L.append(l)

dp=[[INF] for _ in range(2**N)]
dp[0]=[0]
for i in range(2**N):
  dp[i]=min(dp[i])
  if dp[i]!=INF:
    for j in range(M):
      if i!=i|L[j][2]:
        dp[i|L[j][2]].append(dp[i]+L[j][0])
if dp[2**N-1]!=INF:
  print(dp[2**N-1])
else:
  print(-1)

Measured memory_bytes: 44880
#include <bits/stdc++.h>
 
using namespace std;
 
int h[111111];
int n, a, b;
 
bool ok(int t){
	long long q = 0;
	for(int i = 1; i <= n; ++i){
		if (1ll * a * t < h[i]) return false;
		long long x = h[i] - 1ll * b * t;
		if (x > 0) q += (x - 1) / (a - b) + 1;
		if (q > t) return false; 
	}
	return true;
}
 
int main(){
	scanf("%d%d%d",&n,&a,&b);
	for(int i = 1; i <= n; ++i) scanf("%d",&h[i]);
	int l = 1, r = 1e9;
	while (l <= r){
		int md = (l + r) >> 1;
		if (ok(md)) r = md - 1;
		else l = md + 1;
	}
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 640
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
SS = ['SUN','MON','TUE','WED','THU','FRI','SAT']
S = readline().decode().rstrip()
for i in range(7):
    if S == SS[i]:
        print(7-i)
        sys.exit()

Measured memory_bytes: 9080
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

string s;
string t;
int flag = 0;

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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	int sizeS = s.size();
	int sizeT = t.size();

	int minSize = min(s.size(), t.size());

	for(int i = 0; i < minSize; i++)
	{
		if(s[i] != t[i])
		{
			flag = 1;
			break;
		}
	}
	if(!flag)
	{
		if(t.size() == s.size())
		{
			printf("No");
		}
		else if(t.size() > s.size())
		{
			printf("Yes");
		}
		else
		{
			printf("No");
		}
	}
	else
	{
		if(s[0] < t[0])
		{
			printf("Yes");
		}
		else
		{
			printf("No");
		}
	}
		return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
    int H,W,i=0,j=0,k=0;
    while(cin>>H>>W){
        if(H==0&&W==0) break;
        for(i=1;i<=H;i++){
            for(j=1;j<W;j++){
                if(i==1||i==H)cout<<"#";
                else {
                    cout<<"#";
                    for(k=0;k<W-2;k++){
                        cout<<".";
                        }
                    break;
                    }
            }
            cout<<"#"<<endl;
        }
    cout<<endl;
    }
    return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];
    sortA(p);
    sortA(q);
    sortA(r);
    vector<ll> all;
    for(ll i=a-1;i>=(a-x);i--) all.pb(p[i]);
    for(ll i=b-1;i>=(b-y);i--) all.pb(q[i]);
    rep(i,c) all.pb(r[i]);
    sortA(all);
    ll n=all.size();
    ll sum=0;
    for(ll i=n-1;i>=n-(x+y);i--) sum+=all[i];
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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


int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    map<int, int> m;
    rep(i,N) {
        if (m.find(A[i]) == m.end()) m.insert(make_pair(A[i], 1));
        else m[A[i]]++;
    }

    int ans = 0;

    for (auto itr = m.begin(); itr != m.end(); itr++) {
        if (itr->second > 1) continue;
        bool flag = true;
        for (int i = 1; i * i <= itr->first; i++) {
            if (itr->first % i == 0 && m.find(i) != m.end()) flag = false;
            if (itr->first % i == 0 && i > 1 && m.find(itr->first / i) != m.end()) flag = false;
        }
        if (itr->first == 1) flag = true;
        if (flag) ans++;
    }

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

Measured memory_bytes: 13132
#include <cstdio>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);

    if (a > b)
        printf("a > b\n");
    if (a == b)
        printf("a == b\n");
    if (a < b)
        printf("a < b\n");

    return 0;
}

Measured memory_bytes: 2608
#include<bits/stdc++.h>
using namespace std;
const int N = 7368791 + 10;

int main(){
while(1){//start


	bool a[N];
	//init
	for(int i = 0; i < N; i++) a[i] = false;

	int m, n;
	cin >> m >> n;
	if(n == 0 and m == 0) break;

	int cnt = 0;
	for(int i = m; cnt < n; i++){
		for(int j = m; j < N; j++){
			if(!a[j]){
				for(int k = j; k < N; k += j) a[k] = true;
				cnt++;
			}
			if(cnt == n) break;
		}
	}


	//solv
	for(int i = m; i < N; i++){
		if(!a[i]){
			cout << i << endl;
			break;
		}
	}
}//end

	return 0;
}



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

int main() {
    int X,Y;

    cin >> X >> Y;

    int temp;

    for (int i=0; i<=X; i++){
        temp = 2 * i + 4 * (X-i);
        if (temp == Y){
            cout << "Yes" << endl;
            return 0;
        }

    }

    cout << "No" << endl;

}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<int> ds(n);
	for (int i = 0; i < n; i++)
	{
		cin >> ds[i];
	}
	sort(ds.begin(), ds.end());
	cout << ds[n/2] - ds[n/2-1] << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(_i,_n) for(int _i=0;_i<_n;_i++)
int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) cout << "error" << endl;
	else cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

    ll siz = X.size();
    ll hako = 0;
    for(ll i = 0;i < siz;i++){
        char x = X.at(i);
        hako += int(x) - 48;
    }

    if(hako % 9 == 0 or hako == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


}





    

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

int main() {

    int n,m;

    while(1){

        cin >> n >> m;

        if(n==0 && m==0) break;

        int a[n];

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

        int ans = 0;

        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i!=j){
                    if(ans < a[i] + a[j] && m >= a[i] + a[j]){
                        ans = a[i] + a[j];
                    }
                }
            }
        }

        if(ans != 0){
            cout << ans << endl;
        }
        else{
            cout << "NONE" << endl;
        }

    }

    return 0;
}

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

using namespace std;

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

  int pos = -1;
  for (int i = 0; i < min(k, s.size()); i++) {
    if (s[i] != '1') {
      pos = i;
      break;
    }
  }

  if (pos == -1) {
    cout << 1 << endl;
  } else {
    cout << s[pos] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

typedef struct node {
  i64 val;
  i32 size;
  struct node *l, *r;
} node;

uint32_t xor(void) {
  static uint32_t y = 2463534242;
  y = y ^ (y << 13); y = y ^ (y >> 17);
  return y = y ^ (y << 5);
}

i32 get_size (node *t) {
  return t == NULL ? 0 : t->size;
}

void update (node *t) {
  if (t == NULL) return;
  t->size = 1 + get_size (t->l) + get_size (t->r);
}

node* merge (node *l, node *r) {
  if (l == NULL) return r;
  if (r == NULL) return l;
  if ((i32)(xor() % (l->size + r->size)) < l->size) {
    l->r = merge (l->r, r);
    update (l);
    return l;
  } else {
    r->l = merge (l, r->l);
    update (r);
    return r;
  }
}

void split (node *p, i64 v, node **x, node **y) {
  if (p == NULL) {
    *x = *y = NULL;
    return;
  }
  if (p->val <= v) {
    split (p->r, v, x, y);
    p->r = *x;
    *x = p;
  } else {
    split (p->l, v, x, y);
    p->l = *y;
    *y = p;
  }
  update (p);
}

node* insert (node *p, i64 v) {
  node *t = ALLOC (1, node);
  t->val = v;
  t->size = 1;
  t->l = t->r = NULL;
  node *a, *b;
  split (p, v, &a, &b);
  return merge (a, merge (t, b));
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  node *p = NULL;
  p = insert (p, 0);
  i64 sum = 0;
  i64 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    i32 x;
    scanf ("%" SCNi32, &x);
    sum += x;
    node *a, *b, *c, *d;
    split (p, sum, &a, &b);
    split (a, sum - 1, &c, &d);
    ans += get_size (d);
    p = merge (c, merge (d, b));
    p = insert (p, sum);
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (ll)1e16
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=2e5+5;
ll t[4*N],lazy[4*N];

void push(int v) {
    t[v*2] += lazy[v];
    lazy[v*2] += lazy[v];
    t[v*2+1] += lazy[v];
    lazy[v*2+1] += lazy[v];
    lazy[v] = 0;
}

void update(int v, int tl, int tr, int l, int r, ll addend) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
        t[v] += addend;
        lazy[v] += addend;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), addend);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}

ll query(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return -INF;
    if (l <= tl && tr <= r)
        return t[v];
    push(v);
    int tm = (tl + tr) / 2;
    return max(query(v*2, tl, tm, l, min(r, tm)), query(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void solve(){
	int n,m;
	cin>>n>>m;
	vpii segl[n+2];
	vpii segr[n+2];
	int l,r,a;
	fr(i,1,m+1){
		cin>>l>>r>>a;
		l++;r++;
		segl[l].pb({l-1,a});
		segr[r].pb({l-1,-a});
	}
	vll dp(n+3,0);
	n++;
	update(1,1,n,1,1,0);
	fr(i,2,n+1){
		for(auto pp: segl[i]){
			update(1,1,n,1,pp.first,pp.second);
		}
		dp[i]=query(1,1,n,1,i-1);
		if(dp[i]==-INF){
			dp[i]=0;
		}
		for(auto pp: segr[i]){
			update(1,1,n,1,pp.first,pp.second);
		}
		update(1,1,n,i,i,dp[i]);
	}
	ll ans=0;
	fr(i,1,n+2){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);
    rep(i,N){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(),B.end());
    int fmax = B[N-1];
    int smax = B[N-2];
    rep(i,N){
        if(A[i]<fmax)cout << fmax << endl;
        else cout << smax << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N,l,s,input,i;
    vector<int> A;
    cin >> N;
    for(i=0;i<N;i++){
        cin >> input;
        A.push_back(input);
    }
    sort(A.begin(),A.end(),greater<int>());
    l = 0;
    s = 0;
    for(i=0;i<N-1;i++){
        if(A[i] == A[i+1]){
            if(l == 0){
                l = A[i];
                i++;
            }
            else{
                s = A[i];
                break;
            }
        }
    }
    cout << (long)l*(long)s << endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
ll bag[1<<12];
int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int m,n,x,y,cost,a;
	cin>>m>>n;
	repeat(j,0,1<<m)bag[j]=2147483647;bag[0]=0;
	repeat(i,0,n){
		cin>>cost>>x;
		a=0;
		repeat(j,0,x){
			cin>>y;
			a|=(1<<(y-1));
		}
		repeat(j,0,1<<m){
			int p=(j|a);
			bag[p]=min(bag[p],bag[j]+cost);
		}
	}
	if(bag[(1<<m)-1]!=2147483647)cout<<bag[(1<<m)-1]<<endl;
	else cout<<-1<<endl;
	return 0;
}


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

using ll = long long int;

const ll MAX_N = (ll)(2 * 1e5 + 5);

ll n;
ll a[MAX_N];

ll adda[MAX_N];
ll xora[MAX_N];

ll ans = 0;

int main(void) {
  // Here your code !
  scanf("%lld", &n);
  for (ll i = 1; i <= n; ++i) {
    scanf("%lld", &(a[i]));
  }

  a[0] = 0;
  for (ll i = 1; i <= n; ++i) {
    adda[i] = adda[i - 1] + a[i];
    xora[i] = xora[i - 1] ^ a[i];
  }

  for (ll i = 1; i <= n; ++i) {
    ll l = i, r = n + 1;
    while (abs(r - l) > 1) {
      ll mid = (l + r) / 2;

      ll tmpadd = adda[mid] - adda[i - 1];
      ll tmpxor = xora[mid] ^ xora[i - 1];

      if (tmpadd == tmpxor) {
        l = mid;
      }
      else {
        r = mid;
      }
    }
    ans += (l - i + 1);
  }

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

	return 0;
}


Measured memory_bytes: 4992