akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int a[8][1001];
int main(){
  int b;
  while(cin>>b,b){
      memset(a,0,sizeof(a));
      for(int c=0;c<b;c++){
	  a[c][0]=1;
	  int d,e;cin>>d>>e;
	  for(int f=0;f<=e;f++){
	      for(int g=max(f*d,1);g<=1000;g++){
		  a[c+1][g]+=a[c][g-f*d];
		  }
	      }
	  }
	  int s;cin>>s;
	  for(int n=0;n<s;n++){
	      int w;cin>>w;
	      cout<<a[b][w]<<endl;
	      }
      }
}

Measured memory_bytes: 3052
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1&&a!=b){
	cout<<"Alice";
	}else if(b==1&&b!=a){
	cout<<"Bob";
	}else if(a>b){
	cout<<"Alice";
}else if(a<b){
	cout<<"Bob";
	}else if(a==b){
	cout<<"Draw";
}
	}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
const static int SIZE = 100;
const static int MARGIN = 2;

const static int F_NONE = 0;
const static int F_WALL = 1;
const static int F_LINE = 2;

const static int DIR_N = 4;

using namespace std;


void draw( int n ) {
  int field[ SIZE + MARGIN * 2 ][ SIZE + MARGIN * 2 ] = { 0 };
  int pos_y = n + MARGIN - 1;
  int pos_x = MARGIN;
  int vy[] = { -1, 0, 1,  0 };
  int vx[] = {  0, 1, 0, -1 };
  int dir = 0;
  int lastMoveDir = -1;
  int turnNum = 0;
  for( int i = 0; i < n + MARGIN * 2; i++ ) {
    field[ i ][ 0 ] = F_WALL;
    field[ 0 ][ i ] = F_WALL;
    field[ i ][ n + MARGIN * 2 - 1 ] = F_WALL;
    field[ n + MARGIN * 2 - 1 ][ i ] = F_WALL;
  }

  while( 1 ) {
    field[ pos_y ][ pos_x ] = F_LINE;
    if(
      field[ pos_y + vy[ dir ] * 2 ][ pos_x + vx[ dir ] * 2 ] == F_NONE 
    ) {
      pos_y += vy[ dir ];
      pos_x += vx[ dir ];
      lastMoveDir = dir;
    } else {
      dir = ( dir + 1 ) % DIR_N;
      if( turnNum++ == n - 1 ) { break; }
    }
  }

  for( int i = MARGIN; i < n + MARGIN; i++ ) {
    for( int j = MARGIN; j < n + MARGIN; j++ ) {
      cout << ( field[ i ][ j ] ? '#' : ' ' ) << flush;
    }
    cout << endl;
  }
}


int main() {
  int d;
  cin >> d;
  for( int i = 0; i < d; i++ ) {
    int n;
    cin >> n;
    draw( n );
    if( i != d - 1 ) {
      cout << endl;
    }
  }
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
// ConsoleApplication98.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	int aa,dao=0,shu,n, q1, h1,q2,h2;
	string ss, qian,qian2="",hou2="", hou;
	cin >> ss;
	cin >> n;
	while (n--)
	{
		cin >> aa;
		if (aa == 1)
		{
			dao++;
		}
		else
		{
			cin >> shu;
			if ((dao + shu) % 2 != 0)
			{
				cin >> qian;
				qian2 = qian + qian2;
			}
			else
			{
				cin >> hou;
				hou2 = hou2 + hou;
			}
		}

	}
	if (dao % 2 == 0)
	{
		cout <<qian2<< ss <<hou2<< endl;
	}
	else
	{
		ss = qian2 + ss + hou2;
		reverse(ss.begin(), ss.end());
		cout << ss << endl;
	}

}

Measured memory_bytes: 1424
#include <iostream>
#include <set>
#include <map>
#define llint long long
#define mod 1000000007

using namespace std;

llint N, K, M;
llint A[25005];
llint dp[25005][405];
llint sum[25005][405];

llint fact[25005], fact_inv[25005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 25005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 25005; i++){
		fact_inv[i] = pow(fact[i], mod-2);
	}
}


int main(void)
{
	make_fact();
	cin >> N >> K >> M;
	for(int i = 1; i <= M; i++) cin >> A[i];
	
	if(N < K){
		cout << 0 << endl;
		return 0;
	}
	if(N == 1){
		cout << 1 << endl;
		return 0;
	}
	
	llint all = pow(K, N-M) * (N-M+1) % mod;
	
	llint mx = 0;
	map<llint, llint> mp;
	for(int i = 1; i <= M; i++){
		mp[A[i]]++;
		if(i > K){
			mp[A[i-K]]--;
			if(mp[A[i-K]] == 0) mp.erase(A[i-K]);
		}
		mx = max(mx, (llint)mp.size());
	}
	if(mx >= K){
		cout << all << endl;
		return 0;
	}
	
	dp[1][1] = K;
	for(int i = 2; i <= N; i++){
		for(int j = K-1; j >= 1; j--){
			if(j == K-1) dp[i][j] = (2*dp[i-1][j-1] + dp[i-1][j]) % mod;
			else{
				dp[i][j] = (dp[i][j+1] + dp[i-1][j]) % mod;
				dp[i][j] += mod - dp[i-1][j]*(K-j)%mod;
				dp[i][j] %= mod;
				dp[i][j] += dp[i-1][j-1]*(K-j+1)%mod;
				dp[i][j] %= mod;
			}
		}
		/*for(int j = 0; j <= K-1; j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;*/
	}
	
	for(int i = 0; i <= N; i++){
		for(int j = 1; j < K; j++){
			sum[i][j] = (sum[i][j-1] + dp[i][j]) % mod;
		}
	}
	
	llint ans = 0;
	if(mx < M){
		llint l, r;
		set<llint> S;
		for(int i = 1; i <= M; i++){
			if(S.count(A[i])){
				l = i-1;
				break;
			}
			S.insert(A[i]);
		}
		S.clear();
		for(int i = M; i >= 1; i--){
			if(S.count(A[i])){
				r = M-i;
				break;
			}
			S.insert(A[i]);
		}
		
		for(int i = 1; i <= N-M+1; i++){
			llint left = 0, right = 0;
			llint L = l+i-1;
			for(int j = l; j <= min(L, K-1); j++){
				left += dp[L][j] * fact[K-l] % mod * fact_inv[K] % mod;
				left %= mod;
			}
			L = N-(i+M)+r+1;
			for(int j = r; j <= min(L, K-1); j++){
				right += dp[L][j] * fact[K-r] % mod * fact_inv[K] % mod;
				right %= mod;
			}
			ans += left * right % mod;
			ans %= mod;
		}
	}
	else{
		for(int i = 1; i <= N-M+1; i++){
			
			llint L = M+i-1, R, left, right;
			for(int j = M; j <= min(L, K-1); j++){
				R = N-L+j;
				left = dp[L][j] * fact[K-M] % mod * fact_inv[K] % mod;
				right = (sum[R][min(R, K-1)] - sum[R][j-1] + mod) % mod;
				right *= fact[K-j] % mod * fact_inv[K] % mod;
				right %= mod;
				ans += left * right % mod;
				ans %= mod;
			}
		}
	}
	
	ans = (all - ans + mod) % mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 159104
import sys
input = sys.stdin.readline

def linput():
	return list(map(float,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	S = input().rstrip()
	
	res = 0
	B = 0
	
	for s in S:
		if s=='B': B+=1
		else: res += B
	print(res)

if __name__ == "__main__":
	main()


Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

string S, T;
vector<int> cnt_S(26);
vector<int> cnt_T(26);

string abc("abcdefghijklmnopqrstuvwxyz");

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

    //文字数をsortした配列が一致すればよい
    cin >> S >> T;

    for(int i = 0; i < S.size(); i++){

        for(int j = 0; j < abc.size(); j++){

            if(S[i] == abc[j]){
                cnt_S[j]++;
            }
            if(T[i] == abc[j]){
                cnt_T[j]++;
            }
        }
    }

    sort(cnt_S.begin(), cnt_S.end());
    sort(cnt_T.begin(), cnt_T.end());

    bool possible_flg = true;
    for(int i = 0; i < 26; i++){
        if(cnt_S[i] != cnt_T[i]){
            possible_flg = false;
        }
    }

    if(possible_flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 916
from collections import deque

n,m = list(map(int, input().split()))
puted = [1]*(n+1)

ab = [[] for i in range(n+1)]
for i in range(m):
	a,b = map(int, input().split())
	ab[a].append(b)
	ab[b].append(a)

q = deque([1])
flg = [-1]*n
flg[0] = 0

while q:
	item = q.popleft()
	for i in ab[item]:
		if puted[i]:
			flg[i-1]=item
			q.append(i)
			puted[i]=0

if -1 in flg:
	print("No")
	exit()

print("Yes")
for i in range(1,len(flg)):
	print(flg[i])


Measured memory_bytes: 34796
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	vector<int> vec(n+1);
	for(int i = 1;i<=n;i++)
	{
		int x;s(x);
		vec[i] = x;
	}
	vector<int> arr(n+1 , 0);
	
	for(int i = 1;i<=n;i++)
	{
		if(i + vec[i] <= n)
		{
			arr[i+vec[i]]++;
		}
	}
	
	ll count = 0;
	for(int i = n;i>=1;i--)
	{
		if(i - vec[i] >= 1)
		{
			count+=arr[i-vec[i]];		
		}	
	}
	
	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 4872
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	scanf("%d%d", &a, &b);
	c = a * b;
	d = c % 2;
	if(d == 0){
		printf("Even");
	}else{
		printf("Odd");
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin>>a>>b;
    
    int ans=max(0,a-b);
    cout1(ans)
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String sArray[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
        int index = Arrays.asList(sArray).indexOf(s);
        System.out.print(7 - index);
    }
}

Measured memory_bytes: 35488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int n; cin >> n;
  while(n > 1000){
    n -= 1000;
  }
  int ans = 1000 - n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
    #define pb push_back
    #define cmin(a,b) (a>b?a=b:a)
    #define cmax(a,b) (a<b?a=b:a)
    #define mem(a,k) memset(a,k,sizeof(a))
    #define lop(i,s,t) for(int i=s;i<(t);++i)
    #define rep(i,s,t) for(int i=s;i<=(t);++i)
    #define dec(i,s,t) for(int i=s;i>=(t);--i)
    #define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
    using namespace std;
     
    #define Pr(f,...) fprintf(stdout,f,##__VA_ARGS__),fflush(stdout)
     
    typedef long long ll;
     
    template<typename T>
    void read(T &x){
    	x=0; 
    	char c;
    	for(c=getchar();!isdigit(c);c=getchar()); 
    	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
    }
     
    const int N=2e5+50,oo=N;
     
    char col[N]; 
    int siz[N],n,mx[N],sc[N],R[N],L[N]; 
    ll ans;
    vector<int> g[N]; 
     
    void chkMx(int v,int w){
    	if(w>mx[v]){
    		sc[v]=mx[v];
    		mx[v]=w;
    	}else if(w>sc[v]){
    		sc[v]=w;
    	}
    }
     
    void dp(int v,int p){
    	mx[v]=0;
    	sc[v]=-oo;
    	L[v]=oo;
    	siz[v]=col[v]-'0';
    	for(int d:g[v])if(d!=p){
    		dp(d,v);
    		chkMx(v,mx[d]+1); 
    		siz[v]+=siz[d];
    		if(siz[d])cmin(L[v],mx[d]+1); 
    	}
    }
     
    void calc(int v,int p,int uMx){
    	chkMx(v,uMx); 
    	R[v]=min(mx[v],sc[v]+2)-1;
    	if(col[v]=='1')L[v]=0;
    	for(int d:g[v])if(d!=p){
    		int u=mx[v]==mx[d]+1?sc[v]+1:mx[v]+1;
    		if(siz[1]-siz[d]>0)cmin(L[d],u); 
    		calc(d,v,u); 
    	}
    }	
     
    int main(int argc,char *argv[]){
    #ifdef CURIOUSCAT
    	//freopen("dat.in","r",stdin);
    	//freopen("my.out","w",stdout);
    #endif
    	read(n); 
    	rep(i,1,n-1){
    		int u,v; 
    		read(u),read(v); 
    		g[u].pb(v); 
    		g[v].pb(u); 
    	}	
    	scanf("%s",col+1); 
    	dp(1,0); 
    	calc(1,0,0); 
    	rep(i,1,n){
    		ans+=max(0,R[i]-L[i]+1);
    		//Pr("v=%d,L[v]=%d,R[v]=%d\n",i,L[i],R[i]); 
    	}
    	printf("%lld\n", ans+1);
    	return 0;
    }
     

Measured memory_bytes: 24832
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,k,ans;
string s;
signed main(){
	 cin>>s;
	 int f=1;
	 for(int i=0;i<s.size();i+=2){
	 	if(s[i]!='h' || s[i+1]!='i'){
	 		f=0;
	 	}
	 	
	 }
	 if(f)cout<<"Yes"<<endl;
	 else cout<<"No"<<endl;
}


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

namespace ConsoleTest
{
    static partial class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if(s[0]=='7' || s[1]=='7'||s[2]=='7')
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

    }
    static partial class Program
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }
        public static int[] Ints()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
        public static long[] Longs()
        {
            return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        }
        public static int[][] MultiInts(int num)
        {
            var result = new int[num][];
            for(int i = 0; i < num; ++i)
            {
                result[i] = Ints();
            }
            return result;
        }
        public static T[] MultiItems<T>(int num, Func<string,T> parser)
        {
            var result = new T[num];
            for(int i =0; i < num; ++i)
            {
                result[i] = parser(Console.ReadLine());
            }
            return result;
        }
    }
}


Measured memory_bytes: 25812
class UnionFind:
	def __init__(self, n):
		self.n = n
		self.root = [-1]*(n+1)
		self.rnk = [0]*(n+1)
		self.Maxroot = -1

	def Find_Root(self, x):
		if (self.root[x] < 0):
			return x
		else:
			self.root[x] = self.Find_Root(self.root[x])
			return self.root[x]

	def Unite(self, x, y):
		x = self.Find_Root(x)
		y = self.Find_Root(y)
		if x == y:
			return 
		elif self.rnk[x] > self.rnk[y]:
			self.root[x] += self.root[y]
			if self.root[x] < self.Maxroot:
				self.Maxroot = self.root[x]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			if self.root[y] < self.Maxroot:
				self.Maxroot = self.root[y]
			self.root[x] = y
			if self.rnk[x] == self.rnk[y]:
				self.rnk[y] += 1

	def isSameGroup(self, x, y):
		return self.Find_Root(x) == self.Find_Root(y)

	def Count(self, x):
		return self.root[self.Find_Root(x)] * (-1)

N, M, K = map(int, input().split())

solve = UnionFind(N)
cntF = [0] * (N)

for _ in range(M):
	ta,tb = map(int, input().split())
	ta -= 1
	tb -= 1
	cntF[ta] += 1
	cntF[tb] += 1
	solve.Unite(ta,tb)

for _ in range(K):
	tc,td = map(int, input().split())
	tc -= 1
	td -= 1
	if solve.isSameGroup(tc,td):
		cntF[tc] += 1
		cntF[td] += 1

ans = []
for i in range(N):
	ans.append(solve.Count(i) - cntF[i] - 1)
print(*ans)



Measured memory_bytes: 11808
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)
#define FOR(i, n, m) for (int i = n; i < m; ++i)
#define FORR(i, n, m) for (int i = m-1; i >= n; --i)

const int INF = 1e9+9;
const int NN = 210;
const int MAX = 2e4+10;

int T[NN], Vt[MAX], Vi[NN];
int N;

int main() {

  memset(Vt, INF, sizeof(Vt));

  cin >> N;

  REP (i, N) cin >> T[i+1];
  REP (i, N) cin >> Vi[i];

  T[0] = 0;
  Vt[0] = 0;
  int sum = 0;

  REP (i, N) {
    sum += T[i+1];
    T[i+1] = sum;
    FOR (t, T[i], T[i+1])
      Vt[t+1] = min(Vt[t]+1, Vi[i]);
  }

  Vt[sum] = 0;
  REPR (i, N) FORR (t, T[i], T[i+1])
    Vt[t] = min(Vt[t], min(Vi[i], Vt[t+1]+1));

  REP (i, N) FOR (t, T[i], T[i+1])
    Vt[t+1] = min(Vt[t+1], Vt[t]+1);

  double ans = 0;
  REP (i, N) FOR (t, T[i], T[i+1]) {
    if (Vt[t] != Vt[t+1]) ans += 1.0*(Vt[t]+Vt[t+1])/2.0;
    else {
      ans += Vt[t];
      if (Vt[t] < Vi[i]) ans += 0.25;
    }
  }

  cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 384
#include <stdio.h>
int Gcd(int a, int b)
{
	if(a<b)
	{
		int t = a;
		a = b;
		b = t; 
	}
	if(a%b==0) return b;
	return Gcd(b, a%b);
}
int main()
{
	long long int a, b;
	scanf("%lld%lld", &a, &b);
	long long int multi = a*b;
	printf("%lld\n", multi/Gcd(a, b));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

bool isCorrect(int n, bool d[10]) {
    while (n) {
        if (d[n%10]) return false;
        n /= 10;
    }

    return true;
}

int main() {
    int n, k, x;
    bool d[10];

    cin >> n >> k;

    for (int i=0; i<10; i++) {
        d[i] = false;
    }

    for (int i=0; i<k; i++) {
        cin >> x;
        d[x] = true;
    }

    while (!isCorrect(n, d)) {
        n++;
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    L,R = map(int, input().split())

    ans = sys.maxsize

    # 0 がある場合
    # 0 がない場合→全探索

    if R//2019 - (L-1)//2019 > 0:
        return 0
    
    if R//673 - (L-1)//673 > 0 and R//3 - (L-1)//673 > 0:
        return 0

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

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


Measured memory_bytes: 5076
from collections import deque

def bfs(que,d): #幅優先探索
  #入力のグラフを初期化
  #d = [[float("inf")] * w for i in range(h)] 
  #d == mazeリストの"."を"inf"に変えたリスト
  lead = 0
  dx = [-1,0,0,1]
  dy = [0,-1,1,0]
  
  #que = deque([])
  #que.append((sx,sy))
  #d[sx][sy] = 0
  
  while que:
    lead_h,lead_w = que.popleft()
    lead = d[lead_h][lead_w]
    #lead == queの先頭にある要素を取り出す
    for i in range(4):
      nx = lead_w + dx[i]
      ny = lead_h + dy[i]
      if ny<0 or h<=ny or nx<0 or w<=nx:
        continue
      if d[ny][nx]==float("inf"):
        d[ny][nx] = lead + 1
        que.append((ny,nx))
  return lead

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]

d = [[float("inf")] * w for i in range(h)] 

que = deque([])
for i in range(h):
  for j in range(w):
    if maze[i][j] == "#":
      que.append((i,j))
      d[i][j] = 0

#print(bfs())
lead = bfs(que,d)
print(lead)

Measured memory_bytes: 161688
import sys
import math
n=int(input())
s=str(input())
ans_lis=[]
ans=0
for i in range(1000):
    tmp=[str(i//100),str((i%100)//10),str((i%100)%10)]
    f=0
    for j in range(n):
        if s[j]==tmp[f]:f+=1
        if f==3:
            ans+=1
            break
print(ans)
    

Measured memory_bytes: 70472
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, b, ans = 1;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  b = h.at(0);
  for(int i = 1; i < n; i++) {
    if(h.at(i) > b) b = h.at(i);
    else if(h.at(i)+1 < b) ans=0;
  }
  if(ans) cout << "Yes";
  else cout << "No";
}

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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int maxn = 2020;

int n, k;
vector<int> v[maxn];
queue<int> q, p;
bool vis[maxn];
vector<int> vv;

int bfs(int x, int s, bool op) {
    while (!q.empty())q.pop();
    while (!p.empty())p.pop();
    int ct = 0;
    q.push(x);
    ++ct;
    if (op)vv.push_back(x);
    vis[x] = 1;
    for (int i = 0; i <= s; ++i) {
        while (!p.empty()) {
            int x = p.front();
            p.pop();
            for (int j = 0; j < v[x].size(); ++j) {
                if (vis[v[x][j]] == 0) {
                    vis[v[x][j]] = 1;
                    q.push(v[x][j]);
                    if (op) vv.push_back(v[x][j]);
                    ++ct;
                }
            }
        }
        swap(p, q);
    }
    if (s < 0)return 0;
    else return ct;
}

int dp(int x, int s) {
    vis[x] = 1;
    int ct = 0;
    int tot = 0;
    for (int i = 0; i < v[x].size(); ++i) {
        vv.clear();
        int a1 = bfs(v[x][i], s - 1, 1);
        for (auto j:vv) {
            vis[j] = 0;
        }
        int a2 = bfs(v[x][i], s, 0);
        tot = max(tot, a2 - a1);
        ct += a1;
    }
    return ct + tot + 1;
}

int main() {
    __;
    cin >> n >> k;
    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    if (k % 2 == 0) {
        int ans = 0;
        for (int i = 1; i <= n; ++i) {
            memset(vis, 0, sizeof vis);
            ans = max(ans, bfs(i, k / 2, 0));
//            vv.clear();
        }
        cout << n - ans << endl;
    } else {
        int ans = 0;
        for (int i = 1; i <= n; ++i) {
            memset(vis, 0, sizeof vis);
            ans = max(ans, dp(i, k / 2));
            vv.clear();
        }
        cout << n - ans << endl;
    }
    return 0;
}
/*
 6 1
1 2
3 2
4 2
1 6
5 6
 */

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int N; 
cin >> N; 
int C[600], S[600], F[600], K[600]; 
for(int i = 1; i < N; i++){ 
cin >> C[i] >> S[i] >> F[i];
K[i] = S[i] / F[i]; 
}
C[N] = 114514, S[N] = 114514, F[N] = 114514; 
for(int i = 1; i <= N; i++){
int Ai = 0, Ti = S[i];// Aiは到着でTiは出発
for(int j = i; j <= N-1; j++){
Ai = Ti + C[j];  
Ti = max((Ai + F[j+1] - 1)/F[j+1], K[j+1]) 
  * F[j+1]; 
} 
cout << Ai << endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
using namespace std;
using ll = unsigned long long;

int main() {

    int x,y,c;
    bool out = false;
    cin >> x >> y;

    for(int t = 0; t <= x ; t++){
        if(2*(x+t) == y){
            out = true;
        }
    }
    if(out){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int A, B, K;
    cin >> A >> B >> K;
    int i = min(A, B), cnt = 0;
    while(cnt < K){
        if(A % i == 0 && B % i == 0) cnt++;
        if(cnt == K) break;
        i--;
    }
    PRINT(i);
    return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  ll n,k;
  cin>>n>>k;
  ll tmp=n/k;
  n=n-tmp*k;
  ll ans=n;
  while(ans>llabs(n-k)){
    n=llabs(n-k);
    ans=n;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
0に近い方から左右に交互に振り分けるのが最適
よく見る形
*/

ll n,ans=99,p[2]={},d[51];

void init(){
	cin>>n;
	rep(i,n)cin>>d[i];
	sort(d,d+n);
}

int main(void){
	init();
	rep(i,n){
		ans=min({ans, d[i]-p[i%2], 24-d[i]-p[(i+1)%2]});
		p[i%2]=d[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair

typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
    int s = 0, ent;
    for(int i = 0; i < 3; i++){
        scanf("%d", &ent);
        s+=ent;
    }
    if(s > 21){
        printf("bust\n");
    }else{
        printf("win\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<char>a(3);
vector<char>b(3);
for(int i=0;i<3;i++){
cin >> a.at(i);}

for(int i=0;i<3;i++){
cin >> b.at(i);}

int cnt=0;
for(int i=0;i<3;i++){
if(a.at(i)==b.at(2-i))cnt++;
}
  if(cnt==3)cout<<"YES"<<endl;
  else cout <<"NO"<<endl;
  }

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

int main() {
  int N, A;
  int x=0;
  int y=0;
  int z=0;
   cin >> N;
  vector<int> vec(N);
 
  for (int i=0; i< N; i++) {
	cin >> vec.at(i);
    x=vec.at(i);
    if (x>=y) {
      z=y;
      y=x;
    }
    else {
      if (z<x) {
        z=x;
      }
    }
  }
  for (int i=0; i< N; i++) {
	if (vec.at(i)==y) {
      cout << z << endl;
    }
    else {
      cout << y << endl;
    }
  }

}

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

int main()
{
  	string str;
  	cin>>str;
  	map<char,int> char_count;
  	for(int i=0 ; i<str.length() ; ++i)
    {
    	int tmp=++char_count[str[i]];
      	if(tmp>2 || char_count.size()>2)
        {
        	cout<<"No"<<endl;
          	return 0;
        }
    }
  	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N, K;
	cin >> N >> K;

	if( K == 1 ) {
		cout << 0 << endl;
	}
	else {
		cout << N-K << endl;
	}

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, M = list(map(int, input().split()))

switches = []
for _ in range(M):
    switches.append(list(map(int, input().split()))[1:])

p = list(map(int, input().split()))

def on(s, bit):
    return (bit >> (s-1)) & 1

count = 0
for bit in range(2 ** N):
    flag = False
    for k in range(M):
        state = 0
        for s in switches[k]:
            state += on(s, bit)
        if state % 2 != p[k]:
            flag = True
            break
    if flag:
        continue
    count += 1
print(count)


Measured memory_bytes: 41200
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	ans := 0
	for i := 1; i <= n; i+=2 {
		cnt := 0
		for j := 1; j <= i; j++ {
			if i % j == 0 {
				cnt++
			}
		}
		if cnt == 8 {
			ans++
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

string s;
int ans[114514][15];
signed main() {
	cin >> s;
	ans[0][0] = 1;
	rep(i, s.size()) {
		for (int j = 0; j <= 9; j++) {
			if (s[i] != '?' && s[i] - '0' != j)continue;
			for (int k = 0; k <= 12; k++) {
				ans[i][k] %= mod;
				ans[i + 1][(k * 10 + j) % 13] += ans[i][k];
			}
		}
	}
	int sum = 0;
	cout << ans[s.size()][5] % mod << endl;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;
    cin >> s;

    int p = 0;
    int m = 0;

    for (int i = 0; i < 4; i++)
        if (s[i] == '+')
            p++;
        else
            m++;

    cout << p - m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>

using namespace std;

using ll = long long;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<((a*3+b)>>1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M, X[101010], Y[101010];
bool ok[101010];
int n[101010];

int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; ++i) {
		ok[i] = false;
		n[i] = 1;
	}

	ok[0] = true;
	for (int i = 0; i < M; ++i) {
		scanf("%d%d", X + i, Y + i);
		--X[i]; --Y[i];
		ok[Y[i]] |= ok[X[i]];
		n[X[i]]--;
		n[Y[i]]++;
		if (n[X[i]] == 0) ok[X[i]] = false;
	}
	int a = 0;
	for (int i = 0; i < N; ++i) if (ok[i]) ++a;
	printf("%d\n", a);
	return 0;
}


Measured memory_bytes: 1536
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n);
    for (int &i: a) cin>>i;
    sort(a.begin(), a.end());
	int h=(a[n-1]+1)/2,b=0,d=1000000100;
	for (int i=0;i<n-1;i++){
		if (abs(h-a[i])<d){
			d=abs(h-a[i]); 
			b=a[i];
		}
	}
	cout << a[n-1] << " "<<b<< endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
} 

/*
4 2 = 6
6 2 = 15
6 4 = 15
9 2 = 36

6 4 :----->> 15
	
	1 2 3 4
	1 2 3 5
	1 2 3 6
	1 2 4 5
	1 2 4 6
	1 2 5 6
	1 3 4 5
	1 3 4 6
	1 3 5 6
	1 4 5 6
	
	2 3 4 5
	2 3 4 6
	2 3 5 6
	2 4 5 6

	3 4 5 6


6 5 ;---->> 
	
	1 2 3 4 5 
	1 2 3 4 6 
	1 2 3 5 6 
	1 2 4 5 6 
	1 3 4 5 6 
	2 3 4 5 6 
 
 
*/ 


Measured memory_bytes: 4016
#include<iostream>

using namespace std;


int main()
{
int Arr[13]={2,3,4,5,6,7,8,9,10,11,12,13,1};
int A,B;
cin>>A>>B;
if(A==B)
	cout<<"Draw";
else if(A==1 && B!=1)
	cout<<"Alice";
else if(B==1 && A!=1) 
	cout<<"Bob";

else if(A>B)
	cout<<"Alice";
else if(B>A)
	cout<<"Bob";				
}


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

bool is_product_overflow(ll a, ll b) {
        if ( a< (LLONG_MAX/b)){
                return false;
        }else{
                return true;
        }
}

int main()
{
        ll n;
        std::cin >> n;
        std::vector<ll> p(n);
        for(ll i=0; i<n; i++){
                std::cin >> p[i];
                if(p[i]==0){
                        printf("0\n");
                        return 0;
                }
        }

        ll prod=1LL;
        for(ll i=0; i<n; i++){
                //std::cout<<p[i]<< " "<<prod<<"\n";
                if(is_product_overflow(prod, p[i])){
                        printf("-1\n");
                        return 0;
                }
                prod *= p[i];
        }
        if(prod>1000000000000000000){
                printf("-1\n");
                return 0;
        }
        std::cout<<prod<<"\n";

        return 0;
}

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

using namespace std;

vector<int> makeSq(int N){
    vector<int> sq(N+1, 0);
    int a = 1, b = 1;
    for(int i=1;i<=N;i++){
        if(a*b < i){
            if(a == b) b++;
            else a++;
        }
        sq[i] = a+b;
    }
    return sq;
}

void makeSum(vector<vector<int>>& v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(i > 0) v[i][j] += v[i-1][j];
            if(j > 0) v[i][j] += v[i][j-1];
            if(i > 0 && j > 0) v[i][j] -= v[i-1][j-1];
        }
    }
}

int areaSum(int sx, int sy, int ex, int ey, const vector<vector<int>>& v){
    int res = v[ex][ey];
    if(sx > 0) res -= v[sx-1][ey];
    if(sy > 0) res -= v[ex][sy-1];
    if(sx > 0 && sy > 0) res += v[sx-1][sy-1];
    return res;
}

int main(){
    int N, D; cin >> N >> D;
    const auto sq = makeSq(N);
    auto cnt = vector(2*D, vector(2*D, 0));
    auto part = vector(2*D, vector(2*D, 0));
    for(int i=0;i<N;i++){
        int x, y; cin >> x >> y;
        ++cnt[x%D][y%D];
    }
    int mx = 0;
    for(auto& v : cnt){
        for(auto& t : v) { t = sq[t]; mx = max(mx, t); }
    }
    mx = (mx+1)/2*2;
    int num = 0;
    for(int i=0;i<D;i++){
        for(int j=0;j<D;j++){
            if(cnt[i][j] == mx) cnt[i][j] = 1;
            else {
                if((cnt[i][j]+1)/2 == (mx+1)/2) part[i][j] = 1;
                cnt[i][j] = 0;
            }
            num += (cnt[i][j] + part[i][j]);
            cnt[i+D][j] = cnt[i+D][j+D] = cnt[i][j+D] = cnt[i][j];
            part[i+D][j] = part[i+D][j+D] = part[i][j+D] = part[i][j];
        }
    }
    makeSum(cnt);
    makeSum(part);
    auto getSum = [&](int x, int y, int d){
        int res = areaSum(x, y, x+d, y+d, cnt);
        res += areaSum(x, y, x+d, y+D-1, part);
        res += areaSum(x, y, x+D-1, y+d, part);
        res -= areaSum(x, y, x+d, y+d, part);
        return res;
    };
    int res = mx * D;
    for(int i=0;i<D;i++){
        for(int j=0;j<D;j++){
            int L = -1, R = D-1;
            while(R-L > 1){
                int mid = (L+R)/2;
                if(getSum(i, j, mid) >= num) R = mid;
                else L = mid;
            }
            res = min(res, ((mx+1)/2-1)*D+R);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 35144
#include <stdio.h>

typedef long long int llint;

llint h;
llint ans=0;
llint n=1;

int main()
{
    scanf("%lld",&h);
    while(h>0)
    {
        h>>=1;
        ans+=n;
        n<<=1;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1692
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
  int a;
  cin >> a;
  int b = a/100;
  int c = 100*b+10*b+b;
  if(c < a) cout << c+111;
  else cout << c;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <set>

using namespace std;

struct comparator {
  bool operator() (const int *lhs, const int *rhs) const{
    if (lhs[2] == rhs[2] && lhs[3] == rhs[3])
      return lhs[0] < rhs[0];
    else if (lhs[2] == rhs[2])
      return lhs[3] < rhs[3];
    else
      return lhs[2] > rhs[2];
  }
};

int main(int argc, char *argv[]) {
  int n;
  set<int*, comparator> team;
  multiset<int> result;
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      int *tmp = new int[4];
      cin >> tmp[0] >> tmp[1] >> tmp[2] >> tmp[3];
      team.insert(tmp);
    }

    for (set<int*>::iterator itr = team.begin();
         itr != team.end(); itr++) {
      //cout << (*itr)[0];                                                                                                                                                
      if (result.size() < 10 && result.count((*itr)[1]) < 3) {
        cout << (*itr)[0] << endl;
        result.insert((*itr)[1]);
      } else if (result.size() < 20 && result.count((*itr)[1]) < 2) {
        cout << (*itr)[0] << endl;
        result.insert((*itr)[1]);
      } else if (result.size() < 26 && result.count((*itr)[1]) < 1) {
        cout << (*itr)[0] << endl;
        result.insert((*itr)[1]);
      }
    }
    team.clear();
    result.clear();
  }
  return 0;
}

Measured memory_bytes: 1212
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

typedef pair<int, int> paii;
typedef long long ll;


int main()
{
	int n, s;
	
	while(cin >> n >> s, (n||s))
	{
		int c = 0;
		int lim = 1 << 10;
		
		for(int k = 0; k < lim; k++)
		{
			int sum = 0;
			int sel = 0;
			for(int i = 0; i < 10; i++)
			{
				if( k & (1 << i))
				{
					sum += i;
					sel++;
				}
			}
			
			if(sum == s && sel == n)
				c++;
		}
		
		cout << c << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int x,n;
	cin>>x>>n;
	ll int a[n],f[105]={0};
	ll int i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		f[a[i]]=1;
	}
	ll int l,r;
	for(i=0;i<=101;i++)
	{
		if (f[i]==0 && i<=x)
		{
			l=i;
			
		}
	}
	for(i=101;i>=1;i--)
	{
		if (f[i]==0 && i>=x)
		{
			r=i;
		}
		
	}
	if (x-l<=r-x)
	cout<<l<<endl;
	else
	cout<<r<<endl;
}
    
	
		

	
			

		


 







Measured memory_bytes: 3640
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    char[] s = in.next().toCharArray();
    boolean S = false, W = false, N = false, E = false;
    for (char c : s) {
      if (c == 'S') S = true;
      if (c == 'E') E = true;
      if (c == 'W') W = true;
      if (c == 'N') N = true;
    }
    if (N == S && W == E) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

    in.close();
  }
}

Measured memory_bytes: 8660
#include<bits/stdc++.h>
int main(void)
{
	long long a,c;
	char b[10];
	scanf("%lld %s",&a,b);
	c=(b[0]-'0')*100+(b[2]-'0')*10+b[3]-'0';
	printf("%lld\n",a*c/100);
	return 0;
}

Measured memory_bytes: 3796
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum[3300000], ans, a[330000], b[330000];
string str, ss;
bool f[5];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	if ((n+1) / 2 >= m) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int N = 1e9 + 7;

int n, m, f[3005][3005][2];

int main() {
	scanf("%d%d", &n, &m);
	f[0][0][1] = 1;
	for (int i = 1; i <= n; ++i) f[0][i][0] = 1;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j <= n; ++j) {
			for (int k = 0; k < 2; ++k) {
				if (j > 0) {
					f[i + 1][j][k | (j == 1)] = (f[i][j][k] + f[i + 1][j][k | (j == 1)]) % N;
					f[i + 1][j - 1][k | (j == 1)] = (f[i][j][k] + f[i + 1][j - 1][k | (j == 1)]) % N;
				}
				if (j < n) {
					f[i + 1][j][k] = (f[i][j][k] + f[i + 1][j][k]) % N;
					f[i + 1][j + 1][k] = (f[i][j][k] + f[i + 1][j + 1][k]) % N;
				}
			}
		}
	}
	int tot = 0;
	for (int i = 0; i <= n; ++i) tot = (tot + f[m][i][1]) % N;
	printf("%d\n", tot);
	return 0;
}

Measured memory_bytes: 70656
typealias Graph = MutableList<MutableList<Int>>
fun create_empty_graph(n:Int):Graph{
    return MutableList(n) {_ -> mutableListOf<Int>()}
}
fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map(String::toInt)
    var g = create_empty_graph(n)
    for (_i in 0 until m) {
        var (x,y,_) = readLine()!!.split(" ").map(String::toInt)
        x--
        y--
        g[x].add(y)
        g[y].add(x)
    }

    var used = MutableList(n) {_ -> false}
    var cnt = 0
    for (i in 0 until n) {
        if(used[i]) continue
        var stack = mutableListOf<Int>()
        cnt++
        used[i] = true
        stack.add(i)
        while(!stack.isEmpty()){
            val v = stack.lastOrNull()!!
            stack.removeAt(stack.size-1)
            for(to in g[v]) {
                if(!used[to]) {
                    used[to] = true
                    stack.add(to)
                }
            }
        }
    }

    println(cnt)
}


Measured memory_bytes: 74992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

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

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} };
typedef vector<edge> edges;

edges G[3010];
int d[100010];

void dijkstra(int s)
{
    priority_queue<pii, vpii, greater<pii> > pq;
    d[s] = 0;
    pq.push(pii(0, s));
    
    while (pq.size()) {
        pii p = pq.top(); pq.pop();

        int v = p.scd;

        if (d[v] < p.fst) continue;

        rep(i, G[v].size()) {
            edge &e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(pii(d[e.to], e.to));
            }
        }
    }
}

signed main()
{
    omajinai;

    int N, M, K; cin >> N >> M >> K;

    fill_n(d, N + 1, inf);

    rep(i, M) {
        int a, b, l; cin >> a >> b >> l;
        a--, b--;

        G[a].PB(edge(b, l));
        G[b].PB(edge(a, l));
    }

    rep(i, K) {
        int s; cin >> s;
        s--;
        dijkstra(s);
    }

    double ma = -1.0;

    rep(i, N) {
        rep(j, G[i].size()) {
            edge &e = G[i][j];
            ma = max(ma, (d[i] + d[e.to] + e.cost) / 2.0);
        }
    }

    cout << round(ma) << endl;
}

Measured memory_bytes: 4292