akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let mut a: u64 = read();
    let mut b: u64 = read();
    let mut c: u64 = read();

    let k: usize = read();

    for _ in 0..k {
        if a < b && b < c {
            println!("Yes");
            return;
        }

        if a >= b {
            b *= 2;
        } else if b >= c {
            c *= 2;
        }
    }
    if a < b && b < c {
        println!("Yes");
        return;
    }
    println!("No");
}



Measured memory_bytes: 2144
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll X, K, D;

int main() {
  INCANT;
  cin >> X >> K >> D;
  X=abs(X);
  ll r = K-X/D;
  if (r<=0ll) {
    cout << abs(X-K*D) << endl;
    return 0;
  }
  K-=X/D;
  X%=D;
  ll ret = K%2ll?D-X:X;
  cout << ret << endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

void step(string& s) {
  string t(s.size()-1, '0');
  REP(i, s.size()-1) {
    t[i] += abs(s[i]-s[i+1]);
  }
  swap(s, t);
}

// 1-stepすすめると0, 1, 2だけになる
//

int comb_parity(int64 a, int64 b) {
  int64 ret = 1;
  while (a) {
    if (a%2 == 0 && b%2) ret = 0;
    a /= 2;
    b /= 2;
  }
  return ret;
}

bool is_palindrome(const string& s) {
  REP(i, s.size()/2) {
    if (s[i] != s[s.size()-i-1]) return 0;
  }
  return 1;
}

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

  int64 N;
  cin >> N;
  vector<int64> A(N), cnt(N, 0);
  int64 sum = 0;
  REP(i, N) {
    cin >> A[i]; A[i]--;
    cnt[A[i]]++;
  }
  REP(i, N) {
    sum += cnt[i]*(cnt[i]-1)/2;
  }
  REP(i, N) {
    cout << sum - cnt[A[i]]*(cnt[A[i]]-1)/2 + (cnt[A[i]]-1)*(cnt[A[i]]-2)/2 << endl;
  }
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <cmath>
#include<vector>
#include<algorithm>
using namespace std;


int main() {
	int N, T, A;
	cin >> N >> T >> A;
	vector<int> H(N);
	for (auto &x : H) cin >> x;
	auto minitr = min_element(H.begin(), H.end(), [&](int x, int y) {return abs(T - x * 0.006 - A) < abs(T - y * 0.006 - A); });
	cout << minitr - H.begin() + 1 << endl;
}

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

using namespace std;

typedef struct {
	int sum;
	char name[30];
} TEAM;

int main()
{
	int n;
	int win, lose, drow;
	bool flg = false;
	TEAM team[10], tmp;

	while (1){
		scanf("%d", &n);

		if (n == 0){
			break;
		}

		for (int i = 0; i < n; i++){
			scanf("%s %d %d %d", team[i].name, &win, &lose, &drow);
			team[i].sum = win * 3 + drow;
		}

		for (int i = 0; i < n; i++){
			for (int j = n - 1; j > i; j--){
				if (team[j].sum > team[j - 1].sum){
					tmp = team[j - 1];
					team[j - 1] = team[j];
					team[j] = tmp;
				}
			}
		}

		if (flg == true){
			cout << endl;
		}
		
		flg = true;

		for (int i = 0; i < n; i++){
			cout << team[i].name << "," << team[i].sum << endl;
		}
	}

	return (0);
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main {

    static final int MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[][] dp = new long[n+1][4];//a,c,g,t
        dp[1] = new long[]{1,1,1,1};
        dp[2] = new long[]{4,4,4,4};
        dp[3] = new long[]{16,14,15,16};
        for (int i = 4; i <= n; i++) {
            for (int j = 0; j < 4; j++) {
                if(j == 0){
                    dp[i][0] = (dp[i-1][0] +dp[i-1][1] +dp[i-1][2] +dp[i-1][3])%MOD;
                }else if(j == 1){
                    dp[i][1] = (dp[i-1][0] +dp[i-1][1] +dp[i-1][2] +dp[i-1][3] - dp[i-2][0] - dp[i-2][2] - (dp[i-3][0]*3) +MOD)%MOD;
                }else if(j == 2){
                    dp[i][2] = (dp[i-1][0] +dp[i-1][1] +dp[i-1][2] +dp[i-1][3] - dp[i-2][0] +dp[i-3][2] +MOD)%MOD;
                }else{
                    dp[i][3] = (dp[i-1][0] +dp[i-1][1] +dp[i-1][2] +dp[i-1][3])%MOD;
                }
            }
        }
        long ans = (dp[n][0] +dp[n][1] +dp[n][2] +dp[n][3]) %MOD;
        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 22612
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

ll v(string s){
    ll tmp = s[0] - '0';
    tmp *= 10;
    tmp += s[2] - '0';
    tmp *= 10;
    tmp += s[3] - '0';
    return tmp;
}

int main(void){
    ll A; cin >> A;
    string B; cin >> B;
    // cout << v(B);
    ll b = v(B);
    cout << (A * b / 100) << endl;
    return 0;
}


Measured memory_bytes: 3560
X = int(input())

if X>=1800:
    print(1)
elif X>=1600:
    print(2)
elif X>=1400:
    print(3)
elif X>=1200:
    print(4)
elif X>=1000:
    print(5)
elif X>=800:
    print(6)
elif X>=600:
    print(7)
else:
    print(8)

Measured memory_bytes: 9172
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var k = int.Parse(_[1]);

            var ans = 1L;
            for(var i = 0; i < n; i++){
                if(i == 0){
                    ans *= k;
                }else{
                    ans *= (k - 1);
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
n = gets.to_i
n.times { |i|
  x = i+1
  if (x%3==0)
    print " #{x}"
    next
  end

  while(x>0)
    if (x%10 == 3)
      print " #{i+1}"
      x=0
    end
    x/=10
  end
}
puts ""

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

typedef long long ll;


ll solve(ll N, ll P){
    if (N == 1) return P;

    double x = powl(P, 1.0/N);
    if (x < 2.0) return 1;

    // x >= 2
    int d = (int)ceil(x);
    for (ll n=d; n>=2; --n) {
        int cnt = 0;
        ll y = P;
        while (y % n == 0) { ++cnt; y /= n; }
        if (cnt >= N) return n;
    }
    return 1;
}

int main() {
    ll N, P; cin >> N >> P;
    cout << solve(N,P) << endl;
    return 0;
}


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


int main(){
    int A, B, C, K, sum;
    cin >> A >> B >> C >> K;
    sum = 0;
    if(A <= K){
        sum += A;
    } else {
        sum += K;
    }
    K -= A;
    K -= B;
    if(K > 0){
        sum -= K;
    }
        cout << sum << endl;


}

Measured memory_bytes: 3604
#include <stdio.h>

int min (a, b)
{
	if (a > b) { return b; }
	else       { return a; }
}

int calculate_cost (int num_traveler, int cost_train, int cost_taxi)
{
	return min(num_traveler * cost_train, cost_taxi);
}

int main (void)
{
	// variables for main process
	int N, A, B;
	int rtvl_scanf;

	// STEP.01
	// read out the given data
	rtvl_scanf = scanf("%d %d %d", &N, &A, &B);

	// STEP.02
	// output the answer of this task
	printf("%d\n", calculate_cost(N, A, B));

	// STEP.END
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
using namespace std;


int main() {
  int N, K;
  cin >> N >> K;

  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];

  const int INF = 1 << 30;
  vector<int> dp(N, INF);
  dp[0] = 0;

  for (int i = 1; i < N; i++) {
    for (int k = 1; k <= K; k++) {
      if (i - k >=0) dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]));
    }
  }


  cout << dp[N-1] << endl;
  return 0;
}


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

int main() {
  int A,B,C;
  cin >>A>>B>>C;
if(A==B&&B==C){
  cout<<"No"<<endl;
  return 0;
}
  if(A==B||B==C||A==C){
  cout<<"Yes"<<endl;
  return 0;
}
  cout <<"No"<< endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 1, sizeof(s))
const int inf = 0x3f3f3f3f;
#define maxn 1000000
bool mark[maxn];
int pri[maxn];
int a[55000];
void ola(){
	for (int i = 2; i * i < maxn; i++){
		for (int j = 2; j <= i; j++){
			mark[i * j] = 0;
		}
	}
	int t = 0;
	for (int i = 2; i < maxn; i++){
		if(mark[i]){
			pri[t++] = i;
		}
	}
}
bool ispri(int n){
	int temp = pri[maxn / 2];
	int left = 0, right = maxn - 1;
	while (left <= right){
		temp = (right + left) / 2;
		int mid = pri[temp];
		if(n > mid){
			left = temp + 1;
		}
		else if (n < mid){
			right = temp - 1;
		}
		else{
			return 1;
		}
	}
	return 0;
}

int main(int argc, char * argv[]) 
{
	mark[0] = 0;
	mark[1] = 0;
	int ans[100];
	ms(mark);
	ola();
	int n;
	cin >> n;
	int t = 0;
	for (int i = 0; i <= maxn && t < n; i++){
		if(pri[i] % 10 == 1){
			ans[t++] = pri[i];
		}
	}
	for (int i = 0; i < n; i++){
		if (!i) cout << ans[i];
		else cout << " " << ans[i];
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 5120
/* **********************************JAI SAI RAM ************************************* */
// Help in Codeforces  Round Div2 of Devil.
//Well this is just a mere fun.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[20001];
void  solve()
{
  ll i,j,l,k,m,n,o,p,q,r,t,x,y;
  cin>>n;
   ll ans=0;
   for(i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   a[0]=0;
   p=1000;
   ans=p;
   q=0;
   i=2;
   while(i<=n&&a[i]-a[i-1]<=0)
   {
     i++;
   }
   if(i>n)
   {
       cout<<"1000\n";
       return;
   }
   q+=p/(a[i-1]);
   p%=a[i-1];
   ans=max(ans,p);
   while(i<=n)
   {
       j=i;
       while(j<=n&&a[j]-a[j-1]>=0)
       {
          j++;
       }
       p+=(q*a[j-1]);
       q=0;
       ans=max(ans,p);
       while(j<=n&&a[j]-a[j-1]<=0)
       {
           j++;
       }
       q+=p/(a[j-1]);
        p%=a[j-1];
        ans=max(ans,p);
        i=j;
   }
   cout<<ans<<endl;
  return;
  
  return;
  
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,n,m,k;
    n=1;
     t=n;
    while(t--)
    {
       solve();
       n++;
    }
    return 0;
}
    


Measured memory_bytes: 3648
n = int(input())

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

def waru(a,n):
    for i in range(n):
        if a[i]%2==1:
            return False
        else:
            a[i] = a[i]//2
    return True

con = 0
while True:

    if waru(a,n):
        con += 1
    else:
        break

print(con)

Measured memory_bytes: 3060
N, M = map(int, input().split())
inf =  10**9
brid = [inf]*N
for i in range(M):
  a, b =  map(int, input().split())
  brid[a-1] =min(b, brid[a-1])
right_side =  N+1
ans = 0
for i in range(N-1, -1, -1):
  if brid[i] == inf:
    continue
  else:
    if brid[i] <= right_side:
      ans += 1
      right_side = i+1
print(ans)    

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

int main()
{
	int a[5];

	for(int i = 0; i < 5; i++)
		cin >> a[i];

	sort(a, a + 5, greater<int>());

	for (int i = 0; i < 4; i++)
		cout << a[i] << " ";
	cout << a[4] << endl;

	return 0;
}


Measured memory_bytes: 3152
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b:
            a1[j]=0
        if a2[j]==b:
            a2[j]=0
        if a3[j]==b:
            a3[j]=0
answer='No'
if a1.count(0)==3 or a2.count(0)==3 or a3.count(0)==3:
    answer='Yes'
elif a1[0]==0 and a2[0]==0 and a3[0]==0:
    answer='Yes'
elif a1[1]==0 and a2[1]==0 and a3[1]==0:
    answer='Yes'
elif a1[2]==0 and a2[2]==0 and a3[2]==0:
    answer='Yes'
elif a1[0]==0 and a2[1]==0 and a3[2]==0:
    answer='Yes'
elif a1[2]==0 and a2[1]==0 and a3[0]==0:
    answer='Yes'
print(answer)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int a,b,c,f,n,m;
	scanf("%d",&n);
	for(m=0;m<n;m++){
		scanf("%d",&a);
		scanf("%d",&b);
		scanf("%d",&c);
		f=0;
		a=a*a;
		b=b*b;
		c=c*c;
		if(a==b+c){f=1;}
		else if(b==c+a){f=1;}
		else if(c==a+b){f=1;}
		if(f==1){printf("YES\n");}
		else{printf("NO\n");}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//
int main(void) {
    vector<int> v(5),u(5);
    rep(i,5) cin >> v.at(i);
    int ans=0;
    int a,b,c,d,e;
    u.at(0) = v.at(0)%10;
    u.at(1) = v.at(1)%10;
    u.at(2) = v.at(2)%10;
    u.at(3) = v.at(3)%10;
    u.at(4) = v.at(4)%10;
    int tmp=10,buc;
    rep(i,5){
        if(u.at(i)<tmp&&u.at(i)!=0){
            tmp = u.at(i);
            buc = i;
        }
    }
    rep(i,5){
        if(i!=buc){
            if(u.at(i)!=0) ans += v.at(i)+(10-u.at(i));
            else ans += v.at(i);
        }
        else ans += v.at(buc);
    }
    cout << ans << endl;
    return 0;
}

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

N=int(input())
E=[[] for i in range(N+1)]

for i in range(N-1):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

COLOR=[-1]*(N+1)

Q=[1]
COLOR[1]=1

while Q:
    x=Q.pop()
    for to in E[x]:
        if COLOR[to]==-1:
            COLOR[to]=1-COLOR[x]
            Q.append(to)

A1=N//3
A2=N//3
A3=N//3

if N%3==1:
    A1+=1
elif N%3==2:
    A1+=1
    A2+=1

S1=COLOR.count(1)
S2=COLOR.count(0)


SA=A1+A3-A2

if abs(S1-S2)<=SA:
    ANS=[0]*(N+1)
    now1=1
    now2=2
    if S1<S2:
        for i in range(1,N+1):
            if COLOR[i]==1:
                ANS[i]=now2
                now2+=3
            else:
                ANS[i]=now1
                now1+=3

    else:
        for i in range(1,N+1):
            if COLOR[i]==0:
                ANS[i]=now2
                now2+=3
            else:
                ANS[i]=now1
                now1+=3

    now3=3
    for i in range(1,N+1):
        if ANS[i]>N:
            ANS[i]=now3
            now3+=3

    print(*ANS[1:])
    
else:
    ANS=[0]*(N+1)
    now1=1
    now2=2
    now3=3

    if S1<S2:
        for i in range(1,N+1):
            if COLOR[i]==1:
                ANS[i]=now3
                now3+=3
    else:
        for i in range(1,N+1):
            if COLOR[i]==0:
                ANS[i]=now3
                now3+=3

    for i in range(1,N+1):
        if ANS[i]==0:
            if now1<=N:
                ANS[i]=now1
                now1+=3
            elif now2<=N:
                ANS[i]=now2
                now2+=3
            else:
                ANS[i]=now3
                now3+=3

    print(*ANS[1:])

Measured memory_bytes: 54516
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int

template <typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;
ll ans = 0, sum = 0, n, k, t;
string s;



int main()
{
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
}


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

int n,ta,ao,ans;
vector<int> g[100005];
int dis[100005];

void dfs(int x,int p,int d){
    if(d>=dis[x]){//如果被抓到了就退出
        ans=max(ans,dis[x]);
        return;
    }
    for(int i=0;i<g[x].size();i++){
        int &y=g[x][i];
        if(y!=p){
            dfs(y,x,d+1);
        }
    }
    if(g[x].size()==1){//是叶子结点，就特判一下之前做法中提到的情况
        ans=max(ans,dis[x]-1);
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>ta>>ao;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    memset(dis,-1,sizeof(dis));
    dis[ao]=0;
    {//预处理青木到每个结点的距离dis
        queue<int> q;
        q.push(ao);
        while(!q.empty()){
            int x=q.front();q.pop();
            for(int i=0;i<g[x].size();i++){
                int &y=g[x][i];
                if(dis[y]==-1){
                    dis[y]=dis[x]+1;
                    q.push(y);
                }
            }
        }
    }
    dfs(ta,-1,0);
    cout<<ans<<endl;

    return 0;
}

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

int n, w, a[N], dp[N], b[N];

int main()
{
    cin >> n >> w;
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &a[i], &b[i]);

    for (int i = 1; i < N; i++)
        dp[i] = w + 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = N - 1 - b[i]; j >= 0; j--)
            dp[j + b[i] ] = min( dp[j +  b[i] ], dp[j] + a[i] );
    }
    for (int i = N - 1; i >= 0; i--)
    if (dp[i] <= w){
        cout << i << endl;
        return 0;
    }
}




Measured memory_bytes: 1024
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  
  var num = parseInt(lines[0],10);

  var card = lines[1].split(' ');
  
  var hairetu = [];
  for(var i=0;i<card.length;i++){
  	hairetu.push(parseInt(card[i],10));
  }
  

  
  function compareFunc(a, b) {
  return b - a;
}
 

　hairetu.sort(compareFunc);
 var alice =0;
 var bob = 0;
  
 for(var i=0;i<hairetu.length;i++){
 	if(i%2 ===0){
    	alice += hairetu[i];
    }else{
    	bob += hairetu[i];
    }
 } 
  
  console.log(alice-bob);

  
  
});

Measured memory_bytes: 30084
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
  vector<int> od(n);
  iota(od.begin(), od.end(), 0);
  sort(od.begin(), od.end(), [&](int i, int j){
    return a[i] - b[j] > a[j] - b[i];
  });
  long long tak = 0, aok = 0;
  for(int i = 0; i < n; i++){
    if(i&1) aok += b[od[i]];
    else tak += a[od[i]];
  }
  cout << tak - aok << endl;
  return 0;
}

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

int icompare(const void *a,const void *b)
{
  if(*(int *)a>*(int *)b){
    return -1;
  }else if(*(int *)a==*(int *)b){
    return 0;
  }else{
    return 1;
  }
}
int main(void){
  int N,M,*A,sum=0,Msum=0;
  scanf("%d %d", &N, &M);
  A=(int *)malloc(sizeof(int)*(N));
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    sum+=A[i];
  }
  qsort(A,N,sizeof(int),icompare);

  if(sum>4*M*A[M-1]) printf("No");
  else printf("Yes");
  
}

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

int main()
{
  int H,W;
  cin >>H>>W;
  vector<vector<char>> s(H,vector<char>(W));
  
  //data input
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin>>s.at(i).at(j);
    }
  }
  
  vector<bool> dw(W,false);
  vector<bool> dh(H,false);
  
  for(int i=0; i<H; i++){
    int cw=0;
    for(int j=0; j<W; j++){
      if(s.at(i).at(j)=='.') cw++;
    }
    if (cw==W) dh.at(i)=true;
  }
  
  for(int j=0; j<W; j++){
    int ch=0;
    for(int i=0; i<H; i++){
      if(s.at(i).at(j)=='.') ch++;
    }
    if(ch==H) dw.at(j)=true;
  }
  
  for(int i=0; i<H; i++){
    if(dh.at(i)==true) continue;
    for(int j=0; j<W; j++){
      if(dw.at(j)==true) continue;
      cout<<s.at(i).at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
h,w = map(int, input().split())
target = [input() for _ in range(h)]

ans = 'Yes'
break_flg = False

for h_i in range(h):
  if break_flg:
    break
  for w_i in range(w):
    check_str = target[h_i][w_i]
    if check_str == '#':
      left = target[h_i][w_i-1] if w_i-1>=0 else '.'
      right = target[h_i][w_i+1] if w_i+1<w else '.'
      top = target[h_i-1][w_i] if h_i-1>=0 else '.'
      bottom = target[h_i+1][w_i] if h_i+1<h else '.'
      
      if left==right==top==bottom=='.':
        ans = 'No'
        break_flg = True
        break
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n;
int h[100010];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	h[n+1]=2e9; 
	int cnt=0,ans=0;
	for(int i=1;i<=n;i++) {
		if(h[i]<h[i+1]) {
			ans=max(cnt,ans);
			cnt=0;
		}
		else cnt++;
	}
	printf("%d",max(ans,cnt));
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int a[99];
long long dp[100][21];
int main(){
    int n;
    fill(dp[0],dp[0]+2100,0);
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        scanf("%d",a+i);
    }
    dp[0][a[0]]=1;
    int m;
    scanf("%d",&m);
    for(int i=1;i<n-1;i++){
        for(int j=0;j<21;j++){
            if(j+a[i]>=0&&j+a[i]<=20) dp[i][j+a[i]]+=dp[i-1][j];
            if(j-a[i]>=0&&j-a[i]<=20) dp[i][j-a[i]]+=dp[i-1][j];
        }
    }
    printf("%lld\n",dp[n-2][m]);
    return 0;
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#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 ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int H, N;  cin >> H >> N;
    vector<P> ab(N);
    for(int i = 0 ; i < N ; i++){  int a, b;  cin >> a >> b;  ab[i] = make_pair(a, b);  }
    int dp[10001];  for(int i = 0 ; i < 10001 ; i++)  dp[i] = INF;
    dp[H] = 0;
    
    for(int i = H ; 1 <= i ; i--){
      for(pair<int,int> p : ab){
        int keep = ((i - p.first < 0) ? 0 : i - p.first);
        dp[keep] = min(dp[keep], dp[i] + p.second);
      }
    }

    cout << dp[0] << endl;
	return 0;
}

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

int main(){
    string n;
    cin >> n;
    for (size_t i = 0; i < 3; i++) {
        if(n[i] == '9') n[i] = '1';
        else if(n[i] == '1') n[i] = '9';
    }
    cout << n << endl;
    return 0;
}


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

int main() {
  std::map<std::string, int> weeks;
  weeks["SUN"] = 7;
  weeks["MON"] = 6;
  weeks["TUE"] = 5;
  weeks["WED"] = 4;
  weeks["THU"] = 3;
  weeks["FRI"] = 2;
  weeks["SAT"] = 1;
  
  std::string today;
  std::cin >> today;
  std::cout << weeks[today];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, x;
    cin >> n >> x;
    ll ans = 1, d = 0;
    rep(i, 0, n) {
        ll l;
        cin >> l;
        d += l;
        if (d <= x) ans++;
    }
    cout << ans << endl;
}


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

int main() {
	
	int x, n;
	scanf("%d%d", &x,&n);
	map<int, int> mp;
	for(int i=0; i<n; i++) {
		int q;
		scanf("%d", &q);
		mp[q] = 1;
	}
	int cek = 1e4;
	int ans = x;
	for(int i=-101; i<=101; i++) {
		if(mp[i]) continue;
		else if(abs(i-x) < cek) {
			cek = abs(x-i);
			ans = i;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  bool flag = true;
  string A = S.substr(0, (N - 1) / 2);
  string A_ = A;
  reverse(A_.begin(), A_.end());
  if (A_ != A) flag = false;
  string B = S.substr((N + 1) / 2, (N - 1) / 2);
  string B_ = B;
  reverse(B_.begin(), B_.end());
  if (B_ != B) flag = false;
  string S_ = S;
  reverse(S_.begin(), S_.end());
  if (S_ != S) flag = false;
  if (flag == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a < c && c < b) {
    cout << "Yes" << endl;
  } else if (a > c && c > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,op;
int get()
{
	char ch=getchar();
	while (ch<'A'||ch>'Z') ch=getchar();
	if (ch=='M') return 1;
	if (ch=='F') return 2;
	return 0;
}
int main()
{
	scanf("%d",&n);
	printf("%d\n",0);
	fflush(stdout);
	op=get();
	if (op==0) return 0;
	int lx=1,rx=n-1;
	while (rx-lx>1)
	{
		int mid=(lx+rx)/2;
		printf("%d\n",mid);
		fflush(stdout);
		int now=get();
		if (now==0) return 0;
		if ((now+2-op)%2==mid%2) lx=mid; else rx=mid;
	}
	printf("%d\n",lx);
	fflush(stdout);
	int now=get();
	if (now==0) return 0;
	if ((now+2-op)%2==lx%2)
	{
		printf("%d\n",rx);
		fflush(stdout);
	} else
	{
		printf("%d\n",lx);
		fflush(stdout);
	}
	return 0;
}


Measured memory_bytes: 852
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;


int  main (){
	string s; cin >> s;
	s[3] =  s[3]+1;
	for (int i = 0; i < s.size(); i++) {
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll M=1e9+7, Mf[200002];
void Mfi(){
    Mf[0]=Mf[1]=1;
    for(int i=2;i<200002;i++)Mf[i]=(Mf[i-1]*i)%M;
}
ll Mp(ll a, ll b){
    if(b==0)return 1;
    else if(b%2==0)return Mp((a*a)%M, b/2)%M;
    return (a*Mp(a, b-1))%M;
}
ll Mc(ll a, ll b){
    if(a<b)return 0;
    ll c = (Mf[a]*Mp(Mf[a-b], M-2))%M;
    return (c*Mp(Mf[b], M-2))%M;
}

int main(void){
    int n, m;
    ll c=1;
    cin>>n>>m;
    Mfi();
    for(int i=2;i<=m;i++){
        ll u=0;
        while(m%i==0){
            m/=i;
            u++;
        }
        c*=Mc(n+u-1, u);
        c%=M;
        if(i*i>m&&i<m)i=m-1;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  int ans = 0, MIN = INF;
  vector<int> A(N), B(N);
  REP(i, N){
    cin >> A[i] >> B[i];
    ans += A[i];
    if(A[i] > B[i]) chmin(MIN, B[i]);
  }

  if(A == B){
    cout << 0 << "\n";
    return 0;
  }

  cout << ans-MIN << "\n";

  return 0;
}

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

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

    long double W, H, x, y;

    cin >> W >> H >> x >> y;

    if ((W / 2 == x) && (H / 2 == y)) {
        cout << W * H / 2 << " " << 1 << '\n';
    } else {
        cout << setprecision(20) << W * H / 2 << " " << 0 << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int MOD = 1000000007;

int getNext(int& curr, const vector<int>& x, int p)
{
    if(curr == 21)
        return curr;

    int a = curr / 7;
    int b = curr % 7;
    b += p;
    if(x[a] < b)
        return -1;

    if(x[a] == b){
        ++ a;
        b = 0;
    }
    return a * 7 + b;
}

int main()
{
    int n;
    cin >> n;
    vector<int> x(3);
    for(int i=0; i<3; ++i)
        cin >> x[i];

    map<vector<int>, int> dp;
    dp[vector<int>()] = 1;
    long long ans = 0;
    for(int i=0; i<n; ++i){
        ans *= 10;
        ans %= MOD;

        map<vector<int>, int> nextDp;
        for(auto p : dp){
            vector<int> v = p.first;
            v.push_back(0);

            for(int a=1; a<=10; ++a){
                bool ok = false;
                vector<int> w;
                for(int curr : v){
                    int next = getNext(curr, x, a);
                    if(next == 21){
                        ok = true;
                        break;
                    }
                    else if(next != -1){
                        w.push_back(next);
                    }
                }

                if(ok){
                    ans += p.second;
                    ans %= MOD;
                }
                else{
                    nextDp[w] += p.second;
                    nextDp[w] %= MOD;
                }
            }
        }
        dp.swap(nextDp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int n , m , vis[N] ,x ;
int dp[N];

int solve(int idx){

    if(idx > n) return 0;
    if(vis[idx]) return 0;
    if(idx == n) return 1;

    int& ret = dp[idx];
    if(~ret) return ret;

    ret = ((solve(idx + 1))%MOD + solve(idx + 2)%MOD) % MOD;
    return ret;
}


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

    
    cin >> n >> m;
    
    loop(i , m){
        cin >> x;
        vis[x] = 1;
    }
    clr(dp , -1);
    int ans = solve(0);
    printf("%d\n",ans);


    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll a, b;

    cin >> a >> b;

    ll n = __gcd(a, b);

    int ans = 1;

    for (ll i = 2; i*i <= n; i++) {

        if (n%i == 0)
            ans++;
        while (n%i == 0)
            n/=i;
    }

    if (n > 1) ans++;

    cout << ans;

    return 0;
}


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

int c[N][N];

int LCSLength(char *a,char *b){
  int n,m,i,j;

  m = strlen(a);
  n = strlen(b);

  for(i=1;i<=m;++i)c[i][0] = 0;
  for(i=1;i<=n;++i)c[0][i] = 0;

  for(i=1;i<=m;++i){
    for(j=1;j<=n;++j){
      if(a[i-1]==b[j-1])c[i][j] = c[i-1][j-1] + 1;
      else if(c[i-1][j] >= c[i][j-1])c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }

  return c[m][n];
  
}

int main(){
  int n,i;
  char S[2][N];

  scanf("%d",&n);

    for(i=0;i<n;++i){
      scanf(" %s %s",S[0],S[1]);

      printf("%d\n",LCSLength(S[0],S[1]));
    }

  return 0;
}



Measured memory_bytes: 5648
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = a + b;
        if (c >= 24) c -= 24;
        Console.WriteLine(c);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int N;
 cin >> N;
 vector<pair<pair<string, int>, int> > v(N);
 for(int i=0; i<N; ++i){ 
   cin >> v[i].first.first >> v[i].first.second;
   v[i].second = i+1;
 }
 sort(all(v), [&](const pair<pair<string, int>, int> a, const pair<pair<string, int>, int> b){
             if(a.first.first < b.first.first)
               return true;
            else if(a.first.first == b.first.first)
              return (a.first.second > b.first.second) ? true : false;
            return false;
     });
 for(int i=0; i<N; ++i)
   cout << v[i].second << "\n";
 return 0;
}


Measured memory_bytes: 256
N, H = map(int, input().split())

Bs = []
max_swing_i = 0
max_swing = 0
throw_when_max_swing = 0
for i in range(N):
    a, b = map(int, input().split())
    if a > max_swing:
        max_swing = a
        throw_when_max_swing = b
        max_swing_i = i

    Bs.append(b)

# 取りのぞいて並び替える
#Bs = Bs.pop(max_swing_i)
Bs.sort(reverse=True)

ans = 0
for i in range(len(Bs)):
    if H <= 0 or Bs[i] < max_swing:
        break

    H -= Bs[i]
    ans += 1

if H > 0:
    if H % max_swing == 0:
        ans += H // max_swing
    else:
        ans += H // max_swing + 1

print(ans)


Measured memory_bytes: 7388
import java.util.*;

public class Main {
	int INF = 1 << 24;
	int n;
	int [][] data, work, ans;
	int [] vx = {0,-1,0,1};
	int [] vy = {0,0,1,0};
	boolean flg;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		while(dataset-- > 0){
			n = 10;
			data = new int[n][n];
			for(int i = 0 ; i < n; i++){
				for(int j = 0 ; j < n; j++){
					data[i][j] = sc.nextInt();
				}
			}
			work = new int[n][n];
			ans = new int[n][n];
			flg = false;
			dfs(0);
			
			for(int i = 0 ; i < n; i++){
				for(int j = 0 ; j < n; j++){
					System.out.print(ans[i][j]);
					if(j != 9){
						System.out.print(" ");
					}
					else{
						System.out.println();
					}
				}
			}
		}
	}

	private void dfs(int deep) {
		if(flg) return;
		if(deep == 10){
			boolean res = check();
			if(! res) return;
			flg = true;
			for(int i = 0 ; i < n; i++){
				for(int j = 0 ; j < n; j++){
					ans[i][j] = work[i][j];
				}
			}
			return ;
		}
		for(int i = 0 ; i <= 1; i++){
			work[0][deep] = i;
			for(int j = 0; j < vx.length; j++){
				int x = vx[j] + deep;
				int y = vy[j];
				if(! isOK(x,y)) continue;
				data[y][x] = data[y][x] ^ i;
			}
			dfs(deep + 1);
			for(int j = 0; j < vx.length; j++){
				int x = vx[j] + deep;
				int y = vy[j];
				if(! isOK(x,y)) continue;
				data[y][x] = data[y][x] ^ i;
			}
		}
	}

	private boolean isOK(int x, int y) {
		if(0 <= x && x < n && 0 <= y && y < n){
			return true;
		}
		return false;
	}

	private boolean check() {
		int [][] temp = new int[n][n];
		for(int i = 0 ; i < n;i++){
			for(int j = 0 ; j < n; j++){
				temp[i][j] = data[i][j];
			}
		}
		
		for(int i = 1; i < n; i++){
			for(int j = 0 ; j < n; j++){
				if(temp[i-1][j] == 1){
					work[i][j] = 1;
					temp[i-1][j] = 0;
					for(int k = 0; k < vx.length; k++){
						int x = vx[k] + j;
						int y = vy[k] + i;
						if(! isOK(x,y)) continue;
						temp[y][x] = temp[y][x] ^ 1;
					}
				}
				else{
					work[i][j] = 0;
				}
			}
		}
		for(int i = 0 ; i < n; i++){
			if(temp[9][i] == 1){
				return false;
			}
		}
		return true;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

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

int n;
int debt = 100000;
const int DIGITS = 1000;
const float INTEREST_RATE = 1.05;

int main()
{
    cin >> n;

    for (int i = 0; i < n; ++i) {
        debt = ((int)((debt * INTEREST_RATE + DIGITS - 1) / DIGITS)) * DIGITS;
    }

    cout << debt << endl;
    return 0;
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define repz(i, a) for (ll i = 0; i < (a); i++)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

int dx[8] = {0,1,1,1,0,-1,-1,-1};
int dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve()
{
  int n;
  cin >> n;
  int x = n%1000;
  if (x==0)
  {
    cout << 0 << endl;
    re;
  }

  cout << 1000-x << endl;
}

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



Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ii, ll>;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
// const ll N = ;

ll a, b, temp;

ll factorize(ll x) {
    ll ret = 1;
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) {
            ret++;
            while(x % i == 0) x /= i;
        }
    }
    if(x > 1) ret++;
    return ret;
}

void solve() {
    cin >> a >> b;
    temp = __gcd(a, b);
    cout << factorize(temp) << "\n";
}

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int num_test;
  cin>>num_test;
  while(num_test--){

    Int H, W;
    cin>>H>>W;
    vector<string> mp(H);
    cin>>mp;
    vector<Int> ord;
    for(Int i=0;i<H;i++)
      for(Int j=0;j<W;j++)
        if(mp[i][j] != '.') ord.push_back(mp[i][j]);

    sort(ord.begin(), ord.end());
    ord.erase(unique(ord.begin(), ord.end()), ord.end());

    function<_int(Int, vector<string> mp)> check=[&](Int idx, vector<string> mp){
      if(idx == (Int)ord.size()) return 1;

      char ch = ord[idx];
      Int left = 100, right = -100;
      Int top = 100, bottom = -100;
      for(Int i=0;i<H;i++)
        for(Int j=0;j<W;j++)
          if(mp[i][j] == ch){
            Min(left, j);
            Max(right, j);
            Min(top, i);
            Max(bottom, i);
          }

      Int valid = 1;
      for(Int i=top;i<=bottom;i++)
        for(Int j=left;j<=right;j++)
          valid &= mp[i][j] == ch || mp[i][j] == '!';

      if(!valid) return 0;

      for(Int i=0;i<H;i++)
        for(Int j=0;j<W;j++)
          if(mp[i][j] == ch) mp[i][j] = '!' ;

      return check(idx + 1, mp);
    };

    Int safe = 0;
    do{
      if(safe) break;
      safe |= check(0, mp);
    }while(next_permutation(ord.begin(), ord.end()));

    cout<<(safe? "SAFE":"SUSPICIOUS")<<endl;
  }
  return 0;
}



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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint M1,M2,D1,D2;
	cin >> M1 >> D1 >> M2 >> D2;
	// vector<llint> A(N);
	// rep(i,0,N) {
	// 	cin >> A[i];
	// }
	// string S;
	// cin >> S;
	// llint len;
	// len = S.length();
	
	
	//SOLVE
	llint ans=0;
	
	if ((M1+1 == M2) || ((M1 == 12)&&(M2 == 1))) {
		ans = 1;
	}
	
	//OUTPUT
	cout << ans << endl;
	
	return 0;
}






Measured memory_bytes: 256
import sys

def ket(anw,m):
    wk=len(anw)
    while sum(anw)<=wk*m:
        anw[wk-1]+=1
        for i in range(wk-1,-1,-1):
            if anw[i]<m+1:
                return(anw)
            else:
                anw[i-1]+=1
                for j in range(i,wk):
                    anw[j]=anw[i-1]
    anw=[0]*wk
    return(anw)

n,m,q = map(int,input().split()) 
abcd =[]
for i in range(q):
    abcd.append(list(map(int,input().split())))

wk = 0
an = [1]*n
anw = [1]*n
ten = tenw = 0
while sum(anw)<=n*m:
    for k in range(q):
        if anw[abcd[k][1]-1]-anw[abcd[k][0]-1]==abcd[k][2]:
            tenw += abcd[k][3]
        else:
            pass
    if ten < tenw:
        ten = tenw
        an = anw.copy()
        tenw = 0
    else:
        tenw = 0

    anw = ket(anw,m)
    if sum(anw) == 0:
        break

if ten == 0:
    print(0)
else:
    print(ten)

Measured memory_bytes: 9292