akhauriyash/Code-Regression huggingface dataset:
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

char mp[1010][1010];

int main(){

    ll H, W, w, h;
    cin >> H >> W >> w >> h;
    rep1(y, H)rep1(x, W)mp[y][x] = '.';
    for(ll y = 1; W % 2 && y + 1 <= H && h; y += 2){
        mp[y][W] = '^';
        mp[y + 1][W] = 'v';
        h--;
    }
    for(ll x = 1; H % 2 && x + 1 <= W && w; x += 2){
        mp[H][x] = '<';
        mp[H][x + 1] = '>';
        w--;
    }
    
    for(ll y = 1; y + 1 <= H; y += 2){
        for(ll x = 1; x + 1 <= W; x += 2){
            if(h > 1){
                mp[y][x] = '^';
                mp[y][x + 1] = '^';
                mp[y + 1][x] = 'v';
                mp[y + 1][x + 1] = 'v';
                h -= 2;
            }
            else if(w > 1){
                mp[y][x] = '<';
                mp[y][x + 1] = '>';
                mp[y + 1][x] = '<';
                mp[y + 1][x + 1] = '>';
                w -= 2;
            }
            else if(h == 1){
                mp[y][x] = '^';
                mp[y + 1][x] = 'v';
                h--;
            }
            else if(w == 1){
                mp[y][x] = '<';
                mp[y][x + 1] = '>';
                w--;
            }
        }
    }
    if(H >= 3 && W >= 3 && h == 1 && mp[H-1][W-2] == '.' && mp[H-1][W-1] == '.' && mp[H][W-2] == '<' && mp[H][W-1] == '>' && mp[H][W] == '.'){
        h--;
        mp[H-1][W-2] = '^';
        mp[H-1][W-1] = '.';
        mp[H][W-2] = 'v';
        mp[H][W-1] = '<';
        mp[H][W] = '>';
    }
    if(H >= 3 && W >= 3 && w == 1 && mp[H-2][W-1] == '.' && mp[H-2][W] == '^' && mp[H-1][W-1] == '.' && mp[H-1][W] == 'v' && mp[H][W] == '.'){
        w--;
        mp[H-2][W-1] = '<';
        mp[H-2][W] = '>';
        mp[H-1][W-1] = '.';
        mp[H-1][W] = '^';
        mp[H][W] = 'v';
    }
    
    if(h || w){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
        rep1(y, H){
            rep1(x, W)cout << mp[y][x];
            cout << endl;
        }        
    }


    return 0;
}

Measured memory_bytes: 2176
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int a[N][5],dp[N][5];
int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int n;
        cin>>n;
        for(int i=1; i<=n; ++i) {
            for(int j=1; j<=3; ++j)
                cin>>a[i][j];
        }
        dp[1][1]=a[1][1],dp[1][2]=a[1][2],dp[1][3]=a[1][3];
        for(int i=2; i<=n; ++i) {
            dp[i][1]=max(a[i][1]+dp[i-1][2],a[i][1]+dp[i-1][3]);
            dp[i][2]=max(a[i][2]+dp[i-1][1],a[i][2]+dp[i-1][3]);
            dp[i][3]=max(a[i][3]+dp[i-1][2],a[i][3]+dp[i-1][1]);
            //cout<<dp[i][1]<<" "<<dp[i][2]<<" "<<dp[i][3]<<endl;
        }
        cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;
    }
    return 0;
}



Measured memory_bytes: 7488
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define md 1000000000
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res)*(x))%mod;
        }
        x=((x)*(x))%mod;
        y=y/2;
    }
    return res;
}



 
  
int main(){
 
 /* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
 
  ll n,k,i;
  sfl(n);sfl(k);

  ll l=0,r=0,ans=0;

  for(i=0;i<=n;i++){
     l+=i;
     r+=(n-i);

     if(i>=k-1){

     ans+=(r-l+1);

     ans%=mod;

   }

  }

  pf(ans);



   return 0;
 
  
 
    
 }

Measured memory_bytes: 3804
use proconio::{ input, fastout };

#[fastout]
fn main() {
    input! {
        n: i64,
        m: usize,
        hw: [i64; m],
    };
    let mut sum = 0;
    for i in 0..m {
        sum += hw[i];
    };
    let rest = n - sum ;
    if rest < 0 {
        println!("-1");
    } else {
        println!("{}", rest);
    }


}


Measured memory_bytes: 2280
import java.util.Arrays;
import java.util.Scanner;
 
import javax.net.ssl.SSLContext;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int[] obuget = new int[100010];
		int[] ebuget = new int[100010];
		int[] o = new int[100010];
		int[] e = new int[100010];
		int E = 0;
		int O = 0;
		int E2 = 0;
		int O2 = 0;
		int m = n/2;
		boolean f  = true;
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
 
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				ebuget[a[i]]++;
			} else {
				obuget[a[i]]++;
			}
		}
		System.arraycopy(ebuget, 0, e, 0, 100010);
		System.arraycopy(obuget, 0, o, 0, 100010);
		Arrays.sort(ebuget);
		Arrays.sort(obuget);
		E = ebuget[100009];
		O = obuget[100009];
		E2 = ebuget[100008];
		O2 = obuget[100008];
		
		for (int i = 0; i < 100010; i++) {
			if (e[i] == E && o[i] == O) {
				f = false;
			}
		}
		if (f) {
			int ans = (m-E)+(m-O);
			System.out.println(ans);
			return;
		} else {
			int ans1 = (m-E2)+(m-O);
			int ans2 = (m-E)+(m-O2);
			System.out.println(Math.min(ans1, ans2));
		}
	}
}

Measured memory_bytes: 61968
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	scan(N);scan(M);
	vpll AB;
	rep(i,N){
		ll a,b;
		scan(a);scan(b);
		AB.push_back(mp(a,b));
	}
	sort(AB.begin(),AB.end());
	ll ans=0,kosu=0;
	rep(i,N){
		if(kosu+AB[i].second<M){
			ans+=AB[i].first*AB[i].second;
			kosu+=AB[i].second;
		}
		else{
			ans+=(M-kosu)*AB[i].first;
			prin(ans);
			return 0;
		}
	}
	return 0;
}


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

int main()
{
    int n;
    string s;
    cin>>n>>s;
    if(n%2) {cout<<"No"<<endl;return 0;}
    int l=n/2;
    for(int i=0;i<l;i++)
    if(s[i]!=s[l+i]) {cout<<"No"<<endl;return 0;}
    cout<<"Yes"<<endl;return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,x,ans=0,i,j,k;
  while(1){
    scanf("%d %d",&n,&x);
    if(n==0&&x==0){
      break;
    }
    for(i=1; i<=n; i++){
      for(j=1; j<=n; j++){
	for(k=1; k<=n; k++){
          if((i+j+k)==x&&i!=j&&j!=k&&k!=i)ans+=1;
	}
      }
    }
    printf("%d\n",ans/6);
    ans=0;
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
int main()
{
    int A,B,C,count,ans;
    count=0;
    cin>>A>>B>>C;
    int array[]={A,B,C};
    if(A%2==B%2 and A%2==C%2){
        sort(array,array+3);
        ans=(array[2]-array[0])/2+(array[2]-array[1])/2;
        cout<<ans<<endl;
    }else{
        std::vector<int> vec_even;
        std::vector<int> vec_odd;
        int even_count=0;
        for(int i=0;i<3;i++){
            if (array[i]%2==0){
                even_count++;
                vec_even.push_back(array[i]);
            }else{
                vec_odd.push_back(array[i]);
            }
        }
        if(even_count==2){
            int odd=vec_odd[0];
            int max=vec_even[0]; int min=vec_even[1];
            if(max<min) swap(max,min);
            if(odd<max){
                ans=((max+1-odd)/2+1+(max-min)/2);
                cout<<ans<<endl;
            }else{
                ans=1+(odd-(max+1))/2+(odd-(min+1))/2;
                cout<<ans<<endl;
            }
        }else{
            int even=vec_even[0];
            int max=vec_odd[0]; int min=vec_odd[1];
            if(max<min) swap(max,min);
            if(even<max){
                ans=((max+1-even)/2+1+(max-min)/2);
                cout<<ans<<endl;
            }else{
                ans=1+(even-(max+1))/2+(even-(min+1))/2;
                cout<<ans<<endl;
            }
        }


    }
    return 0;

}

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

class Dice{

private:

  int top,front,right,left,back,bottom;

public:

  Dice(){
    top=1;
    front=2;
    right=3;
    left=4;
    back=5;
    bottom=6;
  }

 
int North(void){
  int t;
  t=top,top=front,front=bottom,bottom=back,back=t;
  return top;
}
 
int East(void){
  int t;
  t=top,top=left,left=bottom,bottom=right,right=t;
  return top;
}
 
int West(void){
  int t;
  t=top,top=right,right=bottom,bottom=left,left=t;
  return top;
}
 
int South(void){
  int t;
  t=top,top=back,back=bottom,bottom=front,front=t;
  return top;
}
 
int Right(void){
  int t;
  t=front,front=right,right=back,back=left,left=t;
  return top;
}
 
int Left(void){
  int t;
  t=front,front=left,left=back,back=right,right=t;
  return top;
}

};


int main(void){
  int n,sum;
  string s;
   
  while(cin >> n,n){
 
    Dice *d = new Dice();
    sum=1;
 
    for(int i=0;i<n;i++){
      cin >>s;
      if(s=="North")sum+=d->North();
      else if(s=="East")sum+=d->East();
      else if(s=="South")sum+=d->South();
      else if(s=="West")sum+=d->West();
      else if(s=="Left")sum+=d->Left();
      else if(s=="Right")sum+=d->Right();

    }
    cout << sum << endl;
  }

  return 0;
}

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

typedef long long ll;

vector< pair<ll,ll> > prime_factorize( ll N ){
    vector< pair<ll,ll> > res;
    for(ll i = 2 ; i * i <= N ; i++){
        if(N % i != 0) continue;
        
        ll cnt = 0;
        while(N % i == 0){
            N /= i;
            cnt++;
        }
        res.push_back( make_pair(i,cnt) );
    }
    
    if(N != 1){
        res.push_back( make_pair(N,1) );
    }
    return res;
}


int main(void){
    ll N;
    cin >> N;
    vector< pair<ll,ll> > res = prime_factorize(N);
    
    ll cnt = 0;
    for(int i = 0 ; i < res.size() ; i++){
        for(int j = 1 ; j <= res.at(i).second ; j++){
            
            ll tmp = pow( res.at(i).first , j );
            if(N % tmp == 0){
                N /= tmp;
                cnt++;
            }
            
            if(N < tmp) break;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_set>
using namespace std;

int n, m;
int cnt[200001];
int cover[200000];
int a[200000];

int main() {
	ios_base::sync_with_stdio(0);
	//freopen("game.in", "r", stdin);
	//freopen("game.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n >> m;
	int curr = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if (a[i] - cnt[a[i]] >= 0) {
			cover[a[i] - cnt[a[i]]]++;
			if (cover[a[i] - cnt[a[i]]] == 1) curr++;
		}
	}
	
	for (int i = 0; i < m; i++) {
		int ind, newVal;
		cin >> ind >> newVal;
		ind--;
		
		if (a[ind] - cnt[a[ind]] >= 0) {
		    cover[a[ind] - cnt[a[ind]]]--;
		    if (cover[a[ind] - cnt[a[ind]]] == 0) curr--;
		}
		cnt[a[ind]]--;
		
		cnt[newVal]++;
		if (newVal - cnt[newVal] >= 0) {
		    cover[newVal - cnt[newVal]]++;
		    if (cover[newVal - cnt[newVal]] == 1) curr++;
		}
		a[ind] = newVal;
		cout << n - curr << "\n";
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3840
//2020 2.16 素数

#include <stdio.h>
#include <math.h>
#define N 10000

int main()
{
    int i,j;
    int a;
    int cnt=0,flag=0;
    int A[N];

    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&A[i]);
        if(A[i]==2) {cnt++; continue;}
        if(A[i]%2==0) continue;
        for(j=3;j<=sqrt(A[i]);j=j+2)
        {
            if(A[i]%j==0) {flag=1; break; }
        }
        if(flag==0) {cnt++;}
        flag=0;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll dx[8]={0,0,-1,1,-1,1,-1,1};
ll dy[8]={1,-1,0,0,1,1,-1,-1};
vector<vector<ll> > c(10,vector<ll>(10,0));

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    string s; cin>>s;
    ll leftstock=0; //(
    ll rightstock=0; //)
    rep(i,sz(s)){
        if(s[i]=='('){
            leftstock++;
        }
        else{
            if(leftstock>0) leftstock--;
            else rightstock++;
        }
    }
    rep(i,rightstock) cout<<'(';
    cout<<s;
    rep(i,leftstock) cout<<')';
}


Measured memory_bytes: 3608
LARGE = 10 ** 9 + 7


def solve(n, a, b):

    pow_ab = [1] * (b + 1)
    for i in range(b):
        pow_ab[i + 1] = pow_ab[i] * (i + 1) % LARGE
    pow_ab_inv = [1] * (b + 1)
    pow_ab_inv[-1] = pow(pow_ab[-1], LARGE - 2, LARGE)
    for i in range(b - 1, 0, -1):
        pow_ab_inv[i] = pow_ab_inv[i + 1] * (i + 1) % LARGE

    res_all = pow(2, n, LARGE) - 1
    res_ab = 1
    for i in range(a):
        res_ab *= (n - i)
        res_ab %= LARGE
    res_all -= res_ab * pow_ab_inv[a]
    for i in range(a, b):
        res_ab *= (n - i)
        res_ab %= LARGE
    res_all -= res_ab * pow_ab_inv[b]
    return res_all % LARGE


def main():
    n, a, b = map(int, input().split())
    res = solve(n, a, b)
    print(res)


def test():
    assert solve(4, 1, 3) == 7
    assert solve(1000000000, 141421, 173205) == 34076506


if __name__ == "__main__":
    test()
    main()


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

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

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <tuple>
#include <string>
using namespace std;
int main(void)
{
  for(;;){
    int p,q;
    cin >> p >> q;
    if(p == 0 && q == 0){ return 0; }
    string p1[p];
    string p2[q];
    for(int i = 0 ; i < p ; i++){
      cin >> p1[i];
    }
    for(int i = 0 ; i < q ; i++){
      cin >> p2[i];
    }
    tuple<int,int,int,int> a[p];
    int paren = 0; int brace = 0; int sqbra = 0;
    for(int i = 0 ; i < p ; i++){
      int indent = 0;
      while(p1[i][indent]=='.'){ indent++; }
      a[i] = make_tuple(paren, brace, sqbra, indent);
      for(int j = 0 ; j < p1[i].length() ; j++){
	switch (p1[i][j]){
	case '(':
	  paren++;
	  break;
	case '{':
	  brace++;
	  break;
	case '[':
	  sqbra++;
	  break;
	case ')':
	  paren--;
	  break;
	case '}':
	  brace--;
	  break;
	case ']':
	  sqbra--;
	  break;
	} 
      }
    }
    tuple<int,int,int,int> b[q];
    for(int i = 0 ; i < q ; i++){
      int indent = 0;
      int ptr=0;
      while(p2[i][ptr]=='.'){ indent++;ptr++; }
      b[i] = make_tuple(paren, brace, sqbra, indent);
      for(int j = 0 ; j < p2[i].length() ; j++){
	switch (p2[i][j]){
	case '(':
	  paren++;
	  break;
	case '{':
	  brace++;
	  break;
	case '[':
	  sqbra++;
	  break;
	case ')':
	  paren--;
	  break;
	case '}':
	  brace--;
	  break;
	case ']':
	  sqbra--;
	  break;
	} 
      }
    }
    bool ok[21][21][21];
    for(int R = 1 ; R <= 20 ; R++){
      for(int C = 1 ; C <= 20 ; C++){
	for(int S = 1 ; S <= 20 ; S++){
	  ok[R][C][S] = true;
	  for(int i = 0 ; i < p ; i++){
	    if(R * get<0>(a[i]) + C * get<1>(a[i]) + S * get<2>(a[i]) != get<3>(a[i])){
	      ok[R][C][S] = false;
	    }
	  }
	}
      }
    }
    int ans[q];
    for(int i = 0 ; i < q ; i++){ans[i] = -1;}
    int ansnum[q];
    for(int i = 0 ; i < q ; i++){ansnum[i] = 0;}
    for(int R = 1 ; R <= 20 ; R++){
      for(int C = 1 ; C <= 20 ; C++){
	for(int S = 1 ; S <= 20 ; S++){
	  if(ok[R][C][S] == true){
	    for(int i = 0 ; i < q ; i++){
	      int temp = ans[i];
	      ans[i] = R * get<0>(b[i]) + C * get<1>(b[i]) + S * get<2>(b[i]);
	      if(temp != ans[i]){ansnum[i]++;}
	    }
	  }
	}
      }
    }
    for(int i = 0 ; i < q ; i++){
      cout << ((ansnum[i]==1)?(ans[i]):(-1));
      if(i != q-1){cout << " ";}else{cout << endl;};
    }
  }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define has(c, i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i >= a; i--)

ll n;
ll k;

vl l;

vl dp;

ll compute(ll k) {
  if(dp[k] >= 0) {
    return dp[k];
  }

  FORD(i,0,n) {
    if(l[i] > k)
      continue;

    ll next = compute(k - l[i]);
    
    if(next == 1) {
      dp[k] = 0;
      return 0;
    }
  }

  dp[k] = 1;
  return 1;
}

int main() {
  cout << fixed << setprecision(8);

  cin >> n >> k;
  FOR(i,0,n) {
    ll x;
    cin >> x;
    l.pb(x);
  }
  dp.assign(k+1, -1);

  cout << (compute(k) ? "Second":"First") << endl;
}


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

using namespace std;
typedef long long ll;
typedef long int lt;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define endl "\n"
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void solve()
{
	ll x;
	cin>>x;
	ll ans=0;

	ans+=(x/500)*1000;
	x=x%500;
	ans+=(x/5)*5;

	cout<<ans<<endl;
}

int main()
{
	fst;
	solve();
}

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

typedef struct{
	int k;
	int *a;
}person;

int main(void){
	int n,m,i,j,b,res=0;
	int flag;
	person *p;
	scanf("%d %d",&n,&m);
	p = malloc(sizeof(person) * n);
	for(i=0;i<n;i++){
		scanf("%d",&p[i].k);
		p[i].a = malloc(sizeof(int)*p[i].k);
		for(j=0;j<p[i].k;j++){
			scanf("%d",&p[i].a[j]);
		}
	}
	if(n==1){
		printf("%d\n",p[0].k);
	}else{
		for(b=0;b<p[0].k;b++){
			flag = 1;
			for(i=1;i<n;i++){
				for(j=0;j<p[i].k;j++){
					if(p[i].a[j] == p[0].a[b]){
						flag++;
					}
				}
			}
			if(flag == n)res++;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))

sgn = 0
for i in range(N):
    if A[i] < 0 :
        sgn += 1
    A[i] = abs(A[i])

A.sort()

if sgn % 2 == 0:
    print(sum(A))
else:
    print(sum(A) - A[0] * 2)

Measured memory_bytes: 14284
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;



int main(){
  int N,ans=0,sum=0,temp;
  cin>>N;

  for(int i=0;i<N;i++){
    cin>>temp;
    sum+=temp;
    ans=max(ans,temp);
  }
  cout<<sum-ans/2<<endl;
}


Measured memory_bytes: 256
s = int(input())
li = []
a = s
for i in range(1, 10 ** 6 + 1):
    if i == 1:
        a = s
    else:
        if a % 2 == 0:
            a = a // 2
        else:
            a = 3 * a + 1
    if a in li:
        print(i)
        exit()
    li.append(a)


Measured memory_bytes: 8888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10, INF = 1e9 * 1e9, MOD = 1e9 + 7;

struct node {
	node *l = 0, *r = 0;
	ll sumL = 0, sumR = 0, s = 0, sum = 0;
	node() {};
};

ll dpth[60];

node *root = new node();

void add(string& s, int ind, node* v) {
	if (ind == -1) {
		v->s++;
		v->sum++;
		return;
	}
	if (s[ind] == '0') {
		if (!v->l) {
			auto k = new node();
			v->l = k;
		}
		add(s, ind - 1, v->l);
	}
	else {
		if (!v->r) {
			auto k = new node();
			v->r = k;
		}
		add(s, ind - 1, v->r);
	}

	ll sm = v->s;
	if (v->l) sm += (v->l->sum);
	if (v->r) sm += (v->r->sum);
	v->sum = sm;
}

ll ans = 0;

void dfs(node* v, ll lnth) {
	if (!v->l) {
		if (lnth != 0) {
			for (ll j = 0; j <= 63; j++) {
				if ((lnth >> j) & 1) {
					ans ^= (1ll << j);
					break;
				}
			}
		}
	}
	else {
		dfs(v->l, lnth - 1);
	}

	if (!v->r) {
		if (lnth != 0) {
			for (ll j = 0; j <= 63; j++) {
				if ((lnth >> j) & 1) {
					ans ^= (1ll << j);
					break;
				}
			}
		}
	}
	else {
		dfs(v->r, lnth - 1);
	}
}

int main()
{
	fastInp;

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

	dpth[0] = 1;
	for (int i = 1; i < 60; i++) {
		dpth[i] = (dpth[i - 1] ^ dpth[i - 1]);
	}
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		reverse(s.begin(), s.end());
		add(s, s.size() - 1, root);
	}

	dfs(root, l);

	if (ans) {
		cout << "Alice";
	}
	else {
		cout << "Bob";
	}
	return 0;
}

Measured memory_bytes: 14604
mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    return g1[n] * g2[r] * g2[n-r] % mod


X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    ans = 0
else:
    n = (X + Y) // 3
    r = min(X, Y) - n
    ans = cmb(n, r, mod)
print(ans)


Measured memory_bytes: 122068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,n) for(int i=a;i<n;i++)
#define ps(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define sz(a) int((a).size())
#define pb push_back
typedef vector< int > vi;
typedef pair< int,int > pairs;

int main()
{
 ll n,k,x;
 cin>>n>>k;
 ll sum=0;
 loop(i,0,k)
 {
     cin>>x;
     sum=sum+x;
 }  
 if(sum<=n)  pn(n-sum);
 else   pn("-1");


}

Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
	int n,v[50],c[50],t[50],i,r;
	scanf("%d",&n);
	r=0;
	for(i=0;i<n;i++){
		scanf("%d",&v[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&c[i]);
	}
	for(i=0;i<n;i++){
		t[i]=v[i]-c[i];
		if(t[i]>=1){
		r+=t[i];
		}
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FOR(a,b,c) for(a = b;a<c;a++)
#define IFOR(a,b,c) for(a = b;a>c;a--)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a)  ((a)<(0)?-(a):(a))
#define INF 1000000000



int n,a,b;

int main(){
	scanf("%d",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	
	int total=0;
	int temp = 0;
	int i;
	FOR(i,1,n+1){
		temp = i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10;
		if(temp>=a&&temp<=b) total += i;
	}
	printf("%d",total);
}



Measured memory_bytes: 128
N=int(input())
S = []
for _ in range(N):
    S.append(input())

A=S.count('AC')
B=S.count('WA')
C=S.count('TLE')
D=S.count('RE')

print('AC x ', A)
print('WA x ', B)
print('TLE x ', C)
print('RE x ', D)

Measured memory_bytes: 16136
#include <stdio.h>

int main(void) {

int a = 0;
int b = 0;
int c = 0;

scanf("%d %d %d",&a,&b,&c);

if (a < b){
if (b < c) {
printf("Yes\n");
return 0;
}
printf("No\n");
return 0;
} else {
printf("No\n");
return 0;
}

return 0;
}




Measured memory_bytes: 2048
class heap():
    def __init__(self, maxcom=True):
        if maxcom:
            self.compare = lambda x, y: x > y
        else:
            self.compare = lambda x, y: x < y

    def heappush(self, x, heap):
        heap.append(x)
        length = len(heap)
        pointer = length
        while True:
            if pointer == 1:
                break
            if self.compare(heap[pointer - 1], heap[(pointer >> 1) - 1]):
                heap[pointer - 1], heap[(pointer >> 1) - 1] = heap[(pointer >> 1) - 1], heap[pointer - 1]
                pointer = pointer >> 1
            else:
                break

    def heapreplace(self, function, heap):
        heap[0] = function(heap[0])
        pointer = 1
        length = len(heap)
        while True:
            if (pointer << 1) > length:
                break
            elif (pointer << 1) + 1 > length :
                if self.compare(heap[(pointer << 1) - 1], heap[pointer - 1]):
                    heap[(pointer << 1) - 1], heap[pointer - 1] = heap[pointer - 1], heap[(pointer << 1) - 1]
                else:
                    break
            else:
                if self.compare(heap[(pointer << 1) - 1], heap[pointer << 1]):
                    next_pointer = pointer << 1
                else:
                    next_pointer = (pointer << 1) + 1
                if self.compare(heap[next_pointer - 1], heap[pointer - 1]):
                    heap[next_pointer - 1], heap[pointer - 1] = heap[pointer - 1], heap[next_pointer - 1]
                    pointer=next_pointer
                else:
                    break


n, m = map(int, input().split())
a = map(int, input().split())
heapq = []
heapc=heap(True)
for i in a:
    heapc.heappush(i,heapq)
for _ in range(m):
    heapc.heapreplace(lambda x:x>>1,heapq)
print(sum(heapq))

Measured memory_bytes: 14472
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
vector<int> Graph[1010101];
int visited[1010101], finished[1010101];
vector<int> order;
int dist[1010101];

bool tsort(int cur) {
  visited[cur] = true;
  for (auto nv : Graph[cur]) {
    if (finished[nv]) continue;

    if (visited[nv]) return false;

    if (!tsort(nv)) return false;
  }
  visited[cur] = false;
  finished[cur] = true;
  order.push_back(cur);
  return true;
}

void calc_dist(int cur) {
  int res = 1;
  for (auto nv : Graph[cur]) {
    chmax(res, dist[nv] + 1);
  }
  dist[cur] = res;
}

int getidx(int i, int j) { return (i - 1) * N + j; }

int main() {
  cin >> N;
  repe(i, 1, N) {
    int prev;
    cin >> prev;
    rep(j, 1, N - 1) {
      int a;
      cin >> a;
      int pp = prev;
      int ii = i;
      int iii = i;
      int aa = a;
      if (ii > pp) {
        swap(ii, pp);
      }
      if (iii > aa) {
        swap(iii, aa);
      }
      Graph[getidx(ii, pp)].push_back(getidx(iii, aa));
      prev = a;
    }
  }

  repe(i, 1, N - 1) {
    repe(j, i + 1, N) {
      visited[getidx(i, j)] = false;
      finished[getidx(i, j)] = false;
    }
  }

  repe(i, 1, N - 1) {
    repe(j, i + 1, N) {
      if (finished[getidx(i, j)]) continue;

      if (!tsort(getidx(i, j))) {
        cout << -1;
        return 0;
      }
    }
  }

  int ans = 0;
  for (auto nv : order) {
    calc_dist(nv);
    chmax(ans, dist[nv]);
  }
  cout << ans;
}


Measured memory_bytes: 56412
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

#define F first
#define S second
#define X first
#define Y second
#define all(c) (c).begin(),(c).end()

using namespace std;

typedef pair<int,int>P;
typedef pair<P,P> P2;

int g[110][110];

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

void dfs(int x,int y,int c){
  g[y][x]=-1;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0 || ny<0 || 110<=nx || 110<=y)continue;
    if(g[ny][nx]!=c)continue;
    dfs(nx,ny,c);
  }
}

int main(void){

  int n;
  while(cin >> n,n){
    vector<P2>v(n);
    vector<int>x,y;
    
    for(int i=0;i<n;i++){
      cin >> v[i].F.X >> v[i].F.Y >> v[i].S.X >> v[i].S.Y;
      x.push_back(v[i].F.X);
      x.push_back(v[i].S.X);
      y.push_back(v[i].F.Y);
      y.push_back(v[i].S.Y);
    }
    
    sort(all(x));
    sort(all(y));
    
    x.erase(unique(all(x)),x.end());
    y.erase(unique(all(y)),y.end());
    
    map<int,int>mpx,mpy;
    
    for(int i=0;i<x.size();i++)mpx[x[i]]=i+1;
    for(int i=0;i<y.size();i++)mpy[y[i]]=i+1;
    
    fill(g[0],g[110],0);
    
    for(int i=0;i<v.size();i++){
      for(int j=mpx[v[i].F.X];j<mpx[v[i].S.X];j++){
	for(int k=mpy[v[i].S.Y];k<mpy[v[i].F.Y];k++){
	  g[k][j]+=(i+1);
	}
      }
    }
    
    int cnt=0;
    for(int i=0;i<110;i++){
      for(int j=0;j<110;j++){
	if(g[i][j]>=0)dfs(j,i,g[i][j]),cnt++;
      }
    }
    
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1844
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
//				int maxn=max(max(a[i],a[j]),a[k]);
//				int minn=min(min(a[i],a[j]),a[k]);
//				int mid=max(min(a[i],a[j]),a[k]);
				if(a[i]==a[j]||a[j]==a[k]||a[i]==a[k])continue;
				if(a[i]+a[j]>a[k])ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
} 

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

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

  int a = x % 100;

  int b = a / 5;

  int lower = 0;

  if(a == 0) lower = 100;
  else if(a % 5 == 0) lower = 105 * b;
  else if(a % 5 == 1) lower = 105 * b + 101;
  else if(a % 5 == 2) lower = 105 * b + 102;
  else if(a % 5 == 3) lower = 105 * b + 103;
  else if(a % 5 == 4) lower = 105 * b + 104;

  cout << (x < lower ? 0 : 1) << endl;
}

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

int main(){
    double n, t;
    cin >> n >> t;

    double maxangle = -1;
    for(int i = 0; i < n; i++){
        double x, h;
        cin >> x >> h;
        maxangle = max(maxangle, atan2(h,x));
    }

    cout << fixed << setprecision(6) << t*tan(maxangle) << endl;
    return 0;
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


signed main()
{
    int n;
    while(cin>>n, n) {
        vector<pair<double, string> > produces;
        for(int i=0; i<n; ++i) {
            string l;
            double p, a, b, c, d, e, f, s, m;
            cin >> l;
            cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double t = a + b + c;
            double val = 0;
            for(int j=0; j<m; ++j) {
                t += d+e;
                val += f;
            }
            val *= s;
            val -= p;
            val /= t*1.0;
            produces.push_back(make_pair(val, l));
        }
        sort(produces, [](pair<double, string>& a, pair<double, string>& b) {
            if(a.first>b.first) return true;
            else if(a.first<b.first) return false;
            else {
                if(a.second<b.second) return true;
                else return false;
            }
        });
        for(auto elem : produces) cout << elem.second << endl;
        cout << "#" << endl;
    }
    return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>

using namespace std;

typedef complex<double> P;

const int N = 20;
const double INF = -1.0;

int n;
double r, s, e[N][N][N], d[N][N][10005];
vector<P> in;

main(){
  cin >> n >> r >> s;
  s *= M_PI / 180.0;
  for(int i=0;i<n;i++){
    P a;
    cin >> a.real() >> a.imag();
    in.push_back(a);
  }
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  fill(e[0][0], e[N][0], INF);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i == j) continue;
      for(int k=0;k<n;k++){
        if(j == k) continue;
        P a = in[i] - in[j];
        P b = in[k] - in[j];
        double t = acos(real(conj(a) * b) / (abs(a) * abs(b)));
        //if(i == 0 && j == 3 && k == 4) cout << t << ' ' << M_PI - t << ' ' << s << endl;
        if(M_PI - t <= s) e[i][j][k] = abs(b);
      }
    }
  }
  /*for(int i=0;i<n;i++){
    cout << i << endl;
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        printf("%.3f ", e[i][j][k]);
      }
      cout << endl;
    }
    }*/
  fill(d[0][0], d[N][0], -1.0);
  int ans = 0;
  for(int i=1;i<n;i++){
    if(abs(in[0] - in[1]) <= r){
      d[0][i][1] = abs(in[0] - in[i]);
      ans = 1;
    }
  }
  for(int k=1;(double)k<r+1;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(d[i][j][k] < 0.0) continue;
        ans = max(ans, k);
        for(int l=0;l<n;l++){
          if(e[i][j][l] < 0.0) continue;
          double dist = d[i][j][k] + e[i][j][l];
          //if(e[i][j][l] < 10.0) cout << i << ' ' << j << ' ' << l << ' ' << e[i][j][l] << endl;
          if(dist > r) continue;
          //cout << k+1 << ' ' << j << ' ' << l << ' ' << dist << endl;
          if(d[j][l][k+1] < 0.0) d[j][l][k+1] = dist;
          else if(d[j][l][k+1] > dist) d[j][l][k+1] = dist;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 32656
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

struct s{
    vector<long long> denkyus;
};
int main()
{
        // 整数の入力
    long long N,M,total;
    total = 0;
    vector
 ss;
    vector<long long > ps;

    cin >> N >> M;
    for (int i=0;i<N;i++){
        s new_s;
        ss.push_back(new_s);
    }
    for (int i = 0;i<M;i++){
        long long k;
        cin >> k;
        for(int j = 0;j< k;j++){
            long long s_index;
            cin >> s_index;
            ss[s_index - 1].denkyus.push_back(i);
        }
    }
    for (int i=0;i<M;i++){
        long long temp_p;
        cin >> temp_p;
        ps.push_back(temp_p);
    }

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<N); ++bit) {
        int *dekyu_status = new int[M];
        fill(dekyu_status,dekyu_status+M,0);
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                for (auto dekyu_index: ss[i].denkyus){
                    dekyu_status[dekyu_index]++;
                }
            }
        }

        bool cleared = true;
        for (int i = 0; i <M ;i++) {
            if (dekyu_status[i] % 2  != ps[i]){
                cleared = false;
            }
        }

        if(cleared){
            total++;
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int n;
	scanf("%d", &n);
	int x = 0;
	for (int i = 1;; i++)
	{
		x += i;
		if (n <= x)
		{
			printf("%d\n", i);
			return 0;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

cnt = 0

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]:
                cnt += 1

print(cnt)


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

#define ll long long
#define F first
#define S second
using namespace std;

template <class T, class P>
ostream &operator << (ostream &out, pair<T, P> &a){
    out << a.F << " " << a.S;
    return out;
}

template <class T>
ostream &operator << (ostream &out, vector <T> &a){
    for(auto &x : a)out << x << ' ';
    return out;
}

template <class T>
ostream &operator << (ostream &out, set <T> &a){
    for(auto &x : a) out << x << ' ';
    return out;
}

template <class T, class P>
ostream &operator << (ostream &out, map <T, P> &a){
    for(auto &x : a) out << x.F << " " << x.S << endl;
    return out;
}
const int N = 1e5 + 1;
const ll INF = 1e9 + 7;

int n, m;
string s;
int k1, k2, k3, k4, q;
void solution(){
    cin >> s;
    for(auto x : s){
        if(x == 'N')k1++;
        if(x == 'S')k2++;
        if(x == 'W')k3++;
        if(x == 'E')k4++;
    }
    if(k1 < k2)swap(k1, k2);
    if(k3 < k4)swap(k3, k4);
    if(k1 >= 1 && k2 >= 1)q = 1;
    if(k1 == 0 && k2 == 0)q = 1;
    if(k3 >= 1 && k4 >= 1)q++;
    if(k3 == 0 && k4 == 0)q++;
    if(q == 2){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


int main(){
    int n = 1;
   //cin >> n;
    while(n){
        n--;
        solution();
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int dp[31][51][6];
int main() {
	while (1) {
		for (int i = 0; i < 31; ++i) {
			for (int j = 0; j < 51; ++j) {
				for (int k = 0; k < 6; ++k) {
					dp[i][j][k] = 0;
				}
			}
		}
		int C, D, W, X; cin >> C >> D >> W >> X;
		if (!C)break;
		vector<vector<int>>es(C, vector<int>(D));
		for (int i = 0; i < C; ++i) {
			for (int j = 0; j < D; ++j) {
				cin >> es[i][j];
			}
		}
		vector<vector<int>>fs(C, vector<int>(D));
		for (int i = 0; i < C; ++i) {
			for (int j = 0; j < D; ++j) {
				cin >> fs[i][j];
			}
		}
		for (int d = 0; d < D; ++d) {
			for (int w = 0; w <= W; ++w) {
				for (int k = 0; k <= X; ++k) {
					dp[d + 1][w][k] = max(dp[d + 1][w][k], dp[d][w][k]);
					for (int l = 0; l < C; ++l) {
						int esum = 0;
						int fsum = 0;
						for (int r = l; r < C; ++r) {
							if (es[r][d]) {
								esum += es[r][d];
								fsum += fs[r][d];
							}
							else {
								break;
							}
							const int nextw = w + fsum;
							const int nexte = dp[d][w][k] + esum;
							const int nextk = k + (l == r ? 0 : 1);
							if (nextw <= W&&nextk <= X) {
								dp[d + 1][nextw][nextk] = max(dp[d + 1][nextw][nextk], nexte);
							}
						}
					}
				}
			}
		}
		int ans = 0;
		for (int w = 0; w <= W; ++w) {
			for (int k = 0; k <= X; ++k) {
				ans = max(dp[D][w][k], ans);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

S = input()
n = int(len(S)/2)
for i in range(1,n):
    if S[0:n-i] == S[n-i:2*n-2*i]:
        print((n-i)*2)
        break

Measured memory_bytes: 3060
N, Ma, Mb = map(int, input().split())
A = []
B = []
C = []
for _ in range(N):
    a, b, c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)

INF = 4001
Na = sum(A)
Nb = sum(B)
dp = [[[INF]*(Nb+1) for _ in range(Na+1)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for j in range(Na+1):
        for k in range(Nb+1):
            if j < A[i] or k < B[i]:
                dp[i+1][j][k] = dp[i][j][k]
            else:
                dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-A[i]][k-B[i]]+C[i])
            
ans = INF
for i in range(1, N+1):
    for j in range(1, Na+1):
        for k in range(1, Nb+1):
            if j*Mb == k*Ma:
                ans = min(ans, dp[i][j][k])
                
if ans == INF:
    ans = -1
    
print(ans)

Measured memory_bytes: 64092
import numpy as np


N, D = map(int, input().split())
points = np.array([list(map(int, input().split())) for i in range(N)])

answer = 0
for i in range(N):
  for j in range(i+1, N):
    distance = np.linalg.norm(points[i]-points[j])
    if distance == int(distance):
      answer += 1

print(answer)

Measured memory_bytes: 12408
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int N, M;
  cin >> N >> M;
  int latte[200000] = {}, malta[200000] = {};
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if(a == 0) latte[b] = true;
    if(b == N - 1) malta[a] = true;
  }
  for(int i = 0; i < N; i++) {
    if(latte[i] && malta[i]) {
      cout << "POSSIBLE" << endl;
      return (0);
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;

    long long int lis[100][2];
    long long int ans=4000000000000000001;
    for(int i=0;i<N;i++)cin>>lis[i][0]>>lis[i][1];
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            for(int k=j;k<N;k++){
                for(int l=k;l<N;l++){
                    long long int xmax=-2000000000000000000,ymax=-2000000000000000000,xmin=2000000000000000000,ymin=2000000000000000000;
                    xmax=max(max(lis[i][0],lis[j][0]),max(lis[k][0],lis[l][0]));
                    ymax=max(max(lis[i][1],lis[j][1]),max(lis[k][1],lis[l][1]));
                    xmin=min(min(lis[i][0],lis[j][0]),min(lis[k][0],lis[l][0]));
                    ymin=min(min(lis[i][1],lis[j][1]),min(lis[k][1],lis[l][1]));
                    int cou=0;
                    for(int m=0;m<N;m++){
                        if(xmin<=lis[m][0]&&lis[m][0]<=xmax){
                            if(ymin<=lis[m][1]&&lis[m][1]<=ymax){
                                cou++;
                            }
                        }
                    }
                    if(K<=cou){
                        ans=min(ans,(xmax-xmin)*(ymax-ymin));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();

    int ans = 1e9;
    for (int i = 0; i <= n-m; ++i) {
        int cnt = 0;
        for (int j = 0; j < m; ++j) {
            if(s[i+j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628