akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
  int n;cin>>n;
  vi a(4);
  rep(i,n){
      string s;
      cin>>s;
      if(s=="AC")a.at(0)++;
      else if(s=="WA")a.at(1)++;
      else if(s=="TLE")a.at(2)++;
      else if(s=="RE")a.at(3)++;

  }
  cout<<"AC x "<<a.at(0)<<endl;
  cout<<"WA x "<<a.at(1)<<endl;
  cout<<"TLE x "<<a.at(2)<<endl;
  cout<<"RE x "<<a.at(3)<<endl;
 }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n;
        cin>>n;
        vi a(n),b(n);
        for(int i=0;i<n;i++)cin>>a[i]>>b[i];
        ll ans=0;
        for(int i=n-1;i>=0;i--)
        {
            a[i]+=ans;
            ll x=a[i]%b[i];
            if(x)ans+=(b[i]-x);
        }
        cout<<ans<<endl;
    }
}

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


int main(){
    int n,k;    cin >> n >> k ;
    int cnt = 0;
    int a[n];
    rep(i,n) cin >> a[i];

    rep(i,n){
        if(a[i]>=k)cnt++;
        
    }

    cout << cnt << endl;
}




Measured memory_bytes: 640
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      var n = readLine.split(" ").map(_.toInt)
      while( n(0) != 0 || n(1) != 0) {
        println("#"*n(1))

        (2 to n(0)-1).foreach(s=> { print("#");print("."*(n(1)-2));print("#\n") })

        if(n(0)>1) {
          println("#"*n(1))
        }
        println("")
        n = readLine.split(" ").map(_.toInt)
      }
  }
}

Measured memory_bytes: 44816
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;

int main(){
  string s; cin>>s;
  for(int i=0;i<s.size()-1;i++) {
    if (s[i]=='A'&&s[i+1]=='C') {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

int main() {
  int N;
  cin >> N;
  
  int dmin = 1000;
  int i = 0;
  while (i < N) {
    int x;
    cin >> x;
    int d = 0;
    while (x % 2 == 0) {
      d++;
      x /= 2;
    }
    dmin = min(dmin, d);
    i++;
  }

  cout << dmin << endl;
}


Measured memory_bytes: 256
S = list(input())
T = list(input())

def kakikae_count(S_i):
    count = 0
    for i in range(len(T)):
        if S[S_i + i] != T[i]:
            count += 1
    return count

min_count = len(T)
for i in range(0, len(S) - len(T) + 1):
    need_count = kakikae_count(i)
    if need_count < min_count:
        min_count = need_count
print(min_count)
            

Measured memory_bytes: 9124
while 1:
        n=input()
        if n==0:
                break
        a=b=0
        for i in range(n):
                c=map(int,raw_input().split())
                if c[0]>c[1]:
                        a+=c[0]+c[1]
                elif c[0]<c[1]:
                        b+=c[0]+c[1]
                elif c[0]==c[1]:
                        a+=c[0]
                        b+=c[1]
        print a,b

Measured memory_bytes: 4476
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=2e5+5;
int n,m;
struct po{int x,y,ty;}p[maxn],q[maxn];
int g[205][205],vis[2005],lk[2005];
int dfs(int x){
	for(int i=1;i<=100;i++){
		if(g[x][i] && !vis[i]){
			vis[i] = 1;
			if(lk[i]==-1 || dfs(lk[i])){
				lk[i]=x; 
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&p[i].x,&p[i].y);
	for(int i=1;i<=n;i++)scanf("%d%d",&q[i].x,&q[i].y);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(p[i].x<=q[j].x&&p[i].y<=q[j].y)g[i][j] = 1;
	memset(lk,-1,sizeof lk);int ans=0;
	for(int i=1;i<=n;i++){memset(vis,0,sizeof vis);if(dfs(i))++ans;}
	printf("%d\n",ans); 
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vs ans={
		"pon",
		"pon",
		"hon",
		"bon",
		"hon",
		"hon",
		"pon",
		"hon",
		"pon",
		"hon"
	};
	puta(ans[n%10]);
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




int main() {
    ll w, h;
    cin >> w >> h;
    vector<pair<ll, ll>> a(w + h);
    REP(i, w + h){
        ll t;
        cin >> t;
        a[i] = {t, (i < w)? 0 : 1};
    }
    sort(a.begin(), a.end());
    ll x = w + 1, y = h + 1;
    ll ans = 0;
    REP(i, w + h){
        if(a[i].second == 0){
            ans += a[i].first * y;
            x--;
        }
        else{
            ans += a[i].first * x;
            y--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define INF (1e9)
#define MAX_N 14
using namespace std;
typedef complex<double> P;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int n;
double x,y;
double dp[(1<<MAX_N)][MAX_N*2];
vector<P> v;

int main(){
  int T=1;
  while(1){
    cin>>n;
    if(!n)break;
    double ans=0;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      v.push_back(P(x,y));
      cin>>x>>y;
      v.push_back(P(x,y));
      ans+=abs(v[v.size()-1]-v[v.size()-2]);
    }
    Fill(dp,INF);
    for(int i=0;i<n*2;i++)
      dp[(1<<(i/2))][i]=0;
    for(int i=0;i<(1<<n);i++){
      for(int j=0;j<n*2;j++){
	if(dp[i][j]==INF)continue;
	int p1=j;
	for(int l=0;l<n;l++){
	  if(i&(1<<l))continue;
	  int p3=l*2,p4=l*2+1;
	  int next=p4;
	  dp[i|(1<<l)][next]=min(dp[i|(1<<l)][next],dp[i][j]+abs(v[p1]-v[p3]));
	  next=p3;
	  dp[i|(1<<l)][next]=min(dp[i|(1<<l)][next],dp[i][j]+abs(v[p1]-v[p4]));
	}
      }
    }
    double minl=INF;
    for(int i=0;i<n*2;i++)
      minl=min(minl,dp[(1<<n)-1][i]);
    ans+=minl;
    cout<<"Case "<<T<<": ";
    printf("%.5f\n",ans);
    T++;
    v.clear();
  }
  return 0;
}

Measured memory_bytes: 6836
#include<iostream>
using namespace std;
int main(){
    int a[4][50],b[4][50],hit,blow,n;
    n = 0;
    int i = 0;
    while(cin >> a[0][i] >> a[1][i] >> a[2][i] >> a[3][i] >> b[0][i] >> b[1][i] >> b[2][i] >> b[3][i]) {
        n++; i++;
    };
    for(int i = 0;i < n;i++){
        hit = blow = 0;
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                if(a[j][i] == b[k][i]){
                    if(j == k){
                        hit++;
                    }
                    else{
                        blow++;
                    }
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define f(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define vl vector<ll>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";
#define printv(v) for(auto it : v) cout<<it<<" ";


//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;
const long long int MOD = 1e9+7;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

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

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{
    ll x,t,n;
cin>>n>>x>>t;
if(n%x==0)
cout<<(n/x)*t<<endl;
else
cout<<(n/x+1)*t<<endl;
}
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		//Input
		Scanner sc = new Scanner(System.in);
		int W = Integer.parseInt(sc.next());
		int H = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		sc.close();

		int count = 0;

		if(x + x == W && y + y == H) {
			count = 1;
		}

		double answer = ((double)W * (double)H) / 2;

		System.out.println(answer + " " + count);

	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x *= -1;
    long long ans = 0;
    if (k <= x / d) {
        ans = x - k * d;
    } else {
        long long num = x / d;
        k -= num;
        int mod = k % 2;
        ans = abs(x - d * (num + mod));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
h, w = map(int, input().split())

s = [list(input()) for _ in range(h)]
ans = [["#"]*w for _ in range(h)]

DX = [0, -1, -1, -1,  0,  1, 1, 1]
DY = [1,  1,  0, -1, -1, -1, 0, 1]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        count = 0
        for k in range(8):
            dx, dy = j+DX[k], i+DY[k]
            if not(0<=dx<=w-1 and 0<=dy<=h-1):
                continue
            if s[dy][dx] == "#":
                count += 1
        ans[i][j] = count
for a in ans:
    print(*a,sep="")


Measured memory_bytes: 3444
def main():
    H1, M1, H2, M2, K = list(map(int, input().split()))

    h1 = H1 * 60 + M1
    h2 = H2 * 60 + M2
    ans = h2 - K - h1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include <stdio.h>
int main(){
  int a, b, c;
  scanf("%d %d %d",&a, &b, &c);
  
  if(a == b && a != c || a != b && a ==c || b == c && a != b ){
    printf("Yes");
  }
  
  else {
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    string s ,t;
    cin >>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;

    if (u==s){
        a-=1;
    }
   else if (u==t){
        b-=1;
   }

    cout<<a <<' '<< b;


    return 0;
}


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

int main(){ 
    int H,W;
    cin >> H >> W;
    while(H!=0 || W!=0){
        for(int i=1; i<=H; ++i){
        	for(int j=1; j<=W; ++j){
        		if((i%2==1 && j%2==1) || (i%2==0 && j%2==0)){
        			cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
}


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

using namespace std; 

int main() {

	int a[5]; 
	int totalTime = 0, maxRemainder = 0; 

	for(int i = 0; i < 5; i++) {
		cin >> a[i]; 

		int remainder = a[i]%10;

		if(remainder == 0) {
			totalTime += a[i]; 
		} 
		else {
			maxRemainder = max(maxRemainder, 10 - remainder); 
			totalTime += a[i] + 10 - remainder; 
		}
	}
	cout << totalTime - maxRemainder << endl; 

	return 0; 
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define in(v) if (scanf("%d", &v)<1);

int main() {

  int N; in(N);
  int A[N], B[N], C[N];
  rep(i, N) in(A[i]);
  rep(i, N) in(B[i]);
  rep(i, N) in(C[i]);

  sort(A, A+N); sort(B, B+N); sort(C, C+N);

  ll count_b[N+1];
  count_b[N] = 0;
  rep(i, N) {
    count_b[N-1-i] = count_b[N-1-i+1] + (int)(C+N - upper_bound(C, C+N, B[N-1-i]));
  }
  ll ans = 0;
  rep(i, N) {
    int index = (int)(upper_bound(B, B+N, A[i]) - B);
    if (index >= 0)
      ans += count_b[index];
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

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

Measured memory_bytes: 17328
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		int count = 0;
		Pattern p = Pattern.compile(w, Pattern.CASE_INSENSITIVE);
		
		while(true) {
			String t = sc.next();
			if(t.equals("END_OF_TEXT")) {
				break;
			}
			
			Matcher m = p.matcher(t);
			
			if(m.find()&&m.group().equals(t)) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26308
#include<stdio.h>
int main(void)
{
	int A = 0, B = 0, RESULT = 0;
	
	scanf("%d", &A);
	scanf("%d", &B);

	RESULT = A - B * 2;

	if (RESULT <= 0)
	{
		RESULT = 0;
	}
	if (A <= B)
	{
		RESULT = 0;
	}

	printf("%d", RESULT);

	return 0;
}

Measured memory_bytes: 128
A,B,C = map(int,input().split())

if A == 5 and B == 5 and C == 7:
	print("YES")
elif B == 5 and C == 5 and A == 7:
	print("YES")
elif C == 5 and A == 5 and B == 7:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;

struct Edge
{
    int to;
    int next;
} a[400009];
int cnt;
int head[400009];
int n;
int vis[400009];
void addedg(int u,int v)
{
    a[cnt].to=v;
    a[cnt].next=head[u];
    head[u]=cnt++;
}
int flag=0;
int dfs(int s,int t)
{
    if(t==2)
    {
        if(s==n)
        {
            return 1;
        }
    }
    if(t<2)
    {
        for(int e=head[s]; e!=-1; e=a[e].next)
        {
            if(dfs(a[e].to,t+1))return 1;
        }
    }
    return 0;
}
int main()
{
    int m;
    cin>>n>>m;
    memset(vis,0,sizeof(vis));
    memset(head,-1,sizeof(head));
    cnt=0;
    for(int i=1; i<=m; i++)
    {
        int u,v;
        cin>>u>>v;
        addedg(u,v);
        addedg(v,u);
    }
    // vis[1]=0;
    if(dfs(1,0))
    {
        cout<<"POSSIBLE";
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if ((a + b == c) || (b + c == a) || (c + a == b)) 
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
} 

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)












 
int main(){
    int n;
    cin >> n;
    if(n % 2 == 0){
        printf("%.8lf\n", 1.0 / 2.0);
    }
    else{
        printf("%.8lf\n", (double)(n / 2 + 1) / (double)(n));
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#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 MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	int n;
	int a[100001];
	int p = 0;
	long long int count = 0;

	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
		a[i] += p;
		if (a[i] % 2 == 1&&a[i]!=1) {
			p = 1;
		}
		else {
			p = 0;
		}
		count += a[i] / 2;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S; cin >> S;
  vector<int> W(N, 0);
  vector<int> R(N, 0);
  REP(i, N){
    if(S[i] == 'W'){
      if(i == 0){
        W[i] = 1;
      }else{
        W[i] = W[i-1]+1;
      }
    }else{
      if(i != 0){
        W[i] = W[i-1];
      }
    }
  }
  for(int i = N-1; i >= 0; i--){
    if(S[i] == 'R'){
      if(i == N-1){
        R[i] = 1;
      }else{
        R[i] = R[i+1]+1;
      }
    }else{
      if(i != N-1){
        R[i] = R[i+1];
      }
    }
  }
  int ans = 0;
  REP(i, N){
    if(W[i] >= R[i]){
      ans = R[i];
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5184
N = int(input())
l = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for i in range(3)] for j in range(N+1)]


for i in range(1, N+1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i-1][k]+l[i-1][k])

print(max(dp[N][0], dp[N][1], dp[N][2]))



Measured memory_bytes: 47328
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    
    vector<long long int> P(A);
    vector<long long int> Q(B);
    vector<long long int> R(C);
    for(int a=0; a<A; a++) {
        cin >> P[a];
    }
    for(int b=0; b<B; b++) {
        cin >> Q[b];
    }
    for(int c=0; c<C; c++) {
        cin >> R[c];
    }
    
    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    sort(R.begin(), R.end());
    
    priority_queue<long long int, vector<long long int>, greater<long long int> >pq;
    long long int sum=0;
    for(int x=0; x<X; x++) {
        pq.push(P[P.size()-1-x]);
        sum += P[P.size()-1-x];
    }
    for(int y=0; y<Y; y++) {
        pq.push(Q[Q.size()-1-y]);
        sum += Q[Q.size()-1-y];
    }
    
    int cnt=R.size()-1;
    while(cnt>=0 && R[cnt]>pq.top()) {
        sum -= pq.top();
        pq.pop();
        sum += R[cnt];
        cnt--;
    }
    
    cout << sum << endl;
    

    return 0;
    
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
const int mod = 1000000007;
const int N = 2e5+5, M = N;
//=========================================

const int MAXN = 302;
double dp[MAXN][MAXN][MAXN];
int n, vis[MAXN][MAXN][MAXN];

double solve(int x, int y, int z){
    if(vis[x][y][z]) return dp[x][y][z];
    // mark the state visited
    vis[x][y][z] = 1;

    if(x == 0 && y == 0 && z == 0) return dp[x][y][z] = 0;

    int soma = x + y + z;
    double convert = (double)soma;
    double rem = (n - soma) / convert;

    if(x != 0) rem += x * ((solve(x - 1, y, z) + 1) / convert);
    if(y != 0) rem += y * ((solve(x + 1, y - 1, z) + 1) / convert);
    if(z != 0) rem += z * ((solve(x, y + 1, z - 1) + 1) / convert);

    return dp[x][y][z] = rem;
}


int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    int a[4] = {0, 0, 0, 0};
    cin >> n;

    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        a[x]++;
    }

    double answer = solve(a[1], a[2], a[3]);
    cout << fixed << setprecision(9) << answer << "\n";

    return 0;
}


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

using std::cin; 
using std::cout; 

int main() { 
    long long x; 
    cin >> x; 
    if (x <= 6) { 
        cout << 1 << "\n"; 
        return 0; 
    }
    long long first_steps = x / 11; 
    if (x - 11 * first_steps > 6) { 
        cout << 2 * first_steps + 2; 
    } else if (x - 11 * first_steps > 0){ 
        cout << 2 * first_steps + 1; 
    } else { 
        cout << 2 * first_steps; 
    }
    return 0; 
}

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

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

vector<vector<int> > g;

P bfs(int s){
    vector<int> dist(g.size(),-1);
    queue<int> que;
    que.push(s);
    dist[s] = 0;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto u : g[v]){
            if(dist[u] != -1) continue;
            dist[u] = dist[v] + 1;
            que.push(u);
        }
    }
    int dmax = 0, idx = -1;
    for(int i=0;i<int(g.size());i++){
        if(dist[i] > dmax){
            dmax = dist[i];
            idx = i;
        }
    }
    return P(idx, dmax);
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int u = 0, v, dmax = 0;
    for(int i=0;i<10;i++){
        auto p = bfs(u);
        v = u;
        u = p.first;
        dmax = p.second;
    }
    cout << (dmax%3 == 1 ? "Second" : "First") << endl;
    return 0;
}

Measured memory_bytes: 13600
#include <iostream>
using namespace std;
int main() {
	int a;
	int b;
	int t;
	cin >> t;
	a = (t-(t % 100))/100;
	b = t % 100;
	if (1 <= a && a<= 12)
	{
		if (1 <= b && b<= 12)
			cout << "AMBIGUOUS";
		else
			cout << "MMYY";
	}
	else
	{
		if (1 <= b&& b <= 12)
		{
			cout << "YYMM";
		}
		else cout << "NA";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int aHP = scan.nextInt(), aA = scan.nextInt(), bHP = scan.nextInt(), bA = scan.nextInt();
		
		int ashibou = 0, bshibou = 0;
		
		if(aHP % bA != 0) {
			ashibou = aHP / bA +1;
			
		}else {
			ashibou = aHP / bA;
			
		}
		
		if(bHP % aA != 0) {
			bshibou = bHP / aA +1;
			
		}else {
			bshibou = bHP / aA;
			
		}
		
				
		if(ashibou >= bshibou) {
			System.out.println("Yes");
			
		}else {
			System.out.println("No");
			
		}
		
	}
	
		
		
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string pre;
    string tmp;
    int32 cnt = 0;
    REP(i,s.size()){
        tmp += s[i];
        if(tmp != pre){
            ++cnt;
            pre = tmp;
            tmp = "";
        }
    }
    ANS(cnt);
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define pb push_back

using namespace std;
typedef vector<int> VI;

const int N=2005;

int gcd(int x,int y){return y?gcd(y,x%y):x;}

int n,a[N];
VI E[N],R[N];
bool vis[N];

VI merge(const VI&x,const VI&y){
	VI z;
	z.resize(x.size()+y.size());
	for(int i=0,j=0,k=0,li=x.size(),lj=y.size();i<li||j<lj;){
		if(i==li)z[k++]=y[j++];
		else if(j==lj)z[k++]=x[i++];
		else if(x[i]<y[j])z[k++]=y[j++];
		else z[k++]=x[i++];
	}
	return z;
}

void dfs(int x){
	vis[x]=true;
	for(int v:E[x])if(!vis[v])dfs(v),R[x]=merge(R[x],R[v]);
	R[x].insert(R[x].begin(),1,a[x]);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)
		if(gcd(a[i],a[j])>1)E[i].pb(j),E[j].pb(i);
	++n;
	for(int i=1;i<n;i++)E[i].pb(n),E[n].pb(i);
	dfs(n);
	for(int v:R[n])if(v)printf("%d ",v);
	return 0;
}

Measured memory_bytes: 32000
#include<cstdio>
#include<iostream>
#include<set>
#include<map>
using namespace std;
typedef pair<int,int> ipoint;
#define foreach(it,b,e) for(__typeof((b)) it=(b);it!=(e);++it)
#define foreachall(it,o) foreach(it,(o).begin(),(o).end())
#define rep(i,b,e) for(int i=(b);i<(e);++i)
int main(){
  while(true){
    int ans = 0;
    map<int, set<int> > Xa,Xb;
    int AN,BN,R;

    scanf("%d%d%d", &AN, &BN, &R);
    if( AN == 0 && BN == 0 ) break;

    rep(i,0,AN){ int xa,ya; scanf("%d%d",&xa,&ya); Xa[xa].insert(ya); }
    rep(i,0,BN){ int xb,yb; scanf("%d%d",&xb,&yb); Xb[xb].insert(yb); }

    foreachall(itxa,Xa){
      foreachall(itxas,itxa->second){
	int X=itxa->first;
	int Y=*itxas;	
	foreach(itm,Xb.lower_bound(X-4*R),Xb.upper_bound(X+4*R+1)){	    
	  foreach(its,itm->second.lower_bound(Y-4*R),itm->second.upper_bound(Y+4*R+1)){
	    int dx = X-itm->first, dy = Y-*its, d=dx*dx+dy*dy;
	    if( d <= 16*R*R ) ++ans;
	  }
	}
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

int main() {
  int n;
  string s;

  cin >> n;

  vector<int> a(4,0);

  for(int i=0;i<n;i++) {
    cin >> s;
    if(s=="AC") a[0]++;
    if(s=="WA") a[1]++;
    if(s=="TLE") a[2]++;
    if(s=="RE") a[3]++;
  }

  cout << "AC x " <<a[0]<<  endl;
  cout << "WA x " <<a[1]<<  endl;
  cout << "TLE x " <<a[2]<<  endl;
  cout << "RE x " <<a[3]<<  endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,zs,l;
int main()
{
	cin>>a>>b>>c;
	for (int i=1;i<=a;i++)
	  {
	  	cin>>l;
	  	if (l<b||l>=c) zs++; 
	  }
	cout<<zs<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m,q = map(int,input().split())
abcd = [[*map(int,input().split())] for _ in range(q)]
from itertools import *
ans = 0
for A in combinations_with_replacement(range(1, m+1), n): # nHr
    now = sum(d if A[b-1] - A[a-1] == c else 0 for a,b,c,d in abcd)
    ans = max(ans, now)
print(ans)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
typedef long long ll;
using namespace std;
 
int main(){
  int n,i;
  cin >> n >>i;
  
  int ans;
  ans = n-i+1;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto ans = g.scc();
    pr(ans.size());
    
    for (auto v: ans) {
        cout << v.size() << " ";
        for (int e: v) {
            cout << e << " ";
        }
        pr("");
    }
    return 0;
}


Measured memory_bytes: 40624
# @author 

import sys

class ENEQ:
    def solve(self, tc=0):
        from itertools import permutations
        MOD = 10 ** 9 + 7

        n, m = [int(_) for _ in input().split()]

        # op = [2, 3, 4, 5, 1, 6]
        # # op = [1, 2, 3, 4, 5, 6]
        # cnt = 0
        # for p in permutations(range(1, 7)):
        #     for i in range(6):
        #         if op[i] == p[i]:
        #             break
        #     else:
        #         cnt += 1
        #
        # print(cnt)

        D = [0] * (n + 1)
        D[0] = 1
        D[1] = m - n
        for i in range(2, n + 1):
            D[i] = (m - n + i - 1) * D[i - 1] + (i - 1) * D[i - 2]
            D[i] %= MOD

        fact = [1] * (m + 1)
        for i in range(1, m + 1):
            fact[i] = fact[i - 1] * i
            fact[i] %= MOD
        ans = fact[m] * pow(fact[m - n], MOD - 2, MOD) * D[n]
        ans %= MOD

        print(ans)

solver = ENEQ()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 72144
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=405;
int fa[N],vis[N],in[N],out[N],n,h;
inline int find(R int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	scanf("%d%d",&n,&h);
	fp(i,0,h<<1)fa[i]=i;
	for(R int i=1,a,b,c,d,l,r;i<=n;++i){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		l=(c?-c:a)+h,r=(d?d:-b)+h,fa[find(l)]=find(r);
		++out[l],++in[r];
	}
	fp(i,-h,-1)if(out[i+h]>in[i+h])return puts("NO"),0;
	fp(i,1,h)if(in[i+h]>out[i+h])return puts("NO"),0;
	fp(i,0,h<<1)if(in[i]!=out[i])vis[find(i)]=1;
	fp(i,0,h<<1)if(in[i]&&out[i]&&!vis[find(i)])return puts("NO"),0;
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    double l;
    cin>>l;
    double t = l/3.0;
    cout<<t*t*t;
    
    
    
} 

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

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s[i]==s[i+1])n--;
  }
  cout << n << endl;
}



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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;

int main() {
    string s;
    cin >> s;
    string t = "keyence";
    if (s == t) {
        cout << "YES" << endl;
        return 0;
    } else {
        for (int i = 0; i < s.length(); ++i) {
            for (int j = i; j < s.length(); ++j) {
                string x = s.substr(0, i) + s.substr(j, s.length() - j);
                if (x == t) {
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

	int n;
	ll k;
	cin >> n >> k;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	vector<ll> s(n+1, 0);
	rep(i, n) s[i+1] = s[i] + a[i];

	map<ll, ll> mp;
	mp[0] = 1;

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(i+1 >= k) mp[s[i+1-k]]--;

		s[i+1] = (s[i] + (a[i] - 1)) % k;
		if(mp.count(s[i+1]) > 0){
			ans += mp[s[i+1]];
		}else{
			mp[s[i+1]] = 0;
		}
		mp[s[i+1]]++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 15872
n, x = map(int, input().split())
while not (n == 0 and x == 0):
  count = 0
  for i in range(1, n+1):
    for j in range(1, n+1):
      for k in range(1, n+1):
        if i < j and j < k and i + j + k == x:
          count = count + 1
  print(count)
  n, x = map(int, input().split())


Measured memory_bytes: 5596
using System;

namespace aoj3c
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i = 1; i < 3001; i++)
            {
                string str = Console.ReadLine();
                string[] num = str.Split(' ');
                int a = int.Parse(num[0]);
                int b = int.Parse(num[1]);

                if(a == 0 && b == 0)
                {
                    break;
                }

                if(a > b)
                {
                    Console.WriteLine(b + " " + a);
                }
                else
                {
                    Console.WriteLine(a + " " + b);
                }

            }
        
        }
    }
}

Measured memory_bytes: 9300
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N, M;

  cin >> N >> M;

  priority_queue<ll> pq;

  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    pq.push(tmp);
  }

  for (int i = 0; i < M; i++) {
    ll tmp = pq.top();
    pq.pop();
    pq.push(tmp / 2);
  }

  ll ans = 0;
  while(!pq.empty()){
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        BIT bit = new BIT(n);
        for (int i = 0; i < n; i++) {
            bit.add(i+1, sc.nextInt());
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int t = sc.nextInt();
            if(t == 0){
                int p = sc.nextInt()+1;
                int x = sc.nextInt();
                bit.add(p, x);
            }else{
                int l = sc.nextInt()+1;
                int r = sc.nextInt();
                sb.append(bit.sum(l, r) + "\n");
            }
        }
        System.out.println(sb.toString());
        sc.close();

    }

}
class BIT {

    private int n;
    private long[] bit;

    /**
     * コンストラクタ.<br>
     * 長さ n+1、初期値 0の配列を生成する.<br>
     * 計算量：O(N)
     * @param n
     */
    public BIT(int n){
        this.n = n;
        this.bit = new long[n+1];
    }

    /**
     * i番目の要素にxを加算する.<br>
     * 計算量：O(logN)
     * @param i
     * @param x
     */
    public void add(int i, int x){
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    /**
     * 0～i番目までの要素の総和.<br>
     * 計算量：O(logN)
     * @param i
     */
    public long sum(int i){
        long s = 0L;
        while(0 < i){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    public long sum(int l, int r) {
        return sum(r) - sum(l-1);
    }

    /**
     * k ≦ sum(x) となる最小のxを求める.<br>
     * 計算量：O(logN)
     * @param k
     * @return
     */
    public int lowerBound(int k){
        if(k <= 0) return 0;
        int x = 0;
        int max = 1;
        while(max < n) max *= 2;
        for (int i = max; i > 0; i /= 2) {
            if(x + i <= n && bit[x + i] < k){
                k -= bit[x + i];
                x += i;
            }
        }
        return x + 1;
    }

}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int x,y;
    cin >> x >> y;
    int ans = INT_MAX;
    int dx[4] = {1,1,-1,-1};
    int dy[4] = {1,-1,1,-1};

    for (int i = 0; i < 4; ++i) {
        int tx = x * dx[i];
        int ty = y * dy[i];
        if (tx <= ty) {
            int cnt = 0;
            if (dx[i] == -1) {
                cnt++;
            }
            if (dy[i] == -1) {
                cnt++;
            }
            ans = min(ans, (ty - tx) + cnt);
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;
 
const int N = 1e5 + 5;
 
const int inf = (signed) (~0u >> 2);
 
typedef class Segment {
    public:
        int l, r;
 
        Segment() { }
        Segment(int l, int r) : l(l), r(r) {    }
 
        Segment operator & (Segment b) const {
            return Segment(max(l, b.l), min(r, b.r));
        }
        int length() {
            return max(r - l + 1, 0);
        }
        boolean operator < (Segment b) const {
            return r < b.r;
        }
} Segment;
 
int n;
Segment s[N], sl[N], sr[N];
 
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &s[i].l, &s[i].r);
    }
    sort(s + 1, s + n + 1);
    int ans = 0;
    sl[0] = Segment(0, inf);
    for (int i = 1; i <= n; i++)
        sl[i] = sl[i - 1] & s[i];
    sr[n + 1] = Segment(0, inf);
    for (int i = n; i; i--)
        sr[i] = sr[i + 1] & s[i];
    for (int i = 1; i < n; i++)
        ans = max(ans, sl[i].length() + sr[i + 1].length());
    for (int i = 1; i <= n; i++)
        ans = max(ans, s[i].length() + (sl[i - 1] & sr[i + 1]).length());
    printf("%d\n", ans);
    return 0;
}

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

int V[600][600];

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

	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;

		V[s - 1][t - 1] = 1;
	}

	vector<long double> deg(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; j++) {
			deg[i] += V[i][j];
		}
	}

	vector<long double> e(n);
	e[n - 1] = 0;
	for (int i = n - 2; i >= 0; --i) {
		for (int j = 0; j < n; ++j) {
			if (V[i][j] == 1) {
				e[i] += (1 + e[j]) / deg[i];
			}
		}
	}

	vector<long double> p(n);
	p[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (V[i][j] == 1) {
				p[j] += p[i] / deg[i];
			}
		}
	}

	long double ans = e[0];
	for (int i = 0; i < n - 1; ++i) {
		if (deg[i] == 1) {
			continue;
		}

		for (int j = i + 1; j < n; ++j) {
			if (V[i][j] == 0) {
				continue;
			}

			long double val = e[0];
			long double ne = (e[i] - 1) * deg[i];
			ne -= e[j];
			ne /= (deg[i] - 1);
			ne += 1;

			val += (ne - e[i]) * p[i];

			ans = min(ans, val);
		}
	}

	cout << setprecision(10) << ans;

	return 0;
}


Measured memory_bytes: 1664
import sys
l,r=map(int,input().split())

if 2018<=r-l:
  print(0)
  sys.exit()

L=l%2019
R=r%2019
m=2018

if L>R:
  print(0)
  sys.exit()

  
for i in range(L,R):
  for j in range(i+1,R+1):
    m=min((i*j)%2019,m)

print(m)

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

const int N = 1e5 + 100;

int n, z[N], ans[N];
bool check, mark[N];
vector<int> nei[N], child[N];

int dfs(int v) {
	vector<int> vec;
	if (check && z[v] != (child[v].size() & 1)) {
		cout << "IMPOSSIBLE\n";
		exit(0);
	}
	z[v] = child[v].size() & 1;
	if (z[v] == 0)
		vec.push_back(v);
	for (int u: child[v]) {
		int w = dfs(u);
		if (w != -1)
			vec.push_back(w);
	}
	while (vec.size() >= 2) {
		int a = vec.back();
		vec.pop_back();
		int b = vec.back();
		vec.pop_back();
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	return (vec.size()? vec.back(): -1);
}

void get_tree() {
	int root;
	for (int v = 0; v < n; v++)
		child[v].clear();
	for (int v = 0; v < n; v++) {
		int p;
		cin >> p;
		if (--p >= 0)
			child[p].push_back(v);
		else
			root = v;
	}
	dfs(root);
}

void input() {
	cin >> n;
	get_tree();
	check = true;
	get_tree();
}

void run(int v) {
	for (int u: nei[v])
		if (ans[u] == 0) {
			ans[u] = -ans[v];
			run(u);
		}
}

void solve() {
	for (int v = 0; v < n; v++)
		if (z[v])
			ans[v] = 0;
		else if (ans[v] == 0) {
			ans[v] = 1;
			run(v);
		}
	cout << "POSSIBLE\n";
	for (int v = 0; v < n; v++)
		cout << ans[v] << ' ';
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	solve();
}


Measured memory_bytes: 16640
#include <iostream>
using namespace std;
 
int a[100];
int main() {
    int n, m;
    cin >> n >> m;
    int tot = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        tot += a[i];
    }
    int x = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] * 4 * m >= tot) x++;
    }
    cout << (x >= m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256