akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

long long int powmod(long long int a, long long int k, long long int m){ //0<=a<=1e9, 0<k<=1e9+9, 0<m<=1e9+9
	if(a==0){
		return 0;
	}
	long long int apow[30];
	apow[0]=a;
	for(int i=1; i<30; i++){
		apow[i]=apow[i-1]*apow[i-1]%m;
	}
	long long int ans=1;
	for(int i=29; i>=0; i--){
		if(k>=(1ll<<i)){
			ans=ans*apow[i]%m;
			k-=(1ll<<i);
		}
	}
	return ans;
}
 
ll inv(ll x, ll p){
  return powmod(x, p-2, p);
}

ll f[5001], invf[5001];
void factorial(){
	f[0]=1;
	for(ll i=1; i<=5000; i++){
		f[i]=f[i-1]*i%MOD;
	}
	invf[5000]=inv(f[5000], MOD);
	for(ll i=4999; i>=0; i--){
		invf[i]=invf[i+1]*(i+1)%MOD;
	}
}

vector<ll> polymul(vector<ll> f, vector<ll> g){
	int m=f.size(), n=g.size();
	vector<ll> h;
	for(int k=0; k<m+n-1; k++){
		h.push_back(0);
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			h[i+j]+=(f[i]*g[j]);
			h[i+j]%=MOD;
		}
	}
	return h;
}

int main()
{
	int n;
	scanf("%d", &n);
	vector<int> v[5000];
	for(int i=0; i<n-1; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		x--; y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int d[5000];
	fill(d, d+n, -1);
	d[0]=0;
	queue<int> que;
	que.push(0);
	vector<P> dist;
	while(!que.empty()){
		int x=que.front();
		que.pop();
		dist.push_back(P(d[x], x));
		for(auto y:v[x]){
			if(d[y]<0){
				d[y]=d[x]+1;
				que.push(y);
			}
		}
	}
	sort(dist.begin(), dist.end(), greater<P>());
	int c[5000]={};
	for(auto p:dist){
		int x=p.second;
		for(auto y:v[x]){
			if(d[x]<d[y]) c[x]+=(c[y]+1);
		}
	}
	int cent;
	vector<int> s;
	bool reigai=0;
	for(int x=0; x<n; x++){
		bool ok=1;
		int sum=0;
		for(auto y:v[x]){
			if(d[x]<d[y]){
				sum+=(c[y]+1);
				if(c[y]+1>n/2) ok=0;
			}
		}
		if(n-1-sum>n/2) ok=0;
		if(ok){
			cent=x;
			if(n-1-sum>0) s.push_back(n-1-sum);
			for(auto y:v[x]){
				if(d[x]<d[y]) s.push_back(c[y]+1);
			}
			if(n%2!=0) break;
			for(auto x:s){
				if(x==n/2) reigai=1;
			}
			if(reigai){
				s.clear();
				s.push_back(n/2);
				s.push_back(n/2);
			}
			break;
		}
	}

	factorial();

	vector<ll> poly;
	poly.push_back(1);
	for(auto x:s){
		vector<ll> poly2;
		for(int i=0; i<=x; i++){
			ll t=f[x]*invf[x-i]%MOD*invf[i]%MOD*f[x]%MOD*invf[x-i]%MOD;
			poly2.push_back(t);
		}
		poly=polymul(poly, poly2);
	}

	ll ans=0;
	for(int i=0; i<n; i++){
		ll t=f[n-i]*poly[i]%MOD;
		if(i%2==1) t=MOD-t;
		ans+=t;
		ans%=MOD;
	}
	if(reigai){
		ans+=poly[n];
		ans%=MOD;
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MAX_N 1000000
using namespace std;

int main(){
  bool tp[MAX_N] = {};
  tp[0] = tp[1] = 1;
  for(int i = 2; i <= MAX_N / 2; i++){
    if(!tp[i]){
      for(int j = i+i; j < MAX_N; j+=i) tp[j] = 1;
    }
  }
  //  rep(i, 100) if(!tp[i]) printf("%d ", i); puts("");
  vector<int>p;
  rep(i, MAX_N) if(!tp[i]) p.push_back(i);
      //  rep(i, 100) printf("%d ", p[i]);
  //  puts("");
  int a, b, n;
  while(scanf("%d%d%d", &a, &b, &n) && a+b+n){
    int i = 0;
    while(p[i] < a) i++;
    i--;
    while(n){
      i++;
      if((p[i] - a) % b == 0) n--;
    }
    printf("%d\n", p[i]);
  }
  return 0;
}

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>inline bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
  // vector<vector<int>> vec;
  int n,q;
  cin >> n >> q;
  vector<vector<int>> event;
  for range(i,n){
    int si,ti,xi;
    cin >> si >> ti >> xi;
    event.push_back(vector<int>{si-xi,0,xi});
    event.push_back(vector<int>{ti-xi,-1,xi});
  }
  for range(i,q){
    int d;
    cin >> d;
    event.push_back({d,1,d});
  }
  sort(all(event));
  set<int> S;
  for range(i,event.size()){
    int query = event[i][1];
    int number = event[i][2];
    if (query == 0) { S.emplace(number);}
    else if (query == -1) { S.erase(number);}
    else if (query == 1) {
      if (S.empty()) { cout << -1 << endl;}
      else {cout << *S.begin() << endl;}
    }
  }
}

Measured memory_bytes: 45092
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;
string IntToString(int);
int StringToInt(string);
int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0)break;
    vector<pair<int,int> > d_p(n);
    for(int i = 0;i < n;i++){
      cin >> d_p[i].second >> d_p[i].first;
    }
    sort(d_p.begin(),d_p.end());
    int cnt = 0;
    int ans = 0;
    for(int i = n-1;i >= 0;i--){
      for(int j = 0;j < d_p[i].second;j++){
	if(cnt >= m){
	  ans += d_p[i].first;
	}
	cnt++;
      }
    }
    cout << ans<< endl;
  }
  return 0;   
}
string IntToString(int number){
  stringstream ss;
  ss << number;
  return ss.str();
}
int StringToInt(string number){
  stringstream ss;
  ss << number;
  int numInt;
  ss >> numInt;
  return numInt;
  
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>

int main(void){
    int a,b;
    std::cin >> a >> b;
    std::cout << ((a*b)%2 == 0 ? "Even" : "Odd");
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = sc.next();
    int nai = 0;
    int gai = 0;
    for(int i=0;i<n;i++){
      if(s.charAt(i)=='a'){
        if(nai+gai<a+b){
          System.out.println("Yes");
          nai++;
        }else{
          System.out.println("No");
        }
      }else if(s.charAt(i)=='b'){
        if(nai+gai<a+b&&gai<b){
          System.out.println("Yes");
          gai++;
        }else{
          System.out.println("No");
        }
      }else{
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 34468
class Music:
    def __init__(self, name, time):
        self.name = name
        self.time = int(time)


n = int(input())
data = [(input().split()) for _ in range(n)]
music_list = [Music(d[0], d[1]) for d in data]
x = input()

start_music = None
for music in music_list:
    if music.name == x:
        start_music = music
        break

if start_music is None:
    print(0)
else:
    index = music_list.index(start_music)
    skipped_list = music_list[index+1:]

    skipped_time = 0
    for music in skipped_list:
        skipped_time += music.time
    print(skipped_time)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static final long CAPACITYMAX = 100000 * 10000;

	public static void main(String[] args) throws Exception, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sStr = br.readLine().split(" ");
		int weightCount = Integer.parseInt(sStr[0]);
		int truckCount = Integer.parseInt(sStr[1]);

		int[] weightAry = new int[weightCount];

		for(int i = 0 ; i < weightCount; i++){
			weightAry[i] = Integer.parseInt(br.readLine());
		}

		long max = CAPACITYMAX + 1;
		long mid = 0;
		long min = 0;
		long currentCap = 0;

		while(min < max){
			mid = (max+min) / 2;
			if(search(truckCount,weightAry,mid)){
				max = mid;
				currentCap = mid;
			}else{
				min = mid + 1;
			}
		}

		System.out.println(currentCap);

	}

	private static boolean search(long truckCount,int[] weightAry,long capacity){

		int weight = 0;
		int truckNo = 0;
		for(int i = 0; i < weightAry.length ; i++ ){
			weight += weightAry[i];
			if(capacity < weight){
				weight = 0;
				i--;
				truckNo++;
		    }
			if(truckCount < truckNo){
				break;
			}
		}
		if(truckNo < truckCount){
			return true;
		}

		return false;
   }
}

Measured memory_bytes: 35144
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cmath>
#include <sstream>
#include <queue>
#include <map>
#include <cstring>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
using namespace std;


int main() {
    string S;
    cin >> S;
    string T = S;
    for (int i = 0; i < T.length(); ++i) {
        switch (T[i]) {
            case 'b':
                T[i] = 'd';
                break;
            case 'd':
                T[i] = 'b';
                break;
            case 'p':
                T[i] = 'q';
                break;
            case 'q':
                T[i] = 'p';
                break;
            default:
                break;
        }
    }
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] != T[T.length() - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
A, B, M = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))
min_cost = min(a_li) + min(b_li)

for i in range(M):
    x, y, discount = list(map(int, input().split()))
    a_idx = x - 1
    b_idx = y - 1
    cost = a_li[a_idx] + b_li[b_idx] - discount
    min_cost = min(min_cost, cost)

print(min_cost)


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

//pdf見て解答

int main(){
    ll a, b, n;
    cin >> a >> b >> n;

    ll x = min(b - 1, n);
    put(a * x / b - (a * (x / b)));
}

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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())

int main()
{
    IOS;

    string x, y;

    cin >> x >> y;

    int a = 0;
    for (int i = 0; i < x.length(); i++)
    {
        if (x[i] != y[i])
            a++;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3792
n = int(input())
a = (int(x) for x in input().split())

b = list(a)

cnt = 0

for i in range(len(b)) :
        for j in range(len(b)) :
                for k in range(len(b)):
                        c = [i,j,k]
                        if len(c) == len(set(c)) :
                                d = [b[i],b[j],b[k]]
                                m = max(d) 
                                if m < sum(d) - m and b[i] != b[j] and b[j] != b[k] and b[k] !=b[i]:
                                        cnt += 1
                                else :
                                        None
                        else :
                                None
                                
print(int(cnt/6))

Measured memory_bytes: 68900
import java.io.{PrintWriter, _}
import java.util._


object Main {
  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      val a = in.next
      val b = in.next
      val c = in.next
      out.println(a(0).toUpper + "" + b(0).toUpper + "" + c(0).toUpper)
    }
  }

  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")


    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}


Measured memory_bytes: 27332
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include<string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
using namespace std;
long long x;
long long temp=100;
int main()
{
     cin>>x;
	 for(long long i=1;;i++)
     {
     	temp+=temp/100;
     	if(temp>=x) 
     	{
     		cout<<i;
     		break;
		 }
	}
	 
    
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	llint n, m;
	cin >> n >> m;
	llint tmp = n / m;
	llint ans = tmp*tmp*tmp;
	if (m % 2 == 0) {
		tmp = n / (m / 2) - n / m;
		ans += tmp*tmp*tmp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

vector<int> used;
void dfs(Graph &G, int v){
    used[v] = 1;
    repe(i, G[v]){
        if(!used[i]) dfs(G, i);
    }
}

int main(){
    fastcin();

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<pair<int, int>> ca(n), cb(n);
    rep(i, n) ca[i] = make_pair(a[i], i);
    rep(i, n) cb[i] = make_pair(b[i], i);
    sort(all(ca));
    sort(all(cb));
    rep(i, n){
        if(ca[i].first > cb[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    Graph G(n);
    rep(i, n){
        G[ca[i].second].push_back(cb[i].second);
    }

    used.assign(n, 0);
    int ct = 0;
    rep(i, n)if(!used[i]){
        dfs(G, i);
        ct++;
    }

    if(ct >= 2){
        cout << "Yes" << endl;
        return 0;
    }

    rep(i, n-1){
        if(ca[i+1].first <= cb[i].first && ca[i].first <= cb[i+1].first){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto &a_i : a) {
		cin >> a_i;
	}
	int ans = *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());
	cout << ans << endl;
}


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

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
   long double a, b, n;
   cin >> a >> b >> n;
   if(n<b) cout << floor(a*n/b) << endl;
   else cout << floor(a*(b-1)/b) << endl;
   return 0; 
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
long long a[200002],n,k,ans;
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;++i)ans+=a[i];
	printf("%lld",ans);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> C(N-1);
  vector<int> S(N-1);
  vector<int> F(N-1);
  for(int i=0;i<N-1;i++){
    cin >> C[i] >> S[i] >>F[i];
  }
  for(int i=0;i<N;i++){
    int t=0;
    for(int j=i;j<N-1;j++){
      if(t<S[j]){
        t=S[j]+C[j];
      }
      else if(t%F[j]==0)t+=C[j];
      else{
        t=t+F[j]-t%F[j]+C[j];
      }
    }
    cout << t << endl;
  }
}

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

#define SIZE 30

using namespace std;

int main() {
	int w, n, a, b, temp, node[SIZE];
	cin >> w >> n;

	for (int i = 0; i < w; i++) {
		node[i] = i + 1;
	}

	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);

		temp = node[a - 1];
		node[a - 1] = node[b - 1];
		node[b - 1] = temp;
	}

	for (int i = 0; i < w; i++) {
		cout << node[i] << endl;
	}
	return 0;
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;

  int amari[110] = {};

  REP(i,B){
    int val = (i*A)%B;
    amari[val]++;
  }

  if (amari[C] == 0) {
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n; cin >> n;

	int64_t ans = 0;
	FOR_LE(i, 1, n) {
		int64_t cn = (n / i);
		int64_t ca = i * (cn * (cn + 1) / 2);
		ans += ca;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n,m;
int co;
int link[9][9];
int ar[10];
int used[10];
void saiki(int nn)
{
	if(nn==n)
	{
		int ff=1;
		rep(i,n-1)
		{
			if(link[ar[i]][ar[i+1]]==0)break;
			if(i==n-2)co++;
		}
		return;
	}
	if(nn==0)
	{
		ar[nn]=0;
		used[0]=1;
		saiki(nn+1);
	}
	else
	{
		rep(i,n)
		{
			if(used[i])continue;
			ar[nn]=i;
			used[i]=1;
			saiki(nn+1);
			used[i]=0;
		}
	}
	return;
}
int main()
{
	int a,b;
	cin>>n>>m;
	rep(i,m)
	{
		cin>>a>>b;
		a--;b--;
		link[a][b]=1;
		link[b][a]=1;
	}
	saiki(0);
	cout<<co<<endl;
	return 0;
}

Measured memory_bytes: 256
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define fe first
#define se second
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define last(x)  prev(x.end())
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e5 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <=================================================================================================================================
// <=================================================================================================================================


signed  main() {
   // op();
    lets_go

    int n;
    cin >> n;
    int h[n + 10] = {0};
    IN(h, n, 1);
    int dp[n] = {0};
    for (int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i >= 3)
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    int ans = dp[n];
    PT(ans);




    /**/
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s.size()%2!=0) s=s.substr(0,s.size()-1);
    else s=s.substr(0,s.size()-2);
    while(1){
        int num = s.size()/2;
        string a1=s.substr(0,num),a2=s.substr(num,num);
        if(a1==a2){
            cout << s.size() << endl;
            return 0;
        }
        else s = s.substr(0,s.size()-2);
    }
}


Measured memory_bytes: 256
//package com.atcoder.contest174.b;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        long d = fs.nextInt();
        long D = d*d;
        long ans = 0;
        for(int i=0; i<n; ++i) {
            long x = fs.nextInt();
            long y = fs.nextInt();
            long dist = x*x + y*y;
//            System.out.println(dist + " " + D);
            if(dist <= D) ans++;
        }
        System.out.println(ans);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 54896
#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string s;
    std::cin >> s;

    bool ok = true;
    for (int i = 0; i < 4; ++i) {
        const auto n = std::count(s.begin(), s.end(), s[i]);
        if (n != 2) {
            ok = false;
            break;
        }
    }
    std::cout << (ok ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

llint fact[200005], fact_inv[200005];

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

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

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint N, M;
bool prime[100005];
vector<int> pvec;

int main(void)
{
	cin >> N >> M;
	make_fact();
	
	for(int i = 2; i < 1005; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 100005; j+=i) prime[j] = true;
	}
	for(int i = 2; i < 100005; i++){
		if(!prime[i]) pvec.push_back(i);
	}
	
	llint ans = 1;
	for(int i = 0; i < pvec.size(); i++){
		llint cnt = 0;
		while(M % pvec[i] == 0){
			cnt++;
			M /= pvec[i];
		}
		ans *= comb(N-1+cnt, cnt);
		ans %= mod;
	}
	if(M > 1) ans *= N, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

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

int main(){
int N, M, i, ans=0; cin >> N >> M; int H[N], A[M], B[M];
vector<vector<int>> to(N);
for(i=0; i<N; i++){ cin >> H[i]; }
for(i=0; i<M; i++){
  cin >> A[i] >> B[i];
  A[i]--; B[i]--;
  to[A[i]].push_back(B[i]); to[B[i]].push_back(A[i]); 
}
for(i=0; i<N; i++){
int F=1;
for(auto j:to[i]){ if(H[i]<=H[j]){ F=0; break; } }
if(F){ ans++; }
}
cout << ans << "\n";
}

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

using namespace std;

namespace IO {
	const int SIZE = 1 << 20;
	char buf[SIZE + 10], *iS, *iT;
	inline char Getc() {
		return iS == iT && (iT = (iS = buf) + fread(buf, 1, SIZE, stdin), iS == iT) ? EOF : *iS++;
	}
	template <class TT>
	inline void Read(TT &x) {
		x = 0; register char cc = '\0'; TT fff = 1;
		for (; cc < '0' || cc > '9'; cc = Getc())
			if (cc == '-') fff = -1;
		for (; cc >= '0' && cc <= '9'; cc = Getc())
			x = (x << 1) + (x << 3) + (cc & 15);
		x *= fff;
	}
}
using IO::Read;

typedef long long LL;
const int N = 256, Mod = 998244353;

struct node {
	int x, y;
	node operator - (const node &Other) const { return (node){x - Other.x, y - Other.y}; }
} a[N];

inline int XJ(node ptp, node ptq) { return ptp.x * ptq.y - ptp.y * ptq.x; }

int n, fans, inv_n[N + 10], twopw[N + 10];

inline int Pow(int x, int y) {
	int res = 1;
	for (; y; y >>= 1, x = (LL)x * x % Mod)
		if (y & 1) res = (LL)res * x % Mod;
	return res % Mod;
}

int main()
{
	twopw[0] = 1LL;
	for (int i = 1; i <= N; ++i) {
		inv_n[i] = Pow(i * (i + 1), Mod - 2);
		twopw[i] = (LL)twopw[i - 1] * 2LL % Mod;
	}
	for (int i = 0; i <= N; ++i)
		twopw[i] = ((twopw[i] - i - 1) % Mod + Mod) % Mod;
	Read(n);
	for (int i = 1; i <= n; ++i)
		Read(a[i].x), Read(a[i].y);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j)
			if (i != j) {
				int res = 1;
				for (int k = 1; k <= n; ++k)
					if (k != i && k != j && !XJ(a[k] - a[i], a[j] - a[i]))
						++res;
				fans = (fans + (LL)inv_n[res] * twopw[res + 1]) % Mod;
			}
	}
	fans = (fans + n + 1) % Mod;
	fans = ((Pow(2, n) - fans) % Mod + Mod) % Mod;
	printf("%lld\n", fans);

	return 0;
}


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

typedef long long ll;
#define OO 1e9
using namespace std;
ll dp[101][100000 + 1];

int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int W;
  cin >> W;
  int w[n], v[n];
  for(int i = 0;i < n;i++)
    scanf("%d %d", w + i, v + i);
  dp[0][0] = 0;
  for(int i = 1;i <= 100000;i++)
    dp[0][i] = W + 1;

  for(int i = 1;i <= n;i++){
    for(int j = 0;j <= 100000;j++){
      dp[i][j] = dp[i - 1][j];
      if(j - v[i - 1] >= 0)
        dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
    }
  }
  for(int i = 100000;i >= 0;i--){
//    cout << dp[1][i] << endl;
    if(dp[n][i] <= W){
      cout << i;
      return 0;
    }
  }
}


Measured memory_bytes: 79104
n=int(input())
s=str(input())
t=len(s)
r=set()
g=set()
b=set()
a=0
for i in range(n):
    if s[i]=='R':
        r.add(i)
    if s[i]=='G':
        g.add(i)
    if s[i]=='B':
        b.add(i)
d=len(r)*len(g)*len(b)
for ri in r:
    for gi in g:
        rg=gi-ri
        if rg+gi in b:
            d-=1
        if  ri-rg in b:
            d-=1
        if (gi+ri)/2 in b:
            d-=1

print(d)

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 800 * n - 200 * (n / 15) << endl;
}

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

using namespace std;

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

  int M; cin>>M;
  long sum = 0;
  long len = 0;
  for (int i = 0; i < M; i++) {
    long d, c; cin>>d>>c;
    sum += d * c;
    len += c;
  }
  auto res = (sum-1)/9 + len-1;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}



int main(){
    ll n;
    cin>>n;
    vector<pll> A(n);
    cin>>A;
    for(auto &I:A){swap(I.F,I.S);}
    sort(A.begin(),A.end(),greater<pll>());
    ll sum=0;
    ll last=E;
    for(auto &I:A){
        sum-=last-I.F;
        sum=max(sum,0LL);
        sum+=I.S;
        last=I.F;
    }
    cout<<(sum-last<=0?"Yes":"No")<<endl;
    
    return 0;
}


Measured memory_bytes: 3328
n,k=map(int,input().split())

dp=[[0 for _ in range(n+1)] for _ in range(k+1)]

for i in range(n+1):
  for j in range(k+1):
    if i>1 and j>0:
      dp[j][i]=(j-1)*dp[j][i-1]
    elif i==1 and j>0:
      dp[j][i]=j
    else:
      dp[j][i]=0

print(dp[k][n])

Measured memory_bytes: 9228
from sys import stdin
from collections import defaultdict, deque, Counter
import sys
from bisect import bisect_left
import heapq
import math

sys.setrecursionlimit(10000000)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,k = map(int, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]
A = list(map(int, stdin.readline().rstrip().split()))



ans = 0
for i in range(n):
    right = 0
    left = 0
    for j in range(i):
        if A[i] > A[j]:
            left += 1
    for j in range(i+1, n):
        if A[i] > A[j]:
            right += 1
    ans += int(right*k*(k+1)//2 + left*k*(k-1)//2)

print(ans % MOD)


Measured memory_bytes: 3572
Count = [0,0,0,0]
for j in input():
    if j == 'N':
        Count[0] +=1
    elif j == 'S':
        Count[1] +=1
    elif j == 'W':
        Count[2] +=1
    elif j == 'E':
        Count[3] +=1

if (Count[0] > 0 and Count[1] > 0) and (Count[2] > 0 and Count[3] > 0):
    print("Yes")
elif (Count[0] == 0 and Count[1] == 0) and (Count[2] > 0 and Count[3] > 0):
    print("Yes")
elif (Count[0] > 0 and Count[1] > 0) and (Count[2] == 0 and Count[3] == 0):
    print("Yes")
else:
    print("No")


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

using namespace std;

#define ll long long

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

	vector < ll > a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	ll lcm = 1;
	for (int i = 0; i < N; i++) {
		ll half = a[i] / 2;
		lcm = half * lcm / __gcd(half, lcm);
		if (lcm > M) {
			cout << 0 << endl;
			return 0;
		}
	}

	for (int i = 0; i < N; i++) {
		if (lcm / (a[i] / 2) % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	cout << (M / lcm + 1) / 2 << endl;

	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n&&n){
    vary(ll,v,n,0);
    rep(i,n){
      cin >> v[i];
    }
    sort(all(v));
    v[0] = 0;
    v[v.size()-1] = 0;
    ll ans = 0;
    rep(i,n){
      ans += v[i];
    }
    cout << ans /(n-2) << endl;
  }
  return 0;
}

Measured memory_bytes: 3156
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {
        string ST = Console.ReadLine();
        List<int> Liv = new List<int> {
            5,7
        };
        int LivCT = 0;
        string OutS = "";
        for (int i=0; i < Liv.Count;i++) {
            OutS += ST.Substring(LivCT, Liv[i]) + " ";
            LivCT += Liv[i] + 1;
        }
        OutS += ST.Substring(LivCT);
        Console.WriteLine(OutS);
        Console.ReadLine();
    }
}

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

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())

int main(){
	int n;
	cin>>n;
	vi h(n);
	rep(i,n) cin>>h[i];
	int ans=0;
	int m=1000000000;
	for(int i=n-1;i>=0;i--){
		m=min(m,h[i]);
		if(h[i]-m>1){
			ans=1;
		}
	}
	if(ans==1){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
using namespace std;
inline int read(){
    int x(0),w(1); char c = getchar();
    while(c^'-' && (c<'0'||c>'9')) c = getchar();
    if(c == '-') w = -1, c = getchar();
    while(c>='0' && c<='9') x = (x<<3) + (x<<1) + c - '0', c = getchar();
	return x*w;
}
int a,b,t;
int main(){
	a = read(), b = read(), t = read();
	printf("%d",(t/a)*b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define inf 1000000009
using namespace std;
int main(){
	int n;
	vector<int> v;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.pb(x);
	}
	int ans=0,cnt=0;
	for(int i=1;i<n;i++){
		if(v[i-1]>=v[i])cnt++;
		else{
			if(ans<cnt)ans = cnt;
			cnt = 0;
		}
	}
	if(ans<cnt)ans = cnt;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <unordered_map>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define ll long long
#define INF ((1<<30)-1)
#define NEG (-1)
#define MOD 1000000007
#define MAXN 100100
#define EPS 1e-9
#define INFLL 1e18
using namespace std;
FILE *in,*out;

int N,M,K;

int read()
{
    int i,j,k;
    fscanf(in,"%d%d",&N,&M);
    if(N%M == 0)
        printf("0\n");
    else printf("1\n");
    
    return 0;
}

int main()
{
    // in = fopen("A.in","r");
    // out  = fopen("A.out","w");
    in = stdin;
    out = stdout;
    read();
    return 0;
}
//////////// Local Snippets
// forx
// fory
// vectorx
// pairx
// sizex

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define SZ(x) ((int)(x.size()))
#define FOI(i,a,n) for(int (i)=int(a);(i)<=int(n);++(i))
#define FOD(i,a,n) for(int (i)=int(a);(i)>=int(n);--(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define MSET(tabl,i) memset(tabl, i, sizeof(tabl))
#define PSET(x,y) fixed<<setprecision(y)<<lf(x)
#define DBG(c) cout<<#c<<" = "<<c<<endl;
#define RTIME ((double)clock()/(double)CLOCKS_PER_SEC)

template<typename T,typename S>inline bool REMIN(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool REMAX(T&a,const S&b){return a<b?a=b,1:0;}

typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;

int bit(ll x, int pos){ return (x >> pos) & 1; }
ll power(ll base, ll exp, ll c = 1e9 + 7) { if(!exp) return 1; ll r = power(base, exp >> 1, c); r=(r*r)%c; if(exp&1) r=(r*base)%c; return r; }

ll T,N,M,K;  
int a,b,c;
string s1,s2;

const lf PI = 2*acos(0);
const ll INF = 1e9 + 4;
const ll MOD = 1000000007;
const int NMAX = 3e5+5;

ll ar[NMAX];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> N >> M;
	ll g = 0;
	FOI(i, 1, N) {
		cin >> ar[i];
		g = __gcd(g, ar[i]);
	}

	FOI(i, 1, N) {
		if(M <= ar[i] and (ar[i] - M) % g == 0) {
			cout << "POSSIBLE\n";
			return 0;
		}
	}

	cout << "IMPOSSIBLE";
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
# define INT_MAX implementation-defined
using namespace std;
int main(){
    string s, t; cin >> s >> t;
    int a = s.size();
    int b = t.size();
    if(a<b){
        for(int i=0; i<a; i++){
            cout << s.at(i) << t.at(i);
        }
        cout << t.substr(a, b-a+1) << endl;
        return 0;
    }
    else if(b<a){
        for(int i=0; i<b; i++){
            cout << s.at(i) << t.at(i);
        }
        cout << s.substr(b, a-b+1) << endl;
        return 0;
    }
    else{
        for(int i=0; i<b; i++){
            cout << s.at(i) << t.at(i);
        }
        cout << endl;
        return 0;
    }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class agc021_a {
public:
    void solve(istream& in, ostream& out) {
        string N;
        in >> N;
        int res = 0;
        for (int i = 0; i < (int)N.size(); ++i) res += N[i] - '0';
        if (N[0] == '1') {
            int tmp = 0;
            for (int i = 1; i < (int)N.size(); ++i) tmp += 9;
            res = max(res, tmp);
        } else {
            int tmp = N[0] - '0' - 1;
            for (int i = 1; i < (int)N.size(); ++i) tmp += 9;
            res = max(res, tmp);
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc021_a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, c, min, max int
	fmt.Scan(&n)

	var colors = make([]bool, 8)

	for i := 0; i < n; i++ {
		fmt.Scan(&c)

		if cc := c / 400; c < 3200 && !colors[cc] {
			colors[cc] = true
			min++
		} else if c >= 3200 {
			max++
		}
	}

	if min == 0 {
		fmt.Printf("%d %d\n", 1, max)
	} else {
		fmt.Printf("%d %d\n", min, max+min)
	}
}

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

int main() {
  int64_t N,C,Z=0;
  cin>>N>>C;
  vector<vector<int64_t>> p(N,vector<int64_t>(2));
  for(int i=0;i<N;i++){
    cin>>p.at(i).at(0)>>p.at(i).at(1);
  }
  vector<int64_t> a(N+1);
  vector<int64_t> b(N+1);
  vector<int64_t> c(N+1);
  vector<int64_t> d(N+1);
  a.at(1)=p.at(N-1).at(1)-C+p.at(N-1).at(0);
  for(int i=1;i<N;i++){
    a.at(i+1)=a.at(i)+p.at(N-1-i).at(1)-p.at(N-i).at(0)+p.at(N-1-i).at(0);
  }
  for(int i=0;i<N;i++){
    a.at(i+1)=max(a.at(i),a.at(i+1));
  }
  c.at(1)=p.at(0).at(1)-p.at(0).at(0);
  for(int i=1;i<N;i++){
    c.at(i+1)=c.at(i)+p.at(i).at(1)-p.at(i).at(0)+p.at(i-1).at(0);
  }
  for(int i=0;i<N;i++){
    c.at(i+1)=max(c.at(i),c.at(i+1));
  }
  d.at(1)=p.at(N-1).at(1)+(p.at(N-1).at(0)-C)*2;
  for(int i=2;i<=N;i++){
    d.at(i)=d.at(i-1)+p.at(N-i).at(1)+2*(p.at(N-i).at(0)-p.at(N+1-i).at(0));
  }
  b.at(1)=p.at(0).at(1)-p.at(0).at(0)*2;
  for(int i=2;i<=N;i++){
    b.at(i)=b.at(i-1)+p.at(i-1).at(1)+2*(p.at(i-2).at(0)-p.at(i-1).at(0));
  }
  for(int i=0;i<=N;i++){
    Z=max(Z,max(a.at(i)+b.at(N-i),c.at(i)+d.at(N-i)));
  }
  cout<<Z<<endl;
}




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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  for(int i=0;i<N;i++){
    if(A.at(i)%2==0){
      if(A.at(i)%3!=0 && A.at(i)%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 

int main(void) {
  ll n;cin>>n;
  vector<ll> a(n);
  ll sum = 0;
  fr(i, n) cin>>a[i], sum+=a[i];
  ll r = 0;
  ll x = 1000000000000;
  fr(i, n) {
    r+=a[i];
    x = min(x, abs(2*r-sum));
  }
  cout << x << endl;

  return 0;
}

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


int main(){
  
  int N, M, pos, i, j;
  cin>>N>>M;
  vector<vector<int>> P(N);
  vector<int> Num(N, -1), Sb(N);
  queue<int> node;
  
  for(i=0; i<M; i++){
    int a, b; cin>>a>>b;
    P[a-1].push_back(b-1);
    P[b-1].push_back(a-1);
  }
  
  //幅優先探索でやろう。
  
  
  node.push(0); Num[0]=0;
  while(node.size()){
    
    pos=node.front(); node.pop();
    for(j=0; j<(int)P[pos].size(); j++){
      
      if(Num[P[pos][j]]==-1){
        Num[P[pos][j]]=Num[pos]+1;
        node.push(P[pos][j]);
        Sb[P[pos][j]]=pos+1;
      }
    }
  }
  
  cout<<"Yes"<<endl;
  for(i=1; i<N; i++){
    cout<<Sb[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 10628
def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())

    for _ in range(n):
        b = int(input())

        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    A[i][j] = 0

    ans = 'No'
    for i in range(3):
        if any(A[i]) == 0:
            ans = 'Yes'
    for i in range(3):
        if any([A[0][i], A[1][i], A[2][i]]) == 0:
            ans = 'Yes'
    if any([A[0][0], A[1][1], A[2][2]]) == 0:
        ans = 'Yes'
    if any([A[0][2], A[1][1], A[2][0]]) == 0:
        ans = 'Yes'

    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
	int n, k; cin >> n >> k;

	const int p = 200010;

	vector<int> a(n); 
	vector<int> num(p,0);

	for (int i = 0; i < n; i++) { cin >> a[i];
		num[a[i]]++;
	}
	
	sort(num.begin(), num.end());

	int type = 0;

	for (int j = 0; j < p; j++) {
		if (0 < num[j]) type++;
	}	
	if (type <= k) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	int cnt = 0;
	for (int j = 0; j < p; j++) {
		if (0 < num[j]) {
			ans += num[j];
			cnt++;
		}
		if (cnt == type - k) break;
	}

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

Measured memory_bytes: 1792