akhauriyash/Code-Regression huggingface dataset:
#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 <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#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 REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050
ll dp[50][1<<20];
vector<ll> change(int x){
    vector <ll> v;
    int count=0;
    while(x){
        count++;
        if(x%2){v.pb(count);count=0;}
        x/=2;
    }
    return v;
}
int change2(vector<ll> v){
    ll now=1;
    ll ans=0;
    for(auto e:v){
        rep(i,e)now*=2;
        ans+=now/2;
    }
    return ans;
}
bool judge[N];
ll pw[50];
main(){
    ll n=in();
    ll x[3];
    rep(i,3)x[i]=in();
    int sum=x[0]+x[1]+x[2];
    vector<pair<vector<ll>,ll>> v;
    vector<ll> vvv;
    v.pb({vvv,1ll});
    ll ans=0;
    pw[0]=1;
    rep(i,20)pw[i+1]=pw[i]*2;
    dp[0][0]=1;
    vector<ll> tmp={2,3};
    rep(i,1<<sum){
        if((i&(1<<(x[2]-1))&&(i&(1<<(x[2]+x[1]-1))&&(i&1<<(sum-1)))))judge[i]=1;
    }
    rep(i,n){
        rep(k,1<<sum){
            if(dp[i][k]==0)continue;
            rep2(j,1,7){
                ll next=(k*pw[j]+pw[j-1])%pw[sum];
                if(!judge[next])
                dp[i+1][next]=(dp[i][k]+dp[i+1][next])%MOD;
            }
            dp[i+1][0]=(dp[i+1][0]+dp[i][k]*3)%MOD;
        }
    }
    ll p=1;
    rep(i,n){
        p=p*10ll%MOD;
    }
    rep(i,1<<sum){
        p=(p-dp[n][i]+MOD)%MOD;
    }
    cout<<p<<endl;
}

Measured memory_bytes: 149760
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var kt = Input.ar; 
        var ar = Input.ar; if (kt[1] == 1) { WriteLine(ar[0] - 1);return; }
        var ct = 0;
        for (var i = 0; i < kt[1]; i++)
            if (ar.Sum() - 2 * ar[i] + 1 < 0) ct += 2 * ar[i] - 1 - ar.Sum(); WriteLine(ct);

    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 13396
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void join(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb])swap(ra,rb);
        v[rb]=ra;
        sz[ra]+=sz[rb];
        
    }
    bool same(int a,int b){
        //same set
        return (root(a)==root(b));
    }
    int size(int a){
        return sz[root(a)];
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    string s;
    cin>>s;
    int l=0,r=0;
    for(int i=0;i<3;i++)if(s[i]=='A')l++;else r++;
    if(l!=0 and r!=0){
        cout<<"Yes";
    }
    else cout<<"No";
}

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

int count[26];

int main(){
	char c;
	while(1){
		cin >> c;
		if(cin.eof()) break;
		if(c < 'a') c += 32;
		if(c < 'a' || c > 'z') continue;
		count[c-'a']++;
	}
	for(int i = 0; i < 26; i++){
		c = 'a' + i;
		cout << c << " : " << count[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3044
#include<stdio.h>
#include<iostream>

#define MAX_N 105

using namespace std;

int BubbleSort(int arr[], int N){
    int swapNum=0;
    for(int i=0; i<N-1; i++){
        for(int j=N-1; j>=i+1; j--){
            if(arr[j]<arr[j-1]){
                swap(arr[j], arr[j-1]);
                swapNum++;
            }
        }
    }
    return swapNum;
}

int main(){
    int arr[MAX_N];
    int N;
    scanf("%d", &N);
    for(int i=0; i<N; i++)
        scanf("%d", arr+i);
    int res=BubbleSort(arr, N);
    printf("%d", arr[0]);
    for(int i=1; i<N; i++)
        printf(" %d", arr[i]);
    printf("\n");
    printf("%d\n", res);
    return 0;
}




Measured memory_bytes: 3204
s = input()
t = input()

ans=[]
for i in range(len(s)-len(t)+1):
    kouho=[]
    match=True

    for pre in range(i):
        if s[pre]=="?":
            kouho.append("a")
        else:
            kouho.append(s[pre])

    for j in range(len(t)):
        if s[i+j]=="?":
            kouho.append(t[j])
        elif s[i+j] == t[j]:
            kouho.append(t[j])
        else:
            match=False
            break

    for post in range(i+j+1,len(s)):
        if s[post]=="?":
            kouho.append("a")
        else:
            kouho.append(s[post])
    if match:
        ans.append(kouho)

if len(ans)==0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(*ans[0],sep="")

Measured memory_bytes: 38768
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

int n;
int a[200000];
int x[200000];
int num;
int nim=0;

signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	if(a[0]%2==1){
		x[num]=n;
		num++;
	}
	for(int i=1;i<n;i++){
		if((a[i]-a[i-1])%2==1){
			x[num]=n-i;
			num++;
		}
	}
	for(int i=0;i<num;i++){
		nim^=x[i];
	}
	if(nim==0)cout<<"second"<<endl;
	else cout<<"first"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,ok,ans;
const int N=100010,mod=1e9+7;
int sum[N],f[N],nt[N][3];
char s[N];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
    for(int i=1;i<=n-1;++i)
    	if(s[i]==s[i+1]){ok=1;break;}
    if(!ok)return puts("1")==2333;
    
    for(int i=1;i<=n;++i)sum[i]=(sum[i-1]+(s[i]=='a'?1:2))%3;
	for(int i=0;i<=2;++i)nt[n][i]=n+1;
	for(int i=n-1;i>=0;--i)
	{
		for(int j=0;j<=2;++j)nt[i][j]=nt[i+1][j];
		nt[i][sum[i+1]]=i+1;
	}
	f[0]=1;
	for(int i=0;i<=n;++i)
	{
		for(int j=1;j<=2;++j)(f[nt[i][(sum[i]+j)%3]]+=f[i])%=mod;
		if(i&&sum[i]==sum[n])(ans+=f[i])%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2304
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

n, K = na()
mod = 1000000007

#n乗に**nを使うとTLEになる.powを使いましょう
eqi = [pow(K//(i+1), n, mod) for i in range(K)]#eqi[i] = (gcd(A_1,A_2,...,A_N) = i となる組の数)

for i in range(K,0,-1):
    if i == 1:
        eqi[i-1] -= sum(eqi[1:])
        break
    #A_1,A_2,...,A_Nのすべてがiの倍数になる組の数
    #tmp = (K//i)**n
    #A_1,A_2,...,A_Nのすべてがm*iの倍数になる組の数を引く(n = {2,3,4,...})
    for m in range(2,(K//i)+1):
        eqi[i-1] -= eqi[m*i - 1]
    eqi[i-1] %= mod
ans = 0
for i in range(K):
    ans += ((i+1)*eqi[i])%mod
print(ans%mod)


Measured memory_bytes: 73784
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String str = sc.nextLine();
			if(str.equals("END OF INPUT")) break;
			String[] a = str.split(" ");
			StringBuilder sb = new StringBuilder(str.length());
			
			for(String t:a) {
				sb.append(t.length());
			}
			System.out.println(sb);
		}
	}
}


Measured memory_bytes: 25756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

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

int main() {
  int A,B,C,D; cin>>A>>B>>C>>D;
  if(A==0) cout<<1;
  else cout<<0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <chrono>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a&&c <= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string A; cin >> A;
    lint ans = A.size() * (A.size() - 1) / 2 + 1;
    unordered_map<char, lint> num_occurances;
    for (const char& c : A) {
        ans -= num_occurances[c];
        num_occurances[c] += 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 720
import java.util.*;

public class Main {

    long INF = 1000000001;
    long[][] dp;
    boolean A, B, C;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        dp = new long[N + 1][100001];
        for (int j = 0; j <= 100000; j++) {
            dp[0][j] = INF;
        }
        dp[0][0] = 0;
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= 100000; j++) {
                if (j < v[i]) {
                    dp[i + 1][j] = dp[i][j];
                } else {
                    dp[i + 1][j] = Math.min(dp[i][j], dp[i][j - v[i]] + w[i]);
                }
            }
        }
        long ans = INF;
        for (int i = 0; i <= 100000; i++) {
            if (dp[N][i] <= W) {
                ans = i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 127060
n = int(input())
pli = list(map(int,input().split()))
count = 0
for i in range(n-2):
    if pli[i] < pli[i+1] < pli[i+2] or pli[i] > pli[i+1] > pli[i+2]:
        count += 1
print(count)

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

// 最大値がxである場合の数
long long m[90001];
long long mm[90001];// 0,sum/2,sum/2のやつ
long long MOD = 998244353;

int main()
{
	m[0] = 1;
	mm[0] = 1;
	for (int i = 1; i < 90000; ++i) {
		m[i] = 0;
		mm[i] = 0;
	}


	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a, sum=0;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		sum += a;
		for (int j = 90000; j >= 0; --j) {
			// 最大じゃない奴に足すなら倍
			m[j] *= 2;
			// 最大に足したらその分増える
			if (j >= a) {
				m[j] += m[j - a];
				mm[j] += mm[j - a];
				mm[j] %= MOD;
			}
			m[j] %= MOD;
		}
	}
	// ダメなのは最大の辺の長さが総和の半分以上のとき
	long long dame = 0;
	for (int j = 90000; j * 2 >= sum; --j) {
		dame += m[j];
		dame %= MOD;
	}
	// ダメじゃないのは3^nなので
	long long ans = 1;
	for (int i = 0; i < n; ++i) {
		ans *= 3;
		ans %= MOD;
	}
	ans -= dame*3;
	while (ans < 0)ans += MOD;
	// これでは、0,sum/2,sum/2のパターンを重複して引いているので足す
	if (sum % 2 == 0){ 
		ans += mm[sum / 2] * 3;
	}
	ans %= MOD;
	
	cout << ans << endl;


	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

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

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s,t,u;
	cin >> s >> t;
	int a,b; cin >> a >> b;
	cin >> u;
	if(u==s)a--;
	else b--;
	cout << a << ' ' << b << "\n" << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3660
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll pw(ll a , ll b)  { return (!b ? 1 : (b & 1 ? a * pw(a * a , b / 2) : pw(a * a , b / 2))); }

const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

int w[110], v[110];

ll dp[MAXN];

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n, W;
    cin >> n >> W;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = W; j >= w[i]; j--){
            dp[j] = max(dp[j - w[i]] + v[i], dp[j]);
        }
    }
    ll ANS = 0;
    for(int i = 0; i <= W; i++){
        //cout << i << " " << dp[i] << endl;
        ANS = max(ANS, dp[i]);
    }
    cout << ANS;
    return 0;
}




Measured memory_bytes: 1024
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <string>  	
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
//#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define bublic public
#define kektor vector
#define pii pair<int, int>
#define pp pair
#define all(x) x.begin(), x.end()
#define rand() (rand() << 15)
    
using namespace std;
    
typedef long long ll;

     
int RandInt(int min, int max) {
    if (max < min) swap(min, max);
    random_device rd;                                                                                                                                                                        
    mt19937 mt(rd());
    uniform_int_distribution<int> dist(min, max);
    return dist(mt);
}
                                                                      
const int maxn = 3e5, mod = 1e9 + 7, inf = 1e9;

void solve() {
	string a; cin >> a; 
	int cnt[26]; 
	for (int i = 0; i < 3; ++i) cnt[i] = 0; 
	for (auto i : a) cnt[i - 'a']++; 
	if (cnt[0] && cnt[1] && cnt[2]) cout << "Yes"; 
	else cout << "No"; 
}                               
    
signed main() {
	srand(time(0)); 
    cout.precision(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef offline_judge 
        freopen("TASK.in", "r", stdin);
        freopen("TASK.out", "w", stdout);
    #endif   
    solve();
    return 0;                                        
}    

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

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vector<int> cand;
	for (int i = 1; i * i <= m; i ++) {
		if (m % i == 0) {
			cand.push_back(i);
			if (i != m / i) {
				cand.push_back(m / i);
			}
		}
	}
	sort(cand.rbegin(), cand.rend());
	for (auto c : cand) {
		int a = m / c;
		if (a >= n) {
			printf("%d\n", c);
			return 0;
		}
	}
        return 0;
}


Measured memory_bytes: 256
import bisect

n,k=map(int,input().split())
x=list(map(int,input().split()))

if 0 in x:
	a=bisect.bisect_left(x,0)
else:
	bisect.insort(x,0)
	a=bisect.bisect_left(x,0)
	n+=1
	k+=1

ans=float('inf')
for i in range(max(0,a+k-n),min(k,a+1)):
	ans=min(ans,-2*x[a-i]+x[a-i+k-1])
for i in range(max(0,k-a-1),min(k,n-a)):
	ans=min(ans,2*x[a+i]-x[a+i-k+1])
print(ans)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main()
{
   ll n, l, t;
   cin >> n >> l >> t;
   vector<ll> x(n), w(n);
   rep(i,n) cin >> x[i] >> w[i];
   vector<ll> tmp(n);
   ll start = 0;
   rep(i,n)
   {
      if(w[i] == 1)
      { 
         tmp[i] = (x[i] + t)%l;
         start+=(x[i]+t)/l%n;
      }
      else 
      {
         tmp[i] = (l + (x[i] - t)%l)%l;
			if(x[i]-t<0) start-=(t-x[i]+l-1)/l%n;
      }
     // cout << tmp[i] << endl;
   }
   sort(tmp.begin(), tmp.end());
   start=(start%n+n)%n;
   rep(i,n) cout <<  tmp[(i+start)%n]  << endl;
}

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

int main() {
  string S, T;
  int count = 0;
  cin >> S;
  cin >> T;
  for(int i=0; i<S.size(); i++){
    if(S.at(i) != T.at(i)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3800
import java.util.*;

public class Main {

    static class Edge {
        int from, to;

        public Edge(int from, int to) {
            this.from = from;
            this.to = to;
        }
    }

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

            for (int i = 0; i < n; ++i) {
                size[i] = 1;
                id[i] = i;
            }
        }

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (p != root) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    static int N, M, Q;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        M = Integer.parseInt(sc.next());
        UnionFind uf = new UnionFind(N);

        for (int i = 0; i < M; ++i) {
            uf.unify(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
        }

        Q = Integer.parseInt(sc.next());
        for (int i = 0; i < Q; ++i) {
            if (uf.connected(sc.nextInt(),sc.nextInt()))
                System.out.println("yes");
            else
                System.out.println("no");
        }
    }
}


Measured memory_bytes: 80084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
//必殺技は一番強い敵に使うのが最適です.これを実装するにはsortでよいです.
int main(){
    ll n,k;
    cin >> n >> k;
    ll h[n];
    ll ans = 0;
    for (ll i = 0; i < n; i++) cin >> h[i];
//forもifに同じく,単文一つのみなら括弧なしで処理できます.
    sort(h, h + n);
//必殺技はk回使えるので,体力の少ない順に(n-k)体分足せばよいです.n-k<=0だとちょっと怖いので処理します。
    if(n-k<=0){
        cout << "0" << endl;
        return 0;
    }
    for (ll i = 0; i < n-k; i++) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
import numpy as np
n, m = map(int, input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(m)]
ans = 0
starts =np.array(a)
goals = np.array(b)

for start in range(n):
    dist = 10000000000
    ans = 0
    for goal in range(m):
        if dist > abs(goals[goal][0]-starts[start][0]) + abs(goals[goal][1]-starts[start][1]):
            dist = abs(goals[goal][0]-starts[start][0]) + abs(goals[goal][1]-starts[start][1])
            ans = goal+1
    print(ans)


Measured memory_bytes: 12492
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
    var N = parseInt(input[0][0], 10);
    var RGBWithoutOrder = [1, 0, 0];
    var tmp1, tmp2;
    var ans = 3;
    for (var i = 1; i < N; i++){
        tmp2 = 0;
        tmp1 = parseInt(input[1][i], 10);
        for (var x of RGBWithoutOrder){
            if (x === tmp1) tmp2 ++;
        }
        ans *= tmp2;
        ans %= (1e+9 + 7);

        for (var j = 0; j < 3; j++){
            if (RGBWithoutOrder[j] === tmp1){
                RGBWithoutOrder[j] ++;
                break;
            }
        }
    }
    if (parseInt(input[1][0], 10) !== 0) ans = 0;
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if (A>B & A>C & A == B+C){
     cout<<"Yes"<<endl;
  }
   else if (B>C & B>A & B == A+C){
     cout<<"Yes"<<endl;
  }
  else if (C>B & C>A & C == A+B){
     cout<<"Yes"<<endl;
  }
  else{
     cout<<"No"<<endl;
  }
  
  
}


Measured memory_bytes: 256
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007; /// 1e9+7
const int MAX = 100005;     /// 1e5+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string a, b;
    cin>>a>>b;
    if(a[0]==b[2] and a[1]==b[1] and a[2]==b[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    ll n, a, b, c, d;cin >> n >> a >> b >> c >> d;
    bool ans = false;
    for(int m=0;m<n;m++){
        if(c*(n-1-m)-d*m <= b-a && b-a <= -c*m+(n-1-m)*d){
            ans = true;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// 998244353;// ;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<LL>>g;
vector<edge>edges;
vector<LL>v;
map<LL, LL>ma;
set<Pll>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, dp[210000], a[210000], b[210000];
string str, ss;
bool f;
char c;
LL gcd(LL a, LL b) {
	if (a < b) gcd(b, a);
	LL r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 2 == 0)cnt++;
	}
	while (true) {
		if (cnt % 2 == 1) {
			break;
		}
		LL mn = INF, sum = 0;
		rep(i, n) {
			mn = min(a[i], mn);
			sum += a[i] - 1;
		}
		if (mn == 1) {
			if (mn % 2 == 1)f ^= 1;
			break;
		}
		cnt = 0;
		rep(i, n) 
			if (a[i] % 2 == 1 && a[i] != 1) {
				a[i]--;
				break;
			}
		LL g = a[0];
		rep(i, n) {
			g = gcd(g, a[i]);
		}
		rep(i, n) {
			a[i] /= g;
			if (a[i] % 2 == 0)cnt++;
		}
		f ^= 1;
	}
	if (f == 0)cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 2688
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n;
	cin >> n;

	if (n % 2) {
		out("0");
		return 0;
	}

	ll ans = 0;
	n /= 2;

	while (n > 0) {
		ans += n / 5;
		n /= 5;
	}

	out(ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

double f(int n) {
    if (n == 0) return 0;
    if (n == 1) return 1;
    double d = (2 * n + 2.0) / (2 * n);
    return 1 + d * f(n - 1);
}

int main() {
    // input
    int n, d1, x; scanf("%d%d%d", &n, &d1, &x);
    // solve
    double d = d1 + (2 * n - 1) / 2.0 * x;
    double result = d * f(n);
    // output
    printf("%.15lf\n", result);
    return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  cout << max({A,B,C})*9+A+B+C << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll ans=ll(x/500)*1000;
    x%=500;
    x/=5;
    x*=5;
    cout << x+ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    for (int i = 1; i <= 3; i++) {
        int ans = a * b * i;
        if (ans % 2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    int g=(int)('Z'-s[i]);
    if(g<n){
      int y=n-g-1;
      cout<<(char)('A'+y);
    }
    else{
      cout<<(char)(s[i]+n);
    }
    if(i==s.size()-1){
      cout<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int i=1, num;
    
    while(1){
        scanf("%d", &num);
        //???????????¶
        if(num==0) break;
        printf("Case %d: %d\n", i,num);
        i++;
    }
	 
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstring>
using namespace std;
struct student{
  int start[1000];
  bool used[721];
};
student S[10000];
int main(){
  int N,M;
  while(cin>>N>>M){
    if(N==0)break;
    int r,q;
    memset(S,0,sizeof(S));  
    cin>>r;
    for(int i=0;i<r;i++){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      t-=540;m--;n--;
      if(s==1){
	S[m].start[n]=t;
      }else{
	while(t>0 && S[m].start[n]<t)
	  S[m].used[--t]=true;
      }
    }
    cin>>q;
    for(int i=0;i<q;i++){
      int ts,te,m,ans=0;
      cin>>ts>>te>>m;
      ts-=540;te-=540;m--;
      for(int i=ts;i<te;i++){
	if(S[m].used[i]==true)ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 47300
from scipy.sparse import*
from itertools import permutations as pm

n,m,h = map(int,input().split())
r = [int(i) for i in input().split()]

u,v,l = zip(*[map(int,input().split()) for i in range(m)])

A=csgraph.dijkstra(csr_matrix((l,(u,v)),[n+1]*2),0)

s=min(sum(A[i][j] for i,j in zip(a[:-1],a[1:])) for a in pm(r))
print(int(s))


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

using namespace std;

typedef long long ll;
ll a[105];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    ll ans = 0;
    while(1)
    {
        ll maxx = a[0];
        int index = 0;
        for(int i=1;i<n;i++)
        {
            if(a[i]>maxx)
            {
                maxx = a[i];
                index = i;
            }
        }
        if(maxx<n)
            break;
        for(int i=0;i<n;i++)
        {
            if(i==index)
                a[i] = maxx%n;
            else
                a[i]+= maxx/n;

        }

        ans+=maxx/n;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
# AOJ 0052: Factorial II
# Python3 2018.6.15 bal4u

pow5 = [1, 5, 25, 125, 625, 3125, 15625, 78125]

while True:
	n = int(input())
	if n == 0: break
	ans, i = 0, 1
	while n >= pow5[i]:
		ans += n // pow5[i]
		i += 1
	print(ans)


Measured memory_bytes: 5596
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << "=" << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n); inn(k);
    int a[n]; rep(i, n) in(a[i]);
    std::sort(a, a + n);

    bool dp[k + 1];

    rep(i, k + 1) {
        bool x = 0;
        rep(j, n) {
            if (a[j] > i) break;
            x |= !dp[i - a[j]];
        }
        dp[i] = x;
    }

    dp[k] ? puts("First") : puts("Second");
}

int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)
#define PC __builtin_popcountll
#define BL(a) (a ? 64 - __builtin_clzll(a) : 0)

int main() {
	IN(int, n);
	IN(string, a);
	
	vector<int> v;
	inc(b, 1 << n) {
		if(a[b] == '0') { v.PB(b); }
		if(a[b] != '1') {
			inc(i, n) {
				if(bit(b, i) == 1) { continue; }
				int c = b | (1 << i);
				if(a[c] == '1') { OUT("Impossible"); exit(0); }
				a[c] = '2';
			}
		}
	}
	
	vector<int> w;
	RF(b, v) {
		vector<int> p;
		inc(i, n) { if(bit(b, i) == 1) { p.PB(2 * i); } }
		
		vector<int> x;
		inc(k, SI(p)) {
			if(k == 0) { x.PB(p[0]); }
			else {
				int c = SI(x);
				x.PB(p[k]);
				dec(i, c) { x.PB(x[i] ^ 1); }
				x.PB(p[k] ^ 1);
			}
		}
		RF(e, x) { w.PB(e); }
	}
	
	vector<pair<int, int>> ans = { { 0, 0 } };
	RF(e, w) {
		inc1(i, e / 2) { ans.EB(i, 0); }
		if(e % 2 == 0) {
			ans.EB(e / 2 + 1, 0);
			ans.EB(e / 2 + 1, 1);
			ans.EB(e / 2 + 0, 1);
			ans.EB(e / 2 + 0, 0);
		} else {
			ans.EB(e / 2 + 0, 1);
			ans.EB(e / 2 + 1, 1);
			ans.EB(e / 2 + 1, 0);
			ans.EB(e / 2 + 0, 0);
		}
		dec(i, e / 2) { ans.EB(i, 0); }
	}
	
	OUT("Possible");
	OUT(SI(ans) - 1);
	RF(e, ans) { OUT(e.FI, e.SE); }
}


Measured memory_bytes: 656
n=input()
b = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
for i in range(0, len(a)):
  ans += min(a[i], b[i])
  rem = a[i] - b[i]
  # print(rem)
  temp = max(0, min(rem, b[i + 1]))
  ans += temp
  b[i + 1] -= temp
print(ans)

Measured memory_bytes: 19116
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 2e5 + 5;
vector<int> adj[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    ll ans = 0;
    for(int i = 0; i<n; i++){
        ans += (i + 1)*(n - i);
    }
    for(int i = 0; i<n-1; i++){
        ll u,v;
        cin>>u>>v;
        u--;
        v--;
        ll l = min(u,v);
        ll r = max(u,v);
        ans -= (l + 1)*(n - r);
    }
    cout<<ans;
}

Measured memory_bytes: 8340
#include<bits/stdc++.h>
#define R register int
#define G if(++ip==ie)if(fread(ip=buf,1,SZ,stdin))
using namespace std;
const int SZ=1<<19,N=1e5+9,M=2*N;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
inline int in(){
    G;while(*ip<'-')G;
    R x=*ip&15;G;
    while(*ip>'-'){x*=10;x+=*ip&15;G;}
    return x;
}
int he[N],ne[M],to[M],f[N],a[N],b[N];
int Getf(R x){
    return x==f[x]?x:f[x]=Getf(f[x]);
}
void Dfs(R x,R op){
    a[x]=op;
    for(R y,i=he[x];i;i=ne[i])
        if((y=to[i])!=f[x])
            f[y]=x,Dfs(y,-op),a[x]+=a[y];
}
int main(){
    R n=in(),m=in(),rt=1,re=1,p=0,ans=0;
    for(R i=1;i<=n;++i)f[i]=i;
    for(R p=0,i=1;i<=m;++i){
        R x=in(),y=in();
        if(Getf(x)!=Getf(y))f[f[x]]=f[y];
        else{rt=x,re=y;continue;}//把多的边单独拿出来
        ne[++p]=he[x];to[he[x]=p]=y;
        ne[++p]=he[y];to[he[y]=p]=x;
    }
    f[rt]=0;Dfs(rt,1);
    if(n==m){//基环树
        for(R x=re;x;x=f[x])b[++p]=a[x];
        if(p&1){//奇环
            if(a[rt]&1)return puts("-1"),0;
            for(R x=re;x;x=f[x])a[x]-=a[rt]>>1;
        }
        else{//偶环
            if(a[rt])return puts("-1"),0;
            sort(b+1,b+p+1);
            for(R x=re;x;x=f[x])a[x]-=b[p>>1];
        }
    }//树
    else if(a[rt])return puts("-1"),0;
    for(R i=1;i<=n;++i)ans+=abs(a[i]);
    return cout<<ans<<endl,0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
int main() {
    double a,b,c,d,e,f;
    double x,y;
    while (cin >> a >> b >> c >> d >> e >> f) {
        
        y=(a*f-c*d)/(a*e-b*d);
        x=(c-b*y)/a;
        printf("%.3f %.3f\n",x,y);
    }
}



Measured memory_bytes: 3200
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	int A, B;

	cin >> A >> B;

	string S[105];
	for (int i = 0; i < 100; i++) {

		for (int j = 0; j < 50; j++)S[i].push_back('#');
		for (int j = 0; j < 50; j++)S[i].push_back('.');

	}

	int x = 1, y = 1, z = 1;
	while (1) {

		if (x + 1 > A)break;

		S[z - 1][(y - 1) * 2] = '.';

		x++;
		y++;
		if (y == 26) {

			y = 1;
			z += 2;

		}

	}
	x = 1;
	y = 1;
	z = 1;
	while (1) {

		if (x + 1 > B)break;

		S[z - 1][(y - 1) * 2 + 51] = '#';

		x++;
		y++;
		if (y == 26) {

			y = 1;
			z += 2;

		}

	}

	cout << "100 100" << endl;
	for (int i = 0; i < 100; i++)cout << S[i] << endl;

	return 0;
}

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

using namespace std;

#define ll long long

void solve(){

    string str; cin >> str;
    ll val = 0;
    for(char c : str) val += c-'0';

    cout << (val % 9 == 0 ? "Yes" : "No") << "\n";

    return;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	solve();

	return 0;
}



Measured memory_bytes: 3668
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
        String s[] = a.split("");
        char[] c = a.toCharArray();
        int i;
        int count = 0;
        int check = 0;
        if(!s[0].equals("A")){
          System.out.println("WA");
          System.exit(0);
        }
        for(i = 1;i < a.length(); i++){
          if(Character.isUpperCase(c[i])) {
   			 count += 1;
		  }
          if(s[i].equals("C") && i > 1 && i < a.length() - 1){
             check += 1;
          }
        }
        if(count == 1 && check == 1){
          System.out.println("AC");
          System.exit(0);
        }
		
 		System.out.println("WA");
    }
}

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

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin >> a.at(i);
  }
  int ans=0,cnt;
  
  cnt = 0;
  for(int i=0;i<m;i++){
    for(int j=0;j<x;j++){
      if( a.at(i) == j){
        cnt++;
      }
    }
  }
  ans = cnt;
  cnt = 0;
  for(int i=0;i<m;i++){
    for(int j=x+1;j<n;j++){
      if( a.at(i) == j){
        cnt++;
      }
    }
  }
  ans = min(ans,cnt);
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 256