akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
  string s,t; cin >> s >> t;  
  bool flag;
  FORD(i,s.length()-t.length(),0){
    flag = true;
    FOR(j,0,t.length()-1){
      if(!(t[j]==s[i+j] || s[i+j]=='?')) flag = false;
    }
    if(flag){
      FOR(j,0,t.length()-1){
        s[i+j] = t[j];
      }
      break;
    }
  }

  if(!flag){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  else {
    FOR(i,0,s.length()-1){
      if(s[i]=='?') s[i] = 'a';
    }
  }
  cout << s << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int dir[][2] = {{0, 0}, {1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1,
  1}, {-1, -1}, {2, 0}, {0, 2}, {-2, 0}, {0, -2}};
int map[10][10], dens = 0, rest = 100;
void drop(int x, int y) {
  if (0 <= x && x < 10 && 0 <= y && y < 10) {
    if (map[x][y]++ == 0) rest--;
    dens = max(map[x][y], dens);
  }
}
int main() {
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      map[i][j] = 0;
  int x, y, size;
  char c;
  while (cin >> x >> c >> y >> c >> size)
    for (int i = 0; i <= 4 * size; i++)
      drop(x + dir[i][0], y + dir[i][1]);
  cout << rest << endl << dens << endl;
}

Measured memory_bytes: 1156
def main():
    mod = 998244353
    N = int(input())
    D = list(map(int, input().split()))
    count = dict()
    for i in range(N):
        count[D[i]] = count.get(D[i], 0) + 1

    if D[0] != 0: return 0
    if 0 in D[1:]: return 0

    cnt = 1
    ans = 1
    prev = 1
    for i in range(1, N):
        if i in count:
            ans *= pow(prev, count[i]) % mod
            ans %= mod
            prev =  count[i]
            cnt += count[i]
            if cnt == N:
                return ans % mod
        else:
            return 0
    return 0


if __name__ == '__main__':
    # main()
    print(main())

Measured memory_bytes: 19552
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;

set <int> S;

inline int get( char c ) {
    char T[5] = "ACGT";
    for ( int i = 0; i < 4; ++ i ) {
        if ( c == T[i] ) return i + 1;
    }
    return 0;
}

inline int get( char *s ) {
    int n = strlen( s );
    int sum = 0;
    int t = 1;
    for ( int i = 0; i < n; ++ i ) {
        sum += get( s[i] ) * t;
        t *= 4;
    }
    return sum;
}

void insert( char *s ) {
    S.insert( get( s ) );
}

bool find( char *s ) {
    return S.count( get( s ) ) > 0;
}

int main() {
    int n;
    while ( scanf("%d", &n) != EOF ) {
        S.clear();
        char cmd[13], data[13];
        for ( register int i = 0; i < n; ++ i ) {
            scanf( "%s%s", cmd, data );
            if ( cmd[0] == 'i' ) {
                insert( data );
            } else {
                puts( find( data ) ? "yes" : "no" );
            }
        }
    }
    return 0;
}

Measured memory_bytes: 7252
#include<iostream>
using namespace std;
typedef long long ll;

ll dp[5][4001];
int main(){
  dp[0][0] = 1;
  for(int i=0;i<4;i++){
    for(int j=0;j<=4000;j++){
      for(int k=0;k<=1000;k++){
	if(j+k<=4000)dp[i+1][j+k] += dp[i][j];
      }
    }
  }

  int n;
  while(cin >> n)cout << dp[4][n] << endl;
}
    

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int a, p;
  cin >> a >> p;

  cout << (a * 3 + p) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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;
}

void mod(ll &val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll ret = -INF;
    chmax(ret,A * C);
    chmax(ret,A * D);
    chmax(ret,B * C);
    chmax(ret,B * D);
    cout << ret << endl;
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main()
{
	int scend,s,minute,m,hour;
	cin>>scend;
	s=scend%60;
	scend-=s;
	minute=m=scend/60;
	minute=m%60;
	m-=minute;
	hour=m/60;
	scend=s;
	cout<<hour<<":"<<minute<<":"<<scend<<endl;
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
using namespace std;

int h,w,n;
char p[4] = {'L','R','U','D'};
char q[4] = {'R','L','D','U'};
map<char,int> d;

int main() {
  cin >> h >> w >> n;
  int sr,sc;
  cin >> sr >> sc;
  d['L'] = -1;
  d['R'] = 1;
  d['U'] = -1;
  d['D'] = 1;
  string S,T;
  cin >> S >> T;

  int over[4] = {0,w+1,0,h+1};
  int limit[4] = {w+1,0,h+1,0};
  for(int i = 0; i < 4; i++) {
    int tmp;
    if(i < 2) tmp = sc;
    else tmp = sr;

    //cout <<"i = "<<i << endl;
    for(int j = 0; j < n; j++) {
     
      if(S[j] == p[i]) tmp += d[S[j]];
      if(tmp == over[i]) {
	cout << "NO" << endl;
	return 0;
      }
      if(T[j] == q[i] && (tmp + d[T[j]] != limit[i])) tmp += d[T[j]];
      //  cout << "tmp = "<<tmp << endl;
    }
   
  }
  cout << "YES" << endl;
}
	
	  
  


Measured memory_bytes: 776
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n;
		while ((n = sc.nextInt()) != 0)
		{
			int ans = 0;
			int mi = 10000;
			int ma = 0;
			int in;
			for (int i = 0; i < n; i++)
			{
				in = sc.nextInt();
				ans += in;
				mi = Math.min(mi, in);
				ma = Math.max(ma, in);
			}
			System.out.println((int)((double)(ans - mi - ma) / (n - 2)));
		}
		sc.close();
	}
}


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

int main() {
    int N;
    cin >> N;
    int x = 0;
    
    for (int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        x += r - l + 1;
        
        // cout << x << endl;
        
        //int s = r - l;
        //cout << s << endl;
    }
    cout << x << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 3e3 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[MAXN][MAXN][2], p[MAXN], a[MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

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

    for (int len = 1; len < n; len++) {
        for (int i = 1; i + len <= n; i++) {
            int j = i + len;
            if (dp[i + 1][j][1] + a[i] > dp[i][j - 1][1] + a[j]) {
                dp[i][j][0] = dp[i + 1][j][1] + a[i];
                dp[i][j][1] = dp[i + 1][j][0];
            } else {
                dp[i][j][0] = dp[i][j - 1][1] + a[j];
                dp[i][j][1] = dp[i][j - 1][0];
            }
        }
    }

    cout << dp[1][n][0] - dp[1][n][1] << "\n";
}


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

int main() {
  int x;
  cin >> x;
  int ans = 0;
  if (x < 600) {
    ans = 8;
  } else if (x < 800) {
    ans = 7;
  } else if (x < 1000) {
    ans = 6;
  } else if (x < 1200) {
    ans = 5;
  } else if (x < 1400) {
    ans = 4;
  } else if (x < 1600) {
    ans = 3;
  } else if (x < 1800) {
    ans = 2;
  } else if (x < 2000) {
    ans = 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[30];
string s;
int main()
{
	int i,j,k,n,m,x,y,z,w,q;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin>>s;
		a[s[0]-'A']++;
	}
	ll ans;//march
	x=a['M'-'A'];
	y=a[0];
	z=a['R'-'A'];
	w=a[2];
	q=a['H'-'A'];
	ans=1ll*x*y*z+1ll*x*y*w+1ll*x*y*q+1ll*x*z*w+1ll*x*z*q+1ll*x*w*q+1ll*y*z*w+1ll*y*z*q+1ll*y*w*q+1ll*z*w*q;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

long long N, num = 0, xx, uu, dd;
char str[400000];

inline long long calc(long long x)
{
	long long b = x, rr = 0;
	while(b > 0)
	{
		if(b & 1)
			++rr;
		b >>= 1;
	}
	return x % rr;
}

inline void init()
{
	long long base1 = 1, base2 = 1, now1 = 0, now2 = 0;
	for(int i = N;i >= 1;--i, base1 = base1 * 2ll, base2 = base2 * 2ll)
	{
		if(str[i] == '0')
			continue;
		if(num - 1 != 0)
		{
			now1 += base1 % (num - 1);
			now1 %= (num - 1);
		}
		now2 += base2 % (num + 1);
		now2 %= (num + 1);
		
		if(num - 1 != 0)
			base1 = base1 % (num - 1);
		base2 = base2 % (num + 1);
	}
	
	uu = now2;
	dd = now1;
}

inline long long fastpow(long long bass, long long b, long long mod)
{
	long long ret = 1, base = bass;
	while(b > 0)
	{
		if(b & 1)
			ret = ret * base % mod;
		base = base * base % mod;
		b >>= 1;
	}
	return ret % mod;
}

int main()
{
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	scanf("%lld", &N);
	scanf("%s", str + 1);
	for(int i = 1;i <= N;++i)
		if(str[i] == '1')
			++num;
	xx = num;
	init();
	for(int i = 1;i <= N;++i)
	{
		long long now = 0, ans = 0;
		if(str[i] == '0')
		{
			now = uu;
			now = (now + fastpow(2, N - i, num + 1)) % (num + 1);
			++ans;
			while(now)
			{
				++ans;
				now = calc(now);
			}
			printf("%lld\n", ans);
		}
		else
		{
			if(num == 1)
				printf("0\n");
			else
			{
				now = dd;
				now = (now - fastpow(2, N - i, num - 1) + num - 1) % (num - 1);
				++ans;
				while(now)
				{
					++ans;
					now = calc(now);
				}
				printf("%lld\n", ans);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};

int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     string s;
     int n;
     cin>>n>>s;
     set<int>w,r;
     for(int i=0; i<n; i++)
     {
         if(s[i]=='W') w.insert(i);
         else r.insert(i);
     }
     int cnt=0;
     while((!w.empty() && !r.empty()) && *w.begin() < *r.rbegin())
     {
         ++cnt;
         w.erase(w.begin());
         auto it=r.end();
         --it;
         r.erase(it);
     }
     cout<<cnt<<endl;
}




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

int main()
{   
	int a, b, result;
	char op;
	
	while(1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if(op == '+')
		{
			result = a + b;
		}
		if(op == '-')
		{
			result = a - b;
		}
		if(op == '*')
		{
			result = a * b;
		}
		if(op == '/')
		{
			result = a / b;
		}
		
		if(op == '?')
		{
			break;
		}
		printf("%d\n", result);
	}
	
	return 0;
}


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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int mod=1000000007;

int main(){
    string s;
    cin>>s;
    int ssz=s.size();
    ll dp[ssz+1][4];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,ssz){
        if(s[i]=='A'){
            dp[i+1][0]=dp[i][0]%mod;
            dp[i+1][1]=(dp[i][1]+dp[i][0])%mod;
            dp[i+1][2]=dp[i][2]%mod;
            dp[i+1][3]=dp[i][3]%mod;
        }
        if(s[i]=='B'){
            dp[i+1][0]=dp[i][0]%mod;
            dp[i+1][1]=dp[i][1]%mod;
            dp[i+1][2]=(dp[i][2]+dp[i][1])%mod;
            dp[i+1][3]=dp[i][3]%mod;
        }
        if(s[i]=='C'){
            dp[i+1][0]=dp[i][0]%mod;
            dp[i+1][1]=dp[i][1]%mod;
            dp[i+1][2]=dp[i][2]%mod;
            dp[i+1][3]=(dp[i][3]+dp[i][2])%mod;
        }
        if(s[i]=='?'){
            dp[i+1][0]=3*dp[i][0]%mod;
            dp[i+1][1]=(3*dp[i][1]+dp[i][0])%mod;
            dp[i+1][2]=(3*dp[i][2]+dp[i][1])%mod;
            dp[i+1][3]=(3*dp[i][3]+dp[i][2])%mod;
        }
    }
    cout<<dp[ssz][3]%mod<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
  int d;
  cin >> d;
  if(d == 25){
    cout << "Christmas" << endl;
  }
  else if(d == 24){
    cout << "Christmas Eve" << endl;
  }
  else if(d == 23){
    cout << "Christmas Eve Eve" << endl;
  }
  else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner scn = new Scanner(System.in);
    	int m,n;
    	boolean[] players = new boolean[1000];
    	
    	for(m=scn.nextInt(), n=scn.nextInt(); n!=0 || m != 0; m=scn.nextInt(), n=scn.nextInt()){
    		int num = m;
    		boolean flag = false;
    		
    		for(int i=0; i<m; i++)
    			players[i] = true;
    		
    		for(int i=1,id=0; i<=n; i++){
    			String word = scn.next();
    			String correct;
    			
    			if(i%15 == 0){
    				correct = "FizzBuzz";
    			}else if(i%3 == 0){
    				correct = "Fizz";
    			}else if(i%5 == 0){
    				correct = "Buzz";
    			}else{
    				correct = Integer.toString(i);
    			}
    			
    			if(!word.equals(correct)){
    				players[id] = false;
    				
    				if(--num==1){
    					for(i++;i<=n;i++)
    						scn.next();
    					break;	
    				}
    			}
    			
    			while(true){
    				id = (id+1)%m;
    				if(players[id])
    					break;
    			}
    		}
    		
    		for(int i=0;i<m; i++){
    			if(players[i]){
    				if(flag){
    					System.out.print(" "+(i+1));
    				}else{
    					System.out.print(i+1);
    					flag = true;
    				}
    			}
    		}
    			
    		System.out.println();
    	}
    	
    	return;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; i++) cin >> p.at(i);
  vector<vector<double>> dp(N+1, vector<double>(N+1, 0.0));
  dp.at(0).at(0) = 1.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= i; j++) {
      dp.at(i+1).at(j+1) += dp.at(i).at(j) * p.at(i);
      dp.at(i+1).at(j) += dp.at(i).at(j) * (1.0 - p.at(i));
    }
  }
  double ans = 0.0;
  for (int j = (N+1)/2; j <= N; j++) ans += dp.at(N).at(j);
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70784
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<algorithm>
using namespace std;
struct node{
  int key;
  int cost;
  struct node *next;
};
typedef struct node *GG;
  
GG G[100001];
GG MNode(int,int,GG);
void Insert(int,int,int);
priority_queue<pair<int,int> > PQ;
int main()
{
  int i,j,n,count=0,v,c,c1,v1,e,r;
  long long color[100001],d[100001],mincost,ii;
  pair<int,int> u;
  GG GGG;
  scanf("%d%d%d",&v,&e,&r);
  for(i=0;i<v;i++)G[i]=MNode(0,0,NULL);
  for(i=0;i<e;i++){
    scanf("%d%d%d",&n,&v1,&c1);
    Insert(n,v1,c1);
  }
  for(i=0;i<v;i++){
    color[i]=0;
    d[i]=1000000001;
  }
  d[r]=0;
  PQ.push(make_pair(0,r));
  while(!PQ.empty()){
    u=PQ.top();PQ.pop();
    mincost=(-1)*u.first;
    ii=u.second;
    color[ii]=2;
    for(GGG=G[ii]->next;GGG!=NULL;GGG=GGG->next){
      if(color[GGG->key]!=2 && (GGG->cost+d[ii])<d[GGG->key]){
	d[GGG->key]=GGG->cost+d[ii];
	color[GGG->key]=1;
	PQ.push(make_pair(d[GGG->key]*(-1),GGG->key));
      }
    }
  }
  for(i=0;i<v;i++){
    if(d[i]!=1000000001)printf("%d\n",d[i]);
    else printf("INF\n");
  }
  return 0;
}
  
GG MNode(int key,int cost,GG Node)
{
  GG n;
  n=(GG)malloc(sizeof(struct node));
  n->key=key;
  n->cost=cost;
  n->next=Node;
  return n;
}
void Insert(int s,int t,int u)
{
  GG GGG;
  GGG=MNode(t,u,G[s]->next);
  G[s]->next=GGG;
}

Measured memory_bytes: 22520
/*
今回は、vectorでなく、普通に配列使う。

[ヒープを表す配列A、ヒープのサイズ（要素数）をheap_sizeとすれば、A[1...heap_size]にヒープの要素が格納される。木の根はA[1]であり、節点の添え字iが与えられたとき、その親parent(i)、左の子left(i)、右の子right(i)は以下の式で算出される： ]
と、問題文に書いてあるので、添え字０は使わず、獲得する領域も１大きくする。
*/

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;


int main() {
	int i,j;
	int heap_size;

	//input
	// 標準入力をファイルに変更////////////////////////////////////////////////////////
    //FILE* fp_in = freopen("\\\\k1300\\k1300\\s1350010\\.windows\\Desktop\\input_data.txt", "r", stdin);
	/////////////////////////////////////////////////////////////////////////////////////

	cin >> heap_size;
	int *heap = new int[heap_size+1]; //[1...heap_size]まで使うので

	for(i=1;i<=heap_size;i++){
		cin >> heap[i];
	}
	for(i=1;i<=heap_size;i++){
		printf("node %d: ", i);
		printf("key = %d, ", heap[i]);
		if(i!=1) printf("parent key = %d, ", heap[i/2]);
		if(2*i<=heap_size) printf("left key = %d, ", heap[2*i]);
		if(2*i+1<=heap_size)printf("right key = %d, ", heap[2*i+1]);
		printf("\n");
	}
	
	// ファイルを閉じる//////////////////////////////////////////////////////////////////
    //fclose(fp_in);
	/////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}

Measured memory_bytes: 1172
#include <cstdio>
#include <algorithm>
#define ll long long
#define N 200005
int n, a[N][2], q[N<<1][2];
ll ans;
char s[15];
void proc(int id)
{
	int l=0, ok=0;
	ll num=0;
	for(int i=1; s[i]; ++i)
	{
		if(s[i]=='.') ok=1;
		else
		{
			num=10*num+s[i]-'0';
			l+=ok;
		}
	}
	while(num%2==0) num/=2, ++a[id][0];
	while(num%5==0) num/=5, ++a[id][1];
	a[id][0]-=l, a[id][1]-=l;
}
int lb, rb, lim, sum[N], id[N<<1];
inline int lowbit(int x) { return x&(-x); }
inline void add(int p) { while(p<=lim) ++sum[p], p+=lowbit(p); }
inline int ask(int p) { int ret=0; while(p) ret+=sum[p], p-=lowbit(p); return ret; }
bool cmp(int a, int b) { return q[a][0]==q[b][0]?q[a][1]==q[b][1]?(a&1)<(b&1):q[a][1]>q[b][1]:q[a][0]>q[b][0]; }
int main()
{
	scanf("%d", &n);
	lb=100, rb=-100;
	for(int i=1; i<=n; ++i) scanf("%s", s+1), proc(i), id[i<<1]=i<<1, q[i<<1][0]=a[i][0], q[i<<1][1]=a[i][1],
	id[i<<1|1]=i<<1|1, q[i<<1|1][0]=-a[i][0], q[i<<1|1][1]=-a[i][1], ans-=(a[i][0]>=0&&a[i][1]>=0),
	lb=std::min(lb, a[i][1]<0?a[i][1]:-a[i][1]), rb=std::max(rb, a[i][1]<0?-a[i][1]:a[i][1]);
	++rb;
	lim=rb-lb;
	std::sort(id+2, id+(n<<1|1)+1, cmp);
	for(int i=2; i<=(n<<1|1); ++i)
	{
		if(id[i]&1) ans+=ask(rb-q[id[i]][1]);
		else add(rb-q[id[i]][1]);
	}
	printf("%lld\n", ans/2);
	return 0;
}

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

int main() {
  int N;
  double M;
  double sum=0;
  cin >> N >> M;
  vector<int> vec(N,0);
  for(int i=0;i < N;i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  int cnt=0;
  for(int i=0;i < N;i++){
    if(vec.at(i)/sum >= 1.00/4.00/M){
      cnt++;
    }
  }
  if (cnt >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_173
{
    class F
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            List<int>[] graph = new List<int>[n];
            for(int i = 0; i < n; i++)
            {
                graph[i] = new List<int>();
            }
            for (int i = 0; i < n - 1; i++)
            {
                int[] uv = ReadInts();
                int u = uv[0] - 1;
                int v = uv[1] - 1;
                graph[u].Add(v);
                graph[v].Add(u);
            }

            Queue<int> que = new Queue<int>();
            que.Enqueue(0);
            int[] parents = new int[n];
            parents[0] = -1;
            while (que.Count > 0)
            {
                int now = que.Dequeue();

                for(int i = 0; i < graph[now].Count; i++)
                {
                    int to = graph[now][i];
                    if (to == parents[now])
                    {
                        continue;
                    }

                    parents[to] = now;
                    que.Enqueue(to);
                }
            }

            long res = n;
            for(long i = 1; i < n; i++)
            {
                if (i < parents[i])
                {
                    res += (i + 1) * (parents[i] - i);
                }
                else
                {
                    res += (i - parents[i]) * (n - i);
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 59132
#include<iostream>
#include<string>

using namespace std;

int main(){
    long long int n,m, sm=0;
    cin >> n;
    m=n;
    while(n!=0){
        sm+=n%10;
        n/=10;
    }
    if(m%sm==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
using namespace std;
vi p,q,a[7];
int n,k,x;
vi mul(vi x,vi y)
{
    vi z;
    for(int i=0;i<x.size();i++)
        z.push_back(x[y[i]]);
    return z;
}
vi inv(vi x)
{
    vi y(n);
    for(int i=0;i<x.size();i++)
        y[x[i]]=i;
    return y;
}
vi qpow(vi x,int y)
{
    vi ans(n);
    for(int i=0;i<n;i++) ans[i]=i;
    while(y)
    {
        if(y&1) ans=mul(ans,x);
        x=mul(x,x);
        y>>=1;
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        p.push_back(x-1);
    }
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        q.push_back(x-1);
    }
    a[1]=p;a[2]=q;
    for(int i=3;i<=6;i++)
        a[i]=mul(a[i-1],inv(a[i-2]));
    if(k<=6)
    {
        for(int i=0;i<n;i++)
            printf(i==n-1?"%d\n":"%d ",a[k][i]+1);
        return 0;
    }
    vi A=mul(mul(q,inv(p)),mul(inv(q),p));
    A=qpow(A,(k-1)/6);
    vi ans=mul(mul(A,a[(k-1)%6+1]),inv(A));
    for(int i=0;i<n;i++)
        printf(i==n-1?"%d\n":"%d ",ans[i]+1);
}

Measured memory_bytes: 7492
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    sc.useDelimiter("\\s");
    int W = sc.nextInt();
    int H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r = sc.nextInt();


    if(W > x && H > y){
	if(x >= r && y >= r){
		System.out.println("Yes");
        }else{
		System.out.println("No");
        }
    }else{
		System.out.println("No");
    }

   
  }

}

Measured memory_bytes: 26336
import sys
readline = sys.stdin.readline


def knapsack(N, weight):
    dp = [0] * (weight + 1)
    for _ in range(N):
        v, w = map(int, readline().split())
        ww = w
        dp_prev = dp[:]
        while ww <= weight:
            dp[ww] = max(dp_prev[ww], dp_prev[ww - w] + v)
            ww += 1
    return dp[-1]

if __name__ == "__main__":
    n_goods, weight = map(int, input().split())
    print(knapsack(n_goods, weight))



Measured memory_bytes: 6512
#include<stdio.h>

int main() {
  char s[4];

  scanf("%s", s);
  
  switch(s[0]) {
    case 'S' : if(s[1] == 'U') {
			puts("7"); break;
		   }
			else {
puts("1"); break;
}
    case 'M' : puts("6"); break;
    case 'T' : if(s[1] == 'U') {
puts("5"); break;  
}
else {

puts("3"); break;
}
    case 'W' : puts("4"); break;
    case 'F' : puts("2"); break;
  }
  return 0;
}

Measured memory_bytes: 128