akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

int main(){
  long N, K;
  cin >> N >> K;
  long R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;

  map<char, int> points;

  points['r'] = P;
  points['p'] = S;
  points['s'] = R;
  
  long ans = 0;

  rep(i, N) ans += points[T[i]];

  rep(i, K){
    int j = i + K;
    int same = 0;

    while(j < N){
      if((T[j - K] == T[j]) && (same == 0)){
		ans -= points[T[j]];
		same = 1;
      } else{
		same = 0;
      }
      j += K;
    }
  }

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

Measured memory_bytes: 512
from collections import deque

def bfs():
    q = deque()
    q.append(1)
    ans = [0] * n
    i = 0
    while q:
        p = q.popleft()
        ans[p - 1] = c[i]
        i += 1
        for j in G[p]:
            if ans[j - 1] == 0:
                q.append(j)
    return ans

n = int(input())
G = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
c = list(map(int, input().split()))
c.sort(reverse = True)
s = sum(c) - c[0]
ans = bfs()
print(s)
print(*ans)

Measured memory_bytes: 12008
MOD = 10**9+7
n = int(input())
s1 = input()
s2 = input()
res = 1
skip = False
for i in range(n):
    if skip:
        skip = False
        continue
    if i == 0:
        if s1[i] != s2[i]:
            res *= 3 * 2
            skip = True
        else:
            res *= 3
        res %= MOD
    else:
        if s1[i] != s2[i]:
            if s1[i-1] != s2[i-1]:
                res *= 3
            else:
                res *= 2
            skip = True
        else:
            if s1[i-1] != s2[i-1]:
                pass
            else:
                res *= 2
        res %= MOD
print(res)

Measured memory_bytes: 9156
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants ---------- */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    string S;
    cin >> S;

    ll esum[N+1];
    ll wsum[N+1];
    fill(esum, esum + N+1, 0);
    fill(wsum, wsum + N+1, 0);

    for (ll i = 0; i < N; i++) {
        if (S[i] == 'W') {
            wsum[i+1] = wsum[i] + 1;
            esum[i+1] = esum[i];
        } else {
            esum[i+1] = esum[i] + 1;
            wsum[i+1] = wsum[i];
        }
    }

    ll ret = INF;

    for (int i = 0; i < N; i++) {
        if (i == 0) {
            ret = min(ret, esum[N] - esum[1]);
            continue;
        }

        if (i == N - 1) {
            ret = min(ret, wsum[N-1]);
            continue;
        }

        ret = min(ret, wsum[i] + esum[N] - esum[i+1]);
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 5380
#include<stdio.h>

main(){
	int a, b;
	
	scanf("%d%d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include<utility>    //pair
#include<vector>
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm> //find的&#22836;文件  string用find的&#26102;候会返回字符串的首地址
#include<iterator>
#include<string.h>
#include<deque>   //双向添加数字的数&#32452;  可以&#21024;除或者添加第一个
#include<queue>
#include<set>      //&#24635;&#35273;得没有什&#20040;用&#22788;  无重&#22797;的
#include<list>    //不支持随机&#35775;&#38382;  即缺少下&#26631;
#include<map>       //数据&#31867;型很方便 但是会自己排好序  而且不会有重&#22797;的元素
using namespace std;
int cost[1005][1005];
int mincost[1005];
bool used[1005];
const int INF=10000000;
int d[1005],flag;
int main()
{
    int V,m,a,b,c,t;
    while(cin>>V>>m)
    {
        for(int i=0;i<1005;i++)
            for(int j=0;j<1005;j++)
                cost[i][j]=INF;

        if(V==m&&m==0)
            break;
        flag=0;
        for(int i=0;i<m;i++)
        {

            cin>>a>>b>>c;
            cost[a][b]=c;
            cost[b][a]=c;

        }
        for(int i=1;i<=V;i++)
        {
            mincost[i]=INF;
            used[i]=false;
        }
        mincost[1]=0;
        while(true)
        {
            int v=-1;
            for(int u=1;u<=V;u++)
            {
                if(!used[u]&&(v==-1||mincost[u]<mincost[v]))
                    v=u;
            }
            if(v==-1)
                break;
            used[v]=true;
            d[flag]=mincost[v];flag++;
            for(int u=1;u<=V;u++)
            {
                mincost[u]=min(mincost[u],cost[v][u]);
            }

        }
        sort(d,d+flag);
        cout<<d[V/2]<<endl;

    }

    return 0;
}

Measured memory_bytes: 5136
N = int(input())
A = list(map(int,input().split()))
answer = 1
if not 0 in A:
    for i in A:
        answer = answer * i
        if answer > 10**18:
            print("-1")
            break
    if answer <= 10**18:
        print(answer)
else:
    print("0")

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


int main(){

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

    ll n, l;
    cin >> n >> l;

    vector<ll> a(n);
    ll rope = 0;
    rep(i, n) {
        cin >> a[i];
        rope += a[i];
    }

    int pos = -1;
    for(int i = 0; i < n-1; ++i){
        if(a[i] + a[i+1] >= l){
            pos = i;
            break;
        }
    }
    if(pos == -1){
        ppp("Impossible");
        return 0;
    }

    ppp("Possible");
    for(ll i = 0; i < pos; ++i){
        rope -= a[i];
        ppp(i+1);
    }
    for(ll i = n-1; i > pos; --i){
        rope -= a[i];
        ppp(i);
    }

    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

int main() {
	int N;
	long long int l[89];
	cin >> N;
	l[0] = 2; l[1] = 1;
	for (int i = 2; i <= N; i++) {
		l[i] = l[i-1] + l[i - 2];
	}
	cout << l[N] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#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 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

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

// Iterator
// v.begin
// v.end

int main() {
    long long N;
    long long ans=0;
    cin >> N;

    vector<long long>A(N),B(N),C(N);

    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }
    rep(i,N){
        cin >> C[i];
    }

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    for(int i=0; i<N; i++){
        auto itr_a = A.end();
        auto itr_c = C.end();

        itr_a = lower_bound(A.begin(),A.end(),B[i]);
        itr_c = upper_bound(C.begin(),C.end(),B[i]);

        if(itr_c==C.end()){
            continue;
        }
        ans+=(C.end()-itr_c)*(itr_a-A.begin());
    }

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



Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    ll a, b, c;
    cin >> a >> b >> c;
    ll d0,d1,d2;
    for(int i = 0 ; i < (int)1e6 + 9; i ++ ){
        if(a%2 == 1 || b % 2 == 1 || c % 2 == 1){
            cout << i;
            return 0;
        }
        d0=a/2;
        d1=b/2;
        d2=c/2;
        a=d1+d2;
        b=d0+d2;
        c=d0+d1;
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#ABC 087 B - Coins
import math
s = 0 #払い方の総数
a = int(input()) #500円玉の枚数
b = int(input()) #100円玉の枚数
c = int(input()) #50円玉の枚数
x = int(input()) #払うべき総額

while x >= 0 and a>=0 :
    s += max(0, min(b, math.floor(x/100))-max(0,math.ceil((x-50*c)/100))+1)
    a -= 1
    x -= 500
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n) cin>>a[i];
    rep(i, n) cin>>b[i];
    priority_queue<ll> que;
    ll now = 0;
    rep(i, n){
        if(a[i]<b[i]) now += b[i]-a[i];
        else  que.push(a[i]-b[i]);
    }
    while(!que.empty()){
        if(now<=0) break;
        ll tmp = que.top();
        que.pop();
        now -= tmp;
    }
    int ans = n-que.size();
    if(now > 0) ans = -1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2936
#include<iostream>
using namespace std;
int main(){
	int i,n,c=0,m=0;
	string s;
	cin >>n;
	cin >>s;
	for(i=0;i<=n;i++){
		if (s[i]=='A'&& s[i+1]=='B' && s[i+2]=='C') m++;
    }
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

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


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    //ll n,div,rem,fived;
    string s;
    cin>>s;
    if(s=="SAT")
        cout<<1<<endl;
    else if(s=="SUN")
        cout<<7<<endl;
    else if(s=="MON")
        cout<<6<<endl;
    else if(s=="TUE")
        cout<<5<<endl;
    else if(s=="WED")
        cout<<4<<endl;
    else if(s=="THU")
        cout<<3<<endl;
    else if(s=="FRI")
        cout<<2<<endl;


    return 0;
}





Measured memory_bytes: 3592
// author: gary
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ( (int) (x).size() )
const int N = 212345;

char S[N];

long long ans;

int cnt[N];

int main() {
  while(scanf("%s", S) != EOF) {
    int n = strlen(S);
    ans = 1;
    memset(cnt, 0, sizeof cnt);
    for(int i = 0; i < n; i++) {
      cnt[S[i]-'a']++;
      ans += 1LL * (i + 1 - cnt[S[i]-'a']);
    }
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int n = s.length();

        if (!isPalindrome(s)) {
            System.out.println("No");
            return;
        }
        if (!isPalindrome(s.substring(0, (n - 1) / 2))) {
            System.out.println("No");
            return;
        }
        if (!isPalindrome(s.substring((n + 3) / 2 - 1, n))) {
            System.out.println("No"); 
            return;
        }

        System.out.println("Yes");
    }

    public static boolean isPalindrome(String s) {
        int l = 0, r = s.length() - 1;
        while (l < r) {
            if (s.charAt(l) != s.charAt(r)) {
                return false;
            }
            l++; r--;
        }
        return true;
    }
}


Measured memory_bytes: 23380
import java.util.*;
import java.util.Map.Entry;

public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		
		Map<String, PriorityQueue<Integer>> index = new TreeMap<String, PriorityQueue<Integer>>();
		int page;
		String word;
		while(sc.hasNext()) {
			word = sc.next(); page = sc.nextInt();
			if(index.containsKey(word)) {
				index.get(word).offer(page);
			} else {
				PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
				pq.offer(page);
				index.put(word, pq);
			}
		}
		
		for(Entry<String, PriorityQueue<Integer>> entry : index.entrySet()) {
			System.out.println(entry.getKey());
			PriorityQueue<Integer> pq = entry.getValue();
			while(!pq.isEmpty()) {
				if(pq.size() == 1) {
					System.out.println(pq.poll());
				} else {
					System.out.print(pq.poll() +  " ");
				}
			}
		}
		
	}

}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		sc.close();

		if(N == 1 && M == 1) {
			System.out.print(1);
		} else if(N == 1 && 1 < M) {
			System.out.print(M-2);
		} else if(M == 1 && 1 < N) {
			System.out.print(N-2);
		} else {
			System.out.print((N-2)*(M-2));
		}
	}
	
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int n, r; cin >> n >> r;

	if(n >= 10){
		cout << r << endl;
	}else{
		cout << r + 100 * (10 - n) << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int main(){
    int n,d;
    cin>>n>>d;
    if(n%(2*d+1)!=0)
        cout << n / (2 * d + 1) + 1 << endl;
    else
        cout << n / (2 * d + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
s=int(input())
a=[]
a.append(s)

while 1:
    if s%2==0:
        s=s/2
        a.append(s)
    else:
        s=3*s+1
        a.append(s)
    if len(a)!=len(set(a)):
        print(len(a))
        exit()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;

int n, ans;
string s, t;
queue<int> q;

int main()
{
	cin >> n >> s >> t;
	
	if (s == t)
	{
		puts("0");
		return 0;
	}
	
	int up = n - 1, down = n - 1;
	
	while (down >= 0)
	{
		while (down && t[down - 1] == t[down]) --down;
		while (up >= 0 && (up > down || s[up] != t[down])) --up;
		if (up < 0)
		{
			puts("-1");
			return 0;
		}
		while (!q.empty() && q.front() - q.size() >= down) q.pop();
		q.push(up);
		if (up != down) ans = max(ans, (int)q.size());
		--down;
	}
	
	cout << ans + 1;
	
	return 0;
}

Measured memory_bytes: 6280
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    cin.tie(0);
    int n,c=0;
    cin >> n;
    vector<int> a(n),b(n);

    rep(i,n) {
        cin >> a[i];
        b[i]=a[i];
    }

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

    rep(i,n){
        if(a[i]!=b[i])
            c++;
    }

    if(c<=2){
        cout << "YES" << endl;
        return 0;
    } else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
  int N,X,i,c=0,p=0;
  cin >> N >> X;
  vector<int> L(N);
  for(i=0; i<N; i++)
    cin >> L.at(i);
  
  for(i=0; i<N; i++) {
    c = p+L.at(i);
    if(c>X)
      break;
    p = c;
  }
  
  cout << i+1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,count_w, count_m;
	while(cin >> m >> d){
		if(m == 0) return 0;
		
		count_m = 1;
		count_w = 3;
		while(1){
			for(int i=1; i<=month[count_m-1]; i++, count_w++){
				if(m==count_m && d==i) break;
			}
			if(m == count_m) break;
			count_m++;
		}
		cout << week[count_w%7] << endl;
	}
}

Measured memory_bytes: 0
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;

int digcnt(ll n){
    int dig = 0;
    while(n){
        n/=10;
        dig++;
    }
    return dig;
}

int main(){
        _
        ll n; cin >> n;
        ll ans = digcnt(n);

        for(ll a  = 1; a<=n/a; a++){
            if(n%a!=0)continue;
            ll b = n/a;
            //cout<<a<<' '<<b<<endl;
            ll chek = max(digcnt(a), digcnt(b));
            ans = min(ans, chek);
            //cout<<ans<<endl;
        }
        cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    string s;
    int t = 0,h = 0;
    int a,b,c;
    while(scanf("%d,%d,%d",&a,&b,&c)+1){
        if(a * a + b * b == c * c) t++;
        else if(a == b) h++;
    }
    cout << t << endl;
    cout << h << endl;
}





Measured memory_bytes: 3236
#include <iostream>
using namespace std;
int H,W;
char map[1001][1001];
long long int DP[1001][1001]={};

const long long int LIMIT=1e9+7LL;

void solve(){
	DP[0][1]=1;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(map[i][j]=='.')DP[i][j]=(DP[i-1][j]%LIMIT+DP[i][j-1]%LIMIT)%LIMIT;
		}
	}
}


int main(){
	cin>>H>>W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin>>map[i][j];
		}
	}
	solve();
	cout<<DP[H][W]<<"\n";	
	return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<string>
using namespace std;
int main()
{
    // 入力
    int n;
    cin >> n;

    int count = 0;
    int fst_B = 0;
    int lst_A = 0;
    int fBlA = 0;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < s.length()-1; j++) {
        if(s[j] == 'A' && s[j+1] == 'B')
          count++;
      }
      if(s[0] == 'B')
        fst_B++;
      if(s[s.length()-1] == 'A')
        lst_A++;
      if( (s[0] == 'B') && (s[s.length()-1] == 'A') )
        fBlA++;
    }
  
    // 出力
    int m;
    if (fst_B > lst_A)
      m = lst_A;
    else if (fst_B < lst_A)
      m = fst_B;
    else
      if (fst_B == fBlA)
        m = fst_B <= 0 ? 0 : fst_B - 1;
      else
        m= fst_B;
  
    cout << count + m << endl;
 
    return 0;
}


Measured memory_bytes: 256
S = input()

if S[0] == "A":
    if S[2:-1].count("C") == 1:
        index = S.index("C")
        S = S[1:index] + S[index+1:]
        if S.islower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

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

using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector< vector<int> > sw(m);
    int k;
    for (int i = 0; i < m; i++) {
        cin >> k;
        int s;
        for (int j = 0; j < k; j++) {
            cin >> s;
            sw[i].push_back(s);
        }
    }

    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }

    long long int ans = 0;

    for (long long int i = 0; i < (1<<n); i++) {
        vector<int> p2(m,0);
        for (long long int j = 0; j < n; j++) {
            if (((1<<j) & i )!= 0) {
                for (int ii = 0; ii < m; ii++) {
                    for (int jj = 0; jj < sw[ii].size(); jj++) {
                        if (sw[ii][jj] == j+1) {
                            p2[ii]++;
                            p2[ii] %= 2;
                        }
                    }
                }
            }
        }
        bool h = true;
        for (int j = 0; j < m; j++) {
            if (p[j] != p2[j]) {
                h = false;
            }
        }
        if (h) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}
const int MAXN = 1e5;
ll n, a, b;
ll x[MAXN];
void solve() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i)
		cin >> x[i];
	ll ans = 0;
	for (int i = 0; i + 1 < n; ++i) {
		ans += min(a * (x[i + 1] - x[i]), b);
	}
	cout << ans << endl;
}
int main() {
	solve();
	return 0;
}



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

int main()
{
    string s;
    cin>>s;
    string q = "";
    for(int i = 0 ; i<s.size() ; ++i)
    {
        if(i%2==0) q+=s[i];
    }
    cout<<q<<endl;
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N;
ll A[105];

void out() {
    REP(i, N - 1) {
        cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
}

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    out();
    FOR(i, N, 1) {
        ll v = A[i];
        ll j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        out();
    }
    return 0;
}


Measured memory_bytes: 3088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		
		int[] A = new int[N];
		for(int i=0; i<N; i++){
			A[i] = sc.nextInt();
		}
		
		int temp;
		int swap = 0;
		for(int i=1; i<N; i++){
			for(int j=N-1; j>=i; j--){
				if(A[j] < A[j-1]){
					temp = A[j];
					A[j] = A[j-1];
					A[j-1] = temp;
					swap++;
				}
			}
		}

		for(int i=0; i<N; i++){
			System.out.print(A[i]);
			if(i != N-1){
				System.out.print(" ");
			}
		}
		System.out.println();
		
		System.out.println(swap);
	}
	
	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

int n;
pair<int, int> a[100000];

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}

	sort(a, a + n);

	for (int i = 0; i < n - 1; i++)
		cout << a[i].second << " ";
	cout << a[n - 1].second << endl;

	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int a,b;
  cin>>a>>b;
  string S="x";
  if(a+b==15) S="+";
  if(a*b==15) S="*";
  cout<<S;
return 0;}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef pair<int,int> pii;
const int inf = 1e18;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int fat[MAXN];
int inv[MAXN];

int C(int n,int k){
	int p=1;
	for(int i=n;i>=n-k+1;i--){
		p = (p*i)%M;
	}
	p = mod(p*inv[k],M);
	return p;
}

int32_t main(){
	fastio;
	fat[0] = inv[0] = 1;
	for(int i=1;i<MAXN;i++){
		fat[i] = (fat[i-1]*i)%M;
	}
	inv[MAXN-1] = exp(fat[MAXN-1],M-2,M);
	for(int i=MAXN-2;i>=1;i--){
		inv[i] = (inv[i+1]*(i+1))%M;
	}
	
	int n,a,b;
	cin>>n>>a>>b;
	int res=exp(2,n,M) - 1;
	res-=C(n,a);
	res = mod(res,M);
	res-=C(n,b);
	res = mod(res,M);
	cout<<res<<endl;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
#include <vector>
#define re(i,n) for(int i = 0; i < n; i++)

int main() {
    long long a, b, c, d;
    long long max = -1000000000000000000;

    cin >> a >> b >> c >> d;
    
    if (a * c  > max) max = a * c;
    if (a * d > max ) max = a * d;
    if (b * c > max) max = b * c;
    if (b * d > max) max = b * d;

    
    cout << max << endl;

    
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
	int mt[10];

	for(int i=0; i<10; i++){
		do{
			scanf("%d", &mt[i]);
		}while(mt[i]<1 && mt[i]>10000);
	}

	for(int i=0; i<9; i++){
		for(int j=i; j<10; j++){
			int tmp;
			if(mt[i]<mt[j]){
				tmp = mt[i];
				mt[i] = mt[j];
				mt[j] =tmp;
			}
		}
	}

	for(int i=0; i<3; i++)
		printf("%d\n",mt[i]);

	return 0;
}

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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            int n = 0;
            string marks = Console.ReadLine();

            for(int i = 0;i < 4;i++)
            {
                if (marks[i] == '+') n++;
                else n--;
            }

            Console.WriteLine(n);
        }
    }

    struct Vector2
    {
        public Vector2(int x,int y)
        {
            this.x = x;
            this.y = y;
        }
        public int x;
        public int y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    double a,b,x;
    cin >> a >> b >> x;

    if(2*x/a/a < b){
        printf("%.7lf",atan(a*b*b/2/x)*180/M_PI);
    }
    else{
        printf("%.7lf",atan(2*(b-x/a/a)/a)*180/M_PI);
    }

    

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s;
  s.resize(N);
  for(int i=0; i<N; ++i) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  
  std::string prev = "";
  long long ans = 0;
  long long count = 1;
  for (int i = 0; i < N; ++i) {
    if (i < (N - 1) && s[i + 1] == s[i]) count++;
    else {
      if (count > 1) {
        ans += (count * (count - 1)) / 2;
      }
      count = 1;
    }
    prev = s[i];
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = (int)5e3 + 1, mod = (int)1e9 + 7;
inline int mod_inv(int x) {
	return x <= 1 ? x : mod - (int)(mod / x * (LL)mod_inv(mod % x) % mod);
}
int n, perm[maxn], dsu[maxn];
bool sp[maxn];
int dsu_find(int x) {
	return dsu[x] < 0 ? x : (dsu[x] = dsu_find(dsu[x]));
}
void dsu_merge(int u, int v) {
	u = dsu_find(u);
	v = dsu_find(v);
	if(u == v)
		return;
	if(dsu[u] < dsu[v])
		swap(u, v);
	dsu[v] += dsu[u];
	sp[v] |= sp[u];
	dsu[u] = v;
	sp[u] = 0;
}
int dp[maxn];
int main() {
	scanf("%d", &n);
	memset(dsu + 1, -1, n * sizeof(int));
	memset(sp + 1, 0, n * sizeof(bool));
	for(int i = 1; i <= n; ++i) {
		scanf("%d", perm + i);
		if(perm[i] != -1) {
			dsu_merge(i, perm[i]);
		} else {
			sp[dsu_find(i)] = 1;
		}
	}
	int ans = 0, cnt = 0, ivs = mod_inv(n - 1);
	dp[0] = 1;
	for(int i = 1; i <= n; ++i) {
		if(dsu_find(i) != i)
			continue;
		ans = (ans + 1) % mod;
		if(!sp[i])
			continue;
		int sz = -dsu[i];
		++cnt;
		ans = (ans - (LL)(n - sz) * ivs) % mod;
		dp[cnt] = 0;
		for(int j = cnt; j > 0; --j)
			dp[j] = (dp[j] + (LL)dp[j - 1] * sz) % mod;
	}
	int prd = ivs;
	for(int i = 2; i <= cnt; ++i) {
		prd = (LL)prd * ivs % mod * (i - 1) % mod;
		ans = (ans + (LL)prd * dp[i]) % mod;
	}
	ans = (n - ans) % mod;
	for(int i = 1; i <= cnt; ++i)
		ans = (LL)ans * (n - 1) % mod;
	printf("%d\n", ans < 0 ? ans + mod : ans);
	return 0;
}

Measured memory_bytes: 3892
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[114514];
int x,y,n;
int main(){
	scanf("%s",s+1);
	x=y=n=strlen(s+1);
	for(int i=1;i<=n;++i)if(s[i]=='1')x=min(x,max(i-1,n-i));else
	y=min(y,max(i-1,n-i));
	printf("%d",max(x,y));
	return 0;
}

Measured memory_bytes: 1832
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[2];
  for(int j=0;j<2;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  bool f=false;
  
  
  for(int i=0;i<4;i++){
    d[1].roll('R');
    for(int j=0;j<4;j++){
      d[1].roll('N');
      if(same(d[0],d[1])) f=true;
    }
  }
  d[1].roll('E');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }

  d[1].roll('W');
  d[1].roll('W');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
  
  cout << (f?"Yes":"No") << endl;
  return 0;
}



Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter

# stdin = open("sample.txt")

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

if c-a-b < 0:
    print("No")
else:
    if 4*a*b < (c-a-b)**2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3444
#include <cstdio>
#include <cstring>
#define HW_MAX 300

void
set_line(char* s, int w)
{
  std::memset(s, '#', w);
  s[w] = '\0';
  return;
}

int
main(void)
{
  int h, w, i;
  char s[HW_MAX + 1];
  
  while (std::scanf("%d %d", &h, &w) != EOF) {
    if (h == 0 && w == 0) {
      break;
    }

    set_line(s, w);
    for (i = 0; i < h; i++) {
      std::printf("%s\n", s);
    }
    std::printf("\n");
  }
  
  
  return 0;
}



Measured memory_bytes: 2552
#include <iostream>
using namespace std;
int main() {
    int x,count;
    cin >> x;
    long long int i,y=x;
    while (1) {
        count = 0;
        for (i=2; i <= y / 2; i++) {
            if (y % i != 0) {
                count++;
            }
        }
        if (count == (y / 2)-1) {
            cout << y << endl;
            break;
        }
        y++;
    }
}

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


def main():
    from itertools import accumulate

    n = int(input())
    # 大きさを基準に昇順で並び替えておく
    a = sorted(list(map(int, input().split())))
    sum_a = list(accumulate([0] + a))
    # 色は最大でN種類
    ans = [False for _ in range(n)]
    # 初期化：最も大きいモンスターは，確実に最後まで生き残る
    ans[n - 1] = True

    # KeyInsight
    # あるモンスターiが最後まで残る
    # =吸収を繰り返していき，自分の2倍以上大きなモンスターが存在しないことを満たす，と言い換える
    # サイズの大きなモンスターから順に判定
    for i in range(n - 2, -1, -1):
        if a[i + 1] <= 2 * a[i]:
            if ans[i + 1]:
                ans[i] = True
        # サイズの小さいモンスターjは，事前に自分より小さいモンスターを全て吸収しておく
        # それからモンスターjとモンスターj+1のサイズを比較
        elif a[i + 1] <= 2 * sum_a[i + 1]:
            if ans[i + 1]:
                ans[i] = True
        else:
            ans[i] = False

    print(sum(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14480
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    if(n>=100) cout<<"ABC"<<n<<endl;
    else if(n<100 && n>9) cout<<"ABC0"<<n<<endl;
    else cout<<"ABC00"<<n<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll x[100100], l[100100];

vector<pair<ll,ll>> vec;

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

  REP(i, n) {
    cin >> x[i] >> l[i];
    vec.push_back(make_pair(x[i]+l[i], i));
  }
  sort(vec.begin(), vec.end());
  int ans = n;
  int last = 0;
  for(int v = 1; v < n; v++) {
    if(vec[last].first > x[vec[v].second] - l[vec[v].second]) {
      
      ans--;
      //      cout << "x " << v << endl;
    } else {
      last = v;
    }
  }
  cout <<ans << endl;
    
  
}


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

using namespace std;

#define SZ(x) ((int) (x).size())

int n;
int c0, c1, c2;

int solve() {
    if (c0 > c2 + 1)
        return 0;
    if (c1 > 0) {
        return c2 >= c0;
    }
    return 1;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int x, c = 0;
        scanf("%d", &x);
        while (x > 0 && x % 2 == 0) {
            x /= 2;
            c++;
        }
        c = min(c, 2);

        if (c == 2) c2++;
        if (c == 1) c1++;
        if (c == 0) c0++;
    }
    puts(solve() ? "Yes" : "No");
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// numerous {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// systems }}} 2

// }}} 1

int main() {

    char s[100000];
    bool a[400];

    scanf("%s", s);

    Rep(i, strlen(s) ){
        a[s[i]] = 1;
    }

    int i = 'a';
    while( i <= 'z' + 1 ){
            //printf ("%c\n", i+'a');
        if( i == 'z'+ 1 ){
            printf ("None\n");
            break;
        }
        if(!a[i])  {
            printf ("%c\n", i);
            break;
        }
        i++;
    }

    return 0;
}



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

using namespace std;

const long long base = 1ll << 57;
const int LOG = 60;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector<long long> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    x[i] += base;
  }
  long long ans = 0;
  for (int i = LOG - 1; ~i; --i) {
    bool parity = false;
    for (int j = 0; j < n; ++j) {
      long long w = ans + (1ll << i) - y[j];
      if (w >= 0 && w <= x[j] && (w & x[j]) == w) {
        parity = !parity;
      }
    }
    if (parity) {
      ans += 1ll << i;
    }
  }
  cout << ans - base << "\n";
  return 0;
}


Measured memory_bytes: 1920
while 1:
    n = int(input())
    m = int(input())
    if n == 0:
        break

    data = []
    friend = []
    for _ in range(m):
        a, b = map(int, input().split())
        if a == 1:
            friend.append(b)
        else:
            data.append([a, b])

    friendfriend = []
    for d in data:
        if d[0] in friend:
            friendfriend.append(d[1])
        elif d[1] in friend:
            friendfriend.append(d[0])

    friend.extend(friendfriend)
    friend = list(set(friend))
    print(len(friend))


Measured memory_bytes: 6816
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    string a, b, c;

    cin >> a >> b >> c;

    cout << a[0] << b[0] << c[0] << endl;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long a,b,k;
	cin>>a>>b>>k;
	
	
	if(k>=a)
	{
		cout << 0 << " ";
		k-=a;
		cout << max(b-k,0LL);
	}
	else cout << a-k << " " << b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define MAXN 100000 + 100
int a[MAXN];

int main() {
    int n, num, cnt = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &num);
        a[num]++;
        if(a[num] > 1)  cnt++;
    }
    if(cnt % 2 == 0)
        printf("%d\n", n - cnt);
    else
        printf("%d\n", n - cnt - 1);
    return 0;
}


Measured memory_bytes: 512
<?php
list($r, $g, $b, $n) = ints();
$cnt = 0;
for ($i = 0; $i <= intdiv($n, $r); ++$i)
    for ($j = 0; $j <= intdiv($n - $r * $i, $g); ++$j)
        if (($n - $r * $i - $j * $g) % $b === 0) ++$cnt;
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main() {
  int N, A, B;
  cin >> N;
  vector<int> v;
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort (v.begin(), v.end());
  reverse (v.begin(), v.end());
  A=B=0;
  for (int i=0; i<N; i+=2) A+=v.at(i);
  for (int i=1; i<N; i+=2) B+=v.at(i);
  cout << A-B << endl;
}


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

#define N 1000000

int cnt = 0;

void insertionSort(int *A, int n, int g) {
    int i, j, v;
    for (i = g; i < n; i++) {
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

int main(){

    int A[N], G[N], n, i, j, m, g;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    m = 1;
    for (g = 1; g * 3 + 1 < n; g = g * 3 + 1, m++);
    
    
    for (i = 0; i <= m - 1; i++) {
        G[i] = g;
        insertionSort(A, n, g);
        g = (g - 1) / 3;
    }
    
    printf("%d\n", m);
    
    for (i = 0; i < m - 1; i++) {
        printf("%d ", G[i]);
    }
    printf("%d\n%d\n", G[i], cnt);
    
    for (i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }

    return 0;
}



Measured memory_bytes: 5652
n,a,b=map(int,input().split())
h=[int(input()) for _ in range(n)]
c=a-b

ok=10**9
ng=0

while ok-ng>1:
    cen=(ok+ng)//2
    cnt=0

    for hh in h:
        hh-=b*cen

        cnt+=max(0,(hh+c-1)//c)
    
    if cnt<=cen:
        ok=cen
    else:
        ng=cen

print(ok)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  i64 a;
  double tb;
  cin >> a >> tb;
  int b = round(tb * 100);
  cout << (a * b) / 100 << endl;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = 998244353;
const ll INF = 1LL << 61;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

vec a(1010), memo(1010, -INF);
ll dfs(ll now){
    if(memo[now] != -INF) return memo[now];
    ll ans = a[now];
    for(ll i = now + 2; i < N; i += 2){
        ans = max(ans, a[now] + dfs(i));
    }
    memo[now] = ans;
    return ans;
}

int main(){
    cin>>N;
    rep(i,N) cin>>a[i];
    ll ans = -(1e+9) - 1, id = -1;
    rep(i,N){
        if(ans < dfs(i)){
            ans = dfs(i);
            id = i;
        }
    }
    cout<<ans<<endl;
    vec out(0);
    rep(i,id) out.push_back(1);
    ll sum = a[id], last = id, num = N - id;
    for(ll i = id + 2; i <= N; i += 2){
        if(ans == sum + memo[i]){
            rep(j, (i - last)/2) out.push_back((i - last)/2 + 1 - j);
            num -= i - last;
            last = i;
            sum += a[i];
        }
    }
    while(num > 1){
        out.push_back(num);
        --num;
    }
    cout<<out.size()<<endl;
    for(ll o : out) cout<<o<<endl;
}

Measured memory_bytes: 256