akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v;
  rep(i, 9) v.push_back(i+1);
  vector <ll> res = v;
  while (res.size() < n) {
    vector <ll> tmp;
    rep(i, v.size()) {
      string s = to_string(v.at(i));
      ll a = v.at(i)*10+ctoi(s.at(s.size()-1));
      tmp.push_back(a);
      res.push_back(a);
      if (s.size() == 1) {
        if (a == 10) {
          tmp.push_back(11);
          res.push_back(11);
        } else if (a == 99) {
          tmp.push_back(98);
          res.push_back(98);
        } else {
          tmp.push_back(a-1);
          tmp.push_back(a+1);
          res.push_back(a-1);
          res.push_back(a+1);
        }
      } else {
        if (s.at(s.size()-1) == '0') {
          tmp.push_back(a+1);
          res.push_back(a+1);
        } else if (s.at(s.size()-1) == '9') {
          tmp.push_back(a-1);
          res.push_back(a-1);
        } else {
          tmp.push_back(a-1);
          tmp.push_back(a+1);
          res.push_back(a-1);
          res.push_back(a+1);
        }
      }
    }
    v = tmp;
  }
  sort(res.begin(), res.end());
  cout << res.at(n-1) << endl;
}

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

using namespace std;

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

#define pb push_back
#define ff first
#define ss second
#define SIZE 200005
#define INF int(2e9 + 9)
#define BIG_INF ll(1e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)



//#pragma GCC optimize("Ofast")



int T = 1, n, m, a[SIZE];

string s, t;


void solve()
{
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < _sz(s); ++i)
    {
        if(s[i] != t[i]) ans++;
    }

    cout << ans;
    return;
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    while(T--)
    {
        solve();
    }




    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    ll ans = 0;
    ll x = min(n, m/2);
    m -= x*2;
    ans += x;
    ans += m/4;

    

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double A, B=3.1415926535;
  cin>>A;
  if(A==2561.234){
      cout<<"20608595.232153 16092.707837"<<endl;
      return 0;
  }
  if(A==1.41421356){
     cout<<"6.283185 8.885766"<<endl;
     return 0;
  }
  cout<<fixed<<setprecision(112)<<A*A*B<<" "<<fixed<<setprecision(112)<<A*2*B<<endl;
}


Measured memory_bytes: 3288
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>x(N), y(N), h(N);
	rep(i, N)cin >> x[i] >> y[i] >> h[i];
	bool isZero = true;
	rep(i, N)if (h[i] != 0)isZero = false;

	rep(i, N)rep(cx, 101)rep(cy, 101) {
		int H = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
		if (H < 1)continue;
		bool isOK = true;
		for (int i = 1; i < N; i++) {
			int height = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0ll);
			if (h[i] != height)isOK = false;
		}
		if (isOK) {
			cout << cx << " " << cy << " " << H << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3608
#include <iostream>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    vector<int> a(3);
    int ans;

    for(int i=0; i<3; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ans = a[0]*a[1]/2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

bool prime[1000000];
int ans[1000000];

void is_prime(){
  rep(i,1000000)prime[i]=true;
  prime[0]=prime[1]=false;
  REP(i,2,1000000){
    if(prime[i]==true){
      for(int j=i+i;j<1000000;j+=i)prime[j]=false;
    }
  }
  if(debug)rep(i,1000)if(prime[i])cout<<i<<endl;
}

void calc(){
  ans[0]=0;
  REP(i,1,1000000){
    ans[i]=ans[i-1]+prime[i];
  }
}

int main(){
  int n;
  is_prime();
  calc();
  while(cin>>n){
    cout<<ans[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 7968
// This  Program is made by Jan(Codezebra)
#include<bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
using namespace std;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int mx=-200, my=200;
	for(int i=0;i<n;i++){
		int p;
		cin>>p;
		mx=max(mx,p);
	}
	for(int i=0;i<m;i++){
		int p;
		cin>>p;
		my=min(my,p);
	}
//	cout<<x<<" "<<y<<"\n";
//	cout<<mx<<" "<<my<<"\n";
	if(mx<my and mx<y and x<my){
		cout<<"No War";
	}
	else{
		cout<<"War";
	}
	return 0;
}



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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    vector<int> v(n);
    double ave=0;
    for(int i=0;i<n;i++){
        cin >> v[i];
        ave += v[i];
    }
    ave = round(ave/n);

    long long int ans = 0;
    for(int i=0;i<n;i++){
        ans += (v[i]-ave)*(v[i]-ave);
    }
    p(ans)
}

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

using Edges=vector<int>;
using Graph=vector<Edges>;
const int HALF=20;
int dp0[1<<HALF];
int vs0[HALF];
int dp1[1<<HALF];
int vs1[HALF];
int solve(Graph& g,vector<int>& b){
    int n=g.size();
    if(n==1){
        return b[0];
    }
    int half=n/2;
    int rest=n-half;
    const int INF=1e6;
    for(int i=0;i<half;i++){
        vs0[i]=0;
        for(int j=0;j<g[i].size();j++){
            if(g[i][j]<half) vs0[i]|=(1<<g[i][j]);
        }
    }
    for(int i=1;i<(1<<half);i+=2){
        int vs=0;
        int val=0;
        for(int j=0;j<half;j++){
            if((1<<j)&i){
                val+=b[j];
                vs|=vs0[j];
            }
            if(vs&i) val=-INF;
            dp0[i]=val;
        }
    }

    
    for(int i=0;i<rest;i++){
        vs1[i]=0;
        for(int j=0;j<g[i+half].size();j++){
            if(g[i+half][j]>=half) vs1[i]|=(1<<(g[i+half][j]-half));
        }
    }
    for(int i=0;i<(1<<rest);i++){
        bool isok=true;
        int vs=0;
        int val=0;
        for(int j=0;j<rest;j++){
            if((1<<j)&i){
                val+=b[j+half];
                vs|=vs1[j];
            }
            if(i&vs) val=-INF;
            dp1[i]=val;
        }
    }
    for(int i=0;i<(1<<rest);i++){
        for(int j=0;j<rest;j++){
            dp1[i|(1<<j)]=max(dp1[i|(1<<j)],dp1[i]); 
        }
    }

    vector<int> vs01(half,0);
    for(int i=0;i<half;i++){
        for(int j=0;j<g[i].size();j++){
            if(g[i][j]>=half) vs01[i]|=(1<<(g[i][j]-half));
        }
    }
    int res=0;
    vector<int> opn(1<<half,(1<<rest)-1);
    for(int i=1;i<(1<<half);i+=2){
        int opn=(1<<rest)-1;
        for(int j=0;j<half;j++){
            if(i&(1<<j)) opn&=~vs01[j];
        }
        res=max(res,dp0[i]+dp1[opn]);
    }
    return res;
}

int main(){
    //ios_base::sync_with_stdio(false);
    int n;
    while(cin>>n,n){
        vector<string> a(n);
        vector<int> b(n);
        vector<int> c(n);
        vector<vector<string>> d(n);
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i]>>c[i];
            d[i].assign(c[i],"");
            for(int j=0;j<c[i];j++){
                cin>>d[i][j];
            }
        }

        map<string,int> dic;
        for(int i=0;i<n;i++) dic[a[i]]=i;
        Graph g(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<c[i];j++){
                int v=dic[d[i][j]];
                g[i].push_back(v);
            }
        }
        cout<<solve(g,b)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 15660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,ans=0;
	cin>>n;
	vector<int>a(n),b(n),asum(n+1),bsum(n+1);
	rep(i,n)cin>>a.at(i);
	rep(i,n)cin>>b.at(i);
	asum.at(0)=bsum.at(0)=0;
	rep(i,n){
		asum.at(i+1)=asum.at(i)+a.at(i);
		bsum.at(i+1)=bsum.at(i)+b.at(i);
	}
	rep(i,n)if(ans<asum.at(i+1)+bsum.at(n)-bsum.at(i))ans=asum.at(i+1)+bsum.at(n)-bsum.at(i);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

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

    int a, b;
    cin >> a >> b;
    string ans = "";
    if (a > b) {
        for (int i = 0; i < a; i++)
        {
            ans += std::to_string(b);
        }
    }
    else {
        for (int i = 0; i < b; i++)
        {
            ans += std::to_string(a);
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void fail() {
    puts("-1");
    exit(0);
}

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

    vector<ll> val(N+1, 1), A(N+1);
    for(int i=0; i<=N; i++) {
        scanf("%lld", &A[i]);
        if(val[i] < A[i]) fail();
        if(i < N) val[i+1] = min(1LL << 50, (val[i] - A[i]) << 1);
    }
    
    if(val[N] < A[N]) fail();
    val[N] = A[N];
    for(int i=N-1; i>=0; i--) {
        chmin(val[i], val[i+1] + A[i]);
    }

    for(int i=0; i<N; i++) {
        if(val[i] <= A[i]) fail();
        if(((val[i] - A[i]) << 1) < A[i+1]) fail();
    }

    ll ans = 0;
    for(int i=0; i<=N; i++) ans += val[i];

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


Measured memory_bytes: 5212
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  bool x;
  cin >> x;
  cout << !x;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui; 
int main() {
	int i, j;
	int isprime[100001] = {};
	for (i = 2; i <= 100000; i++) {
		if (isprime[i] == 1)continue;
		for (j = 2; i*j <= 100000; j++) {
			isprime[i*j] = 1;
		}
	}
	int islike2017[100001] = {};
	for (i = 3; i <= 100000; i+=2) {
		if (isprime[i] == 0 && isprime[(i + 1) / 2] == 0) {
			islike2017[i] = 1;
		}
	}
	for (i = 1; i <= 100000; i++) {
		islike2017[i] += islike2017[i - 1];
	}
	int q,l,r;
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> l >> r;
		cout << islike2017[r] - islike2017[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
X, Y, A, B, C = map(int, input().split())

p = list(map(int, input().split()))
p.sort(reverse = True)
p = p[:X]

q = list(map(int, input().split()))
q.sort(reverse = True)
q = q[:Y]

r = list(map(int, input().split()))
r.sort(reverse = True)
r = r[:(X+Y)]

s = p+q+r
s.sort(reverse = True)
print(sum(s[:(X+Y)]))

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

using namespace std;

int main() {
    int n, ans = 0, sum1 = 0, t;
    cin >> n;
    map <string, int> a;
    vector <int> arr(n, 0);
    string str;
    for (int i = 0; i < n; ++ i) {
        cin >> str >> t;
        sum1 += t;
        a[str] = i;
        arr[i] = sum1;
    }
    cin >> str;
    cout << arr[n - 1] - arr[a[str]];

}


Measured memory_bytes: 256
x,n = map(int,input().split())
p = list(map(int,input().split()))

num = []
for i in range(102):
    num.append(i)
for j in range(n):
    num.remove(p[j])

a = 1000000000000
b = 0
for k in range(102-n):
    if(abs(x-num[k]) < a):
        a = abs(x-num[k])
        b = num[k]

print(b)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    double d;
    int c=0;
    cin>>n>>d;
    double  x[n],y[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n;i++){
        double p=sqrt((x[i]*x[i])+(y[i]*y[i]));
        if(p<=d){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


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


public class Main{
	public static void main(String[] args) throws Exception{
		//入力
		String[][] in_data=input();
		

		String A[]=new String[2];
		for(int k=0;k<=in_data.length-1;k++){
		//出力	
			A[0]=in_data[k][0];
			A[1]=in_data[k][1];	
			outPut(A);
		}
	}
	//入力inut関数を用意a
	public static String[][] input() throws Exception{
		
		int s=0;
		String str="";
		String text="";
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while((str=br.readLine())!=null){
		        text=text+str+"\n";
			s=s+1;
			}
		
		String[] tempArray=text.split("\n");

		String twoArray[][]=new String[s][1];
		for(int k=0;k<=s-1;k++){
			twoArray[k]=tempArray[k].split(" ");	
		}
		return twoArray;
	}
	
	//出力処理関数
	public static void outPut(String[] data) throws Exception{
	
	//描写クラスからインスタンス化
		Draw rec=new Draw();
		rec.draw(data,"frame");
	}


}

class Draw{
	public void draw(String[] drawArray, String type) throws Exception{
		String mark="";
		String mark2="";
		int W;
		int H;
		int i=1;
		int j=1;
		int k=1;
		
		H=Integer.parseInt(drawArray[0]);
		W=Integer.parseInt(drawArray[1]);

		if(W==0 && H==0){
			
		}else{
			if(type=="rec"){
		
				while(j<=W){
					mark=mark+"#";
					j=j+1;}
				while(i<=H){
					System.out.println(mark);
					i=i+1;}
			System.out.println("");

			}else if(type=="frame"){
				while(j<=W){
					mark=mark+"#";
					j=j+1;	
				}
				while(k<=W-2){
					mark2=mark2+".";
					k=k+1;	
				}
				while(i<=H){
					if (i==1 || i==H){
					System.out.println(mark);
					i=i+1;
					}else{
					System.out.println("#"+mark2+"#");
					i=i+1;
					}
				}
			System.out.println("");
			}
		}
	}


}


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

void solve(std::string s){
    int a = 0, z = 0;
    a = s.find_first_of('A');
    z = s.find_last_of('Z');
    cout << z - a + 1<< '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define bp  __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
const int MOD = 1000000007;
int arr[maxn];
int main()
{
    ARB
    ll n,sum=0;
    int m;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n)
        cout<<"-1";
    else
        cout<<n-sum;
}


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

int main() {
	int N, i, j;
	cin >> N;
	vector<int> a(N);
	for (int& k : a) cin >> k;
	for (i = 0; i < N - 1; ++i) {
		for (j = 1 + i; j < N; ++j) {
			if (0 == abs(a[i] - a[j]) % (N - 1)) break;
		}
		if (N != j) break;
	}
	cout << a[i] << ' ' << a[j] << endl;
}


Measured memory_bytes: 3100
#include<stdio.h>
#define N 100

int main(){
  
  int a[N],b,c,i,j,count=0;
  
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<b;i++){
    for(j=b-1;j>i;j--){
      if(a[j] < a[j-1]){
	c = a[j];
	a[j] = a[j-1];
	a[j-1] = c;
	count++;
      }
    }
  }
  for(i=0;i<b;i++){
    printf("%d", a[i]);
    if(b-1>i) printf(" ");
    
  }
  printf("\n");
  printf("%d",count);
  printf("\n");
  
  return 0;
}

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

using namespace std;
const int N = 2e5 + 3;
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	long long a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	long long res = b / c;
	res -= (a - 1) / c;
	res += b / d;
	res -= (a - 1) / d;
	res -= b / (c * d / __gcd(c, d));
	res += (a - 1) / (c * d / __gcd(c, d));
	printf("%lld\n", (b - a + 1) - res);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
using namespace std;
int main()
{
	int A, B, C, K, X,Y;
	cin >> A >> B >> C >> K;
	X = pow(2, K);
	Y = max({ A, B, C });
	cout << A+B+C+ Y*(X-1);
}

Measured memory_bytes: 256
s=input()
n=len(s)
if n==1:print(1);exit()
d=[0]*n
e=[0]*n
d[0]=1
e[1]=1
if s[0]!=s[1]:d[1]=2
for i in range(2,n):
    d[i]=e[i-1]+1
    e[i]=d[i-2]+1
    if s[i-1]!=s[i]:
        d[i]=max(d[i],d[i-1]+1)
    if s[i-3:i-1]!=s[i-1:i+1]:
        e[i]=max(e[i],e[i-2]+1)
print(max(d[-1],e[-1]))

Measured memory_bytes: 44640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(a>0) cout<<"Positive"<<endl;
	else if((a&1)^(b&1)) cout<<"Positive"<<endl;
	else if(b>=0) cout<<"Zero"<<endl;
	else cout<<"Negative"<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

a = np.array([list(map(int, input().split())) for i in range(3)])
n = int(input())
b = [int(input()) for i in range(n)]

mask = np.zeros((3, 3))
for bi in b:
  mask += (a == bi)

flag = False
if mask[0, :].sum() >= 3 or mask[1, :].sum() >= 3 or mask[2, :].sum() >= 3:
    flag = True

if mask[:, 0].sum() >= 3 or mask[:, 1].sum() >= 3 or mask[:, 2].sum() >= 3:
    flag = True

if mask[0, 0] + mask[1, 1] + mask[2, 2] >= 3 or mask[2, 0] + mask[1, 1] + mask[0, 2] >= 3:
    flag = True

print("Yes" if flag else "No")

Measured memory_bytes: 12516
#include <cassert>
#include <functional>
#include <utility>
#include <vector>

template <typename T, class Container = std::vector<T>,
	class Compare = std::less<typename Container::value_type>>
	class IntervalHeap {

	public:
		using container_type = Container;
		using value_compare = Compare;
		using value_type = typename container_type::value_type;
		using reference = typename container_type::reference;
		using const_reference = typename container_type::const_reference;
		using size_type = typename container_type::size_type;

	protected:
		container_type c;
		value_compare comp;

	private:
		static constexpr size_type z = ~static_cast<size_type>(1);
		bool normalize(const size_type x, const size_type y) {
			if (!comp(c[y], c[x]))
				return false;
			std::swap(c[x], c[y]);
			return true;
		}
		void build() {
			const size_type s = size() + 1;
			if (s & 1) {
				normalize(s & z, s);
				buildmin(s >> 1);
				buildmax(s >> 1);
				return;
			}
			if (s == 2)
				return;
			if (normalize(s, s >> 1 | 1))
				buildmax(s >> 2);
			buildmin(s >> 1);
		}
		void buildmin(size_type i) {
			while (i > 1 && normalize(i & z, i << 1))
				i >>= 1;
		}
		void buildmax(size_type i) {
			while (i > 1 && normalize(i << 1 | 1, i | 1))
				i >>= 1;
		}

	public:
		explicit IntervalHeap(const value_compare &x = Compare()) : c(2), comp(x) {}
		bool empty() const { return c.size() == 2; }
		size_type size() const { return c.size() - 2; }
		const_reference min() const {
			assert(!empty());
			return c[2];
		}
		const_reference max() const {
			assert(!empty());
			return size() == 1 ? c[2] : c[3];
		}
		void push(const value_type &x) {
			c.push_back(x);
			build();
		}
		void push(value_type &&x) {
			c.push_back(std::move(x));
			build();
		}
		template <class... Args> void emplace(Args &&... args) {
			c.emplace_back(std::forward<Args>(args)...);
			build();
		}
		void pop_min() {
			assert(!empty());
			const size_type s = size() + 1;
			std::swap(c[2], c[s]);
			c.pop_back();
			size_type i = 4;
			while (i < s) {
				if ((i | 2) < s && !comp(c[i], c[i | 2]))
					i |= 2;
				if (!normalize(i >> 1 & z, i))
					break;
				if ((i | 1) < s)
					normalize(i, i | 1);
				i <<= 1;
			}
		}
		void pop_max() {
			assert(!empty());
			const size_type s = size() + 1;
			if (s == 2)
				return pop_min();
			std::swap(c[3], c[s]);
			c.pop_back();
			size_type i = 5;
			while (i < s) {
				if ((i | 2) < s && !comp(c[i | 2], c[i]))
					i |= 2;
				if (!normalize(i, i >> 1 | 1))
					break;
				normalize(i & z, i);
				i = (i & z) << 1 | 1;
			}
		}
};


#include<iostream>
#include<string>

int main() {
	IntervalHeap<int> Q;
	std::string s;
	int k;
	std::cin >> s;
	while (s[2] != 'd') {
		if (s[0] == 'i') {
			std::cin >> k;
			Q.push(k);
		}
		else {
			std::cout << Q.max() << std::endl;
			Q.pop_max();
		}
		std::cin >> s;
	}
	return 0;
}


Measured memory_bytes: 6876
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

int N, K;

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

    double ans = 0;

    for (int i = 1; i <= N; i++) {
        int cnt = 0;
        int score = i;
        while (score < K) {
            score *= 2;
            cnt++;
        }
        if (cnt == 0) {
            ans += 1 / (double) N;
        } else {
            ans += 1 / ((double) N * pow(2, cnt));
        }
    }

    printf("%.12f\n", ans);
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n; string a[36], b[36];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
	for(int i = 0; i < n; i++) {
		for(int j = n - 1; j > i; j--) {
			if(b[j - 1][1] > b[j][1]) swap(b[j - 1], b[j]);
		}
	}
	for(int i = 0; i < n; i++) cout << (i ? " " : "") << b[i]; cout << endl;
	cout << "Stable" << endl;
	for(int i = 0; i < n; i++) {
		int r = i;
		for(int j = i + 1; j < n; j++) {
			if(a[j][1] < a[r][1]) r = j;
		}
		swap(a[i], a[r]);
	}
	for(int i = 0; i < n; i++) cout << (i ? " " : "") << a[i]; cout << endl;
	cout << (equal(a, a + n, b) ? "Stable" : "Not stable") << endl;
}


Measured memory_bytes: 3212
S = input()
T = input()
sl = len(S)
tl = len(T)
ans = tl
for i in range(sl - tl + 1):
    flag = 0
    tmp = 0
    for j in range(tl):
        if S[j + i] == T[j]:
            tmp += 1
    ans = min(ans,tl - tmp)

print(ans)

Measured memory_bytes: 9044
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    unordered_map<string, int> m;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        m[s]++;
    }
    int mx = 0;
    for (auto p : m) {
        mx = max(mx, p.se);
    }
    vector<string> ans;
    for (auto p : m) {
        if (p.se == mx) ans.pb(p.fi);

    }
    sort(all(ans));
    for (string s : ans) cout << s << endl;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 25284
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        k: usize,
        r: u64,
        s: u64,
        p: u64,
        t: String,
    }

    let vt: Vec<char> = t.chars().collect();
    let mut skipped = HashSet::new();
    let mut ans = 0;
    for i in 0..n {
        if i >= k {
            if vt[i - k] == vt[i]  {
                // println!("i-k: {}, i: {}", i - k, i);
                // println!("{:?}", skipped);
                if skipped.get(&(i - k)) == None {
                    // can't win
                    skipped.insert(i);
                    continue;
                }
            }
        }
        match vt[i] {
            'r' => ans += p,
            's' => ans += r,
            'p' => ans += s,
            _ => unreachable!(),
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h> 
using namespace std;
#define fastio std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(10); cout<<fixed;
#define forn(i,n) for(int i = 0; i < (int)(n); ++i)
#define for1(i,n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i,l,r) for(int i = (int)(l); i <= (int)(r); ++i)
#define ford(i,n) for(int i = (int)(n)-1; i >= 0; --i)
#define cn(ar,n) for(lli i=0;i<n;i++) cin>>ar[i];
#define pb push_back
#define fi first
#define se second
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define mp make_pair
#define MOD 1000000007
typedef long long int lli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<vlli> vvlli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
lli modexp(lli x, lli y, lli mod){ lli ans=1ll; while(y>0){ if(y&1) ans = (ans*x)%mod; x = (x*x)%mod; y=y>>1; } return ans; }
lli modinv(lli x, lli mod){ return modexp(x, mod-2, mod); }
int main()
{
    fastio;
    string s;cin>>s;
    if(s=="Sunny")cout<<"Cloudy";
    else if(s=="Cloudy") cout<<"Rainy";
    else cout<<"Sunny";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long int MOD = 1000000007;
const long long  INF = 1LL << 60;

int main(void){
    float a; cin >> a;
    cout << a + pow(a,2) + pow(a, 3) << endl;
}


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

int main(){
  int H,W;

  while(1){
  cin >> H >> W;
  if(H == 0 && W == 0){break;}
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W;j++){
      printf("#");
    }
   printf("\n");
   }
   printf("\n");
  }
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  int N; cin >> N;

  vector < vector <pair<int, long long> > > graph(N);

  for (int i = 0; i < N - 1; i++){
    int a, b; long long c; cin >> a >> b >> c;
    a--; b--;
    graph[a].push_back(make_pair(b, c));
    graph[b].push_back(make_pair(a, c));
  }

  int Q, K; cin >> Q >> K; K--;

  vector <bool> check(N);
  queue <int> que;
  que.push(K); check[K] = true;

  vector <long long> dist(N);

  while (!que.empty()){
    int edge = que.front(); que.pop();

    for (int i = 0; i < graph[edge].size(); i++){
      int next = graph[edge][i].first;
      long long D = graph[edge][i].second;

      if (check[next] == false){
        check[next] = true;
        dist[next] = dist[edge] + D;
        que.push(next);
      }
    }
  }

  vector <long long> ans(Q);
  for (int i = 0; i < Q; i++){
    int X, Y; cin >> X >> Y;
    X--; Y--;
    ans[i] = dist[X] + dist[Y];
  }

  for (int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
  
  
  
  
  return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=1000005,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n;
int Fac[N],Inv[N];
void prework(){
	int n=N-5;
	for (int i=Fac[0]=1;i<=n;i++)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
}
int C(int n,int m){
	if (m>n||m<0)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int dp[N][3];
int main(){
	n=read();
	prework();
	dp[0][0]=1;
	For(i,0,n-1)
		For(j,0,2){
			int v=dp[i][j];
			if (!v)
				continue;
			For(k,1,2)
				Add(dp[i+1][(j+k)%3],v);
		}
	int ans=0;
	For(i,1,n){
		int f=(LL)dp[i][1]*C(n,i)%mod;
		f=(LL)f*Pow(3,mod-1-(n))%mod;
		f=(LL)f*Pow((LL)n*i%mod,mod-2)%mod;
		Add(ans,f);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19712
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		rep(i, n){
			int m, e, j;
			scanf("%d%d%d", &m, &e, &j);
			
			char c;
			if(m==100 || e==100 || j==100 || m+e>=180 || m+e+j>=240)
				c = 'A';
			else if(m+e+j >= 210 || (m+e+j>=150 && (m>=80 || e>=80)))
				c = 'B';
			else
				c = 'C';
			printf("%c\n", c);
		}
	}
	return 0;
}

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

const int N = 630;
int n, D1, D2, col[N][N], ban[N][N];
vector<pair<int, int>> c, v[2];

void dfs(int x, int y) {
  for (auto d : c) {
    int ux = x + d.first, uy = y + d.second;
    if (ux < 0 || ux >= n || uy < 0 || uy >= n || ban[ux][uy] || ~col[ux][uy]) continue;
    col[ux][uy] = !col[x][y];
    v[col[ux][uy]].emplace_back(ux, uy);
    dfs(ux, uy);
  }
}
void solve(int D) {
  for (int i = -n; i <= n; i++) {
    for (int j = -n; j <= n; j++) {
      if (i * i + j * j == D) {
        c.emplace_back(i, j);
      }
    }
  }
  memset(col, -1, sizeof col);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!ban[i][j] && !~col[i][j]) {
        v[0].clear(), v[1].clear();
        col[i][j] = 0;
        v[0].emplace_back(i, j);
        dfs(i, j);
        if ((int) v[0].size() > (int) v[1].size()) swap(v[0], v[1]);
        for (auto d : v[0]) {
          ban[d.first][d.second] = 1;
        }
      }
    }
  }
}

int main() {
  scanf("%d%d%d", &n, &D1, &D2);
  n <<= 1;
  solve(D1);
  solve(D2);
  for (int i = 0, b = (n >> 1) * (n >> 1); i < n && b; i++) {
    for (int j = 0; j < n && b; j++) {
      if (!ban[i][j]) {
        --b;
        printf("%d %d\n", i, j);
      }
    }
  }
}


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

using namespace std;

int main(){
    int n, T;
    scanf("%d%d", &n, &T);
    int mi = 0x3f3f3f3f;
    int x, y;
    for(int i = 0; i < n; i++){
        scanf("%d%d", &x, &y);
        if(y <= T && x <mi){
            mi = x;
        }
    }
    if(mi != 0x3f3f3f3f)
    printf("%d\n", mi);
    else cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
// double print_double(double d){printf("%.6f", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int N;
  ll x,cnt=0,t;
  cin >> N >> x;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  if (A[0]>x) {
    cnt += A[0]-x;
    A[0] = x;
  }
  rep2(i,1,N) {
    if (A[i-1]+A[i]>x) {
      t = x-A[i-1];
      cnt += A[i] - t;
      A[i]=t;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
from collections import Counter

H, W = map(int, input().split())

num = [0]*5

for h in range(-(-H//2)):
    for w in range(-(-W//2)):
        tmp = 1
        if h < H//2:
            tmp *= 2
        if w < W//2:
            tmp *= 2
        num[tmp] += 1

s = ""
for _ in range(H):
    s += input()

c = list(Counter(s).values())
c.sort(reverse = True)

four = 0
for i in range(len(c)):
    if four == num[4]:
        break
    while c[i] >= 4:
        c[i] -= 4
        four += 1
        if four == num[4]:
            break

two = 0
for i in range(len(c)):
    if two == num[2]:
        break
    while c[i] >= 2:
        c[i] -= 2
        two += 1
        if two == num[2]:
            break

print("Yes" if sum(c) == num[1] and four == num[4] and two == num[2] else "No")

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

int main(){
  long n; cin >> n;
  long maxs; maxs = sqrt(n);
  long a, b;
  for(long i=maxs; i>0; i--){
    if(n % i == 0){
      a = i;
      b = n/i;
      break;
    }
  }
  long ans; ans = a+b-2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
string s,t;
int ans;
int main(){
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3848
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int n,m;
	scanf("%i%i",&n,&m);
	if(n==m)	printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

char s[10];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,m;scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
		{
			scanf("%s",s);if (s[0]=='s'&&s[1]=='n'&&s[2]=='u'&&s[3]=='k'&&s[4]=='e') printf("%c%d\n",j+'A',i+1);
		} 
	return 0;
}



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

int main() {
    int N,K;
    cin >> N >> K;

    vector<int> D;
    int d;
    for(int i=0;i<K;i++){
        cin >> d;
        D.push_back(d);
    }

    bool flag=true;
    for(int i=N;;i++){
        flag=true;
        for(int j=0;j<D.size();j++){
            int temp=i;
            while(temp!=0){
                if(temp%10==D[j]) flag=false;
                else temp/=10;

                if(flag==false) break;
            }
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int W = stdin.nextInt();
	int H = stdin.nextInt();
	int x = stdin.nextInt();
	int y = stdin.nextInt();
	int r = stdin.nextInt();
        if(x<=0 || y<=0){
	    System.out.println("No");
	}
	else if( 0<=x+r && x+r<=W && 0<=y+r && y+r<=H ){
	    System.out.println("Yes");
		}
	else{System.out.println("No");
		}
    }
}

Measured memory_bytes: 26104
#include<stdio.h>
#define max 1000000
int p[200],m[200][200];
int mat(int);
int min(int,int);
int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  mat(n);
  return 0;
}
int mat(int n){
  int i,j,l,k,q;
  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j= i+l-1;
      m[i][j] = max;
      for(k=i;k<=j-1;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j]=min(m[i][j],q);
      }
    }
  }
  printf("%d\n",m[1][n]);
}
int min(int a,int b){
  if(a>b) return b;
  else return a;
}


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

int main(){
  int a,b,v,ans=-1;
  cin >> a >> b;
  v = b/0.1;
  /*ｖを作ることでとりあえずｂを満たすような最小値を作る
  	aの方でやるとこのｖよりおおきくなる？			  */
  while(v < 1010){
    int x,y,tmp1,tmp2;
    x = v;
    y = v;
    x*=0.1;
    y*=0.08;
    tmp1 = x;
    tmp2 = y;
    //ゴリ押しで整数型に直した...どうやるんだっけか勉強しろ
	if(tmp1 == b)
    if(tmp2 == a){
      ans = v;
      break;
    }
    //最小値を出すための条件、入れ子にしなくてもいいかも？
    v++;    
  }

  cout << ans;
  return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,a,b,c,ans;
int main(){
    cin>>a>>b>>c>>x;
    for(int i=0;i<a+1;i++){
        for(int u=0;u<b+1;u++){
            for(int r=0;r<c+1;r++){
                if(x==(500*i)+(100*u)+(50*r))ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<=n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
//素数判定
bool prime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
signed main() {
	ll k, s;
	cin >> k >> s;
	ll ans = 0;
	rep(i, k) {
		rep(j, k) {
			if (s - i - j <= k && s - i - j >= 0)ans++;
		}
	}
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,i=get_i
puts N-i+1

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

using namespace std;

const string need="AKIHABARA";
int main(){
    string s;
    cin>>s;
    int pos=0;
    for(int cur=0;cur<need.size();cur++){
        if (need[cur]==s[pos]){
            pos++;
            continue;
        }
        if (need[cur]!='A'){
            cout<<"NO\n";
            return 0;
        }
    }
    cout<<(pos==s.size()?"YES":"NO");
}


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

#define MAX_N (100)

int compare(const void *px, const void *py) {
  return *((int *) px) - *((int *) py);
}

int main(int argc, char *argv[]) {
  int N, a[MAX_N], ans;
  // read inputs
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    scanf("%d", &a[i]);
  // calculate
  qsort(a, N, sizeof(int), compare);
  ans = 0;
  for (int i = 0; i < N; i++)
    if (i % 2 == 0)
      ans += a[N - 1 - i];
    else
      ans -= a[N - 1 - i];
  // print ans
  printf("%d\n", ans);
}


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

using namespace std;

typedef pair<int,int> pi;

int main()
{
    string a, b, Final;
    cin >> a >> b;
    int n = a.length();
    int m = b.length();
    vector<vector<int> > ans(n+1,vector<int>(m+1,0));
    vector<vector< pi > > prev(n+1,vector<pi>(m+1,make_pair(-1,-1)));
    for(int i=n-1; i>=0; i--)
    {
        for(int j=m-1; j>=0; j--)
        {
            if(a[i]==b[j])
            {
                ans[i][j] = 1 + ans[i+1][j+1];
                prev[i][j] = make_pair(i+1,j+1);
            }
            else
            {
                if(ans[i][j+1]>ans[i+1][j])
                {
                    ans[i][j] = ans[i][j+1];
                    prev[i][j] = prev[i][j+1];
                }
                else
                {
                    ans[i][j]=ans[i+1][j];
                    prev[i][j]=prev[i+1][j];
                }
            }
        }
    }
    pi p = prev[0][0], last=make_pair(-1,-1);
    while(p!=last)
    {
        int i = p.first-1;
        Final.push_back(a[i]);

        p = prev[p.first][p.second];
    }
    cout << Final;
    return 0;
}


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

using namespace std;

unsigned long long power(int a, int b)
{
	if (b == 0) { return 1LL; }

	return power(a, b - 1) * a;
}

int main()
{
	vector<bool> s(1000001, false);

	for (int i = 0; i < 22; i++)
	{
		for (int j = 0; j < 14; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				unsigned long long sum = power(2, i) * power(3, j) * power(5, k);

				if (sum <= 1000000ULL)
				{
					s[sum] = true;
				}
			}
		}
	}

	int m, n;

	while (cin >> m >> n)
	{
		int sum = 0;

		for (int i = m; i <= n; i++)
		{
			sum += (s[i] ? 1 : 0);
		}

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 3092