akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	while(true) {
	    int n = s.nextInt();
	    if(n==0) break;
	    int[] d = new int[n];
	    for(int i=0 ; i<n ; i++)
		d[i] = s.nextInt();
	    int[] t = new int[n];
	    int c = 0;
	    while(true) {
		c++;
		for(int i=0 ; i<n ; i++)
		    t[i] = count(d,i);
		if(same(d,t)) {
		    System.out.println(c-1);
		    for(int i=0 ; i<n-1 ; i++)
			System.out.print(d[i]+" ");
		    System.out.println(d[n-1]);
		    break;
		} else {
		    for(int i=0 ; i<n ; i++)
			d[i] = t[i];
		}
	    }
	}
    }
    static int count(int[] d,int i) {
	int t = d[i];
	int c = 0;
	for(int j=0 ; j<d.length ; j++) {
	    if(t==d[j])
		c++;
	}
	return c;
    }
    static boolean same(int[] a, int[] b) {
	if(a.length!=b.length) return false;
	for(int i=0 ; i<a.length ; i++) {
	    if(a[i]!=b[i])
		return false;
	}
	return true;
    }
}

Measured memory_bytes: 12000
N=int(input())

def div(n):
    table=[]
    for i in range(1,int(n**0.5)+1):
        if i*i>n:
            break
        if n%i==0:
            table.append(i)
            if n//i!=i:
                table.append(n//i)
    return table

ans=0
for i in range(1,N+1,2):
    if len(div(i))==8:
        ans+=1
        
print(ans)




Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(26,0));
    rep(i,0,n){
        string s;
        cin>>s;
        rep(j,0,s.length()){
            v[i][s[j]-'a']++;
        }
    }
    
    rep(i,0,26){
        int mi=INF;
        rep(j,0,n){
            mi=min(mi,v[j][i]);
        }
        
        rep(j,0,mi){
            cout<<(char)('a'+i);
        }
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < v.length; i++) {
			v[i] = sc.nextInt();
		}
		for (int i = 0; i < c.length; i++) {
			c[i] = sc.nextInt();
		}
		int result = calc(v, c, 0, 0);
		System.out.println(result);
	}
	
	public static int calc(int[] v, int[] c, int money, int i) {
		if (i >= v.length) {
			return money;
		} else {
			if (v[i] - c[i] > 0) {
				money += v[i] - c[i];
			}
			return calc(v, c, money, ++i);
		}
	}
}


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

int main(){
    int n, taro_points=0, hanako_points=0;
    string taro, hanako;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> taro >> hanako;
        if (taro == hanako){
            taro_points++;
            hanako_points++;
        } else if (taro < hanako){
            hanako_points+=3;
        } else {
            taro_points+=3;
        }
    }
    cout << taro_points << " " << hanako_points << endl;
    return 0;
}


Measured memory_bytes: 3192
// sandeep_007	

#include <bits/stdc++.h>
 
using namespace std;
 
#define PI acos(-1)
#define mod 1000000007
#define ll long long
#define nitro std::ios_base::sync_with_stdio (false); cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define vi vector < int >
#define INV 333333336

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b){
    return (a.second < b.second);
}

inline ll mx(ll a,ll b){
	if(a > b) return a;
	else return b;	
}

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

ll power(ll x,ll y,ll p){
    ll res = 1;   
    x = x % p;    
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; 
        x = (x*x) % p; 
    }
    return res;
}

int main(){
	nitro;

	#ifdef DBG
		freopen("in","r",stdin);
	#endif
	
	int n;
	cin >> n;
	ll A[n+1];
	for(int i=0;i<n;i++) cin >> A[i];
	int ans = 0;	
	while(1){
		int f = 0;	
		for(int i=0;i<n;i++){
			if(A[i]%2 == 0) f++;
		}
		if(f == n){
			ans++;			
			for(int i=0;i<n;i++) A[i] = A[i]/2;
		}
		else break;
	}	
	cout << ans << "\n";
	return 0;	
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		ArrayList<Pair<Integer,Integer>> robots=new ArrayList<>(n);

		for(int i=0;i<n;++i) {
			int x=s.nextInt(),l=s.nextInt();
			robots.add(new Pair<>(x+l,x-l));
		}
		robots.sort(null);
		//System.err.println(robots);

		TreeMap<Integer,Integer> map=new TreeMap<>();

		for(Pair<Integer,Integer> p:robots){
			SortedMap<Integer,Integer> sub=map.subMap(Integer.MIN_VALUE,p.b+1);
			if(sub.isEmpty()){
				map.merge(p.a,1,Integer::max);
			}else{
				map.merge(p.a,
						1+sub.values().stream().mapToInt(i->i).max().getAsInt(),
						Integer::max);
				sub.clear();
			}
			//System.err.println(map);
		}
		System.out.println(map.values().stream().mapToInt(i->i).max().getAsInt());
	}
}

class Pair<A extends Comparable<A>,B extends Comparable<B>> implements Comparable<Pair<A,B>>{
	A	a;
	B	b;

	public Pair(A A,B B){
		a=A;
		b=B;
	}
	public Pair(Pair<A,B> p){
		this(p.a,p.b);
	}

	public Pair<B,A> swapped(){
		return new Pair<>(b,a);
	}

	@Override
	public String toString(){
		return "P["+a+", "+b+"]";
	}

	@Override
	public int compareTo(Pair<A,B> o){
		int v=a.compareTo(o.a);
		if(v!=0)
			return v;
		return b.compareTo(o.b);
	}

	@Override
	public int hashCode(){
		return Objects.hashCode(a)*31+Objects.hashCode(b);
	}

	@Override
	public boolean equals(Object obj){
		if(this==obj) return true;
		if(!(obj instanceof Pair))
			return false;
		Pair<?,?> other=(Pair<?,?>)obj;
		return Objects.equals(a,other.a)&&Objects.equals(b,other.b);
	}
}


Measured memory_bytes: 103452
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
int get(int mx, int my, int x, int y)
{
	if (x == 0)return y;
	if (y == my)return x + my;
	if (x == mx)return mx + my + my - y;
	if (y == 0)return mx + my + mx + my - x;
	return -1;
}
int main()
{
	int mx, my, num;
	scanf("%d%d%d", &mx, &my, &num);
	vector<pii>vec;
	for (int i = 0; i < num; i++)
	{
		int za, zb, zc, zd;
		scanf("%d%d%d%d", &za, &zb, &zc, &zd);
		int a = get(mx, my, za, zb), b = get(mx, my, zc, zd);
		if (a != -1 && b != -1)vec.push_back(make_pair(a, i)), vec.push_back(make_pair(b, i));
	}
	sort(vec.begin(), vec.end());
	vector<int>now;
	for (int i = 0; i < vec.size(); i++)
	{
		if (!now.empty() && now[now.size() - 1] == vec[i].second)now.pop_back();
		else now.push_back(vec[i].second);
	}
	if (now.empty())printf("YES\n");
	else printf("NO\n");
}

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

#define endl '\n'

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(0);

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

int main() { BUFF
  ll a, b, c, k; cin >> a >> b >> c >> k;
  ll tot = min(a, k);
  k -= tot;
  k -= min(b, k);
  tot += -1*min(c, k);
  cout << tot << endl;
  return 0;
}


Measured memory_bytes: 3604
def gcd(a_, b_):
    while b_ != 0:
        a_, b_ = b_, a_ % b_
    return a_


def lcm(a_, b_):
    return a_ * b_ // gcd(a_, b_)


a, b, c, d = map(int, input().split())

c_count = b // c - (a-1) // c
d_count = b // d - (a-1) // d
cd_lcm = lcm(c, d)
cd_count = b // cd_lcm - (a-1) // cd_lcm

ans = 1 + b - a - (c_count + d_count - cd_count)
print(ans)


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

int main(){
    int n;
    cin>>n;
    vector<int>b(n-1);
    vector<int>a(n);

    for(int i=0;i<n-1;i++){
      cin>>b.at(i);
    }
    long int total=0;
    for(int i=1;i<n-1;i++){
        a.at(i)=min(b.at(i),b.at(i-1));
        total+=a.at(i);
    }
    total+=b.at(0)+b.at(n-2);
    cout<<total<<endl;
}

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

int solve() {
    int XMAX = 1e5;
    int N, M, x;
    cin >> N >> M;
    vector<int> cn(XMAX+1), cm(M);
    for ( int i = 0; i < N; i++ ) {
        cin >> x;
        cn[x]++;
        cm[x%M]++;
    }
    vector<int> odd(M);
    for ( int i = 1; i <= XMAX; i++ ) {
        if ( cn[i] & 1 ) odd[i%M]++;
    }
    int ans = 0;
    ans += cm[0] / 2;
    if ( (M & 1) == 0 ) {
        ans += cm[M/2] / 2;
    }
    for ( int i = 1; 2*i < M; i++ ) {
        int c1 = cm[i], c2 = cm[M-i];
        int o1 = odd[i], o2 = odd[M-i];
        if ( c1 < c2 ) {
            swap(c1, c2);
            swap(o1, o2);
        }
        if ( o1 >= c2 ) o1 -= c2;
        else if ( o1 > 0 && ((c2 - o1)%2 == 1) ) o1 = 1;
        else o1 = 0;
        ans += c2;
        c1 -= c2;
        ans += (c1 - o1) / 2;
    }
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1408
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
int main(void){
	int n;
	int total;
	double ave;
	while(1){
		cin>>n;
		if(n==0){
			break;
		}
		total=0;
		vector<int> a(n);
		ave=0.0;
		FOR(i,0,n-1){
			cin>>a[i];
			ave+=(double)a[i];
		}
		ave/=(double)n;

		FOR(i,0,n-1){
			if((double)a[i]<=ave){
				total++;
			}
		}

		cout<<total<<endl;


	}

}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%I64d", &x)
#define ss(s) scanf("%s", s)
#define pb push_back
#define em emplace_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1e9 + 7;
int epow(int base, int pow)
{
    int result = 1;
    while (pow)
    {
        if (!(pow % 2))
        {
            base = (base * base) % mod;
            pow /= 2;
        }
        else
        {
            result = (result * base) % mod;
            pow--;
        }
    }
    return result;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    si(n);
    double d = 2 * n * PI;
    cout << setprecision(20) << d;
}

Measured memory_bytes: 3884
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

void solve1() {
	int N;
	cin >> N;
	if (N / 10 == 9 || N % 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	solve1();
	return 0;
}

Measured memory_bytes: 256
#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;
ll n,r[50001],g[50001],b[50001],ans;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    cin>>s;
    s=' '+s;
    for(int i=1;i<=n;i++)
    {
        r[i]=r[i-1];
        g[i]=g[i-1];
        b[i]=b[i-1];
        if(s[i]=='R')
            r[i]++;
        if(s[i]=='G')
            g[i]++;
        if(s[i]=='B')
            b[i]++;
    }
    for(int j=2;j<n;j++)
        for(int k=j+1;k<=n;k++)
            if(s[j]!=s[k])
            {
                if(s[j]!='R'&&s[k]!='R')
                {
                    ans+=r[j-1];
                    if(j-(k-j)>0)
                        if(s[j-(k-j)]=='R')
                            ans--;
                }
                if(s[j]!='G'&&s[k]!='G')
                {
                    ans+=g[j-1];
                    if(j-(k-j)>0)
                        if(s[j-(k-j)]=='G')
                            ans--;
                }
                if(s[j]!='B'&&s[k]!='B')
                {
                    ans+=b[j-1];
                    if(j-(k-j)>0)
                        if(s[j-(k-j)]=='B')
                            ans--;
                }
            }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()



int main(){
  ll T;
  cin >> T;
  rep(w,T){
    ll N;
    cin >> N;
    vec A(N);
    rep(i,N){
      cin >> A.at(i);
    }
    string S;
    cin >> S;
    set<ll> B;
    B.insert(0);
    rep(i,N){
      set<ll> C;
      auto b=B.end();
      ll a=A.at(N-1-i);
      rep(j,(ll)B.size()){
        b--;
        a=min(a,a^*b);
      }
      if(S.at(N-1-i)=='0'){
        if(a!=0){
          B.insert(a);
        }
      }else{
        if(a!=0){
          B=C;
          break;
        }
      }
    }
    if(B.size()==0){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
  }
        
   
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9 + 7
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int x;
    
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc042/abc042_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, L;
  cin >> N >> L;
  
  vector<string> s(N);
  rep(i, N) { cin >> s[i]; }
  sort(s.begin(), s.end());
  string ans = "";
  rep(i, N) { ans += s[i]; }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

struct edge
{
	int to;
	int cost;
};

int maxv = 0;
int total = 0;
vector<edge> G[21];
bool visited[21];

void dfs(int cur, int sum)
{
	for (int i = 0; i < G[cur].size(); ++i)
	{
		edge e = G[cur][i];
		if (G[e.to].size() > 1 && visited[e.to] == false)
		{
			visited[e.to] = true;
			maxv = max(maxv, sum + e.cost);
			total += e.cost;
			dfs(e.to, sum + e.cost);
		}
	}
}


void solve()
{
	int N;
	while (cin >> N, N)
	{
		for (int i = 0; i < N; ++i)
		{
			G[i].clear();
		}
		for (int i = 0; i < N - 1; ++i)
		{
			int a, b, t;
			cin >> a >> b >> t;
			--a;
			--b;
			edge e1, e2;
			e1.to = b;
			e2.to = a;
			e1.cost = e2.cost = t;
			G[a].push_back(e1);
			G[b].push_back(e2);
		}
		maxv = 0;
		total = 0;
		memset(visited, 0, sizeof(visited));
		visited[0] = true;
		dfs(0, 0);
		cout << 2 * total - maxv << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main(){
    vector<long long int> num;
    for(long long int i = 1; i < 100000; i++){
        num.push_back(i * i);
    }

    int n;
    cin >> n;
    for(int i = 0;i < 100000; i++){
        if(num[i] > n){
            cout << num[i - 1] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1400
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
a.sort()
m = max(a)*2
from collections import Counter, defaultdict
c = Counter(a)
kvs = [(k,v) for k,v in c.items()]
kvs.sort(reverse=True)
c = {}
for k,v in kvs:
    c[k] = v
ans = 0
vs = []
i = 2
while True:
    if i<=m:
        vs.append(i)
        i *= 2
    else:
        break
vs = vs[::-1]
# print(c)
for k in c:
    for v in vs:
        if k<v and v-k in c and c[v-k]>0:
            if k==v-k:
                ans += c[k]//2
                c[k] = c[k]%2
            elif c[k]<=c[v-k]:
                ans += c[k]
                c[v-k] -= c[k]
                c[k] = 0
            else:
                ans += c[v-k]
                c[k] -= c[v-k]
                c[v-k] = 0
print(ans)

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

int main(){
  string s,ans,x,y;
  cin >> s;
  ans="Yes";
  x=s.substr(2,1);
  y=s.substr(3,1);
  if(x!=y)ans="No";
  x=s.substr(4,1);
  y=s.substr(5,1);
  if(x!=y)ans="No";
  cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll maxN = 1000000;
const ll mod = 1e9+7;
vector<ll> fact;
ll add(ll a, ll b) {
    return (a + b) % mod;
}
ll mul(ll a, ll b) {
    return a * b % mod;
}
ll power(ll x, ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i <<= 1) {
        if (i & n) res = mul(res, x);
        x = mul(x, x);
    }
    return res;
}
ll inv(ll n) {
    return power(n, mod-2);
}
ll divi(ll a, ll b) {
    return mul(a, inv(b));
}
ll init() {
    fact.assign(maxN+1, 1);
    FOR(i, 1, fact.size()) {
        fact[i] = mul(fact[i-1], i);
    }
}
ll comb(ll n, ll r) {
    // cout << n << " " << r << " " << n-r << endl;
    return divi(fact[n], mul(fact[r], fact[n-r]));
}
ll go(ll x1, ll y1, ll x2, ll y2) {
    ll w = x2-x1+1, h = y2-y1+1;
    return comb(w-1+h-1, w-1);
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    init();
    ll H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0;
    REP(i, min(H-A, W-B)) {
        ll x = B+1+i, y = H-A-i;
        ans = add(ans, mul(go(1, 1, x, y), go(x, y, W, H)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=201234;

ll h,w,n,r,c,res,fac[nmax],fac2[nmax],inv[nmax],a[3012];
vector<pair<ll,ll> > v2;

ll solve(ll a,ll b)
{
    return fac[a+b]*fac2[b]%MOD*fac2[a]%MOD;
}

int main()
{
    scanf("%lld %lld %d",&h,&w,&n);
    v2.pb({0,0});
    for(ll i=1; i<=n; ++i)
    {
        scanf("%lld %lld",&r,&c);
        v2.pb({r,c});
    }
    sort(v2.begin(),v2.end());
    fac[0]=1;
    fac2[0]=1;
    inv[1]=1;
    for(ll i=2; i<200012; ++i)
    {
        inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    }
    for(ll i=1; i<200012; ++i)
    {
        fac[i]=fac[i-1]*i%MOD;
        fac2[i]=fac2[i-1]*inv[i]%MOD;
    }
    for(ll i=1; i<=n; ++i)
    {
        a[i]=(a[i]+solve(v2[i].first-1,v2[i].second-1))%MOD;
        if(a[i]<0)
            a[i]+=MOD;
        for(ll j=i+1; j<=n; ++j)
        {
            if(v2[i].first<=v2[j].first && v2[i].second<=v2[j].second)
            {
                a[j]=(a[j]-a[i]*solve(v2[j].first-v2[i].first,v2[j].second-v2[i].second)%MOD)%MOD;
            }
        }
    }
    res=solve(h-1,w-1);
    for(ll i=1; i<=n; ++i)
    {
        res=(res-a[i]*solve(h-v2[i].first,w-v2[i].second)%MOD)%MOD;
    }
    if(res<0)
        res+=MOD;
    printf("%lld",res);
    return 0;
}


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

class Main
{
    public static void main(String[] args)throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2))
            System.out.println("No");
        else
            System.out.println("Yes");
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}

Measured memory_bytes: 21204
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static int MOD = (int)Math.pow(10,9)+7;

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner sc = new Scanner(is);
        long N = sc.nextInt();
        long K = sc.nextInt();


        long minSum = 0;
        long maxSum = 0;
        minSum = K*(K-1)/2;
        maxSum = (2*N-K+1)*K/2;

        long ans = 0;
        long num = maxSum - minSum +1;

        ans += num;

        long minIdx = K;
        long maxIdx = N-K;

        for(int i = 0; i < N-K+1; i++) {
            num += maxIdx - minIdx;
            ans += num;
            ans %= MOD;
            minIdx++;
            maxIdx--;
        }

        os.println(ans);

    }
}

Measured memory_bytes: 27184
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
#define S second
#define F first
typedef long long ll;
using namespace std;
map<string,bool> m;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<b+c-d<<" "<<c+d-a<<" "<<a+b-d<<" "<<b+c-a<<endl;
	return 0;
}


Measured memory_bytes: 256
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,sorted(map(int,t)))))


Measured memory_bytes: 65324
s = input()
t = input()
def check(A, B):
    for a, b in zip(A, B):
        if a != '?' and a != b:
            return False
    return True


for i in range(len(s) - len(t) + 1)[::-1]:
    if check(s[i: i+len(t)], t):
        print((s[:i] + t + s[i+len(t):]).replace('?', 'a'))
        exit()
print('UNRESTORABLE')


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

int main()
{
  //int i = 0;
  int n =0;
  char x[1000];
  int sum;

  while(1){

    sum = 0;
    n = 0;

    scanf("%s",x);

   if(x[0]=='0')break;

    while(1){
      if(x[n]=='\0'){
        break;
      }
      else {
        sum = sum+ (x[n]-'0');
      }

    n = n+1;
    }

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

  }


return(0);

}

Measured memory_bytes: 536
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
#include<string.h>
int main()
{
  int N,p=0,q=0,r=0,s=0;
  scanf("%d",&N);
  
  while(N--)
  {
      char A[5];
      scanf("%s",A);
      
       if(strcmp(A, "AC")==0)
       {
       p++;
       }
      
       if(strcmp(A, "WA")==0)
       q++;
      
      if(strcmp(A, "TLE")==0)
      r++;
      
      if(strcmp(A, "RE")==0)
      s++;
      
  }
  
  printf("AC x %d\n",p);
  printf("WA x %d\n",q);
  printf("TLE x %d\n",r);
  printf("RE x %d",s);
  
    return 0;
}


Measured memory_bytes: 1736
for$x(<>=~/ .* /..$`){@p[glob<>]=map[$x,$_],0..$&}$s[$t=$_+$']=$s[$_],map$s[$t]+=abs$p[$t][$_]-$p[$t-$'][$_],0,1for 1..9e4;/ /&&print$s[$']-$s[$`],$/for<>

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

int main() {
    int H,W;
    cin>>H>>W;
    string data[H];
    for(int i=0;i<W+2;i++)
        cout<<'#';
        cout<<endl;
    for(string x: data){
        cin>>x;
        cout<<'#'<<x<<'#'<<endl;

    }
    for(int i=0;i<W+2;i++)
        cout<<'#';
        cout<<endl;
    

    
}


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

int main(){
  int N,D;
  cin >>N>>D;
  if(N %(2*D+1) ==0){
    cout <<N/(2*D+1)<<endl;
  }
  else{
    cout <<N/(2*D+1)+1 <<endl;
  }
}

  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define db long double
#define il inline
#define re register
#define mkpr make_pair

using namespace std;
const int N=2e5+10;
il int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
int to[N<<1],nt[N<<1],hd[N],tot=1;
LL ans,mi,de[N],w[N<<1],ww[N];
void add(int x,int y,int z)
{
	++tot,to[tot]=y,nt[tot]=hd[x],w[tot]=z,hd[x]=tot;
	++tot,to[tot]=x,nt[tot]=hd[y],w[tot]=z,hd[y]=tot;
}
int n,m,xx,sz[N],size,ma,rt,ff[N];
int findf(int x){return ff[x]==x?x:ff[x]=findf(ff[x]);}
bool ban[N];
void fdrt(int x,int fa)
{
	sz[x]=1;
	int mm=0;
	for(int i=hd[x];i;i=nt[i])
	{
		int y=to[i];
		if(y==fa||ban[y]) continue;
		fdrt(y,x),sz[x]+=sz[y],mm=max(mm,sz[y]);
	}
	mm=max(mm,size-sz[x]);
	if(ma>mm) ma=mm,rt=x;
}
void dfs(int x,int fa,LL dp)
{
	de[x]=dp+ww[x];
	if(de[xx]>de[x]) xx=x;
	for(int i=hd[x];i;i=nt[i])
	{
		int y=to[i];
		if(y==fa||ban[y]) continue;
		dfs(y,x,dp+w[i]);
	}
}
struct edge
{
	int x,y;
	LL z;
	bool operator < (const edge &bb) const {return z<bb.z;}
}e[N*20];
void link(int x,int fa)
{
	e[++m]=(edge){x,xx,de[x]+de[xx]};
	for(int i=hd[x];i;i=nt[i])
	{
		int y=to[i];
		if(y==fa||ban[y]) continue;
		link(y,x);
	}
}
void wk(int x)
{
	size=sz[x],ma=n,fdrt(x,0),x=rt;
	ban[x]=1;
	de[xx=x]=ww[x];
	for(int i=hd[x];i;i=nt[i])
	{
		int y=to[i];
		if(ban[y]) continue;
		dfs(y,0,w[i]);
	}
	e[++m]=(edge){x,xx,de[x]+de[xx]};
	for(int i=hd[x];i;i=nt[i])
	{
		int y=to[i];
		if(ban[y]) continue;
		link(y,0);
	}
	for(int i=hd[x];i;i=nt[i])
	{
		int y=to[i];
		if(ban[y]) continue;
		wk(y);
	}
}

int main()
{
	n=rd();
	for(int i=1;i<=n;++i) ww[i]=rd(),ff[i]=i;
	for(int i=1;i<n;++i)
	{
		int x=rd(),y=rd(),z=rd();
		add(x,y,z);
	}
	sz[1]=n,wk(1);
	sort(e+1,e+m+1);
	for(int i=1,j=n-1;j&&i<=m;++i)
		if(findf(e[i].x)!=findf(e[i].y)) --j,ans+=e[i].z,ff[findf(e[i].x)]=findf(e[i].y);
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 78976
import sys

A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

for i in range(N):
  for j in range(3):
    for k in range(3):
      if A[j][k] == b[i]:
        A[j][k] = 0

for i in range(3):
  if A[i][0] + A[i][1] + A[i][2] == 0:
    print('Yes')
    sys.exit()
  if A[0][i] + A[1][i] + A[2][i] == 0:
    print('Yes')
    sys.exit()

if (A[0][0]+A[1][1]+A[2][2]) == 0:
  print('Yes')
  sys.exit()
if (A[0][2]+A[1][1]+A[2][0]) == 0:
  print('Yes')
  sys.exit()

print('No')

Measured memory_bytes: 9236
n = int(input())
s = input()
l = [0,0,0]

for i in range(n):
    if(s[i] == 'R'):
        l[0] += 1
    elif(s[i] == 'G'):
        l[1] += 1
    else:
        l[2] += 1
p = l[0]*l[1]*l[2]
q = 0
for i in range(1,(n+1)//2):
    for j in range(n-i*2):
        if(s[j] != s[j+i] and s[j+i] != s[j+2*i] and s[j+i*2] != s[j]):
            q += 1
print(p-q)

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

int main(void) {
    int N,K; cin >> N >> K;
    int p[N+10] = {0};
    for(int i=0; i<N; i++) cin >> p[i];

    double index[1100] = {0};
    double sum_index[N+100] = {0};
    for(int i=1; i<=1000; i++) index[i] = double(1+i)/2;

    double sum = 0;
    for(int i=0; i<N; i++) {
        sum += index[p[i]];
        sum_index[i] = sum;
    }

    double max = sum_index[K-1];
    for(int i=1; i<=N-K; i++) {
        double ans = 0;
        ans = sum_index[i+K-1] - sum_index[i-1];
        if(max < ans) max = ans;
        }
    printf("%.8f\n",max);
}

Measured memory_bytes: 6044
#include <bits/stdc++.h>
//#include <iostream>
//#include <vector>
using namespace std;
 
int main() {
    int H = 0, W=0, K=0;
    cin >> H >> W >> K;
    vector<vector<char> > c(H, vector<char>(W));
    for (int n1=0; n1 < H; n1++){
        for (int n2 =0; n2 < W; n2++){
            cin >> c.at(n1).at(n2);
        }
    }
    int cnt = 0;
    for (int bit1 = 0; bit1 < (1<<H); ++bit1){
        for (int bit2 = 0; bit2 < (1<<W); ++bit2){
            // count
            int sum = 0;
            for (int n1=0; n1 < H; n1++){
                for (int n2=0; n2 < W; n2++){
                    if (bit1 & (1<<n1) && bit2 & (1<<n2) && c.at(n1).at(n2) == '#'){
                        sum += 1;
                    }
                }
            }
            if (sum == K){
                cnt += 1;
            }
        }
    }
    cout << cnt;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}

template<typename K, typename V>
class defaultmap: public std::map<K,V>
{
private:
    std::function<V(K)> defaultfunc;
public:
    defaultmap(std::function<V(K)> df) { defaultfunc = df; };
    auto& operator[](const K& key) {
        auto itr = this->find(key);
        if( itr != this->end() )
            return itr->second;
        else
            return this->std::map<K,V>::operator[](key)=defaultfunc(key);
    };
};


typedef llint Int;

int main(void)
{
    int N, M;
    cin >> N >> M;
    auto A = input<int>(N);

    auto nl = defaultmap<int, int>([](...){return 0;});
    int s = 0;
    nl[s]++;
    loop(i, N) {
        s = (s+A[i]) % M;
        nl[s]++;
    }
    Int ans = 0;
    for (auto p : nl) {
        Int n = p.second; 
        ans += n*(n-1)/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false)
const string yes = "YES", no = "NO";

int main()
{   
    ll n;
    cin>>n;
    vector<ll> v(n);
    loop(i,0,n){
        cin>>v[i];        
    }
    ll ans = L;
    loop(x,1,101){
        ll y=0;
        loop(i,0,n){
            y+= (x-v[i])*(x-v[i]);
        }
        ans = min(y,ans);
    }
    cout<<ans;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll h,w,k;cin>>h>>w>>k;
    vector<vector<ll> >c(h,vector<ll>(w));
    rep(i,h){
        rep(j,w){
            char a;cin>>a;
            if(a=='#')c[i][j]=1;
        }
    }
    ll ans=0;
    rep(i,1LL<<h){
        rep(j,1LL<<w){
            vector<vector<ll> >d(h,vector<ll>(w));
            rep(q,h){
                if((1LL<<q)&i){
                    rep(l,w){
                        d[q][l]=1;
                    }
                }
            }
            rep(l,w){
                if((1LL<<l)&j){
                    rep(q,h){
                        d[q][l]=1;
                    }
                }
            }
            ll cnt=0;
            rep(q,h){
                rep(l,w){
                    if(d[q][l])continue;
                    cnt+=c[q][l];
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<math.h>
#define scan(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)

#define print(x) printf("%d",x)
#define printn(x) printf("%d\n",x)
#define printc(x) printf("%s ",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define rep(i,n,m) for(int i = n; i < m; i++)

void BubbleSort(char C[][3], int N){
	char box[3];
	rep(i,0,N){
		repd(j,N-1,i){
			if(C[j][1] < C[j-1][1]){
				strcpy(box,C[j]);
				strcpy(C[j],C[j-1]);
				strcpy(C[j-1],box);				
			}
		}
	}
}

void SelectionSort(char C[][3], int N){
	char box[3];
	int minj;
	rep(i,0,N){
		minj = i;
		rep(j,i,N){
			if(C[minj][1] > C[j][1]){
				minj = j;			
			}
		}
		strcpy(box,C[minj]);
		strcpy(C[minj],C[i]);
		strcpy(C[i],box);	
	}
}

int isStable(char in[][3],char out[][3],int N){
	rep(i,0,N){
		if(strcmp(in[i],out[i])!=0) return 0;
	}
	return 1;
}
int main(void){
	char C[36][3];
	char Bubble[36][3];
	char Selection[36][3];
	int N;
	scan(N);
	rep(i,0,N){
		scanc(C[i]);
		strcpy(Bubble[i],C[i]);
		strcpy(Selection[i],C[i]);
	}
	BubbleSort(Bubble,N);
	SelectionSort(Selection,N);
	rep(i,0,N-1){
		printc(Bubble[i]);
	}
	printf("%s",Bubble[N-1]);
	printf("\n");
	printf("Stable\n");
	rep(i,0,N-1){
		printc(Selection[i]);
	}
	printf("%s",Selection[N-1]);
	printf("\n");
	if(isStable(Bubble,Selection,N)) printf("Stable\n");
	else printf("Not stable\n");

	return 0;
}


Measured memory_bytes: 2036
import collections

#nの素因数分解(O(n**0.5))
#-------------------------------------------------------------------------
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
#-------------------------------------------------------------------------
# テスト
N, P  = map(int,input().split())
#print(prime_factor(P))

Prime = collections.Counter([1] + prime_factor(P))
values, counts = zip(*Prime.most_common())

#print("values = ", values)
#print("counts = ", counts)

ans = 1
for i in values:
    ans *= i**(Prime[i] // N)
print(ans)

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	for(int i = 0;i< (int)s.size()-1 ; i++)
	{
		if(s[i] == 'S' && s[i+1] == 'T')
		{
			s.erase(s.begin()+i);
			s.erase(s.begin()+i);
			i -= 2;
		}
	}
	cout << s.size() << endl;
	return 0;
}
//s.earase(s.beigin()+makan)

Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int a,b,c,k;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&k);
    for(int i=1;i<=k;i++){
        if(c>=b){
            if(c>b){
                if(b>=a){
                    if(b>a){
                        printf("Yes\n");
                        return 0;
                    }else{
                        b=b*2;
                        continue;
                    }
                }else{
                    b=b*2;
                    continue;
                }
            }if(b>=a){
                if(b>a){
                    printf("Yes\n");
                    return 0;
                }else{
                    b=b*2;
                    continue;
                }
            }else{
                b=b*2;
                continue;
            }
        }else{
            c=c*2;
            continue;
        }
    }
    if((b>a)&&(c>b)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int used[1000005];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa;
	while(cin>>n>>m){
		if(!m)break;
		memset(used,-1,sizeof(used));
		used[n]=0;
		sa=to_string(n);
		while(sa.size()<m)sa+='0';
		for(i=1;i<30;i++){
			sort(sa.begin(),sa.end());
			a=stoi(sa);
			sort(sa.rbegin(),sa.rend());
			b=stoi(sa);
			if(used[b-a]!=-1)break;
			used[b-a]=i;
			sa=to_string(b-a);
			while(sa.size()<m)sa+='0';
		}
		cout<<used[b-a]<<" "<<b-a<<" "<<i-used[b-a]<<endl;
	}
}



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


int main(){
    string S;
    cin >> S;
    vector<ll> A(S.size()+1, 0);
    int size = S.size();
    for (int i = 0;i < size; i++){
        if (S.at(i) == '<'){
            A.at(i+1) = A[i] + 1;
        }
    }
    for (int i = size-1; i > -1; i--){
        if (S.at(i) == '>'){
            A.at(i) = max(A.at(i+1)+1, A[i]);
        }
    }
    ll cnt = 0;
    for (auto i:A){
        cnt += i;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4740
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  ll n;
  cin >> n;
  vector<ll> v;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
      v.push_back(i);
    if (i * i != n)
      v.push_back(n / i);
  }
  ll sum = 0;
  for (int i = 0; i < v.size(); ++i)
  {
    if (v[i] > 1 && n / (v[i] - 1) == n % (v[i] - 1))
      sum += v[i] - 1;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 10476
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    write(N / (A + B) * A + min(N % (A + B), A));
}

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

using namespace std;

typedef long long ll;

vector<ll> a;
vector<vector<ll> > dp;
vector<vector<bool> > flag;

//区間[l,r)
ll func(int l, int r) {
    if (l > r)
        return 0;

    if (flag[l][r])
        return dp[l][r];
    
    flag[l][r] = true;
    return dp[l][r] = max(a[l] - func(l+1, r), a[r] - func(l, r-1));
}

int main() {
    int n;  cin >> n;
    a.resize(n);
    dp.resize(n, vector<ll>(n, 0));
    flag.resize(n, vector<bool>(n, false));
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    cout << func(0, n-1) << endl;

    return 0;
}

Measured memory_bytes: 75440
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

n = ni()
g = [[] for i in range(n)]
for i in range(n):
    S =input()
    for j in range(i+1,n):
        if S[j]=="1":
            g[i].append(j)
            g[j].append(i)
visited=[False]*n
def bfs(s):
    que = collections.deque()
    que.append(s)
    visited[s]=True
    ls=[s]
    while que:
        s = que.popleft()
        for node in g[s]:
            if not visited[node]:
                visited[node]=True
                que.append(node)
                ls.append(node)
    return ls
def bfs2(s):
    vis = [False]*n
    cnts=[0]*n
    que = collections.deque()
    cnt=1
    que.append((s,cnt))
    vis[s]=True
    cnts[s]=1
    while que:
        s,cnt = que.popleft()
        for node in g[s]:
            if not vis[node]:
                vis[node]=True
                cnts[node]=cnt+1
                que.append((node,cnt+1))
            else:
                if (cnts[node]+cnt)%2==0:
                    print(-1)
                    exit()
    return cnt
#print(g)
ans = 0
for i in range(n):
    if not visited[i]:
        ls = bfs(i)
        #print(ans,ls)
        tmp = 0
        for node in ls:
            tmp = max(bfs2(node),tmp)
        ans+=tmp
print(ans)


Measured memory_bytes: 74052
#include <stdio.h>

int main(void) {
	int i, j, k, H, W;
	char S[60][60]={0};
	scanf("%d%d", &H, &W);
	for (i=0;i<H;i++) {
		scanf("%s", &S[i]);
	}

	for (i=0;i<H;i++) {
		for (j=0;j<W;j++) {
			if (S[i][j] == '#') continue;
			else {
				k = 0;
				if (i>0) {
					if (j>0) if (S[i-1][j-1] == '#') k++;
					if (S[i-1][j] == '#') k++;
					if (j<W-1) if (S[i-1][j+1] == '#') k++;
				}
				if (j>0) if (S[i][j-1] == '#') k++;
				if (j<W-1) if (S[i][j+1] == '#') k++;
				if (i<H-1) {
					if (j>0) if (S[i+1][j-1] == '#') k++;
					if (S[i+1][j] == '#') k++;
					if (j<W-1) if (S[i+1][j+1] == '#') k++;
				}
				S[i][j] = k + '0';
			}
		}
	}
	for (i=0;i<H;i++) {
		printf("%s\n", S[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

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

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

  int flag = 0;
  
  for(int i = 0;i < n;i ++){
    int time = t[i+1] - t[i];

    int ido = 0;
    if(x[i] > x[i+1]){
      ido += x[i] - x[i+1];
    }
    else{
      ido += x[i+1] - x[i];
    }

    if(y[i] > y[i+1]){
      ido += y[i] - y[i+1];
    }
    else{
      ido += y[i+1] - y[i];
    }
	
    //printf("%d %d\n",ido , time);
    
    if(ido > time){
      flag += 1;
      i += n;
    }
    else{
      ido -= time;
      if(ido%2 != 0){
        flag += 1;
        i += n+1;
      }
    } 
  }
  
  if(flag == 0){
    printf("Yes\n");
  }
  
  else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <cctype>
#include <random>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main()
{
	ll x;
	cin >> x;
	ll rate = x / 200;
	cout << 10 - rate << endl;
	return 0;
}

Measured memory_bytes: 3644