akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = -1;
    imfor(i, s.size() - 1) {
        int tmp = 0;
        set<char> s1, s2;
        for (int j = 0; j <= i; j++) {
            s1.insert(s[j]);
        }
        for (int j = i + 1; j < s.size(); j++) {
            s2.insert(s[j]);
        }
        for (auto x : s1) {
            if (s2.find(x) != s2.end()) {
                tmp++;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++) 
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int c[16],n,v[200005],dp[1<<16];
int dfs(int x){
	if(dp[x]!=-1)RE dp[x];
	int re=1000000000;
	rep(i,1,16){
		if(x&(1<<i)){
			rep(j,i+1,16){
				if(x&(1<<j)){
					re=min(re,dfs(x^(1<<i)^(1<<j)^(1<<(i^j)))+1+((x&(1<<(i^j)))?1:0));
				}
			}
			break;
		}
	}
	RE dp[x]=re;
}
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	cin>>n;
	int x,y,z;
	rep(i,1,n){
		cin>>x>>y>>z;
		v[x]^=z;v[y]^=z;
	}
	int ans=0;
	rep(i,0,n){
		c[v[i]]++;
	}
	FOR(i,1,15){
		ans+=c[i]/2;
		c[i]&=1;
	}
	int get=0;
	FILL(dp,-1);dp[0]=0;
	FOR(i,1,15)if(c[i])get^=(1<<i);
	cout<<dfs(get)+ans;
	RE 0;
}




Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		String way,place;
		Scanner sc = new Scanner(System.in);
		
		while(true){
			way = sc.next();
			if(way.equals("#")){
				break;
			}
			place = "A";
			
			for(int i=0;i<way.length();i++){
				if(place.equals("A")){
					if((way.charAt(i)+"").equals("0")){
						place = "X";
					}else{
						place = "Y";
					}
				}else if(place.equals("X")){
					if((way.charAt(i)+"").equals("0")){
						place = "NA";
					}else{
						place = "Z";
					}
				}else if(place.equals("Y")){
					if((way.charAt(i)+"").equals("0")){
						place = "X";
					}else{
						place = "NA";
					}
				}else if(place.equals("Z")){
					if((way.charAt(i)+"").equals("0")){
						place = "W";
					}else{
						place = "B";
					}
				}else if(place.equals("W")){
					if((way.charAt(i)+"").equals("0")){
						place = "B";
					}else{
						place = "Y";
					}
				}else if(place.equals("B")){
					if((way.charAt(i)+"").equals("0")){
						place = "Y";
					}else{
						place = "X";
					}
				}else{
					break;
				}
			}
			
			if(place.equals("B")){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];

    rep(i, k, n) {
        if (a[i - k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


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

// typedef long long ll;
long long n, m = 1e9 + 7;
long long poww(long long a, long long b)
{
	if (b == 0) return 1;
	if (b == 1) return a % m;
	long long x = poww(a, b / 2) % m;
	x = (x * x) % m;
	if (b % 2 == 0) return (x) % m;
	else return (x * a) % m;
}
int gcd(int a, int b) {
	if (b == 0) return a;
	if (b == 1) return 1;
	return gcd(b, a % b);
}
int summ(long long n) {
	int sum = 0;
	for (int i = 0; i < 18; i++)
	{
		sum += n % 10; n /= 10;
		if (n == 0) break;
	}
	return sum;
}
vector<long long> fc;
long long fact(long long n) {
	fc[0] = 1; fc[1] = 1; fc[2] = 2;
	for (long long i = 3; i <= n; i++)
	{
		fc[i] = (i % m * fc[i - 1] % m) % m;
	}
	return fc[n] % m;
}
bool check(unordered_map<int, int>& map) {
	return 0;
}

int main() {
	// ios::sync_with_stdio(false); cin.tie(NULL);
	int t;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++)
	{cin >> h[i];}
	int a[n]; a[0] = 0; a[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++)
	{
		a[i] = min(a[i - 2] + abs(h[i] - h[i - 2]), a[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << a[n - 1] << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
ll mod=1e9+7;
int main()
{
    ll n ;
    cin >> n ;
    ll sum=0 , ans=0;
    int arr[n];
    for(int i = 0 ; i < n ; i++)
    {
        cin >> arr[i];
        sum+=arr[i];
    }
    for(int i = 0 ; i < n ; i++)
    {
        sum-=arr[i];
        ans+=((arr[i]%mod)*(sum%mod));
        ans%=mod;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n, greater<int>());
	int ans = 0;
	for(int i = 0; i < k; i++) ans += a[i];
	cout << ans;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ball = [1]*n
flg = [False]*n
flg[0] = True

for _ in range(m):
    x, y = map(int, input().split())
    if flg[x-1]:
        flg[y-1] = True
    if ball[x-1] == 1 and flg[x-1]:
        flg[x-1] = False
    ball[y-1] += 1
    ball[x-1] -= 1
    # print(x, y, ball, flg)

ans = flg.count(True)
print(ans)


Measured memory_bytes: 10384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;
    cin>>s;
    int max=0;
    int count=0;
    for(int i=0;i<3;i++){
        if(s.at(i)=='R'){
            count++;
        }else{
            if(count>max){
                max=count;
            }
            count=0;
        }
    }
    if(count>max){
        max=count;
    }
    cout<<max<<endl;
}

Measured memory_bytes: 3592
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

set<char> s;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		char c;
		cin>>c;
		s.insert(c);
	}
	if(s.size()==3) cout<<"Three";
	else cout<<"Four";
}

Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

void solve()
{
    string s;cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

ll two(ll n)
{
    assert(n >= 0);
    if (n == 0) {
        return numeric_limits<ll>::max();
    }
    ll cnt = 0;
    while (n % 2 == 0) {
        n /= 2;
        cnt++;
    }
    return cnt;
}

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

    if (A % 2 == 1 and B % 2 == 1 and C % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    if (A == B and B == C) {
        cout << -1 << endl;
        return 0;
    }
    const ll a = two(abs(A - B));
    const ll b = two(abs(B - C));
    const ll c = two(abs(C - A));

    cout << min({a, b, c}) << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, K, ans = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a >= K)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def bubbleSort(C1,N):
    for i in range(N):
        for j in range(N-1,i,-1):
            if C1[j][1] < C1[j-1][1]:
                C1[j],C1[j-1] = C1[j-1],C1[j]
    return C1[:]
    
def selectSort(C2,N):
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            if C2[minj][1] > C2[j][1]:
                minj = j
        C2[i],C2[minj] = C2[minj],C2[i]
    return C2[:]

N = int(input())
C1 = input().split()
C2 = C1[:]

C1 = bubbleSort(C1,N)
C2 = selectSort(C2,N)

print(*C1)
print("Stable")
print(*C2)
if C1 == C2:
    print("Stable")
else:
    print("Not stable")


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

using namespace std;

int main()
{
	int n;
	int x = 0;
	int max = 0;
	string str;
	cin >> n >> str;
	for (int i = 0; i < n; i++) {
		if (str[i] == 'I') x++;
		if (str[i] == 'D') x--;
		if (x > max) max = x;
	}
	cout << max << endl;
	
}

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

vector<bool> sieve_of_eratosthenes(int n) {
  /* O(n log log n) */
  vector<bool> is_prime(n, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<=n; i++)
    if(is_prime[i]) 
      for(int k=2; k * i <= n; k++)
        is_prime[k*i] = false;
  return is_prime;
}

vector<int> prime_list(int n) {
  /* O(n log log n) */
  auto is_prime = sieve_of_eratosthenes(n);
  vector<int> primes;
  for(int i=0; i<=n; i++) 
    if(is_prime[i]) 
      primes.push_back(i);
  return primes;
}

map<int, int> prime_factorization(int n) {
  /* O(n log log n) */
  auto primes = prime_list((int)ceil(sqrt(n)));
  map<int,int> factors;
  for(auto i : primes) {
    while (n%i==0) {
      factors[i]++;
      n /= i;
    }
  }
  if(n!=1) factors[n]++;
  return factors;
}

bool is_prime(int n){
  /* O(log n) */
  if(n<=1) return false;
  for(int i=2;i*i<=n;i++) if(n%i==0) return false;
  return true;
}

signed main() {
#if 0
  // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
  const int n_max = 999999;
  auto is_prime = sieve_of_eratosthenes(n_max);
  vector<int> csum(n_max, 0);
  for(int i=2; i<=n_max; i++) 
    csum[i] = csum[i-1] + (is_prime[i] ? 1 : 0);

  int n;
  while(cin >> n) cout << csum[n] << endl;

#elif 0
  // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A
  int n;
  cin >> n;
  cout << n << ":";
  auto factors = prime_factorization(n);
  for(auto f : factors) for(int i=0; i<f.second; i++) cout << " " << f.first;
  cout << endl;

#else
  // https://atcoder.jp/contests/abc149/tasks/abc149_c
  int x;
  cin>>x;

  int p=x;
  while(!is_prime(p)) p++;

  cout << p << endl;
#endif
}


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

using namespace std;

#define int long long

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

signed main(void) {
  int m1, m2, d1, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2) cout << 1 << endl;
  else cout << 0 << endl;
}

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

int n;
vector<int> G[MAX];
int d[MAX];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		d[i] = -1;
	}
	for (int i = 0, u, k; i < n; i++) {
		cin >> u >> k;
		for (int j = 0, v; j < k; j++) {
			cin >> v;
			G[u - 1].push_back(v - 1);
		}
	}
	queue<int> q;
	q.push(0);
	d[0] = 0;
	while (!q.empty()) {
		for (int &v : G[q.front()]) {
			if (d[v] == -1) {
				q.push(v);
				d[v] = d[q.front()] + 1;
			}
		}
		q.pop();
	}

	for (int i = 0; i < n; i++) {
		cout << i + 1 << ' ' << d[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
import sys
sys.setrecursionlimit(10**9)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

H, W = mi()
C = li2(10)
a = li2(H)
memo = [C[i][1] for i in range(10)]
flag = -1
'''
def dfs(column, m):
    if column == 1:
        global flag
        flag = max(m, flag)
    for i in range(10):
        if i!=column and C[column][i] < m:
            dfs(i, m-C[column][i])
    #return

for i in range(10):
    if i != 1:
        dfs(i, C[i][1])
        if flag != -1:
            memo[i] = C[i][1]-flag
        flag = -1
'''
flag = 10**9

def dfs(col, m):
    if col == 1:
        global flag
        flag = min(m, flag)
    for i in range(10):
        if i != col and m + C[col][i] < lim:
            dfs(i, m + C[col][i])

for i in range(10):
    if i != 1:
        flag = 10**9
        lim = C[i][1]
        dfs(i, 0)
        if flag != 10**9:
            memo[i] = flag

ans = 0
for i in range(H):
    for j in range(W):
        if abs(a[i][j]) != 1:
            ans += memo[a[i][j]]

print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

long double dfs(int v, int par, int d, long double p,
                vector<int> &cnt, const vector< vector< pair<int,int> > > &t){
  cnt[d]++;
  long double res = 0;
  for(int i=0;i<t[v].size();i++){
    pair<int,int> e = t[v][i];
    int u = e.first, c = e.second;
    if(u==par) continue;
    res += (dfs(u,v,d+1,p,cnt,t) + c) * p;
  }
  return res;
}

int main(){
  long double p; cin >> p;
  int n; cin >> n;
  vector< vector< pair<int,int> > > t(n);
  rep(i,n-1){
    int a,b,c;
    cin >> a >> b >> c; a--; b--;
    t[a].push_back(MP(b,c));
    t[b].push_back(MP(a,c));
  }
  vector<int> cnt(n,0);
  cnt[0]++;
  long double exp = dfs(0,-1,0,p,cnt,t);

  long double ans = 0, k = 1;
  rep(i,n){
    ans += exp*cnt[i]*k;
    k *= p;
  }
  cout << fixed << setprecision(9) << ans << endl;
}

Measured memory_bytes: 19800
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;

typedef long long ll;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25

int n;
ll x;

int main()
{
	cin >> n;
	cin >> x;
	ll a[n];
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	rep(i,n) {
		if (a[i] <= x) {
			ans++;
			x -= a[i];
		} else {
			break;
		}
	}
	if (x > 0 && n == ans) ans--;
	ans = max(ans, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=[int(x) for x in list(input())]
l=len(n)
k=int(input())
"""
桁DP
桁数,0でないcount,ギリギリflagでdp
"""
dp = [[[0 for _ in range(2)] for _ in range(k+1)] for _ in range(l+1)]
#n[0]は0ではない
dp[1][0][0] = 1
dp[1][1][0] = n[0] - 1
dp[1][1][1] = 1
for i in range(2,l+1):
  for j in range(0,min(i,k)+1):
    if j > 0:
      dp[i][j][1] += dp[i-1][j-1][1]*(n[i-1]>0)
      dp[i][j][0] += dp[i-1][j-1][0]*9+dp[i-1][j-1][1]*max(0,n[i-1]-1)
    dp[i][j][1] += dp[i-1][j][1]*(n[i-1]==0)
    dp[i][j][0] += dp[i-1][j][0] + dp[i-1][j][1]*(n[i-1]>0)
    #print(i,j,dp[i][j])
print(sum(dp[l][k]))

Measured memory_bytes: 9300
N,M=map(int,input().split())
A=list(map(int,input().split()))
from itertools import accumulate
from collections import Counter
A=[0]+list(map(lambda x:x%M,accumulate(A)))
A=Counter(A).values()
ans=0
for a in A:
    ans+=a*(a-1)//2
print(ans)

Measured memory_bytes: 14408
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < 3; i++) {
			set.add(sc.nextInt());
		}
		System.out.println(set.size());
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public void run() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println((x - a) % b);
	}

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


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a % 2 == 0 || b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}

		sc.close();
	}
}

Measured memory_bytes: 20692
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;

int main(){
  int n,m;
  while(cin >> n >> m , n+m){
    cin.clear();
    int a,b;
    int cne[501][501] = {{0}};
    for(int i = 0 ; i < m ; i++){
      cin >> a >> b;
      if(a > b)swap(a,b);
      cne[a][b] = 1;
      cne[b][a] = 1;
    }
    int f[501] = {0};
    int cnt = 0;
    for(int i = 1 ; i <= n ; i++){
      if(cne[1][i]){
	f[i] = 1; 
	for(int j = 2 ; j <= n ; j++ ){
	  if(cne[i][j]){
	    f[j] = 1;
	  }
	}
      }
    }
    for(int i = 1 ; i <= n ; i++ ){
      if(f[i])cnt++;
}
    cout << cnt << endl;

  }
  return 0;
}

Measured memory_bytes: 2148
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
#======================================================#

def main():
    n = II()
    sumv = 0
    divs = enumerate_divs(n)
    for p,q in divs:
        if p!=1:
            if n//(p-1) == n%(p-1):
                sumv += p-1
        if q!=1:
            if n//(q-1) == n%(q-1):
                sumv += q-1
    print(sumv)

if __name__ == '__main__':
    main()

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int T;
    cin >> T;
    rep(t, T){
        int n, k;
        cin >> n >> k;
        vector<int> x(n);
        rep(i, n){
            cin >> x[i];
        }
        vector<int> diff(n - 1);
        rep(i, n - 1){
            diff[i] = x[i + 1] - x[i];
        }
        SORT(diff);
        int ans = 0;
        rep(i, n - k){
            ans += diff[i];
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

ll a, b, n;

ll f(ll x) {
  return (a * x) / b - a * (x / b);
}
/*
y = (a * x) / b - a * (x / b);
b * y = (a * x) - a * x;
*/
int main() {
  cin >> a >> b >> n;
  cout << f(min(b-1, n)) << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<array>
#include<string>
#include<map>
#include<utility>

using namespace std;

int main(){
    int N;
    cin >> N;
    int value, min, count;
    min = N;
    count = 0;
    
    for(int i=0;i<N;++i){
        cin >> value;
        if(value <= min){
            ++count;
        }
        min = min >= value ? value : min;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 1000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
/////bitset<maxx/2>vis;
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//bool isprime(ll a)
//{
//    if(a==2){
//        return true;
//    }
//    if(a%2==0){
//        return false;
//    }
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++){
//        if(a%prime[i]==0){
//            return false;
//        }
//    }
//    return true;
//}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
int n,m,pp;
vector<int>vec[100005];
int dp[100005];
bool vis[100005];
int ans;
int dfs(int xx)
{
    if(vis[xx]==true){
        return dp[xx];
    }
    vis[xx]=true;
    for(int i=0;i<vec[xx].size();i++){
        dp[xx]=max(dp[xx],1+dfs(vec[xx][i]));
    }
    return dp[xx];
}
void Dufaux()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        vec[a].pb(b);
    }
    ans=0;
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=n;i++){
        if(dp[i]!=0){
            ans=max(ans,dp[i]);
        }
        else{
            if(vec[i].size()){
                for(int j=0;j<vec[i].size();j++){
                    ans=max(ans,dfs(vec[i][j]));
                }
            }
        }
    }
    cout<<ans+1<<endl;
}
int main()
{
	FastIO;
	///sieve();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 11632
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define ll long long
ll ans,ans1;
int n;
ll a[15][15];
int main(){
	scanf("%d",&n);
	ans=0;ans1=0;
	int x=0,y=0,j;	
	for(int i=1;i<=n;i++){
		j=i;
		y=j%10;
		while(j/10)j/=10;
		x=j;
		ans+=a[y][x];
		if(x==y)ans1++;
		a[x][y]++;
	}
	cout<<ans*2+ans1<<endl;
	return 0;
}


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

int main(void) 
{
	int w, h, x, y ,r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if((x + r <= w && x - r >= 0) && (y + r <= h && y - r >= 0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
    return 0;
}


Measured memory_bytes: 2692
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	if(k==0){
		cout << n*n << endl ;
		return 0 ;
	}
	ll ans = 0 ;
	for(int i=k+1;i<=n;i++){
		ll p = n/i ;
		ll r = n%i ;
		ans += p*(i-k)+(0>r+1-k?0:r+1-k) ;
	}
	cout << ans << endl ;
}


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


Measured memory_bytes: 2588
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N;


int digit(int n){
	return log10(n)+1;
}


int solve(){
	int ans = INF;
	repif(i, 1, i*i <= N)
		if(N%i == 0) chmin(ans, max(digit(i), digit(N/i)));
	return ans;
}


signed main(){
	cin >> N;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 512
<?php
  fscanf(STDIN, "%d", $n);

  $ans = $n - 1;
  for ($i=2; $i*$i<=$n; $i++) {
    if ($n % $i == 0) {
      $ans = min($ans, $i + $n/$i - 2);
    }
  }

  echo $ans . "\n";
?>

Measured memory_bytes: 4604
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <bitset>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define rrep(i,a,b) for(ll i=a-1;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define popcount __builtin_popcount
#define LIST(a) memset(a, 0, sizeof(a))
#define REVERCE greater<>()


int main(void){
    ll n, ans;
    cin >> n;
    vector<int> a(n), b(n), c(n), c_on_b(n, 0), rui(n, 0);
    rep(i, 0, n) cin >> a[i];
    sort(ALL(a));
    rep(i, 0, n) cin >> b[i];
    sort(ALL(b));
    rep(i, 0, n) cin >> c[i];
    sort(ALL(c));
    // a < b < cが必要
    // c_on_b
    rep(i, 0, n){
        ans += (lower_bound(ALL(a), b[i]) - a.begin())*(c.end() - upper_bound(ALL(c), b[i]));
    }
    cout << ans << endl;
    return 0;
}


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

###
# main
if(__name__ == '__main__'):
    # input
    n, k = map(int, input().split(" "))

    times = n // k
    ans = n - k * times

    if ans < k-ans:
        print(ans)
    else:
        print(k-ans)

# else:
    # do nothing


Measured memory_bytes: 2940
import queue

K = int(input())

que_lunlun = queue.Queue()
for i in range(1, 10):
    que_lunlun.put(i)

for _ in range(K):
    now_lunlun = que_lunlun.get()
    
    first_digit = now_lunlun % 10
    if first_digit != 0:
        que_lunlun.put(now_lunlun*10 + first_digit-1)
    
    que_lunlun.put(now_lunlun*10 + first_digit)

    if first_digit != 9:
        que_lunlun.put(now_lunlun*10 + first_digit+1)
    
print(now_lunlun)

Measured memory_bytes: 57300
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;
#define chmax(a, b) a=(((a)<(b))?(b):(a))
#define chmin(a, b) a=(((a)>(b))?(b):(a))
#define F first
#define S second
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T> ostream& operator << (ostream& s, const set<T>& st) {
   s << "{";
   for (auto i = st.begin(); i != st.end(); ++i) {
      s << *i;
      if (next(i) != st.end()) s << ", ";
   }
   s << "}";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}



signed main()
{
   int N, M; cin >> N >> M;
   V<int> A(N);
   REP(i, N) {
      cin >> A[i];
   }

   V<int> sum(N+1);
   REP(i, N) {
      sum[i+1] = sum[i] + A[i];
   }

   map<int,int> cnt;
   REP(i, N+1) {
      ++cnt[sum[i] % M];
   }

   int ans = 0;
   EACH(it, cnt) {
      ans += it->S * (it->S -1) / 2;
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 5760
#include"bits/stdc++.h"

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int i = 0; i < 3; i++)
	{
		if (S[i] == T[i]) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
    int N, sum = 1;

    vector<vector<char>> data(2, vector<char>(3));

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

    if (data.at(0).at(0) == data.at(1).at(2) && data.at(0).at(1) == data.at(1).at(1) && data.at(0).at(2) == data.at(1).at(0)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

int main(){
    long long n,m,ans=0;
    cin >> n >> m;
    if(n>1&&m>1) ans=(n-2)*(m-2);
    else if(n==1&&m==1) ans=1;
    else if(n==1&&m!=1) ans=m-2;
    else if(m==1&&n!=1) ans=n-2;
    
    cout << ans << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;



void solve() {
    int r; cin >> r;
  	cout << r * r << endl;
}

signed main() {
    solve();
    return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
int a,b;
int main(){
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
p=998244353
n=int(input())
d=list(map(int,input().split()))
dep = [0]*n
for x in d:
  dep[x] += 1

ans = 1 if d[0]==0 and dep[0]==1 else 0
for i in range(1,n):
  ans *= (dep[i-1]%p) ** dep[i] % p
  ans %= p

print(ans)

Measured memory_bytes: 20516
#include <stdio.h>

int main(void){
  int n,i,answer,x;
  while(1){
    scanf("%d",&n);
    if(n==0)  break;
    else{
      int five=0;
      for(i=n;i>0;i--){
	x=i;
	while(x%5==0&&x!=1){
	  five++;
	  x=x/5;
	  //printf("/f");
	}
      }
      printf("%d\n",five);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;

int main()
{
  int N, M, p, y;
  cin >> N >> M;
  vector<vector<int>> vv(M, vector<int>(4));
  for(int i = 0; i < M; i++){
    cin >> p >> y;
    vv.at(i).at(0) = p;
    vv.at(i).at(1) = y;
    vv.at(i).at(2) = i;
    vv.at(i).at(3) = 0;
  }
  sort(vv.begin(), vv.end(),
    [](auto const &lvv, auto const &rvv)->bool{
      if(lvv.at(0) != rvv.at(0)){
        return lvv.at(0) < rvv.at(0);
      }else{
        return lvv.at(1) < rvv.at(1);
      }
  });
  for(int i = 0, j = 1; i < M; i++){
    if(i != 0 && vv.at(i).at(0) != vv.at(i-1).at(0)) j = 1;
    vv.at(i).at(3) = j;
    j++;
  }
  sort(vv.begin(), vv.end(), [](auto const &lvv, auto const &rvv)->bool{
    return lvv.at(2) < rvv.at(2);
  });
  
  for(int i = 0; i < M; i++){
    printf("%06d", vv.at(i).at(0));
    printf("%06d\n", vv.at(i).at(3));
  }
  
  return 0;
}

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e3 + 7;
const int N = 2e5 + 7;
const int M = 22;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);

int n;
int a[N];
int ans[N];
vector < int > v[N];
vector < int > d;

void dfs( int x , int p , int res )
{
    ans[x] = res;
    for( auto y : v[x] ){
        if( y == p )continue;
        int cnt = (int)(upper_bound( d.begin() , d.end() , a[y] ) - d.begin());
        int mx = res;
        int f = 0;
        if( d[cnt - 1] < a[y] && a[y] < d[cnt] ){
            f = d[cnt];
            d[cnt] = a[y];
            mx = max( mx , cnt );
        }
        dfs( y , x , mx );
        if( f ){
            d[cnt] = f;
        }
    }
}

void solve1()
{
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> a[i];
    }
    d.resize(n + 1 , 2e9);
    d[0] = -2e9;
    for( int i = 1; i < n; i++ ){
        int x,y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    d[1] = a[1];
    dfs( 1 , 1 , 1 );
    for( int i = 1; i <= n; i++ ){
        cout << ans[i] << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 30812
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n,x,y; cin>>n>>x>>y;
    vector<int> dist(n,0);

    for (int i = 1; i <= n-1; i++)
    {
      for (int j = i+1; j <= n; j++)
      {
        if(i<=x && j >= y) {
          dist[abs(i-j)-(y-x)+1]++;
        }else if(i<=x && j>x && j<y){
          dist[min(abs(i-x)+1+abs(y-j), abs(i-j))]++;
        }else if(i>x && i<y){
          dist[min(abs(i-x)+1+abs(y-j), abs(i-j))]++;
        }else{
          dist[abs(i-j)]++;
        }
      }
    }
    for (int i = 1; i < n; i++)
    {
      cout << dist[i] << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
P sg[10];
int d[1005][1005]={};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int fi[1005][1005];
int ans[1005][1005]={};
bool graph[55][55];
bool visited[55];
int a[55],b[55];

signed main(){
    int a,b;cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
    return 0;
}


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

#define MAX 1000

void show(int A[], int N) {
  for ( int i = 0; i < N - 1; i++ ) {
    cout << A[i] << " " << flush;
  }
  cout << A[N - 1] << endl;
}

void insertionSort(int A[], int N) {
  show(A, N);

  for ( int i = 1; i < N; i++ ) {
    int v = A[i];
    int j = i - 1;
    while ( j >= 0 && A[j] > v ) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    show(A, N);
  }
}

int main() {
  int N;
  int A[MAX];

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

  insertionSort(A, N);

  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    double res = 0;
    for (int i = 0; i < n; ++i) {
        res += 1.0 / a[i];
    }
    res = 1 / res;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int INF = (1LL << 31) - 1;

struct SegmentTree {
    int n;
    vector<int> v;

    SegmentTree(int n_, int x) : v(n_ * 4) {
        for (int i = 0; (1 << i) <= n_; ++i, n = 1 << i);
        for (int i = 0; i < n_ * 4; ++i)
            v[i] = x;
    }

    void set(int i, int x) {
        i += n - 1;
        v[i] = x;
        for (; i > 0;) {
            i = (i - 1) / 2;
            v[i] = min(v[2 * i + 1], v[2 * i + 2]);
        }
    }

    int find(int l, int r) {
        return find(l, r, 0, 0, n);
    }

    int find(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)
            return INF;
        if (a <= l && r <= b) {
            return v[k];
        } else {
            int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    SegmentTree st(n, INF);

    for (int i = 0; i < q; ++i) {
        //for (int i = 0; i < st.n * 2 - 1; ++i) printf(" %d", st.v[i]); puts("");
        int c, x, y;
        scanf("%d %d %d", &c, &x, &y);
        if (c == 0) {
            st.set(x, y);
        } else /*if (c == 1)*/ {
            printf("%d\n", st.find(x, y + 1));
        }
    }

    return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    for(int z=0;z<t;z++){
        int n,k;
        cin >> n >> k;
        vector<int> x(n);
        for(int i=0;i<n;i++) cin >> x[i];
        vector<int> sub(n-1);
        for(int i=0;i<n-1;i++) sub[i]=x[i+1]-x[i];
        sort(sub.begin(),sub.end());
        int ans=0;
        for(int i=0;i<n-k;i++) ans+=sub[i];
        cout << ans << endl;
    }
}



Measured memory_bytes: 3684
n, m, c = map(int, input().split())
ans = 0
b = list(map(int, input().split()))

for i in range(n):
    a = list(map(int, input().split()))
    cal = 0
    for j in range(len(a)):
        cal += a[j] * b[j]
    cal += c
    if cal > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct FenwickTree{
	vector<ll> data;
	FenwickTree(int n):data(n+1){}
	void AddRange(int i,int x){
		for(;i;i-=i&-i)
			data[i]+=x;
	}
	void AddRange(int i,int j,int x){
		AddRange(i,-x);
		AddRange(j,x);
	}
	int Get(int i){
		ll res=0;
		for(i++;i<data.size();i+=i&-i)
			res+=data[i];
		return res;
	}
};

int main()
{
	for(int n;scanf("%d",&n),n;){
		FenwickTree ft(86400);
		while(n--){
			int h[2],m[2],s[2];
			rep(i,2) scanf("%d:%d:%d",h+i,m+i,s+i);
			int b=h[0]*3600+m[0]*60+s[0];
			int e=h[1]*3600+m[1]*60+s[1];
			ft.AddRange(b,e,1);
		}
		int res=0;
		rep(i,86400)
			res=max(res,ft.Get(i));
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 1860
#include <stdio.h>
#include <vector>

int main(void) {
  int n, i, j, max = 0, ans = 0;
  scanf("%d", &n);
  int t[n];
  std::vector<int> v;
  for(i = 0; i < n; ++i) {
    scanf("%d", &t[i]);
    if(max < t[i]) max = t[i];
  }
  for(i = 1; i <= max; ++i) if(!(max % i)) v.push_back(i);
  for(i = 0; i < n; ++i) {
    for(j = 0;; ++j) {
      if(v[j] >= t[i]) {
        ans += v[j] - t[i];
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3056