akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e7 + 100;
const int mod = (int)998244353;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

int f[maxn], inv[maxn], pw[maxn], ans;
int n, s;

int binpow(int a, int b){
	int res = 1;
	while(b){
		if(b & 1)
			res = (res * 1ll * a) % mod;
		b >>= 1;
		a = (a * 1ll * a) % mod;
	}
	return res;
}
int C(int n, int k) {
  if (k > n || k < 0) return 0;
  int res = f[n];
  res = res * 1ll * inv[k] % mod;
  res = res * 1ll * inv[n - k] % mod;
  return res;
}
main () {
	f[0] = pw[0] = 1;
  forn(i, 1, maxn - 1)
	f[i] = f[i - 1] * 1ll * i % mod, pw[i] = pw[i - 1] * 2ll % mod;
    inv[maxn - 1] = binpow(f[maxn - 1], mod - 2);
	forev(i, maxn - 1, 1)
  	inv[i - 1] = inv[i] * 1ll * i % mod;
	cin >> n;
	forn(a, n / 2 + 1, n){
		ans = (ans + C(n, a) * 1ll * pw[n - a] % mod) % mod;
	}	
	ans = (ans + ans) % mod;
	cout << (binpow(3, n) - ans + mod) % mod;
}

Measured memory_bytes: 117376
n = int(input())
c = list(input())
r = 0
w = 0
for i in range(len(c)):
    if(c[i]=="R"):
        r += 1
ans = max(r,w)
for i in range(len(c)):
    if(c[i]=="R"):
        r -= 1
    else:
        w += 1
    now = max(r,w)
    ans = min(ans,now)
print(ans)    

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if(a < b) {
    if(b < c) {
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }
  }else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n, yin;
  cin >> n >> yin;
  yin /= 1000;
  for(int x = 0; x <= yin/10 + 1; ++x)
  {
    for(int y = 0; y <= yin/5 + 1; ++y)
    {
      int z = n - x - y;
      if (z < 0) continue;
      if (10 * x + 5 * y + z == yin)
      {
        cout << x << " " << y << " " << z;
        return;
      }
    }
  }
  cout << "-1 -1 -1";
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int n,m=0,k,aim,a[101000],b[101000];
ll ans,an;

int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	ans=0;
	for (int t=k;t;t>>=1) m++;
	for (int i=-1;i<m;i++){
		if (i==-1?1:(k&(1<<i))){
			aim=0;
			for (int j=0;j<i;j++){
				aim|=(1<<j);
			}
			for (int j=i+1;j<m;j++){
				aim|=(1<<j)&k;
			}
			an=0;
			for (int j=1;j<=n;j++){
				if ((a[j]|aim)==aim){
					an+=b[j];
				}
			}
			ans=max(ans,an);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1024
import math
N = int(input())
a = list(map(int, input().split()))

b = [0]*N
ans = []
for i in range(N, 0, -1):
  if b[i-1] % 2 != a[i-1]:
    ans += [i]
    if i == 1:
      b[i-1] += 1
      b[i-1] %= 2
      continue
    for j in range(1, math.floor(math.sqrt(i))+1):
      if i % j == 0:
        b[j-1] += 1
        b[j-1] %= 2
        if i//j != j and i//j-1 <= N-1:
          b[i//j-1] += 1
          b[i//j-1] %= 2

print(len(ans))
ans = list(map(str, ans))
print(" ".join(ans))

Measured memory_bytes: 78832
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(long long i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll t,n;
int main(){
	cin>>n;
//	rept(i,1,5000){
//		if(i*i*i*i*i>=1e18){
//			cout<<i<<endl;
//			return 0;
//		}
//	}
	rept(i,-3981,3981){
		rept(j,-3981,3981){
			if(1ll*i*i*i*i*i-1ll*j*j*j*j*j==n){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

const ll N=2e5+10;
vec check(N,-1);
vector<set<ll>> E(N);

void dfs(ll f, ll id) {
  check[f]=id;
  for(ll t:E[f]) {
    if(check[t]>-1) continue;
    dfs(t,1-id);
  }
}
 
int main() {
  ll n;
  cin >> n;
  for(ll i=0;i<n-1;i++) {
    ll a,b;
    cin >> a >> b;
    a--,b--;
    E[a].insert(b);
    E[b].insert(a);
  }
  dfs(0,0);
  ll cnt=0;
  for(ll i=0;i<n;i++) {
    cnt+=check[i];
  }
  vec ans(n);
  if(cnt<=n/3) {
    ll t3=3;
    ll t=1;
    ll f=0;
    for(ll i=0;i<n;i++) {
      if(check[i]) {
        ans[i]=t3;
        t3+=3;
      }
      else {
        ans[i]=t;
        if(f)t-=3;
        else t++;
        if(!f&&t%3==0) t++;
        if(t>n) {
          t=n/3*3;
          f=1;
        }
      }
    }
  }
  else if(n-cnt<=n/3) {
    ll t3=3;
    ll t=1;
    ll f=0;
    for(ll i=0;i<n;i++) {
      if(!check[i]) {
        ans[i]=t3;
        t3+=3;
      }
      else {
        ans[i]=t;
        if(f)t-=3;
        else t++;
        if(!f&&t%3==0) t++;
        if(t>n) {
          t=n/3*3;
          f=1;
        }
        
      }
    }
  }
  else {
    ll t1=1;
    ll t2=2;
    ll t3=3;
    for(ll i=0;i<n;i++) {
      if(check[i]) {
        if(t1<=n) {
          ans[i]=t1;
          t1+=3;
        }
        else {
          ans[i]=t3;
          t3+=3;
        }
      }
      else {
        if(t2<=n) {
          ans[i]=t2;
          t2+=3;
        }
        else {
          ans[i]=t3;
          t3+=3;
        }
      }
    }
  }
  for(ll i=0;i<n;i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 34816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;

int main(){
    int n,m;
    cin >> n;
    map<string,int> x,y;
    rep(i,n){
        string t;
        cin >> t;
        x[t]++;
    }
    cin >> m;
    rep(i,m){
        string t;
        cin >> t;
        y[t]++;
    }
    int ans = 0;
    for (auto r:x){
        if (y.count(r.first)){
            ans = max(ans,r.second-y[r.first]);
        }
        else ans = max(ans,r.second);
    }
    cout << ans << endl;
    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 a = sc.nextInt();
			int b = sc.nextInt();
			
	 StringBuilder A = new StringBuilder();
	 StringBuilder B = new StringBuilder();
	 
	 for(int i=0; i<b; i++) {
		   A.append(a);
	 }
	 for(int i=0; i<a; i++) {
		   B.append(b);
	 }
	 if(a<b) {
		 System.out.println(A);
	 }else {
		 System.out.println(B);
	 }
			
		}
}

Measured memory_bytes: 21844
a,b = gets.chomp.split(" ").map(&:to_i)

def GCD(m, n)
	return 0 if m == 0 || n == 0
	while m != 0 && n != 0
		if m > n then
			m %= n
		else
			n %= m
		end
	end
	return [m, n].max
end

def LCM(m, n)
	return 0 if m == 0 || n == 0
	return m * n / GCD(m, n)
end

puts LCM(a,b)




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

Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.parents = [-1 for _ in range(n)]  # 各要素の親 自分が根の場合は -1 * (木の要素数)

    def root(self, x):  # xが属する木の根を返す
        if self.parents[x] < 0:  # 自分が根の場合
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def merge(self, x, y):  # xが属する木とyが属する木を合体する
        x_root = self.root(x)  # xの根
        y_root = self.root(y)  # yの根

        if x_root == y_root:  # 同じ木に属する
            return

        if abs(self.parents[x_root]) >= abs(self.parents[y_root]):  # 要素数の比較
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def size(self, x):  # xが属する木の要素数
        return -self.parents[self.root(x)]

    def same(self, x, y):  # xとyが同じ木に属するか判定
        return self.root(x) == self.root(y)

    def roots(self):  # すべての根を求める
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # 木が何個あるか
        return len(self.roots())


def main():
    n, k, l = map(int, input().split())

    uf_road = UnionFind(n)
    uf_train = UnionFind(n)

    for _ in range(k):
        p, q = map(int, input().split())
        uf_road.merge(p - 1, q - 1)

    for _ in range(l):
        r, s = map(int, input().split())
        uf_train.merge(r - 1, s - 1)

    count_dict = dict()
    for i in range(n):
        p = (uf_road.root(i), uf_train.root(i))
        if p in count_dict:
            count_dict[p] += 1
        else:
            count_dict[p] = 1

    for i in range(n):
        print(count_dict[(uf_road.root(i), uf_train.root(i))], end=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 123236
N = int(input())
A,B=map(int,input().split())
P_s = list(map(int,input().split()))
CNT_s = [0]*3
for P in P_s:
    if P <= A:
        CNT_s[0] += 1
    elif A <  P <= B:
        CNT_s[1] += 1
    if B <  P:
        CNT_s[2] += 1
print(min(CNT_s))

Measured memory_bytes: 62004
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// 最大公約数
ll GCD(ll a, ll b)
{
    if (a < 0)
        a = -a;
    if (b < 0)
        b = -b;
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

// 最小公倍数
ll LCM(ll a, ll b)
{
    ll g = GCD(a, b);
    return a / g * b;
}

int main()
{
    string in;
    cin >> in;
    string ret = in.substr(0, 4) + " " + in.substr(4);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
d = int(input())
c = list(map(int,input().split()))
cmax = max(c)
for al in range(26):
  if c[al] == cmax:
    maxc = al
up = []
for _ in range(d):
  up.append(list(map(int,input().split())))
ans = [[-1] for _ in range(26)]
for i in range(d):
  ans[maxc].append(i)
task = [maxc for i in range(d)]
#print(task)
#ans[0].append(0)
#ans[16].append(1)
#ans[12].append(2)
#ans[13].append(3)
#ans[12].append(4)

for al in range(26):
  ans[al].append(d)
#print(ans)
import bisect
from random import random
from random import randrange
import math
scr = 0
for al in range(26):
  now = ans[al]
  l = len(now)
  for j in range(1,l):
    scr -= c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2
    #print(c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2)
  for j in range(1,l-1):
    scr += up[now[j]][al]
    #print(up[now[j]][al])
  #print('$')
#print(scr)
est = 20000
for _ in range(222):
  for _ in range(5000):
    day = randrange(d)
    pre = task[day]
    pst = randrange(26)
    if pre == pst:
      continue
    bpre = bisect.bisect_left(ans[pre],day)
    bpst = bisect.bisect_left(ans[pst],day)
    bpre1 = ans[pre][bpre-1]
    bpre2 = ans[pre][bpre+1]
    bpst1 = ans[pst][bpst-1]
    bpst2 = ans[pst][bpst]
    #print(day,ans[pre][bpre],ans[pst][bpst])
    #print(day)
    #print(bpre1,day,bpre2,'#',pre)
    #print(bpst1,day,bpst2,'#',pst)
    tmp = 0
    tmp -= c[pre] * (day-bpre1) * (bpre2-day)
    #print(c[pre] * (day-bpre1) * (bpre2-day))
    tmp += c[pst] * (day-bpst1) * (bpst2-day)
    #print(c[pst] * (day-bpst1) * (bpst2-day))
    tmp -= up[day][pre]
    #print(up[day][pre])
    tmp += up[day][pst]
    #print(up[day][pst])
    #print(tmp)
    r = random()
    if est > 0:
      exp = math.exp(tmp/est)
    else:
      exp = bool(tmp>0)
    if exp > r:
      #print(ans[pre])
      #print(ans[pst])
      ans[pre].remove(day)
      bisect.insort(ans[pst],day)
      #print(ans[pre])
      #print(ans[pst])
      task[day] = pst
      scr += tmp
      #print(scr)
    #print('%')
  est -= 100
#for x in ans:
  #print(x)
for x in task:
  print(x+1)
#print(scr)

Measured memory_bytes: 94244
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 100005
#define LL long long
int n,a[MAXN];
int main()
{
	LL ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		ans+=a[i]/2;
		a[i]%=2;
		if(a[i]==1&&a[i+1]>0) a[i]=0,ans++,a[i+1]--;//尽量把单个的牌放在后面
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 512
use std::process;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn ord(c: char) -> i64 {
    i64::from((c as u8) - b'a')
}

fn no() -> ! {
    println!("No");
    process::exit(0);
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let s = sc.chars();
    let t = sc.chars();
    let n = s.len();

    let mut fw = [None; 26];
    let mut bk = [None; 26];
    for i in 0..n {
        let x = ord(s[i]);
        let y = ord(t[i]);
        if let Some(fwx) = fw[x as usize] {
            if fwx != y { no(); }
        }
        if let Some(bky) = bk[y as usize] {
            if bky != x { no(); }
        }
        fw[x as usize] = Some(y);
        bk[y as usize] = Some(x);
    }

    println!("Yes");
}


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

using namespace std;

int main() {
  
  int t;
  int n;
  string data;

  bool shelf[21000];

  int count;
  int left, right;

  cin >> t;

  for(int i = 0;i < t;i++) {

    cin >> n;
    cin >> data;

    for(int i = 0;i < (int)(sizeof(shelf) / sizeof(shelf[0]));i++) {

      shelf[i] = false;

    }

    count = 0;
    left = 0;
    right = 0;

    if(data[0] == 'Y') shelf[0] = true;

    for(int j = 1;j <= n-1;j++) {

      if(data[2*j-1] == 'Y' || data[2*j] == 'Y') shelf[j] = true;

    }

    if(data[2*n-1] == 'Y') shelf[n] = true;
    if(data[2*n] == 'Y') shelf[n+1] = true;

    for(int j = n+2;j <= 2*n;j++) {

      if(data[2*j-3] == 'Y' || data[2*j-2] == 'Y') shelf[j] = true;

    }

    if(data[4*n-1] == 'Y') shelf[2*n+1] = true;

    // for(int j = 0;j <= 2*n+1;j++) cout << shelf[j] << endl;

    for(int j = 0;j <= 2*n+1;j++) {

      if(shelf[j] == true) count++;

    }

    for(int j = 0;j <= n;j++) {

      if(shelf[j] == false && shelf[j+n+1] == false) continue;

      else {

	if(shelf[j] == true) {

	  left = 1;

	}

	else break;

      }

    }

    for(int j = n;j >= 0;j--) {

      if(shelf[j] == false && shelf[j+n+1] == false) continue;

      else {

	if(shelf[j] == true) {

	  right = 1;

	}

	else break;

      }

    }

    // cout << count << endl;
    // cout << left << endl;
    // cout << right << endl;
    cout << n + count + 2 - left - right << endl;

  }

  return 0;

}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int w, h, x, y = 0;
	cin >> w >> h >> x >> y;
	double ans = (double(w) * double(h)) / 2;
	int num = (x + x == w && y + y == h) ? 1 : 0;
	cout << ans << " " << num << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int a[100010],n;

int main() {
    //freopen("test.in");
    cin >> n;
    int mx = -1;
    int mn = 10000;
    for (int i=1;i<=n;i++) {
        cin >> a[i];
        mx = max(mx,a[i]);
        mn = min(mn,a[i]);
    }
    cout << mx-mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n;
	cin >> n;
	int a[n];
	long long Sum1[n], Sum2[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		Sum1[i] = Sum2[i] = a[i];
		if (i) {
			Sum1[i] = Sum1[i - 1] + Sum1[i];
			Sum2[i] = Sum1[i];
		}
	}
	long long sum1 = 0; //偶数番目が-
	long long sum2 = 0; //偶数番目が+
	long long tmp1 = 0, tmp2 = 0;
	for (int i = 0; i < n; i++) {
		Sum1[i] += tmp1;
		Sum2[i] += tmp2;
		if (i % 2 == 0) {
			if (Sum1[i] >= 0) {
				sum1 += 1 + Sum1[i];
				tmp1 += -1 - Sum1[i];
			}
			if (Sum2[i] <= 0) {
				sum2 += 1 + (-1 * Sum2[i]);
				tmp2 += 1 - Sum2[i];
			}

		} else {
			if (Sum1[i] <= 0) {
				sum1 += 1 + (-1 * Sum1[i]);
				tmp1 += 1 - Sum1[i];
			}
			if (Sum2[i] >= 0) {
				sum2 += 1 + Sum2[i];
				tmp2 += -1 - Sum2[i];
			}

		}
	}
	cout << min(sum1, sum2) << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int H_given;
	int N_given;

	cin >> H_given >> N_given;
	int Ai_given[N_given+1],Bi_given[N_given+1];
	rep(i,N_given){
		cin >> Ai_given[i+1] >> Bi_given[i+1];
	}


	ll dp[H_given+20000][N_given+1];
	rep(i,N_given+1){
		rep(j,H_given+20000){
			dp[j][i] = INF;
		}
		dp[0][i] = 0;
	}

	rep(i,N_given+1){
		if(i == 0){
			continue;
		}
		rep(j,H_given+20000){

			dp[j][i] = min(dp[j][i-1],(j - Ai_given[i] >= 0)?dp[j - Ai_given[i]][i]+Bi_given[i]:INF);
		}
	}

	ll ans = INF;
	for(int i = H_given;i < H_given+20000;i++){
		chmin(ans,dp[i][N_given]);
	}
	cout << ans << endl;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c % __gcd(a, b) == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

vector<ll> cache(100, -1);

ll lucas(int n) {
  if (n==0) return 2;
  if (n==1) return 1;
  ll &cc = cache[n];
  if (~cc) return cc;
  return cc = lucas(n-2)+lucas(n-1);
}

void solve() {
  int n;
  cin >> n;
  cout << lucas(n) << endl;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll a , b;

ll gcd(ll a , ll b){
    while(a > 0 && b > 0){
        if(a > b)   a %= b;
        else    b %= a;
    }
    return a + b;
}

ll lcm(ll a , ll b){
    return (a * b) / (gcd(a , b));
}

int main()
{
    _FastIO;
    cin >> a >> b;
    cout << lcm(a , b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}

template <class T>
inline void show(T a) {
    cout << a << endl;
}

//------------------------main function-------------------------------
void Main(){
    int r; cin >> r;
    cout << r*r << endl;
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,tmp;
  cin >> N;
  priority_queue <int> S;
  for(int i=0;i<N;i++){
    cin >> tmp;
    S.push(tmp);
  }
  int A,B,sum;
  A=0;
  B=0;
  sum=0;
  
  for(int i=0;i<N;i++){
    if(i%2==0){
      tmp = S.top();
      A += tmp;
      S.pop();
    }else{
      tmp = S.top();
      B += tmp;
      S.pop();
    }
  }
    sum = A - B;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
struct edge {
    int to;
    double cost;
};
const int MAX_N = 10005;
int N, M;
int X[MAX_N], Y[MAX_N];
double d[MAX_N];
bool used[MAX_N];
vector<edge> G[MAX_N];

//2点間の距離を返す
double dist(int a, int b) {
    unsigned int num = (X[a]-X[b]) * (X[a]-X[b]) + (Y[a]-Y[b])*(Y[a]-Y[b]);
    double ret = sqrt(num);
    return ret;
}

int main(int argc, const char * argv[])
{
    scanf("%d %d", &N, &M);
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &X[i], &Y[i]);
    }
    double ret = 0;
    for (int i = 0; i < M; i++) {
        int a,b;
        scanf("%d %d", &a, &b);
        a--; b--;
        double d = dist(a, b);
        //printf("%d-%d:%f\n",a,b,d);
        ret += d;
        edge e1, e2;
        e1.to = b;
        e2.to = a;
        e1.cost = e2.cost = -d;  //負にすることで最大全域木を計算
        G[a].push_back(e1);
        G[b].push_back(e2);
    }
    for (int i = 0; i < N; i++) d[i] = 0;
    fill(used, used+N, false);
    //プリム法
    while (true) {
        int v = -1;
        for (int i = 0; i < N; i++) {
            if (!used[i] && (v == -1 || d[v] > d[i])) v = i;
        }
        if (v == -1) break;
        //頂点vを集合xに加える
        used[v] = true;
        ret += v[d];
        //集合xまでの最短距離を更新
        for (int i = 0; i < (int)G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > e.cost) {
                d[e.to] = e.cost;
            }
        }
    }
    printf("%.3f\n", ret);
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
     
        using namespace std;
        #define sd(x) scanf("%d",&x);
        #define sdl(x) scanf("%lld",&x);
        #define pr(x) printf("%d\n",x);
        #define prl(x) printf("%lld\n",x);

    void solve()
    {
        int s,w;
        cin >> s >> w;
        if (w>=s)
            cout << "unsafe" << endl;
        else cout << "safe" << endl;
        
            
        
    }

    int main ()
    {
      
     int t;
     //cin >> t;
     t=1;

     for (int tt=1;tt<=t;tt++)
     {
         solve();
     }

    return 0;
     
     
     
     
        }


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
 
int ans = 0;
char m[100][100] = { 0 };
bool sirusi[100][100] = { 0 };
 
void kukaku(int h, int w, int y, int x, char c, int cnt)
{
    if (y < 0 || y >= h || x < 0 || x >= w || sirusi[y][x] || m[y][x] != c) {
        return;
    }
 
    if (cnt == 0) {
        ++ans;
    }
 
    sirusi[y][x] = true;
 
    kukaku(h, w, y + 1, x, c, cnt + 1);
    kukaku(h, w, y - 1, x, c, cnt + 1);
    kukaku(h, w, y, x + 1, c, cnt + 1);
    kukaku(h, w, y, x - 1, c, cnt + 1);
}
 
int main(void)
{
    int h, w;
    while (1) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        ans = 0;

        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
            	m[i][j] = '\0';
            	sirusi[i][j] = false;
            }
        }

        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> m[i][j];
            }
        }
 
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                kukaku(h, w, i, j, m[i][j], 0);
            }
        }
 
        cout << ans << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> as;
map<P, ll> number;
ll rmemo[101][300001];
ll memo[101][300001];
int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> as(n);
    memo[n][k] = 1;
    REP(i, n) { cin >> as[i]; }
    for (int i = n - 1; i >= 0; i--) {
        REP(j, 200001) { rmemo[i + 1][j + 1] = (memo[i + 1][j] + rmemo[i + 1][j]) % mod; }
        REP(j, k + 1) {
            memo[i][j] = (rmemo[i + 1][j + as[i] + 1] - rmemo[i + 1][j]) % mod;
            // cout << memo[i][j] << endl;
        }
    }
    cout << (memo[0][0] + mod) % mod << endl;
}

Measured memory_bytes: 238708
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using i64 = long long;
using f64 = double;
using pll = pair<i64, i64>;
using pii = pair<int, int>;
using ptx = pair<f64, f64>;

i64 mp[256];

int main() {
#ifdef HOME
    freopen("agc019b.in", "r", stdin);
    freopen("agc019b.out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string str;
    cin >> str;
    for (auto i: str)
        mp[i]+= 1;

    i64 ans = str.size() * (str.size() - 1) / 2;
    for (char ch = 'a'; ch <= 'z'; ++ch)
        ans-= mp[ch] * (mp[ch] - 1) / 2;

    cout << 1 + ans << endl;

    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
const ll mod = 1000000007;


int main(){
  ll n,a,b;
  scanf("%lld%lld%lld",&n,&a,&b);

  vector<ll> h(n);
  r(i,n)scanf("%lld", &h.at(i));


  ll left=0,right=0;

  r(i,n){
    right=max(right,h.at(i));
  }

  while(left < right){
    ll mid= left+(right - left)/2;

    ll cnt=0;
    r(i,n){
      if(h.at(i) - mid* b>0){
        cnt+=(h[i]-mid*b+a-b-1)/(a-b);
      }
    }

    if(cnt <= mid and right == mid){
      break;
    }else if(cnt <= mid){
      right = mid;
    }else{
      left = mid + 1;
    }
  }

  printf("%lld\n", left);

  return 0;
}


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


int main(){

	while(true){
		int n;
		cin>>n;
		if(n==0)
			break;

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

		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){		
				int d=abs(a[i]-a[j]);
				if(d<dif){	
					dif=d;		
				}
			}		
		}
		cout<<dif<<endl;
	}
	return 0;

}

Measured memory_bytes: 3080
N, W = map(int, input().split())

dp = [[float("inf")] * (N * 10 ** 3 + 1) for _ in range(2)]
dp[0][0], dp[1][0] = 0, 0
for i in range(N):
    index = i % 2
    w, v = map(int, input().split())
    for j in range(1, len(dp[0])):
        if j <= v:
            dp[index][j] = min(w, dp[index-1][j])
        else:
            dp[index][j] = min(w + dp[index-1][j-v], dp[index-1][j])

ans = 0
for i, w in enumerate(dp[N % 2 - 1]):
    if w <= W:
        ans = max(ans, i)
    else:
        break

print(ans)


Measured memory_bytes: 132668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>

using i64 = std::int64_t;

int main() {
	i64 n, m, v, p;
	std::cin >> n >> m >> v >> p;

	std::vector<i64> s(n);
	for (auto&& e : s)
		std::cin >> e;

	std::sort(s.begin(), s.end());

	std::vector<i64> sum(n);
	sum[0] = s[0];
	for (int i = 1; i < n; ++i)
		sum[i] = sum[i - 1] + s[i];

	auto getSum = [&sum](int l, int r) -> i64 {
		if (l > r)
			return 0;

		return sum[r] - sum[l - 1];
	};

	auto check = [&](int x) {
		if (x == n - 1 || n - x <= p)
			return true;

		const i64 g = s.end() - std::upper_bound(s.begin() + x, s.end(), s[x] + m);
		if (g >= p)
			return false;

		i64 a = v - (p - 1) - (x + 1);
		if (a <= 0)
			return true;

		i64 w = n - (x + 1) - (p - 1);
		return a * m <= (s[x] + m) * w - getSum(x + 1, x + w);
	};

	int l = -1, r = n;
	while (std::abs(r - l) > 1) {
		int mid = (l + r) / 2;

		if (check(mid))
			r = mid;
		else
			l = mid;
	}

	std::cout << n - r << std::endl;
}

Measured memory_bytes: 1920
// D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
    long long n;

    cin >> n;

    cout << (n - 1) * n / 2 << endl;
}



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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b;
    while(cin>>a && cin>>b){
        if(a==0 && b==0) break;
        for(int i=0; i<b; i++) cout<<"#";
        cout<<endl;
        for(int i=0; i<a-2; i++){
            cout<<"#";
            for(int j=0; j<b-2; j++) cout<<".";
            cout<<"#"<<endl;
        }
        for(int i=0; i<b; i++) cout<<"#";
        cout<<endl;
        cout<<endl;
    }
    
    
}


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


void solve(long long N, std::vector<long long> A){
    map<long long, long long> mp;
    for(int i = 0; i < N; ++i) mp[A[i]] += 1;
    long long res = 0;
    for(auto itr : mp) res += itr.second * (itr.second - 1) / 2;
    for(int i = 0; i < N; ++i){
        long long n = mp[A[i]];
        long long before = n * (n-1)/2;
        long long after = (n-1) * (n-2)/2;
        cout << res - before + after << endl;
    }
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 12752
cnt = 0

def dfs(v, n, used, linked_list):
    global cnt
    if len(used) == n:
        cnt += 1
        return
    else:
        for next_v in linked_list[v]:
            if next_v not in used:
                used.append(next_v)
                dfs(next_v, n, used, linked_list)
                used.remove(next_v)
        return

def main():
    global cnt
    n, m = map(int, input().split())
    linked_list = [[] for _ in range(n+1)]
    for i in range(m):
        a, b = map(int, input().split())
        linked_list[a].append(b)
        linked_list[b].append(a)
    used = [1]
    dfs(1, n, used, linked_list)
    print(cnt)

if __name__ == '__main__':
    main()
    


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

 int main(){
    int n;cin>>n;
    map<string,int> m;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        m[s]++;
    }
    int mm=0;
    for(auto it=m.begin();it!=m.end();it++)mm=max(mm,it->second);
    vector<string> v;
    for(auto it=m.begin();it!=m.end();it++){
        if(it->second==mm){
            v.push_back(it->first);
        }
    }
    sort(v.begin(),v.end());
    for(string x:v)cout<<x<<endl;
 }

Measured memory_bytes: 26868
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ans = true;
    if(s.size() !=(a+b+1)){
        ans = false;
    }
    for(int i=0;i<s.size();i++){
        if(i<a || a<i){
            if(s[i]<'0'||s[i]>'9'){
                ans = false;
            }
        }
        else if(i == a){
            if(s[i] != '-'){
                ans = false;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;

    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    vec A(3);
    cin >> A[0] >> A[1] >> A[2];
    ASC(A);

    ll b = (A[2]-A[0])/2;
    ll c = (A[2]-A[1])/2;
    A[0] += b*2;
    A[1] += c*2;
    ASC(A);
    A[1] -= A[0];
    A[2] -= A[0];
    A[0] = 0;
    ll ans = b + c;
    if(A[0]%2+A[1]%2+A[2]%2 == 1) ans += 1;
    else if(A[0]%2+A[1]%2+A[2]%2 == 2) ans += 2;
    PR(ans);

    return 0;
}

/*



*/

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

using namespace std;

const int dx4[] = {1, 0, -1, 0};
const int dy4[] = {0, 1, 0, -1};

const int INF = 100000;
int H, W;
char g[25][25];
int vis[25][25];
int ans = 0;

void bfs(int x, int y) {
    if (g[x][y] == '#') return;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            vis[i][j] = INF;
        }
    }
    vis[x][y] = 0;

    queue<pair<int, int> > q;
    q.push({x, y});
    while (!q.empty()) {
        pair<int, int> curr = q.front();
        q.pop();
        for (int i = 0; i < 4; ++i) {
            auto nx = curr.first + dx4[i];
            auto ny = curr.second + dy4[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W || g[nx][ny] == '#') continue;
            if (vis[nx][ny] > vis[curr.first][curr.second] + 1) {
                vis[nx][ny] = vis[curr.first][curr.second] + 1;
                q.push({nx, ny});
                ans = max(ans, vis[nx][ny]);
            }
        }
    }
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> g[i][j];
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            bfs(i, j);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<bool> flg(n,false);
	for(int i=0;i<k;i++)
	{
		int d;
		cin >> d;
		for(int j=0;j<d;j++)
		{
			int a;
			cin >> a;
			a--;
			flg[a]=true;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++)
		if(!flg[i])cnt++;
	cout << cnt << endl;




}


Measured memory_bytes: 3164
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	int N;
	in >> N;
	std::vector<std::vector<std::vector<LL>>>F(N, std::vector<std::vector<LL>>(5, std::vector<LL>(2)));
	rep(i, N) rep(j, 5) rep(k, 2) in >> F[i][j][k];
	std::vector<std::vector<LL>>P(N, std::vector<LL>(11));
	rep(i, N) rep(j, 11) in >> P[i][j];

	LL ans = -1145148101919364364;
	rep(bit, (1LL << 10LL))
	{
		if (bit == 0) continue;
		std::vector<LL>cnt(N);
		rep(i, 10)
		{
			if (bit&(1LL << i))
			{
				rep(j, N)
				{
					if (F[j][i / 2][i % 2] == 1) ++cnt[j];
				}
			}
		}

		LL res = 0;
		rep(i, N) res += P[i][cnt[i]];
		ans = std::max(ans, res);
	}

	out << ans << std::endl;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n;
    cin >> n;

    ll x = 0;
    rep(i,0,n) {
        ll y;
        cin >> y;
        x += y - 1;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K,x;
  cin>>N>>K;
  x=1;
  for(int i=0;i<N;i++){
    if(x < K)
      x*=2;
    else
      x+=K;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  ll x,i=0;
  cin>>x;
  ll y=x/11;
  if(x-y*11==0){cout<<2*y<<endl;}
  else if(x-y*11<=6)cout<<2*y+1<<endl;
  else cout<<2*y+2<<endl;





  return 0;
}


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

int main(void){
  char temp, str[1001], re[1001], p[101];
  int i, j, a, b, q;

  scanf("%s", str);
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf(" %s%d%d", p, &a, &b);
    if(strcmp(p, "print") == 0){
      for(j = a; j <= b; j++){
	printf("%c", str[j]);
      }
      printf("\n");
    }else if(strcmp(p, "reverse") == 0){
      for(j = 0; a+j < b-j; j++){
	temp = str[a+j];
	str[a+j] = str[b-j];
	str[b-j] = temp;
      }
    }else if(strcmp(p, "replace") == 0){
      scanf(" %s", re);
      for(j = 0; a+j <= b; j++){
	str[a+j] = re[j];
      }
    }
  }
  return 0;
}

Measured memory_bytes: 572
n = int(input())
list_ta = []
for i in range(n):
    list_ta.append(list(map(int, input().split())))

ans_t = list_ta[0][0]
ans_a = list_ta[0][1]
for i in range(1,n):
    if ans_t % list_ta[i][0] != 0:
        ans_t = list_ta[i][0] * (ans_t // list_ta[i][0] + 1)
    if ans_a % list_ta[i][1] != 0:
        ans_a = list_ta[i][1] * (ans_a // list_ta[i][1] + 1)
    if ans_t * list_ta[i][1] // list_ta[i][0] >= ans_a:
        ans_a = ans_t * list_ta[i][1] // list_ta[i][0]
    else:
        ans_t = ans_a * list_ta[i][0] // list_ta[i][1]

print(ans_a + ans_t)


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

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			var arr_input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var r = arr_input[0]; var c = arr_input[1];
			//var sum_of_sum_c = 0;
			var arr_sum_c = new int[c + 1];
			for (int i = 0; i < r; i++)
			{
				List<int> arr_row = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
				var sum_c = arr_row.Sum();
				//sum_of_sum_c += sum_c;
				arr_row.Add(sum_c);
				Console.WriteLine(string.Join(" ", arr_row));
				arr_row.Select((value, index) => new { index, value }).ToList().ForEach(ci =>
				{
					arr_sum_c[ci.index] += ci.value;
				});
			}
			Console.WriteLine(string.Join(" ", arr_sum_c));
		}
	}
}



Measured memory_bytes: 18416
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		int[] k = new int[M];
		int[,] s = new int[M, 10];
		for(int i = 0; i < M; i++)
		{
			k[i] = GetInt();
			for(int j = 0; j < k[i]; j++)
				s[i,j] = GetInt() - 1;
		}
		int[] p = new int[M];
		for(int i = 0; i < M; i++)
			p[i] = GetInt();

		int ans = 0;
		for(int mask = 0; mask < (1 << N); mask++)
		{
			bool isCorrect = true;
			for(int i = 0; i < M; i++)
			{
				int sum = 0;
				for(int j = 0; j < k[i]; j++)
					sum += ((mask >> s[i, j]) & 1);
				if((sum % 2) != p[i])
				{
					isCorrect = false;
					break;
				}					
			}
			if(isCorrect)
				ans++;
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
import java.io.FileNotFoundException;
import java.util.Scanner;

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

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int mod = N%1000;
    	if(mod==0){
    		System.out.println(0);
    	} else {
    		System.out.println(1000-mod);
    	}

    }
}


Measured memory_bytes: 35860
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 53
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

int k,n,x[MAX],la=-1,ans,ia,ib;

int main(){
	scanf("%d%d",&k,&n);
	F1(a,0,n)scanf("%d",&x[a]);
	F1(a,0,k){
		ia=ib=-2;
		F1(b,0,n)if(x[b]>0){
			if(b!=la){
				if(x[b]>ib)ia=b,ib=x[b];
			}else if(ib==-2)ia=b,ib=-1;
		}
		x[la=ia]--;
		if(ib==-1)ans++;
	}
	printf("%d\n",ans);
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INF 999999999

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	int D, N;
	cin >> D >> N;
	if(D == 0){
		if( N == 100){
			cout << 101 << endl;
			return 0;
		}
		cout << N << endl;
	}else if(D == 1){
		if( N == 100){
			cout << 10100 << endl;
			return 0;
		}
		cout << N * 100 << endl;
	}else{
		if( N == 100){
			cout << 1010000 << endl;
			return 0;
		}
		cout << N * 100 * 100 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import numpy as np

x = input()
x = str(x)
y = 0
z = len(x)
for i in range(z):
  if x[i] == '1':
    y = y + 9 * (10 ** (z - i - 1))
  else:
    y = y + 1 * (10 ** (z - i - 1))
print(y)

Measured memory_bytes: 21156