akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

#define _For(idx, from, to, inc, cmp) \
	for(auto idx=(from) ; idx cmp (to) ; inc idx)
#define ForLE(idx, from, to) \
	_For(idx, from, to, ++, <=)
#define ForGE(idx, from, to) \
	_For(idx, from, to, --, >=)
#define ForLT(idx, from, to) \
	_For(idx, from, to, ++, <)
#define ForGT(idx, from, to) \
	_For(idx, from, to, --, >)
#define For(idx, from, to) \
	_For(idx, from, to, ++, <)
using u64 = uint64_t;
using u64p = std::pair<u64, u64>;
using i64 = int64_t;
constexpr int NA = 50;
int main() {
	u64 n;
	std::cin >> n;

	std::vector<u64p> v;
	u64 val = NA,
		add = 1;
	for(;;) {
		v.emplace_back(val, add);
		add *= NA;
		const u64 prev = val;
		val *= NA;
		if(val < prev)
			break;
	}

	std::vector<u64> ret(NA, NA-1);
	const int len = v.size();
	if(n >= NA) {
		ForGE(i, len-1, 0) {
			if(v[i].first <= n) {
				const u64 times = n / v[i].first;
				n -= v[i].first * times;
				const u64 toAdd = v[i].second * times;
				for(auto& a : ret)
					a += toAdd;
			}
		}
	}
	For(i, 0, n) {
		ret[i] += NA;
		For(j, 0, NA) {
			if(j != i) {
				ret[j] -= 1;
			}
		}
	}
	std::cout << NA << std::endl;
	For(i, 0, NA) {
		if(i!=0)
			std::cout << ' ';
		std::cout << ret[i];
	}
	std::cout << std::endl;
	return 0;
}


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

namespace ABC125
{
    class D
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            int mi = 0;
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] < 0) { mi++; }
                else if (a[i] == 0) { mi = -1;break; }
            }
            for (int i = 0; i < n; i++)
            {
                a[i] = Math.Abs(a[i]);
                ans += a[i];
            }
            if (mi == -1) { }
            else if (mi % 2 == 1) { ans -= 2 * a.Min(); }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 31068
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,m;
bool red[N];
int num[N];
int main()
{
	scanf("%d%d",&n,&m);
	int x,y;
	for(int i=1;i<=n;i++)
	{
		num[i]=1;
	}
	red[1]=1;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		num[x]--;
		num[y]++;
		if(red[x])
		{
			if(!num[x])
			{
				red[x]=0;
				red[y]=1;
			}
			else
			{
				red[y]=1;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	if(red[i])
	{
		ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {

    public static void main (String [] args){
        Scanner  sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> num = new HashSet<>();
        for (int i =0;i<N;i++){
            int d = sc.nextInt();
            if (!num.contains(d)){
                num.add(d);
            }
        }
        System.out.println(num.size());
    }
}

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

public class Main {
  public static void main(String[] args) {
    // 入力をもらうための変数を用意
    Scanner s = new Scanner(System.in);
    // 10こ分の配列
    int[] inputs = new int[10];

    for (int i = 0; i < 10; i++) {
    // 入力されたものをinputに入れる
      inputs[i] = s.nextInt();
    }   

    Arrays.sort(inputs);

    // 出力
    System.out.println(inputs[9]);
    System.out.println(inputs[8]);
    System.out.println(inputs[7]);
  }
}

Measured memory_bytes: 17168
X, N = map(int, input().split())
P = list(map(int, input().split()))
P = set(P)

for i in range(100):

  if X-i in P:
    pass
  else:
    print(X-i)
    break

  if X+i in P:
    pass
  else:
    print(X+i)
    break


Measured memory_bytes: 9168
def linear_search(num_list,target):
    for num in num_list:
        if num == target:
            return 1
    return 0

n = input()
num_list = list(map(int,input().split()))
q = input()
target_list = list(map(int,input().split()))
ans = 0

for target in target_list:
    ans += linear_search(num_list,target)
print(ans)


Measured memory_bytes: 6548
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;

int main()
{
	LL N, M;
	cin >> N >> M;

	LL cnt;
	if (N == 1 || M == 1)
		if (N != 1)
			cnt = N - 2;
		else if (M != 1)
			cnt = M - 2;
		else
			cnt = 1;
	else
		cnt = (N - 2) * (M - 2);

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,Q = map(int, input().split(' '))
ab = [list(map(int, input().split(' '))) for i in range(n-1)]
q = [list(map(int, input().split(' '))) for i in range(Q)]
graph = [[] for i in range(n+1)]
parent = [0 for i in range(n+1)]
root = 1
order = []
stack = [root]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if parent[x] == y:
            continue
        parent[y] = x
        stack.append(y)
cnt = [0]*(n+1)
for i,x in q:
    cnt[i] += x
ans = [0]*(n+1)
for x in order:
    if x == 1:
        ans[1] += cnt[1]
        continue
    ans[x] += cnt[x]+ans[parent[x]]
del ans[0]
print(*ans,sep=" ")

Measured memory_bytes: 139564
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b;
	int p,q,r,s,t;
	cin >> a >> b ;

	seiyaku_check(a,0,100);
	seiyaku_check(b,0,100);
	
	p=(3*a)/2;
	q=(3*a)%2;
	r=b/2;
	s=b%2;
	t=(q+s)/2;
	
	cout << p+r+t << endl;

return 0;
}


Measured memory_bytes: 256
e_1, e_2, e_3, e_4 = map(int, input().split())

if e_1 == e_2 and e_3 == e_4:
    print("yes")
elif e_1 == e_3 and e_2 == e_4:
    print("yes")
elif e_1 ==e_4 and e_2 == e_3:
    print("yes")
else:
    print("no")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace  std;
#define f(i,n) 		for(i=0;i<n;i++)
#define fr(i,n,a) 	for(i=n;i>=a;i--)
#define fa(i,a,n) 	for(i=a;i<n;i++)
#define deb(x)		cout<<#x<<" "<<x<<endl;
#define deb2(x,y)	cout<<#x<<","<<#y<<" "<<x<<","<<y<<endl;
#define buf(x)		cout<<"Check"<<x<<endl;
#define ll			long long int 
#define ft			first
#define s			second
#define pb			push_back
#define mp			make_pair
#define do			double
#define all(v)		v.begin(),v.end()	
#define et(v)		for(auto itr:v)
#define mod			1000000007
inline void p(int x[],int n)	{	int i;f(i,n)cout<<x[i]<<" ";cout<<endl; }

void solve()
{  	
	ll N,M,K,i,j,sum=0;
	string s;
	cin>>s;
	N=s.size();
	f(i,N)
	{
		sum+=s[i]-'0';
		sum%=9;

	}
	if(sum==0)
		cout<<"Yes";
	else
	{
		cout<<"No";
	}
	



}
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	ll t=1,c=1;
	//cin>>t;
	while(t--)
	{
		

		//cout<<"Case #"<<c++<<": "<<endl;
		solve();
		cout<<"\n";
		
	}
	return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
   int a,b,c;
   string s;
   cin >> a >> b >> c;
   cout << c << " " << a << " " << b << endl;
   

   
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL a,b,ans;
        cin>>a>>b;
        ans=a*b;
        cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=5e5;

  ll n,s;
  ll a[N];
void in()
{
  cin>>n;
  for (ll i=0;++i<=n;)
    scanf("%lld",a+i),
		s+=a[i];
}

void GG()
{
  puts("NO");
  exit(0);
}

  ll c[N];
void get()
{
  ll t=(1+n)*n/2;
  if (s%t) GG();
  else s/=t;
  for (ll i=0,x;++i<=n;)
    {
      int j=i%n+1;
      x=a[i]-a[j]+s;
      if (x%n||x<0) GG();
      else
			c[1]+=x/n*(n-j+1);
			c[j]-=x;
    }
  for (ll i=0;++i<=n;)
    c[i]+=c[i-1]+s;
}

void che()
{
  for (ll i=0;++i<=n;)
    if (c[i]^a[i]) GG();
  puts("YES");
}

int main()
{
  in();
  get();
  che();
  exit(0);
}

Measured memory_bytes: 5120
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int x,h;
  while(scanf("%d%d",&x,&h),x||h){
    double a = (double)x/2;
    a = sqrt(h*h+a*a);
    printf("%.9lf\n",2*a*x+x*x);
  }
}

Measured memory_bytes: 1064
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 1050;
const long long INF = 1e18;

int n, m;
long long x[MAXN], y[MAXN], z[MAXN];
long long dp[MAXN][MAXN];
long long ans = -INF;

int getBit(long long x, int pos) {
  return (x & (1ll << pos)) > 0 ? 1 : 0;
}

int main() { 

  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
  }

  for (int mask = 0; mask < (1 << 3); mask++) {
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++) {
      if (getBit(mask, 0)) {
        x[i] = -x[i];
      }
      if (getBit(mask, 1)) {
        y[i] = -y[i];
      }
      if (getBit(mask, 2)) {
        z[i] = -z[i];
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        dp[i][j] = -INF;
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= min(i, m); j++) {
        if (i > 1) {
          dp[i][j] = dp[i - 1][j];
        }
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + x[i - 1] + y[i - 1] + z[i - 1]);
      }
    }

    for (int i = 0; i < n; i++) {
      if (getBit(mask, 0)) {
        x[i] = -x[i];
      }
      if (getBit(mask, 1)) {
        y[i] = -y[i];
      }
      if (getBit(mask, 2)) {
        z[i] = -z[i];
      }
    }

    ans = max(ans, dp[n][m]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9592
n = int(raw_input())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

ac=0
bc=0
for i in range(n):
   if (a[i]>b[i]):
      bc=bc+(a[i]-b[i])
   if (a[i]<b[i]):
      ac=ac+(b[i]-a[i]+1)/2
      bc=bc+(b[i]-a[i])%2

if ac>=bc:
   print "Yes"
else:
   print "No"


Measured memory_bytes: 3696
// Aizu 1155: How can I satisfy thee? Let me count the...
// 2017.9.13 bal4u@uu

#include <stdio.h>
#include <ctype.h>

char buf[100], *bp;
int p, q, r;

int term();

int factor()
{
	int x;

	if      (*bp == '(') bp++, x = term(), bp++;
	else if (*bp == '-') bp++, x = 2-factor();
	else if (isdigit(*bp)) x = *bp++ - '0';
	else if (*bp == 'P') bp++, x = p;
	else if (*bp == 'Q') bp++, x = q;
	else bp++, x = r;
	return x;
}

int term()
{
	int x, y, op;

	x = factor();
	if      (*bp == '*') bp++, op = 1;
	else if (*bp == '+') bp++, op = 0;
	y = factor();
	if (op) {
		if (x == 2 && y == 2) x = 2;
		else if (x == 0 || y == 0) x = 0;
		else x = 1;
	} else {
		if (x == 0 && y == 0) x = 0;
		else if (x == 2 || y == 2) x = 2;
		else x = 1;
	}
	return x;
}

int main()
{
	int ans;

	while (scanf("%s", buf) && *buf != '.') {
		ans = 0;
		for (p = 0; p <= 2; p++) for (q = 0; q <= 2; q++) for (r = 0; r <= 2; r++) {
			bp = buf; if (factor() == 2) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1684
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int n,i,j,min,minj,max=0,maxa,maxb;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	min=a[n-1];
	for(i=0;i<n;i++){
		if(min>abs(2*a[i]-a[n-1])){
			min=abs(2*a[i]-a[n-1]);
			minj=a[i];
		}
	}
	cout << a[n-1] << " " << minj <<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
char s[20],a[10]="YAKI";
int main() {
    scanf("%s",s);
    bool f=true;
    for(int i=0;i<4;i++) {
        if(s[i]!=a[i]) f=false;
    }
    if(f) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
n=int(input())
def di(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
li=di(n)
a=li[-1]
if a**2==n:
    print(len(str(a)))
elif n==1:
    print(1)
else:
    b=li[-2]
    print(max(len(str(a)),len(str(b))))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <random>
using namespace std;
int h,w;
bool match[15][15];
bool dp[1 << 13];
char s[15][15];
int main()
{
	random_device r;
	mt19937 mt(r());
	scanf("%d %d",&h,&w);
	for(int i = 0; i < h; i++)
	{
		scanf("%s",s[i]);
	}

	for(int t = 0 ; t < 100000; t++)
	{
		memset(match,1,sizeof(match));
		for(int k = 0; k < w; k++)
		{
			for(int j = k ; j < w; j++)
			{
				for(int i = 0; i < h; i++)
				{
					if(s[i][k] != s[h - 1 - i][j])
						match[k][j] = false;
				}
			}
		}
		memset(dp,0,sizeof(dp));
		dp[0] = true;
		for(int mask = 0; mask < (1 << w); mask++)
		{
			if(dp[mask] == false)
				continue;
			for(int i = 0 ; i < w; i++)
			{
				for(int j = i+1 ; j < w; j++)
				{
					if(!(mask >> i & 1) && !(mask >> j & 1) && match[i][j])
						dp[mask | (1 << i) | (1 << j)] = true;
				}
			}
		}
		bool can = false;
		if(w & 1)
		{
			for(int i = 0 ; i < w; i++)
			{
				if(dp[((1 << w) -1) - (1 << i)] && match[i][i])
				{
					can = true;
					break;
				}
			}
		}
		else
		{
			can = dp[(1 << w)-1];
		}
		if(can)
		{
			puts("YES");
			return 0;
		}
		shuffle(s,s+h, mt);
	}

	puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int N;
char S;

int main(void) {
  
  scanf("%d\n", &N);
  for(int i = 0; i < N ; ++i) {
    scanf("%c ", &S);
    if(S == 'Y') { printf("Four"); return 0; }
  }
  printf("Three");  
  return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 T1, T2;
  i64 A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  if (A1 < B1) {
    swap(A1, B1);
    swap(A2, B2);
  }
  if (A2 > B2) {
    cout << 0 << endl;
    return;
  }
  if (A1 * T1 + A2 * T2 > B1 * T1 + B2 * T2) {
    cout << 0 << endl;
    return;
  }
  if (A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2) {
    cout << "infinity" << endl;
    return;
  }
  i64 x = A1 * T1 - B1 * T1;
  i64 y = B1 * T1 + B2 * T2 - A1 * T1 - A2 * T2;
  i64 c = (x + y - 1) / y;
  if (x % y == 0) {
    cout << c * 2 << endl;
  } else {
    cout << c * 2 - 1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    string ans = s + t;
    for(int i = 1; i <= N; i++){
        if(s.substr(N-i,i) == t.substr(0,i)){
            ans = s + t.substr(i, N-i);
        }
    }
    cout << ans.size() << endl;
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int n,a;
  cin >> n >> a;
  n%=500;
  if(n>a) print("No");
  else print("Yes"); 

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
        if(N % 1.08 == 0){
            System.out.println((int)(N / 1.08));
            return;
        }
        for(int i =(int) (N / 1.08); i <= N; i++){
            if((int) (i * 1.08) == N){
                System.out.println((int) i);
                return;
            }
        }
        System.out.println(":(");
    }
}

Measured memory_bytes: 35784
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int vis[N];
long long f1[N]={1,1},f2[N]={1,1},inv[N]={1,1};
const long long mod = 1e9+7;
long long quick( long long a,long long b ){
    long long res = 1;
    long long t = a;
    while( b ){
        if(b&1){
            res =(res*t)%mod;
        }
        t=t*t%mod;
        b>>=1;
    }
    return res;
}
void init(){
    for(long long i = 2 ; i <= N ;i++){
        f1[i] = (f1[i-1]*i)%mod;
        inv[i] = quick(i,mod-2);//费马小定理
        //cout<<i<<" ="<<inv[i]<<endl;
        f2[i] = (f2[i-1]*inv[i])%mod;
    }
}
long long ans(long long n,long long m){
    return f1[n]*f2[n-m]%mod*f2[m]%mod;
    //f2为逆元
}
int main()
{
    int n ;
    long long dis = 0;
    init();
    memset(vis,0,sizeof(vis));
    cin>>n;
    for(int i = 1 ; i <= n+1 ; i ++ ){
        int x;
        cin>>x;
        if(vis[x]) dis = n-(i-vis[x]);
        vis[x] = i;
    }
    long long sum=0;
    for(int i = 1 ; i <= n+1 ; i ++ ){
        sum = ans( (long long)n+1 , (long long)i )%mod;
       // cout<<sum<<" = - "<<endl;
        if(dis >= i-1){
            sum = ((long long)sum-(long long)ans(dis,i-1)+mod)%mod;
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

int main() {
  int n,k,q;
  cin>>n>>k>>q;
  map<int,int> a;
  rep(i,n){
    a[i]=0;
  }
  rep(i,q){
    int A;
    cin>>A;
    a[A-1]++;
  }
  rep(i,n){
    if(q-a[i]>=k){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
    }
  }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
 
    x = x % p; // Update x if it is more than or  
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
 
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
 
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
#define MAXN   1000001 

int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking sp for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 


int main()
{
 
  fastio();

ll int T=1;
sieve();
while(T--)
{
    ll int n,m;
    cin>>n;
    ll int a[n],g,i;
    map<ll int,ll int> mp;
    for(i=0;i<n;i++)
      {  cin>>a[i];
        if(i)g=__gcd(a[i],g);
        else g= a[i];
      }
      
    for(i=0;i<n;i++)
    {
        while(a[i]!=1)
        {
            ll int x= spf[a[i]];
            while(a[i]%x==0)a[i]/=x;
            mp[x]++;

        }
    }
    ll int flag=0;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(it->second>1)
        {
            flag=1;break;
        }
    }
    if(!flag)
        {cout<<"pairwise coprime"<<endl;}
    else if(g==1)
    {

        cout<<"setwise coprime"<<endl;
        continue;
    }
    else
    {
        cout<<"not coprime"<<endl;
    }
     

    


}



return 0;}

Measured memory_bytes: 20072
#include<stdio.h>

int main(void){
	double weight;
	
	while(scanf("%lf",&weight)!=EOF){
		if(weight<=48.00){
			printf("light fly\n");
		}else if(weight>48.00 && weight<=51.00){
			printf("fly\n");
		}else if(weight>51.00 && weight<=54.00){
			printf("bantam\n");
		}else if(weight>54.00 && weight<=57.00){
			printf("feather\n");
		}else if(weight>57.00 && weight<=60.00){
			printf("light\n");
		}else if(weight>60.00 && weight<=64.00){
			printf("light welter\n");
		}else if(weight>64.00 && weight<=69.00){
			printf("welter\n");
		}else if(weight>69.00 && weight<=75.00){
			printf("light middle\n");
		}else if(weight>75.00 && weight<=81.00){
			printf("middle\n");
		}else if(weight>81.00 && weight<=91.00){
			printf("light heavy\n");
		}else if(weight>91.00){
			printf("heavy\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w; ll l;
    while(cin >> h >> w >> l, h){
        vector<vector<int>> v(h+2, vector<int>(w+2, 0));
        auto d = make_v(h+2, w+2, 4, -1);
        int y = -1, x = -1, deg = 0;
        string t  = "NESW";
        for (int i = 0; i < h; ++i) {
            string s;
            cin >> s;
            for (int j = 0; j < w; ++j) {
                v[i+1][j+1] = (s[j] != '#');
                if(isalpha(s[j])){
                    y = i, x = j;
                    for (int k = 0; k < 4; ++k) {
                        if(s[j] == t[k]){
                            deg = k;
                        }
                    }
                }
            }
        }
        y++; x++;
        array<int, 4> dy{-1, 0, 1, 0}, dx{0, 1, 0, -1};
        ll turn = 0;
        while(!(~d[y][x][deg]) && turn < l){
            d[y][x][deg] = turn;
            while(!v[y+dy[deg]][x+dx[deg]]) deg = (deg+1)%4;
            y += dy[deg]; x += dx[deg];
            turn++;
        }
        if(turn == l){
            printf("%d %d %c\n", y, x, t[deg]);
            continue;
        }
        l -= d[y][x][deg];
        l %= (turn-d[y][x][deg]);
        for (int i = 0; i < l; ++i) {
            while(!v[y+dy[deg]][x+dx[deg]]) deg = (deg+1)%4;
            y += dy[deg]; x += dx[deg];
            turn++;
        }
        printf("%d %d %c\n", y, x, t[deg]);
    }
    return 0;
}


Measured memory_bytes: 3700
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		sc.fill(T);
		int M = sc.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		sc.fill(P, X);

		int sum = IntStream.of(T).sum();

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < M; i++) {
			sb.append(sum - (T[P[i] - 1] - X[i]));
			sb.append(System.lineSeparator());
		}

		System.out.print(sb.toString());
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 14284
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

vector<pair<int, int> > graph[100001];
int color[100001];
bool visited[100001];

void coloring(int now, int col){
	visited[now] = true;
	color[now] = col;
	for (auto x : graph[now]){
		if (!visited[x.first]){
			if (x.second % 2){
				coloring(x.first, (col+1)%2);
			}else{
				coloring(x.first, col);
			}
		}
	}
	return;
}

int main(){
	int n;
	cin >> n;
	for (int i = 1; i < n; i++){
		int u, v, w;
		cin >> u >> v >> w;
		graph[u].push_back(make_pair(v, w));
		graph[v].push_back(make_pair(u, w));
	}
	coloring(1, 0);
	for (int i = 1; i <= n; i++){
		cout << color[i] << endl;
	}
	return 0;
}

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

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll count = 0;
  count = (N / (A+B)) *A;
  if (N % (A+B) <= A) count += N % (A+B);
  else count += A;
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int H,W;
  cin >> H >> W;
  
  for(int i = 0 ; i < W+1 ; i++){
    cout << "#" ;
  }
  cout << "#" << endl;
  
  for(int k = 0 ; k < H ; k++){

    cout << "#";
    string str;
    cin >> str;
    
    for(int i = 0 ; i < W ; i++){
      
      cout << str.at(i);
    }
    cout << "#" << endl;
  }
  for(int i = 0 ; i < W+1 ; i++){
    cout << "#" ;
  }
  cout << "#" << endl;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> v(n);
	for (auto& x : v) cin >> x;
	sort(v.begin(), v.end());
	pair<int, int> maxv = { 0,0 };
	int s = v.back();
	for (int i = 0; i + 1 < v.size(); i++)
	{
		maxv = max(maxv, make_pair(min(v[i], s - v[i]), v[i]));
	}
	cout << s << ' ' << maxv.second << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int T,S[4*200010],N[200010];
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
//????????¢??°?????????MIN???
int hyoka(int a,int b){return (a<0||b<0)?(a<0?b:a):N[a]<N[b]?a:b;}
//?????°??¨?????????n?????°???d??§?????????????§????
void sset(int n){
  int i;
  for(T=1;T<n;T*=2);
  for(i=0;i<T;i++)S[T+i]=i<n?i:-1;
  for(i=T-1;i;i--)S[i]=hyoka(S[i*2],S[i*2+1]);
}
//?????°??¨???update??¢??°
//i???????????°??????n????????´???????§????
void sud(int i,int n){for(N[i+=T]=n;i/=2;)S[i]=hyoka(S[i*2],S[i*2+1]);}
//?????°??¨???find??¢??°
//[a,b)????????????????????????sout(a,b,1,0,T);
int sout(int a,int b,int i,int l,int r){//printf("%d %d %d %d %d\n",a,b,i,l,r);
  if(r<=a||b<=l)return -1;
  if(a<=l&&r<=b)return S[i];
  return hyoka(sout(a,b,i*2,l,(l+r)/2),sout(a,b,i*2+1,(l+r)/2,r));
}
int ta[100010],to[100010],nt[100010],d[100010],r=0,fi[100010],ID[200010];
void ldfs(int s){
  int i;
  N[fi[s]=r]=d[s];
  ID[r++]=s;
  for(i=ta[s];i+1;i=nt[i]){
    if(fi[to[i]])continue;
    d[to[i]]=d[s]+1;
    ldfs(to[i]);
    N[r]=d[s];
    ID[r++]=s;
  }
}
void slca(int p){
  d[p]=1;
  r=0;
  ldfs(p);
  sset(r);
}
int alca(int a,int b){return sout(MIN(fi[a],fi[b]),MAX(fi[a],fi[b])+1,1,0,T);}
int main(){
  int n,m,i,j,e=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)ta[i]=-1;
  for(i=0;i<n;i++){
    scanf("%d",&m);
    while(m--){
      scanf("%d",&j);
      nt[e]=ta[i];
      to[e]=j;
      ta[i]=e++;
    }
  }
  slca(0);
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&i,&j);
    printf("%d\n",ID[alca(i,j)]);
  }
  return 0;
}

Measured memory_bytes: 10360
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

struct Point{
    int i;
    int j;
};

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

    // input
    ll H, W, D;
    cin >> H >> W >> D;

    map<int, Point> mp;

    ll A[H][W];
    FOR(i, 0, H){
        FOR(j, 0, W){
            int a;
            cin >> a;
            A[i][j] = a;

            auto p = Point();
            p.i = i;
            p.j = j;
            mp[a] = p;
        }
    }

    // 累積和
    ll AC[H*W+1];
    FOR(i, 0, D){
        AC[i] = 0;
    }
    FOR(i, D, H*W+1){
        AC[i] = AC[i-D] + abs(mp[i].i - mp[i-D].i) + abs(mp[i].j - mp[i-D].j);
    }

    ll Q;
    cin >> Q;
    FOR(i, 0, Q){
        ll L, R;
        cin >> L >> R;

        ll cost = AC[R] - AC[L]; 
        p(cost);
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = 1e6;
    vector<int> z(mx + 1);
    for (int i = 2; i * i <= mx; i++) {
        if (!z[i]) {
            for (int j = i * i; j <= mx; j += i) {
                z[j] = 1;
            }
        }
    }
    vector<int> p;
    for (int i = 2; i <= mx; i++) {
        if (!z[i]) {
            p.push_back(i);
        }
    }
    int s = p.size(), g = a[0];
    vector<int> c(mx + 1);
    bool f = true;
    for (int i = 0; i < n; i++) {
        g = __gcd(g, a[i]);
        for (int j = 0; j < s && p[j] * p[j] <= a[i]; j++) {
            if (a[i] % p[j] == 0) {
                if (c[p[j]]) {
                    f = false;
                }
                c[p[j]] = 1;
                while (a[i] % p[j] == 0) {
                    a[i] /= p[j];
                }
            }
        }
        if (a[i] > 1) {
            if (c[a[i]]) {
                f = false;
            }
            c[a[i]] = 1;
        }
    }
    cout << (f ? "pairwise coprime" : g == 1 ? "setwise coprime" : "not coprime") << endl;
    return 0;
}


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

int main() {
    int a,b;
    cin >>a>>b;
    int A=1,B=1,C=1;
    if(a!=1 &&b!=1) cout <<1<<endl;
    if(a!=2 && b!=2)    cout <<2<<endl;
    if(a!=3&&b!=3)  cout <<3<<endl;

    return 0;
}


Measured memory_bytes: 3556
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
 
int s_asorts(const void* a, const void* b);
 
//昇順
int s_asorts(const void* a, const void* b) {
    return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
    return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
    int i;
    rept(i, 0, n) {
        l_cin2(*(a + i), *(b + i));
    }
    return 0;
}
int i_cins(int n, int* a) {
    int i;
    for (i = 0; i < n; i++) {
        i_cin(*(a + i));
    }
 
    return 0;
}
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}
 
long _max(long a, long b) {
    return a > b ? a : b;
}
long _min(long a, long b) {
    return a < b ? a : b;
}
int _swp(int* a, int* b)
{
    int tmp;
    tmp = *b; *b = *a; *a = tmp;
    return 0;
}


int main(){
    int n,k;
    int cnt=0;
    int a[n];
    scanf("%d%d",&n,&k);
    for(int i=0;i<k;i++){
        int d;
        int b[102];
        scanf("%d",&d);
        for(int j=0;j<d;j++){
            scanf("%d",&b[j]);
            a[b[j]-1]++;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]==0){
            cnt++;
        }
    }
    
    printf("%d",cnt);
    
}

Measured memory_bytes: 1736
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = 5;
        int[] positions = new int[n];
        for (int i = 0; i < n; i++) {
            positions[i] = sc.nextInt();
        }
        
        int border = sc.nextInt();
        boolean pass = true;
        
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                int difference = positions[j] - positions[i];
                if (difference > border) {
                    pass = false;
                    break;
                }
            }
        }
        
        if (pass) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a<c && c<b) cout<<"Yes"<<endl;
  else if(b<c && c<a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a * (1 + a * (1 + a)) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    #define int long long
    int H,W;
    cin>>H>>W;
    int ch,cw,dh,dw;
    cin>>ch>>cw>>dh>>dw;
    vector<string> vec(H);
    vector<vector<int>> tree(H*W,vector<int>(0));
    for(int i=0;i<H;i++){
        cin>>vec.at(i);
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int k=i-2;k<=i+2;k++){
                for(int l=j-2;l<=j+2;l++){
                    if(k>=0 && k<H && l>=0 && l<W){
                        if(vec.at(k).at(l)=='.'){
                            tree.at(i*W+j).push_back(k*W+l);
                        }
                    }
                }
            }
        }
    }
    //H×Wのグリッドグラフのダイクストラ
    vector<int> dist(H*W,-1);
    vector<int> determined(H*W,0);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
    que.push(make_pair(0,(ch-1)*W+cw-1));//距離,座標
    dist.at((ch-1)*W+cw-1)=0;
    while(!que.empty()){
        int v=que.top().second;//que.top().firstとdist.at(v)は同値
        que.pop();
        if(determined.at(v)==1){continue;}
        determined.at(v)=1;
        for(int i=0;i<(int)tree.at(v).size();i++){
            int nv=tree.at(v).at(i);
            if(determined.at(nv)==1){continue;}
            int dist_to_v=dist.at(v);
            if(nv-v!=1 && nv-v!=-1 && nv-v!=W && nv-v!=-W){dist_to_v++;}
            if(dist.at(nv)!=-1 && dist_to_v>=dist.at(nv)){continue;}
            dist.at(nv)=dist_to_v;
            que.push(make_pair(dist_to_v,nv));
        }
    }
    cout<<dist.at((dh-1)*W+dw-1)<<endl;
}

Measured memory_bytes: 188196
#include<iostream>
#include<cmath>
using namespace std;
int c[2]={0,1};
 
int main()
{
	int n,i=0,k,t;
	int s[3000]={0};
	cin>>n;
	if(n==0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	while(n!=0)
	{
		k=n%(-2);
		t=n/(-2);
		if(k<0)
		{
			k=k-(-2);
			t++;
		}	
		i++;
		n=t;
		s[i]=c[k];	
	}
	for(;i>=1;i--)
		cout<<s[i]; 
	return 0; 
}

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

#入力
A, B = map(int, input().split())

if A == B :
  print ("Draw")
else :
  if A == 1 :
    print ("Alice")
  elif B == 1 :
    print ("Bob")
  elif A > B :
    print ("Alice")
  elif A < B :
    print ("Bob")


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    return modExp(base, MOD-2);
}

ll mul(ll A, ll B) {
    return (A*B)%MOD;
}

ll add(ll A, ll B) {
    return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}

ll* facs = new ll[MAX_N];
ll* facInvs = new ll[MAX_N];

ll choose(ll a, ll b) {
    if (b > a) return 0;
    if (a < 0) return 0;
    if (b < 0) return 0;
    ll cur = facs[a];
    cur = mul(cur, facInvs[b]);
    cur = mul(cur, facInvs[a-b]);
    return cur;
}

void initFacs() {
    facs[0] = 1;
    facInvs[0] = 1;
    for (int i=1; i<MAX_N; i++) {
        facs[i] = (facs[i-1] * i) % MOD;
        facInvs[i] = inv(facs[i]);
    }
}

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

    ll n, a, b;
    cin >> n >> a >> b;

    initFacs();
    ll ans = modExp(2, n);
    ans = sub(ans, 1LL);

    ll x = 1LL;
    ll y = 1LL;

    for (ll i = n-a+1; i <= n; i++) {
        x = mul(x, i);
    }
    for (ll i = n-b+1; i <= n; i++) {
        y = mul(y, i);
    }

    //cout << facInvs[a] << " " << facInvs[b] << " ";
    //cout << "D: " << ans << " " << x << " " << y << "\n";

    x = mul(x, facInvs[a]);
    y = mul(y, facInvs[b]);

    //cout << "D: " << x << " " << y << "\n";

    ans = sub(ans, x);
    ans = sub(ans, y);

    cout << ans;







    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
	string n;
	cin>>n;
	
	if (n[0] == n[1] && n[0] == n[2] ) cout<< "Yes"<<"\n";
	else if (n[3] == n[2] && n[3] == n[1] ) cout<< "Yes"<<"\n";
	else cout<< "No"<<"\n";
	
	


return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b)
	{
		printf("a > b\n");
	}
	else if(a<b)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}



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

int main() {
    int N, M, k, p[10], a, ans = 0;
    cin >> N >> M;
    vector<int> s[M];
    rep(i, M) {
        cin >> k;
        rep(j, k) {
            cin >> a;
            s[i].push_back(a-1);
        }
    }
    rep(i, M) cin >> p[i];

    rep(i, (1 << N)) {
        bool ok = true;
        rep(j, M) {
            int cnt = 0;
            for (int id : s[j]) {
                if (i & (1 << id)) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[j]) ok = false;
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256