akhauriyash/Code-Regression huggingface dataset:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_2_A&lang=jp
# Stack

from collections import deque
import sys
input = sys.stdin.readline

def loop_proc():
    (n1,n2) = map(int,input().split())
    wl =[]
    for i in range(n1):
        wl.append(deque())
    for i in range(n2):
        l = list(map(int,input().split()))  
        if (l[0] == 0 ):
            wl[l[1]].append(l[2])
        elif (l[0] == 1 ):
            if ( len(wl[l[1]]) != 0 ):
                tl = wl[l[1]]
                print (tl[-1])
        elif (l[0] == 2 ):
            if ( len(wl[l[1]]) != 0 ):
                wl[l[1]].pop()
 

loop_proc()





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

int main() {
    string S,T;
    int a,flag;
    flag = 0;
    cin >> S;
    cin >> T;

    a = S.size();
    for(int i = 0;i < a; i++){
        if(S.at(i) == T.at(i)){
            continue;
        }
        else{
            flag = 1;
            break;
        }
    }
    if(flag == 0 && a == T.size() - 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
//constexpr long long MOD = 1777777777LL;
using ld = long double;
using tp = tuple<ll, ll, ll>;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

// long dobule
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    vvec<int> g(n + 1, vec<int>(26, -1));
    vec<int> pre(26, -1);
    REP2(i, n) {
        REP(j, 26) {
            g[i + 1][j] = pre[j];
        }
        pre[s[i] - 'a'] = i + 1;
    }

    REP(j, 26) {
        g[0][j] = pre[j];
    }

    vec<ll> dp(n + 1, -1);

    auto dfs = [&](auto &&self, int i) -> int {
        if(dp[i] != -1)
            return dp[i];

        int ret = INF_INT;
        REP(j, 26) {
            if(g[i][j] == -1) {
                return dp[i] = 1;
            } else {
                chmin(ret, self(self, g[i][j]) + 1);
            }
        }
        return dp[i] = ret;
    };

    dfs(dfs, 0);

    int pos = 0;
    while(pos != -1) {
        REP(j, 26) {
            if(g[pos][j] == -1) {
                cout << (char)('a' + j) << en;
                pos = -1;
                break;
            }
            if(dp[pos] == dp[g[pos][j]] + 1) {
                cout << (char)('a' + j);
                pos = g[pos][j];
                break;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 32140
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s;
const int Kmax=1e7;
int sum[Kmax];
int R[Kmax];

int main()
{
    int n;
    cin>>n;
    cin>>s;
    int Max=0;
        for(int j=1;j<n;j++){
         sum[j]=sum[j-1];
         if(s[j-1]=='E'){
            sum[j]++;
			//printf("%d:%d\n",j,sum[j]);
         }
         }
        for(int k=n;k>0;k--){
        R[k-1]=R[k];
        if(s[k]=='W'){
        R[k-1]++;
        }
         sum[k-1]=sum[k-1]+R[k-1];
		// printf("%d:%d\n",k-1,sum[k-1]);
         
         Max=max(Max,sum[k-1]);
        }
        cout<<n-1-Max<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  if (h <= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
def renew(lis,id1,id2):
  tar = lis[id1]; bow = lis[id2]
  if tar[0] < bow[0]:
    tar = [bow[0],max(bow[1],tar[0])]
  else:
    tar[1] = max(bow[0],tar[1])
  lis[id1] = tar
  return

n = int(input())
a = [[x,0] for x in list(map(int, input().split()))]
for j in range(n):
  for i in range(2**n):
    if not i & (1<<j):
      renew(a,i|(1<<j),i)
a = [x+y for x,y in a[1:]]
for i in range(1,2**n-1):
  if a[i] < a[i-1]:
    a[i] = a[i-1]
for x in a:
  print(x)


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n, m;
	cin >> n >> m;
	vector<string> board(n);
	for(int i=0; i<n; i++){
		cin >> board[i];
	}

	vector<vector<int>> dp(n, vector<int>(m));
	dp[0][0] = 1;

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if((i == 0 && j == 0) || board[i][j] == '#')
				continue;
			if(i == 0){
				// We are in first row
				dp[i][j] = dp[i][j-1];
			}

			else if(j == 0){
				// We are in the first column
				dp[i][j] = dp[i-1][j];
			}

			else
				dp[i][j] = dp[i-1][j]%MOD + dp[i][j-1]%MOD;
		}
	}
	dp[n-1][m-1] %= MOD;
	cout << dp[n-1][m-1] << "\n";
	return 0;
}

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

int main(){
	ll n; cin >> n;
	ll a[n];
	for(ll i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	ll sum = a[0], ans = 1;
	for(ll i = 1; i < n; ++i){
		if(sum * 2 >= a[i]) ++ans;
		else ans = 1;
		sum += a[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  bool ans = true;
  if(N%2 !=0){
    ans= false;
  }
  else{
    int M = N/2;
    for(int i =0; i<M; i++){
      if(S.at(i)!=S.at(i+M)){
        ans = false;
      }
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println(minimalDistance(A, K));
    }

    private static int minimalDistance(int[] a, int k) {
        Arrays.sort(a);
        int low = Integer.MAX_VALUE;
        for (int i = 0; i <= a.length - k; i++) {
            if (low > (a[i + k - 1] - a[i])) {
                low = a[i + k - 1] - a[i];
            }
        }
        return low;
    }
}

Measured memory_bytes: 51500
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll n,k;
    ll ans;
    cin>>n>>k;
    ans=pow(n/k,3);
    if(k%2==0){
        ans+=pow((n/(k/2)+1)/2,3);
    }
    cout<<ans<<endl;
}

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


  int n,k;
  vector<int> d;
  vector<vector<int>> a;

int main(){
  cin >> n >> k;
  d.resize(k);
  a.resize(k,vector<int>());
  rep(i,k){
    cin >> d[i];
    a[i].resize(d[i]);
    rep(j,d[i]){
      cin >> a[i][j];
    }
  }
  
  int ans = 0;
  for(int i= 1;i <= n; i++){
    bool have = false;
    for(auto v: a){
      for(auto p: v){
        if(p == i) have = true;
      }
    }
    if(!have) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
const int N=200005;
vector<int> G[N];
int dis[N], ans, n, rt;

inline int read()
{
 	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}

void dfs(int u, int fa)
{
	for (int v: G[u]) if (v^fa)
		dis[v]=dis[u]+1, dfs(v, u);
}

int main()
{
	n=read();
	rep(i, 1, n-1)
	{
		int u=read(), v=read();
		G[u].push_back(v); G[v].push_back(u);
	}
	dfs(1, 0);
	rep(i, 1, n) if (dis[i]>dis[rt]) rt=i;
	memset(dis, 0, sizeof(dis)); dfs(rt, 0);
	rep(i, 1, n) if (dis[i]>ans) ans=dis[i];
	if (ans%3==1) puts("Second"); else puts("First");
	return 0;
}


Measured memory_bytes: 21376
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, D;

	while (true)
	{
		scanf("%d", &N);
		scanf("%d", &M);

		if (N == 0 && M == 0) { break; }

		vector<int> C; C.push_back(0);

		for (int i = 0; i < N; i++)
		{
			scanf("%d", &D);

			if (D <= M)
			{
				C.push_back(D);
			}
		}

		vector<int> r;

		for (int i = 0; i < C.size(); i++)
		{
			for (int j = i; j < C.size(); j++)
			{
				if (C[i] + C[j] <= M)
				{
					r.push_back(C[i] + C[j]);
				}
			}
		}

		sort(r.begin(), r.end());

		int ret = 0, lc = 0, rc = r.size() - 1;

		while (rc - lc >= 0)
		{
			if (r[lc] + r[rc] > M)
			{
				rc--;
			}
			else
			{
				ret = max(ret, r[lc] + r[rc]); lc++;
			}
		}

		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
const int N=105;
const int M=15;
long long int n,f[N][M],p[N][M],x,ans=-1000000000000,c[N];
 
int main(){
    bool b=0;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin>>p[i][j];
        }
    }
    for(int i=1;i<(1<<10);i++){
        memset(c,0,sizeof(c));
        x=0;
        for(int j=0;j<=9;j++){
            if((1<<j)&i){
                for(int k=0;k<n;k++){
                    c[k]+=f[k][j];
                }
            }
        }
        for(int j=0;j<n;j++){
//            cout<<j<<' '<<c[j]<<'\n';
            x+=p[j][c[j]];
        }
//        cout<<i<<' '<<x<<'\n';
        ans=max(ans,x);
    }
    cout<<ans<<'\n';
}

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

int main() {
  int n;
  cin >> n;
  vector<int64_t> l(n+1);
  l[0]=2;
  l[1]=1;
  for (int i = 2;i < n+1;i++){
    l[i]=l[i-1]+l[i-2];
  }
  cout << l[n] << endl;
}  
  

Measured memory_bytes: 256
#include<stdio.h>
#define LEN 10000
int judge(int x,int y){

  if(x == y){
    return 1;
    
  }
  else{
    return 0;
  }
      }

int main(){

  int i,j,n,q,u,s[LEN],t[LEN],a[LEN],count=0;

  
  scanf("%d",&n);

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

  scanf("%d",&q);

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

      u = judge(s[i],t[j]);
      
      if(u == 1){
	a[j]++;
	if(a[j] < 2)
	count++;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2144
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[] ch=sc.next().toCharArray();
    int f=0;
    for(int i=0;i<6;i++){
      if(ch[i]=='1'){
        f++;
      }
    }
    System.out.println(f);
    
  }
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e3+5;
const int INF = 1e9;

int n,m;
string str[N];
int lev[N][N], vis[N][N];

bool check(int i,int j)
{
    return (i>=0 && j>=0 && i<n && j<m && str[i][j] == '.' && !vis[i][j]);
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        pii d[4] = {{0,1},{0,-1},{1,0},{-1,0}};
        cin>>n>>m;
        pii s,e;
        cin>>s.ff>>s.ss;
        s.ff--,s.ss--;
        cin>>e.ff>>e.ss;
        e.ff--,e.ss--;
        for(int i=0;i<n;i++)cin>>str[i];
        set<pair<int,pii>> dist;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++)lev[i][j] = INF;
        lev[s.ff][s.ss] = 0;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++)dist.insert({lev[i][j],{i,j}});
        while(dist.size())
        {
            auto now = dist.begin();
            int clev = (*now).ff;
            if(clev == INF)break;
            pii c = (*now).ss;
            vis[c.ff][c.ss]++;
            dist.erase(dist.begin());
            for(int i=0;i<4;i++)
            {
                pii ne = {c.ff + d[i].ff, c.ss + d[i].ss};
                if(!check(ne.ff, ne.ss))continue;
                if(lev[ne.ff][ne.ss] > clev)
                {
                    dist.erase(dist.find({lev[ne.ff][ne.ss], ne}));
                    lev[ne.ff][ne.ss] = clev;
                    dist.insert({lev[ne.ff][ne.ss], ne});
                }
            }
            for(int i=-2;i<=2;i++)for(int j=-2;j<=2;j++)
            {
                pii ne = {c.ff+i, c.ss+j};
                if(!check(ne.ff, ne.ss))continue;
                if(lev[ne.ff][ne.ss] > clev + 1)
                {
                    dist.erase(dist.find({lev[ne.ff][ne.ss], ne}));
                    lev[ne.ff][ne.ss] = clev + 1;
                    dist.insert({lev[ne.ff][ne.ss], ne});
                }
            }
        }
        int ans = lev[e.ff][e.ss];
        if(ans == INF)ans = -1;
        cout<<ans<<endl;
    }
    return 0;
}


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

int dp[102][4][2];

int main(){
	string N;
	int K;
	cin >> N >> K;
	int ketasu = N.size();
	dp[0][0][0] = 1;//0桁の/非０数が０個の/不確定に１
	rep(i, ketasu)rep(j, K+1)rep(k, 2){
		int a = N[i] - '0';
		int ni = i+1;
		rep(d, 10){
			int nj = j, nk = k;
			if(d != 0) nj++;
			if(nj > K) continue;
			if(nk == 0){
				if(d > a) continue;
				if(d < a) nk = 1;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}
	cout << dp[ketasu][K][0] + dp[ketasu][K][1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
c=[0]*n
mod=10**9+7
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:
            b[i]+=1
    for j in range(i):
        if a[i]>a[j]:
            c[i]+=1
ans=sum(b)
anst=sum(c)
# print(b)
print((ans*k*(k+1)//2+anst*(k-1)*k//2)%mod)

Measured memory_bytes: 42476
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

vector<int> prime;

void calcPrime(int n){

    bool isPrime[n+1];
    fill(isPrime, isPrime+n+1, true);
    isPrime[0] = false;
    isPrime[1] = false;

    int i1 = 2; 
    while(i1 <= n){
        if(isPrime[i1] == false){
            i1++;
            continue;
        }

        int temp = i1;
        int i2 = i1*2;
        while(i2 <= n){
            isPrime[i2] = false;
            i2 += temp;
        }
        i1++;
    }

    prime.clear();
    for(int i=2; i<=n; i++){
        if(isPrime[i]){
            prime.push_back(i);
        }
    }
}

int main(){

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

    ll x; cin >> x;

    calcPrime(1e6);

    for(auto p : prime){
        if(x <= p){
            cout << p << endl;
            break;
        }
    }

    return 0;
}

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


int main() {
	int N;
	cin >> N;
	vector<unsigned long long> L(87);
	L.at(0) = 2;
	L.at(1) = 1;
	for(int i = 2; i <= N; i++){
		L.at(i) = L.at(i - 1) + L.at(i - 2);
	}
	cout << L.at(N) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main(String[] main)
    {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        
        if (x >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}

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

#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define MOD 1000000007
#define INF 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y) 
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,a,tmp;
	cin>>n>>a;
	ll sum=0;
	for (int i = 0; i < a; ++i)
	{
		cin>>tmp;
		sum+=tmp;
	}
	if(sum>=n){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  int a = 0;
  int count = 0;
  for(int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  for(int i = 0; i < N; i++) {
    if(i == 0) {
      a = H.at(0);
    }
    else {
      a = max(H.at(i),a);
    }
    if(H.at(i) >= a) {
      count++;
    }
  }
  cout << count << endl;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  int s = a * 100 + b * 10 + c;
  if(s % 4 == 0){
    std::cout << "YES" << std::endl;
  }
  else
    std::cout << "NO" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
  
static const int MAX = 1000;
static const int VMAX = 10000;
  
int n, A[MAX], s;
int B[MAX], T[VMAX + 1];
  
int solve(){
    int ans = 0;
    bool V[MAX];
    for (int i = 0; i < n; i++){
        B[i] = A[i];
        V[i] = false;
    }
    sort(B, B + n);
    for (int i = 0; i < n; i++) T[B[i]] = i;
    for (int i = 0; i < n; i++){
        if (V[i]) continue;
        int cur = i;
    	int S = 0;
    	int m = VMAX;
    	int an = 0;
        while (1){
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur]) break;
        }
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
    }
    return ans;
}
  
int main(){
    cin >> n;
    s = VMAX;
    for (int i = 0; i < n; i++){
        cin >> A[i];
        s = min(s, A[i]);
    }
    int ans = solve();
    cout << ans << endl;
    return 0;
}

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

//#define int long long
const int MOD = 1e9 + 7;
using ll = long long;
using intpair = pair<int, int>;
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    string s,t;
    cin >> s >> t;
    cout << (s==t.substr(0,s.length()) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  int n;
  cin >> n;
  ll x[n],y[n];
  rep(i,n)cin >> x[i] >> y[i];
  rep(i,n){
    if(i==0)continue;
    x[i]-=x[0],y[i]-=y[0];
  }
  x[0]=0;
  y[0]=0;
  ll ans = 0;
  vector<P> v1,v2,v3,v4;
  rep(i,n){
    if(x[i]>=0&&y[i]>0)v1.push_back(P(x[i],y[i]));
    if(x[i]<0&&y[i]>=0)v2.push_back(P(x[i],y[i]));
    if(x[i]<=0&&y[i]<0)v3.push_back(P(x[i],y[i]));
    if(x[i]>0&&y[i]<=0)v4.push_back(P(x[i],y[i]));
  }

  ll mx1=0;
  for(auto p:v1)chmax(mx1,p.first+p.second);

  ll mx3=0;
  for(auto p:v3)chmax(mx3,-p.first-p.second);

  chmax(ans,mx1+mx3);

  ll mx2=0;
  for(auto p:v2)chmax(mx2,-p.first+p.second);

  ll mx4=0;
  for(auto p:v4)chmax(mx4,p.first-p.second);

  chmax(ans,mx2+mx4);

  rep(_,4){
    ll max1=0;
    for(auto p:v1)chmax(max1,p.first+p.second);

    ll max2=0;
    for(auto p:v2)chmax(max2,-p.first-p.second);

    chmax(ans,max1+max2);

    ll max1r=0;
    for(auto p:v1)chmax(max1r,p.first-p.second);

    ll max2r=0;
    for(auto p:v2)chmax(max2r,-p.first+p.second);

    chmax(ans,max1r+max2r);

    rep(i,n){
      ll xv = x[i];
      ll yv = y[i];
      x[i]=-yv;
      y[i]=xv;
    }
    v1.clear();
    v2.clear();
    v3.clear();
    v4.clear();
    rep(i,n){
      if(x[i]>=0&&y[i]>0)v1.push_back(P(x[i],y[i]));
      if(x[i]<0&&y[i]>=0)v2.push_back(P(x[i],y[i]));
      if(x[i]<=0&&y[i]<0)v3.push_back(P(x[i],y[i]));
      if(x[i]>0&&y[i]<=0)v4.push_back(P(x[i],y[i]));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 21580
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with

#A = int(input())
N,M= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
p=1
left=1
right=N
for m in range(M):
    l,r = map(int,input().split())
    if left<=l and l<=right:
        left=l
    if left<=r and r<=right:
        right=r

    if right<l or r<left:
        p=0

if not p:
    print(p)
    exit()
print(right-left+1)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double x;
    cin >> x;
    cout << fixed << setprecision(10) << pow(x / 3.0, 3) << '\n';
}


Measured memory_bytes: 384
from itertools import accumulate

N = int(input())
S = list(input())

A = [0]*(N+1) #N+1まで入れること忘れず

#リーダーの方向を向く，W->1の累積和，[0]start
for i in range(1, N+1):
    j = 0
    if S[i-1] == "W":
        j = 1
    A[i]=A[i-1] +j
#A =list(accumulate(A))
#print(A)

#iより左にいて西を向いている人の最小値
ans=N
for i in range(1, N+1):
    val = N-i +A[i] -A[N]
    ans = min(ans, A[i-1] +val)

print(ans)

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

using ll = long long int;

int main() {
    #ifdef LU_SERIOUS
        freopen( "in.txt", "r", stdin );
    #endif // LU_SERIOUS
    int n, m;
    string s[105];
    while( cin >> n >> m ) {
        for( int i=1; i<=n; i++ ) {
            cin >> s[i];
        }
        for( int i=1; i<=2*n; i++ ) {
            for( int j=0; j<m; j++ ) {
                cout << s[ ( i+1 ) / 2 ][ j ];
            }
            cout << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

vector<int> dat;
int leaves;

void init(int n){
    int t = 1;
    while(t<n)t*=2;
    leaves = t;
    dat.resize(leaves*2);
    for(int i=leaves;i<2*leaves;i++)dat[i] = (1LL<<31)-1;
    for(int i=leaves-1;i>=1;i--){
        dat[i] = min(dat[2*i],dat[2*i+1]);
    }
}

void update(int ind,int x){
    int m = ind+leaves;
    dat[m] = x;
    int p = m/2;
    while(p>0){
        dat[p] = min(dat[p*2],dat[p*2+1]);
        p/=2;
    }
}

int find(int s,int t,int num=1,int l=0,int r=-1){
    if(r==-1)r = leaves;
    
    if(s<=l && r<=t)return dat[num];
    else if(r<=s || t<=l)return (1LL<<31)-1;
    else{
        return min(find(s,t,num*2,l,(l+r)/2),
                   find(s,t,num*2+1,(l+r)/2,r));
    }
}


int main(){
    int n,q;
    cin>>n>>q;
    init(n);
    while(q--){
        int type;
        cin>>type;
        if(type==0){
            int i,x;
            cin>>i>>x;
            update(i,x);
        }else{
            int s,t;
            cin>>s>>t;
            cout<<find(s,t+1)<<endl;
        }
    }
}

Measured memory_bytes: 3844
#include "bits/stdc++.h"
using namespace std;
#define int 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(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 10
#else
#define SIZE 333
#endif

int N,M;
int A[SIZE][SIZE];

void solve(int _t) {
    cin>>N>>M;
    REP(n,N) {
        REP(m,M) {
            cin>>A[n][m];
            A[n][m]--;
        }
    }
    int ans = INT_MAX;
    vector<int> NG(M,0);
    REP(_,M) {
        vector<int> C(M,0);
        REP(n,N) {
            REP(m,M)if(!NG[A[n][m]]) {
                C[A[n][m]]++;
                break;
            }
        }
        int cnt = 0;
        int mai = -1;
        REP(m,M) if (chmax(cnt, C[m])) mai=m;
        debug("mai:%lld, cnt:%lld\n",mai,cnt);
        chmin(ans,cnt);
        NG[mai]=1;
    }
    _PN(ans);
}
EXEC(1)



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

int main() {
	ll k, n;
	cin >> n >> k;
	vector<ll> p(n);
	for (ll i = 0; i < n; ++i)cin >> p[i];
	sort(p.begin(), p.end());
	cout << accumulate(p.begin(), p.begin() + k, 0ll) << endl;
}


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

int main() {
  int n;
  cin >> n;
  string s;
  int ans = 0;
  cin >> s;
  for(int i = 1; i < n; i++){
    int cnt = 0;
    for(char c = 'a'; c <= 'z'; c++){
      bool left = false;
      bool right = false;
      for(int j = 0; j < i; j++){
        if(s.at(j) == c) left = true;
      }
      for(int j = i; j < n; j++){
        if(s.at(j) == c) right = true;
      }
      if(left && right) cnt++;
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	l := nextInts(n)
	sort.Sort(sort.IntSlice(l))

	ok := func(i, j, k int) bool {
		return l[i]+l[j] > l[k]
	}

	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if l[i] == l[j] {
				continue
			}
			for k := j + 1; k < n; k++ {
				if l[j] == l[k] {
					continue
				}
				if ok(i, j, k) {
					ans++
				}
			}
		}
	}

	puts(ans)
}


Measured memory_bytes: 1792
P=10**9+7
N,M=map(int,input().split())
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
mx=A[0]-1
my=B[0]-1
m=min(mx,my)
ans=1
if len(set(A))!=N or len(set(B))!=M:
    print(0)
    exit()
x=0
y=0
D=N*M
while(len(A)>0 and len(B)>0):
    if max(A[-1],B[-1])==D:
        if A[-1]>B[-1]:
            A.pop()
            ans*=y
            ans%=P
            x+=1
        elif A[-1]<B[-1]:
            B.pop()
            ans*=x
            ans%=P
            y+=1
        else:
            A.pop()
            B.pop()
            x+=1
            y+=1
        D-=1
    else:
        C=max(A[-1],B[-1])+1
        for i in range(C,D+1):
            ans*=x*y-N*M+i
            ans%=P
        D=max(A[-1],B[-1])
if len(A)>0:
    D=my
    while(len(A)>0):
        C=A[-1]+1
        for i in range(C,D+1)[::-1]:
            ans*=x*y-N*M+i
            ans%=P
        D=A.pop()-1
        x+=1
        ans*=M
        ans%=P
if len(B)>0:
    D=mx
    while(len(B)>0):
        C=B[-1]+1
        for i in range(C,D+1):
            ans*=x*y-N*M+i
            ans%=P
        D=B.pop()-1
        y+=1
        ans*=N
        ans%=P
for i in range(1,m+1):
    ans*=i
    ans%=P
print(ans)


Measured memory_bytes: 3320
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

vector<P> a;

int main() {
  int n,m,s,c1,m1,s1,m2,s2,m3,s3,m4,s4;
  while(cin >> n) {
    a.clear();
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
      m = m1+m2+m3+m4;
      s = s1+s2+s3+s4+m*60;
      P temp;
      temp.first = s;
      temp.second = c1;
      a.push_back(temp);
    }
    sort(a.begin(),a.end());
    cout << a[0].second << endl;
    cout << a[1].second << endl;
    cout << a[n-2].second << endl;
  }
}

Measured memory_bytes: 968
using System;
using System.Collections.Generic;
using System.Linq;

namespace algorithm
{
	class Program
	{

		static void Main(string[] args)
		{
			//全体/必要本数
			var q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			//座標
			var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			int k = q[1];
			
			//0から近い端を調べる
			int min = int.MaxValue;
			for (int i =0; i + k - 1 < q[0]; i++)
			{
				min = Math.Min(Math.Min(min,d[i + k - 1] - d[i] + Math.Abs(d[i])), d[i + k - 1] - d[i] + Math.Abs(d[i + k - 1]));
			}
			
			//出力
			Console.WriteLine(min);
		}
	}
}


Measured memory_bytes: 20320
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int x;
  cin>>x;
  int a=x/100;
  int b=x%100;
  int c = ((b%5==0)? b/5:b/5+1);
  if(a<c) cout<<0<<endl;
  else cout<<1<<endl;
}

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

const int depth = 17;
class Segtree {
public:
	unsigned int data[1<<(depth+1)];
	void ini() {
		for(int i= 0; i < (1<<(depth+1)); i++)
			data[i] = ((unsigned int)1<<31)-1;
	}
	
	void update(int x, int v) {
		x = (1<<depth)-1 + x;
		data[x] = v;
		while( x > 0 ) {
			x = (x-1)/2;
			data[x] = min(data[x*2 + 1], data[x*2 + 2]);
		}
	}
	
	unsigned int find(int l, int r, int a=0, int b=(1<<depth)-1, int index=0) {
		if ( a > r || b < l ) return ((unsigned int)1<<31)-1;
		if ( l <= a && b <= r ) return data[index];
		unsigned int u = find(l, r, a, a+(b-a-1)/2, index*2+1);
		unsigned int v = find(l, r, a+(b-a+1)/2, b, index*2+2);
		return min(u, v);
	}
}seg;

int main() {
	seg.ini();
	int n, q;
	int com, x, y;
	
	cin >> n >> q;
	for(int i = 0; i < q; i++ ) {
		cin >> com >> x >> y;
		if ( com == 0 )
			seg.update(x, y);
		else
			cout << seg.find(x, y) << endl;
	}
	return 0;
}

Measured memory_bytes: 2184
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = T

for i in range(N-1):
    if t[i+1] - t[i] >= T:
        ans += T
    else: # t[i+1]-t[i]<T
        ans += t[i+1] - t[i]

print(ans)

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

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	for (ll b = k+1; b <= n; b++){
		ans += (b-k)*(n/b) + max(0LL,n%b-k+(k==0?0:1));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n, l;
	cin >> n >> l;
	vector<string>s;
	for (int i = 0; i < n; i++) {
		string a;
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
}

Measured memory_bytes: 256
#include <iostream>
#define N 15
using namespace std;
void func(int,int);
int jump(int,int);
int X,Y,data[N][N],memo[N][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j],memo[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) func(0,i);
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=memo[0][i];
    cout << cnt << endl;
  }
  return 0;
}
void func(int y,int x){
  if(y==Y-1){
    memo[Y-1][x]=1;
    return ;
  }
  if(0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]==0) func(y+1,x-1);
    memo[y][x]+=memo[y+1][x-1];
  }
  if(x+1<X&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]==0) func(y+1,x+1);
    memo[y][x]+=memo[y+1][x+1];
  }
  if(data[y+1][x]==0){
    if(memo[y+1][x]==0) func(y+1,x);
    memo[y][x]+=memo[y+1][x];
  }
  if(data[y+1][x]==2){
    int r=jump(y+1,x);
    if(r==-2) memo[y][x]+=1;
    else if(r!=-1){
      if(memo[r][x]==0) func(r,x);
      memo[y][x]+=memo[r][x];
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    //    if(y>Y-1) return -2;
    if(y<=Y-1&&data[y][x]==1) break;
    if(y>=Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

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

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};


int main() {
    int N,M; cin >> N >> M;
    vector<int>v(N+1,0);

    rep(i,M){
        int a,b; cin >> a >> b;
        v[a]++;
        v[b]++;
    }

    string ans="YES";
    for(int i=1; i<=N; i++){
        if(v[i]%2){
            ans="NO";
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    A,B,N = map(int,input().split())

    def f(x):
        return math.floor((A*x)/B) - A * math.floor(x/B)
	
    print(f(min(B-1,N)))


if __name__ == "__main__":
  main()


Measured memory_bytes: 62164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int x,y;
  cin >> x >> y;

  rep(i,x+1){
    int sum = i*2 + (x-i)*4;
    if(sum == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n;
	cin >> n;
	
	map<string, lli> mp;
	
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		sort(ALL(s));
		++mp[s];
	}
	
	lli ans = 0;
	
	for (auto x : mp) {
		ans += x.Y * (x.Y - 1) / 2;
	}
	
	cout << ans << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int n,m,p[100010];
vector <int> g[100010];

vector <int> lim[100010];
int cnt,flag[100010];

void dfs(int node){
  flag[node]=1;
  lim[cnt].push_back(node);
  for(int i=0;i<(int)g[node].size();i++)
    if(!flag[g[node][i]])
      dfs(g[node][i]);
}


int main(){

  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>p[i];
  for(int j=0;j<m;j++){
    int x,y;
    cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  for(int i=0;i<n;i++){
    if(!flag[i]){
      dfs(i);
      cnt++;
    }
  }

  // cnt--;

  vector <int> lia[100010];

  for(int i=0;i<cnt;i++)
    for(int e:lim[i])
      lia[i].push_back(p[e-1]);

  for(int i=0;i<cnt;i++) sort(lim[i].begin(),lim[i].end());
  for(int i=0;i<cnt;i++) sort(lia[i].begin(),lia[i].end());

  /*
  for(int i=0;i<cnt;i++){
    cout<<i<<":"<<endl;
    for(int j=0;j<(int)lia[i].size();j++){
      if(j) cout<<" ";
      cout<<lia[i][j];
    }
    cout<<endl;

    for(int j=0;j<(int)lim[i].size();j++){
      if(j) cout<<" ";
      cout<<lim[i][j];
    }
    cout<<endl<<endl;

    }*/

  int r=0;
  for(int i=0;i<cnt;i++){

    int mc=0,ac=0;
    for(;(int)lia[i].size()!=ac && (int)lim[i].size()!=mc;){
      if(lim[i][mc]>lia[i][ac]) ac++;
      else if(lim[i][mc]<lia[i][ac]) mc++;
      else {
	ac++;
	mc++;
	r++;
      }
    }

  }

  cout<<r-1<<endl;

  return 0;

}

Measured memory_bytes: 15352
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
 
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b>=c)	printf("Yes\n");
	else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;
void swap(int&a, int&b) {
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}


int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A < B) swap(A, B);
	if (A < C) swap(A, C);
	cout<< A * 10 + B + C;
	return 0;
}

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

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

	int64_t ans, n;
	n = 1000000000000000000;
	//cout << n << endl;
	ans = 1;

	vector<int64_t> v(N);
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());

	if (v.at(0) == 0) {
		cout << 0 << endl;
	}
	else {
		for (int i = 0; i < N; i++) {
			if (v.at(i) > (n / ans)) {
				cout << -1 << endl;
				return 0;
			}
			else {
				ans *= v.at(i);
			}
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 4060
n, m = map(int, input().split())
p = list()
for i in range(m):
    a, b = map(int, input().split())
    p.append((b, a))
p = sorted(p)
broken = -1
ans = 0
for item in p:
    a = item[1]
    b = item[0]
    if a >= broken:
        ans += 1
        broken = b
print(ans)

Measured memory_bytes: 17788