akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    string s,t;
    cin>>s>>t;
    if(t.find(s)==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
    int t;
   // cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,min1=10000000000000,max2=-100;
 // char c;
  
  long long int a[1000000];
  memset(a,0,sizeof(a));
  cin>>n;
  //p=n;
  for(i=0;i<n;i++)
  {
      cin>>p;
      a[p]++;
      o=o+p;
  }
  cin>>k;
  while(k--)
  {
      cin>>f>>p;
      o=o-a[f]*f+a[f]*p;
    
      a[p]=a[p]+a[f];
        a[f]=0;
        
        cout<<o<<"\n";
        }
    }
 return 0;
}


Measured memory_bytes: 11492
N=int(input())
A=[str(i)for i in range(1,10)]
ans=0
for a in A:
    for b in A:
        countA=0
        if a==b and int(a)<=N:
            countA+=1
        for i in range(5):
            m=int(a+'0'*i+b)
            M=int(a+'9'*i+b)
            if m<=N:
                if M<=N:
                    countA+=10**i
                else:
                    while m<=N:
                        countA+=1
                        m+=10

        countB=0
        if b==a and int(b)<=N:
            countB+=1
        for i in range(5):
            m=int(b+'0'*i+a)
            M=int(b+'9'*i+a)
            if m<=N:
                if M<=N:
                    countB+=10**i
                else:
                    while m<=N:
                        countB+=1
                        m+=10

        ans+=countA*countB
print(ans)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)

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

  ll ans = a-b;
  ll amari = k % 2;

  if(amari == 0){
    cout << ans << endl;
  }
  else{
    cout << ans * (-1) << endl;
  }
}       

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

#define ll long long

int main() {
    ll d,t,s;
    cin>>d>>t>>s;
    double tt=t;
    double tv=(1.0*d) / (1.0*s);
    if(tv>tt) {
        cout<<"No"<<endl;
    } else {
        cout<<"Yes"<<endl;
    }

}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
  char a,b,c;
  int n;

  a = getchar();
  b = getchar();
  c = getchar();

  if(a>c)
    printf(">\n");
  else if(a<c)
    printf("<\n");
  else
    printf("=\n");

  return 0;
}


Measured memory_bytes: 128
A, B, C, X, Y = map(int, input().split())

ans = 1000000007
for i in range(max(X, Y) + 1):
    i_C = 2 * i
    i_A = max(0, X - i)
    i_B = max(0, Y - i)
    #
    ans = min(ans, A * i_A + B * i_B + C * i_C)

print(ans)


Measured memory_bytes: 2940
data = list(map(int,input().split()))
N = data[0]
flag = 0
for i in range(1,10,1):
  div = N / i
  pl = N % i
  if 1<=div<=9 and pl==0:
    flag = 1
    break
if flag == 0:
  print("No")
else:
  print("Yes")
  

Measured memory_bytes: 2940
//????????¶??????C++???????????¨";"?????\??????????????????????????????
#include<iostream>
using namespace std;

int N,A[10010];
int min(){
  int k;
  k = A[0];
  for(int i = 0;i < N;i++){
    if(k > A[i]){
      k = A[i];
    }
  }
  return k;
}

int max(){
  int k;
  k = A[0];
  for(int i = 0;i < N;i++){
    if(k < A[i]){
      k = A[i];
    }
  }
  return k;
}

signed long int sum(){
  signed long int k;
  k = 0;
  for(int i = 0;i<N;i++){
    k+=A[i];
  }
  return k;
}

int main(){
  cin >> N;
  for (int i=0; i<N;i++){
    cin >> A[i];
  }
  cout << min() << " " << max() << " " << sum() << endl;
}

Measured memory_bytes: 3112
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Usize1},
};

#[fastout]
fn main() {
    input! {
        n : i32,
        x : i32,
        t : i32
    }
    println!("{}", (n+x-1)/x*t);
}


Measured memory_bytes: 2204
#include<stdio.h>
#define MAX 100000

typedef long long llong;
int n, k;
llong t[MAX];

int solve();
int check(llong p);

int main(void){

	int i;
	llong ans;

	scanf("%d %d", &n, &k);
	for(i =0;i<n;i++){
		scanf("%d", &t[i]);
	}
	ans = solve();
	
	printf("%d\n", ans);
	return 0;
}


int check(llong p){
	int  j, i = 0;
	llong s;
	for( j =0;j<k;j++){
		s = 0;
		while(s + t[i] <=p){
			s+= t[i];
			i++;
			if(i ==n){
				return n;
			}
		}
		
	}
	return i;
	
}

int solve(){
	llong left =0;
	llong right = 100000*10000;
	llong mid;
	while(right -left >1){
		mid = (left +right)/2;
		int v = check(mid);
		if(v>=n){
			right = mid;}
		else{left = mid;}
	}
	
	return right;
	
}


Measured memory_bytes: 2636
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cstring>

using namespace std;

struct pairhash {
public:
  template <typename T, typename U>
  std::size_t operator()(const std::pair<T, U> &x) const
  {
    return std::hash<T>()(x.first) ^ std::hash<U>()(x.second);
  }
};

vector<int> s;
int mem[100001][201];

const int MOD = 1e9 + 7;

vector<int> pos;

long long dp(int x, int rem) {
  if (x == 0) {
    return 0;
  }
  if (mem[x][rem] != -1) { return mem[x][rem]; }
  int ans = 0;
  if (rem > 0) {
    ans = (dp(x, rem - 1) * rem) % MOD;
  }
  if (x < s[0]) {
    if (rem == 0) ans = x;
    //cerr << "go x: " << x << " rem: " << rem << " ans: " << ans << endl;
    return mem[x][rem] = ans;
  }

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] > x) break;
    int xx = x % s[i];
    ans = ans + dp(xx, rem + pos[x] - pos[xx] - 1);
    while (ans >= MOD) ans -= MOD;
  }
  //cerr << "mem x: " << x << " rem: " << rem << " ans: " << ans << endl;
  return mem[x][rem] = ans;
}

int main() {
  memset(mem, -1, sizeof(mem));
  int n,x;
  cin >> n >> x;
  s.resize(n);
  for (auto& a : s) cin >> a;
  sort(s.begin(),s.end());
  int rem = 0;
  pos.resize(x + 1);
  int p = 0;
  for (int i = 0; i <= x; ++i) {
    while (p < s.size() && s[p] <= i) p++;
    pos[i] = p;
  }
  rem = s.size() - pos[x];
  //cerr << "rem: " << rem << endl;
  cout << dp(x, rem);
}


Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s == "SUN"){
    cout << 7 << endl;
    return 0;
  }
  if(s == "MON"){
    cout << 6 << endl;
    return 0;
  }
  if(s == "TUE"){
    cout << 5 << endl;
    return 0;
  }
  if(s == "WED"){
    cout << 4 << endl;
    return 0;
  }
  if(s == "THU"){
    cout << 3 << endl;
    return 0;
  }
  if(s == "FRI"){
    cout << 2 << endl;
    return 0;
  }
  if(s == "SAT"){
    cout << 1 << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int w, h, cnt;
int island[51][51];
int dx[] = {1, 1, 0, -1, -1, -1,  0,  1};
int dy[] = {0, 1, 1,  1,  0, -1, -1, -1};

bool check(int nx, int ny){

  if(nx < 0 || ny < 0 || w <= nx || h <= ny)return false;
  else return true;

}

void dfs(int sy, int sx){

  island[sy][sx] = 0;

  for(int i = 0 ; i < 8 ; i++){
    int nx = sx + dx[i];
    int ny = sy + dy[i];
    if(!check(nx, ny)) continue;
    if(island[ny][nx]) dfs(ny, nx);
  }
}

int main(void){

  while(cin >> w >> h, w || h){

    for(int i = 0 ; i < h ; i++)
      for(int j = 0 ; j < w ; j++)
	cin >> island[i][j];

    int cnt = 0;
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	if(island[i][j]){
	  dfs(i, j);
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = decimal.Parse(input[0]);
            var B = decimal.Parse(input[1]);
            var ans = Math.Floor(A * B);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 200010
#define test(a,n) REP(i,n) cout << a[i] << " ";
using namespace std;


//fac=n!, finv=1/n!
ll fac[MAX], finv[MAX], inv[MAX];
 
void facmod() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long myPow(long x, long n){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % MOD, n / 2);
  else
    return x * myPow(x, n - 1) % MOD;
}

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  ll sum1 = 1;
  ll sum2 = 1;
  
  facmod();
  for(int i=n; i>n-a; i--){
    sum1 *= i;
    sum1 %= MOD;
  }
  for(int i=n; i>n-b; i--){
    sum2 *= i;
    sum2 %= MOD;
  }
  sum1 *= finv[a] % MOD;
  sum1 %= MOD;
  sum2 *= finv[b] % MOD;
  sum2 %= MOD;
  
  ll ans = myPow(2,n) - 1 - sum1 + MOD - sum2 + MOD;
  cout << ans % MOD;
  return 0;
}

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

using namespace std;


int main(){
    //freopen("i.txt", "s", stdin);
    int k;

    string s;
    cin >> k >> s;
    string ans;
    if(s.size() <= k) ans = s;
    else ans = s.substr(0, k) + "...";
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}


//------------------変数-----------------------//
//-------------------関数----------------------//

int main() {
	ll n, t, retu[100000] = {}, saidai[100000] = {}, saishou[100000] = {};
	cin >> n >> t;
	REP(i, n) { cin >> retu[i]; }
	ll maxa = 0;
	for (ll i = n-1; i >=1; i--)
	{
		saidai[i-1] = max(maxa, retu[i]);
		maxa = max(maxa, retu[i]);

	}
	ll mini = INF;
	REP(i, n - 1) {
		saishou[i] = min(mini, retu[i]);
		mini = min(retu[i], mini);
	}
	ll izryt = 0;
	for (ll i = 0; i < n-1; i++)
	{
		izryt = max(izryt, saidai[i] - saishou[i]);
	}
	ll cnt = 0;
	for (ll i = 0; i < n-1; i++)
	{
		if (izryt == saidai[i] - retu[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
	long n,m,k=1;
	cin>>n>>m;
	if(m<n*n){
	for(int i=0;i<m/n;i++){
		if(m%(i+1)==0)k=(i+1);
	}
	cout<<k<<endl;
	}
	else{
		int j=n;
		while(m%j!=0)j++;
	cout<<m/j<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int in1,in2;
	cin >> in1 >> in2;
	while(in1+ in2!=0){
		if(in1>in2){
			cout<<in2<<" "<<in1<<endl;
		}else{
			cout<<in1<<" "<<in2<<endl;
		}
		cin >> in1 >> in2;
	}
}





Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
const int mxN=2020;
vector<pll> a;
int n;
ll dp[mxN][mxN];
ll run(int ind, ll i, ll j)
{
    if(ind==n)
    {
        return 0;
    }
    ll &ans=dp[ind][i];
    if(ans!=-1)
    {
        return ans;
    }
    ans=(abs(i-a[ind].second)*a[ind].first)+run(ind+1,i+1,j);
    ans=max(ans,(abs(j-a[ind].second)*a[ind].first)+run(ind+1,i,j-1));
    return ans;
}
int main()
{
    vok();
    IN n;
    a.resize(n);
    loop(i,0,n)
    {
        IN a[i].first;
        a[i].second=i;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    memset(dp,-1,sizeof(dp));
    ll ans= run(0,0,n-1);
    OUT ans<<endl
    return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int sum = 0;
  rep(i,n){
    if (i%2==0){
    sum += v.at(i);
    }
    else {
      sum -= v.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234][1234];
signed main() {
	ll n = 0, k, a, cnt = 0, ans = 0; cin >> n >> k;
	for (int h = 0; h < k; h++) {
		cin >> a; cnt = max(cnt, a);
	}
	cout << max((ll)0, cnt - (n - cnt) - 1) << endl;
	cin >> n; 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 FOR(i, m, n) for (int i = (m); i < (int)(n); i++)

template <typename T>
struct fenwick_tree {
    int n;
    vector<T> d;
    fenwick_tree(int n = 0) : n(n), d(n + 1) {}

    void add(int i, T x) {
        i++;
        while (i <= n) {
            d[i] += x;
            i += i & -i;
        }
    }
    T sum(int i) {
        i++;
        T x = 0;
        while (i > 0) {
            x += d[i];
            i -= i & -i;
        }
        return x;
    }
};

int main() {
    ll N, Q, l, r, idx = 0;
    cin >> N >> Q;
    vector<ll> c(N), good(N, -1), ans(Q);
    REP(i, N) {
        cin >> c[i];
        c[i]--;
    }
    vector<tuple<ll, ll, ll>> query(Q);
    REP(i, Q) {
        cin >> l >> r;
        query[i] = {r - 1, l - 1, i};
    }

    sort(query.begin(), query.end());
    fenwick_tree<ll> fw(N);

    REP(i, N) {
        if (good[c[i]] != -1) fw.add(good[c[i]], -1);
        good[c[i]] = i;
        fw.add(i, 1);

        while (idx != Q && get<0>(query[idx]) == i) {
            ans[get<2>(query[idx])] =
                fw.sum(get<0>(query[idx])) - fw.sum(get<1>(query[idx]) - 1);
            idx++;
        }
    }

    REP(i, Q) cout << ans[i] << endl;
}

Measured memory_bytes: 31132
fun main(args: Array<String>) {
    val (a, b, c, k) = readLine()!!.split(" ").map(String::toInt)
    var life = k
    var result = 0

    for (i in 1..a) {
        if (life > 0) {
            result += 1
            life--
        } else {
            break
        }
    }

    for (i in 1..b) {
        if (life > 0) {
            result += 0
            life--
        } else {
            break
        }
    }

    for (i in 1..c) {
        if (life > 0) {
            result -= 1
            life--
        } else {
            break
        }
    }

    println(result)
}

Measured memory_bytes: 36684
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;

queue<int> que;

int main(){
  int h,w;
  int n;
  int a;
  int mp[111][111];
   
  scanf(" %d %d",&h,&w);
  scanf(" %d",&n);
  for(int i=1;i<=n;i++){
    scanf(" %d",&a);
    for(int j=0;j<a;j++){
      que.push(i); 
    }
  }
  
  for(int i=0;i<h;i++){
    
    if(i%2){
      for(int j=w-1;j>=0;j--){
        mp[i][j] = que.front();
        que.pop(); 
      }
    } else {
      for(int j=0;j<w;j++){
        mp[i][j] = que.front();
        que.pop();
      }
    }
  
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      printf("%d",mp[i][j]);
      if(j+1!=w)printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}

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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  auto ac = ((A < C) ? C : A);
  auto bd = ((B < D) ? B : D);
  cout << ((ac < bd) ? bd - ac : 0);
  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll digit_sum(ll n) {
    if (n < 10) return n;
    else return n%10 + digit_sum(n/10);
}
#endif


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

    int N; cin >> N;

    ll ans = LINF;
    for(ll a=1; a<N; a++) {
        ll b = N - a;

        ll sum = digit_sum(a) + digit_sum(b);
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(N-1)-a.at(0)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 33

ll POW[SIZE],table[SIZE];


int main(){

	POW[0] = 1;
	table[0] = 0;
	table[1] = 0;

	ll sum = 0;

	for(int i = 1; i < SIZE; i++){
		if(i > 1){

			table[i] = sum;
		}
		POW[i] = POW[i-1]*3;
		sum += POW[i];
	}

	ll T;
	scanf("%lld",&T);

	if(T <= 3){

		printf("%lld\n",T);
		return 0;
	}

	T -= 1;

	ll ans = 1;
	ll rank;
	//上り
	for(int i = 2; i < SIZE; i++){
		if(POW[i]+2*table[i] > T){
			T -= (POW[i-1]+table[i-1]);
			ans += i-1;
			rank = i-1;
			break;
		}
	}

	//下り
	ll mult;

	while(T > 0){

		mult = (T-table[rank])/POW[rank];
		ans += mult;
		T -= POW[rank]*mult;
		if(T == 0)break;
		rank--;
	}

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

	return 0;
}




Measured memory_bytes: 3200
#include<iostream>
#include<set>
using namespace std;
#define rep(i, st, end) for (int i = st; i < end; ++i)
//inline 関数をその場所に埋め込むことで呼び出しに時間がかからない
inline void solve() {
    multiset<int> num;
    int n; cin >> n;
    rep(i, 0, n) {
        int a; cin >> a;
        if (num.count(a) == 0) {
            num.insert(a);
        } else {
            num.erase(a);
        }
    }
    cout << num.size() << endl;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4992
import math
import itertools
import statistics
#n = int(input())
a, b = list(map(int, input().split()))
s = input()
for i in range(len(s)):
    if i==a and s[i]!="-":
        print("No")
        exit()
    if i!=a and (s[i]!="0" and s[i]!="1" and s[i]!="2" and s[i]!="3" and s[i]!="4"
    and s[i]!="5" and s[i]!="6" and s[i]!="7" and s[i]!="8" and s[i]!="9"):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;



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

  int a[101];

  REP(i, 0, 101){
    a[i] = 0;
  }

  REP(i, 1, 10){
    REP(j, 1, 10){
      a[i*j] = 1;
    }
  }

  if (a[N] == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  int k = n%10;
  
  if(k==3)
    printf("bon\n");
  else if(k==0||k==1||k==6||k==8)
    printf("pon\n");
  else
    printf("hon\n");
  
  return 0;
}

Measured memory_bytes: 1640
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;

/*
問題文
AtCoder 社は、毎週土曜日にコンテストを開催しています。
コンテストには ABC と ARC の 2 つの種類があり、毎週どちらか一方が開催されます。
ABC が開催された次の週には ARC が開催され、ARC が行われた次の週には ABC が開催されます。

先週開催されたコンテストを表す文字列 S が与えられるので、今週開催されるコンテストを表す文字列を出力してください。

制約
S は ABC または ARC
*/
public class Main{
    public static void main(String[] args){
 
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        HashMap<String, String> map = new HashMap<>();

        map.put("ARC", "ABC");
        map.put("ABC", "ARC");

        System.out.println(map.get(s));
    }
}

Measured memory_bytes: 35700
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define INF 10e9

static const int MAX_N=10e5,MAX_M=10e5;
int N,M,K,X,Y,Z;
int maxs=-1,mini=INF,ans,res;
int A[MAX_N],B[MAX_N],C[MAX_N];
int a,b,c,d,e;
int main(void){
	cin >> a >> b >> c >> d >> e  ;
	int aa=a,bb=b,cc=c,dd=d,ee=e;
	a=(a+9)/10;
	b=(b+9)/10;
	c=(c+9)/10;
	d=(d+9)/10;
	e=(e+9)/10;
	int res=0;
	res=max(res,a*10-aa);
	res=max(res,b*10-bb);
	res=max(res,c*10-cc);
	res=max(res,d*10-dd);
	res=max(res,e*10-ee);
	int ans=a+b+c+d+e;
	puts(ans*10-res);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, ans=0;

    cin >> N;

    vector<pair<ll, ll>> pairs(N+1);

    for(i=1; i<=N; i++){
        pairs[i].first = i;
        cin >> pairs[i].second;

        if(pairs[i].first > pairs[i].second){
            if(pairs[pairs[i].second].second == pairs[i].first){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
from functools import reduce

def factors(n):
    return set(reduce(list.__add__,
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))


n,m=map(int,input().strip().split(" "))
fact=sorted(factors(m),reverse=True)
ans=1
for i in fact:
    if m//i >=n:
        ans=i
        break
print(ans)


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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  
  while(true){
    if(a%k == 0){
      cout << "OK" << endl;
      break;
    }
    
    a++;
    if(a>b){
      cout << "NG" << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
 
#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)
 
int N, M, dp[102][102];
char ch[102][102];
 
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) scanf("%s", ch[i] + 1);
  dp[1][1] = (ch[1][1] == '#');
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      if (i > 1 || j > 1) dp[i][j] = 0x3f3f3f3f;
      if (i > 1)
        dp[i][j] = min(dp[i][j],
                       dp[i - 1][j] + (ch[i][j] == '#' && ch[i - 1][j] == '.'));
      if (j > 1)
        dp[i][j] = min(dp[i][j],
                       dp[i][j - 1] + (ch[i][j] == '#' && ch[i][j - 1] == '.'));
    }
  }
  printf("%d\n", dp[N][M]);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	li num;
	map<li,li> table;
	while(cin>>num){
		table[num]++;
	}
	
	vector<pair<li,li> > s;
	
	for(map<li, li>::iterator it=table.begin(); it!=table.end(); it++){
		s.pb(mp(it->S, -(it->F)));
	}
	
	sort(allof(s) ,greater<pair<li,li> >());
	
	//rep(i,sz(s)){p2(s[i].F, s[i].S);}
	
	li maxval=s[0].F;
	cout<<-s[0].S<<endl;
	li ma=1;
	while(s[ma].F==maxval){
		cout<<-s[ma].S<<endl;
		ma++;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;
int N;
int primes[1000000];

void prime() {
    fill(primes, primes + 1000000, 1);
    for (int i = 2; i <= 999999; i++) {
        if (primes[i]) {
            for (int j = i + i; j <= 999999; j += i)
                primes[j] = 0;
        }
    }
}

int main() {
    prime();
    while (~scanf("%d", &N)) {
        int ans = 0;
        for (int i = 2; i <= N; ++i)
            ans += primes[i];
        printf("%d\n", ans);
    }
    return 0;
}

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

int main() {
    ll h, w;
    cin >> h >> w;
    ll ans = (h * w + 1)/2;
    if(h == 1 || w == 1) {
        cout << 1 << endl;
    }
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
double calcTime()
{
    struct::timespec getTime;
    clock_gettime(CLOCK_MONOTONIC, &getTime);
    return (getTime.tv_sec + getTime.tv_nsec*1e-9);
}

void solve(){
    double t = calcTime();
    ll D;
    cin >> D;
    ll c[30];
    rep(i,0,26) cin >> c[i];
    ll s[370][30];
    rep(i,0,D){
        rep(j,0,26){
            cin >> s[i][j];
        }
    }
    rep(i,0,D){
        ll max_idx = -1, max_val = 0;
        rep(j,0,26){
            if(max_val < s[i][j]){
                max_idx = j;
                max_val = s[i][j];
            }
        }
        print(max_idx+1);
    }

    

}

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

Measured memory_bytes: 3744
x1,y1,x2,y2=map(int,input().split())
dx=x2-x1
dy=y2-y1

x3,y3,x4,y4=0,0,0,0

x3=x2-dy
y3=y2+dx

x4=x1-dy
y4=y1+dx

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

static const int MAX = 100;
static const int INF = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

using namespace std;

int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];

    for (int i = 0; i < n; ++i) {
        d[i] = INF;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while (true) {
        minv = INF;
        int u = -1;
        for (int i = 0; i < n; ++i) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
            break;

        color[u] = BLACK;
        for (int v = 0; v < n; ++v) {
            if (color[v] != BLACK && M[u][v] != INF) {
                if (d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            M[i][j] = INF;
        }
    }

    int k, c, u, v;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
ll dp[100005];
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    in(n);in(W);
    vl w,v;
    for(int i=0;i<n;i++){
        in(temp1);in(temp2);
        w.push_back(temp1);v.push_back(temp2);
    }
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=W-w[i]+1;j>=0;j--){
            dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    cout<<dp[W]<<endl;
    return 0;
}

Measured memory_bytes: 4444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, x;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    double tmp = 1.08;
    for (int i = 1; i <= 50000; i++) {
        if ((int)(i*tmp) == n) {
            x = i;
            break;
        }
    }
    if (x) cout << x << E;
    else cout << ":(" << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  rep(i,5){
    int x; cin >> x;
    if(x == 0){
      cout << i+1 << endl;
    }
  }
}


Measured memory_bytes: 3484
s = list(input())

max = 0
length = 0

for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        length += 1
        if max < length:
            max = length
    else:
        length = 0

print(max)

Measured memory_bytes: 3060
//https://atcoder.jp/contests/abc143/tasks/abc143_a
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a;
	cin>>a;
	ll b;
	cin>>b;
	ll c;
	if(b>=a)
	{
		cout<<"0"<<"\n";
	}
	else if((2*b)>=a)
	{
		cout<<"0"<<"\n";
	}
	else
	{
		c=a-(2*b);
		cout<<c<<"\n";
	}
	return 0;
}

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

int main(void) {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    
    rep(i,k+1)
    rep(j,k+1) {
        int z = s - i - j;
        if(z>=0 && z <= k)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000000ll
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n,k;
    cin>>n>>k;
    
    vll p(n);
    vll c(n);

    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    rep(i,n) cin>>c[i];
    
    ll ans = -1e18;
    rep(i,n){
        ll cur= i;
        vll v;
        ll l=0;
        ll tot = 0;

        rep(j,n){
            cur = p[cur];
            v.push_back(c[cur]);
            tot += c[cur];
            l++;
            if(cur == i) break;
        }
        
        ll t = 0;
        rep(j,l){
            t += v[j];
            if(j + 1 > k) break;
            ll num = t;
            if(tot > 0){
                ll loop = (k -(j+1))/l;
                num += loop*tot;
            }
            ans = max(num,ans);
        }
    }

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

Measured memory_bytes: 3788
/*
 *
 *  1. sprawdz corner cases
 *  2. sprawdz limity, jesli sie da pozamieniaj wszystkie lokalne zmienne na LL!
 *  3.  MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE
 *  4. lokalne zmienne, iteracja po tablicach dwuwymiarowych uwazaj
 *  5. SPRAWDZ CZY input jest POSORTOWANY jaki jest niezmiennik
 *
 *
 */
#include <algorithm>
#include <cstdio>
#include <iomanip> // std::setprecision
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>
#define FOR(x, y, z) for (int x = (y); x < (z); x++)
#define FORD(x, y, z) for (int x = (y); x >= z; x--)
#define REP(r, n) for (int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define ND second
#define SIZE(c) ((int)((c).size()))
#define FOREACH(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define ALL(u) (u).begin(), (u).end()
#define RALL(u) (u).rbegin(), (u).rend()
#define PB push_back
#define PF push_front
#define SZ(x) long long((x).size())
#define IS_IN(x, t) (t.find(x) != t.end())
#define BIT(n, i) (((n) >> (i)) & 1)

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) \
    {              \
    }
#endif

#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<LL> VI;
typedef pair<LL, LL> PR;

inline LL GCD(LL a, LL b)
{
    LL r;
    while (b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
};
inline LL LCM(LL a, LL b) { return a / GCD(a, b) * b; };
inline LL fpow(LL n, LL k, LL p)
{
    LL r = 1;
    for (; k; k >>= 1) {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
};
inline LL inv(LL a, LL p) { return fpow(a, p - 2, p); }

[[maybe_unused]] const LL MOD = (LL)1e9 + 7;
[[maybe_unused]] const LL MAXUS = TYPEMAX(LL);
[[maybe_unused]] const LD PI = acos((LD)-1);
[[maybe_unused]] const LD epsilon = 1e-9;

template <typename T>
T input()
{
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e)
{
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    LL total = input<LL>();
    LL K = input<LL>();
    int letters[10];
    REP(i, K)
    {
        char c;
        cin >> c;
        letters[c - '0'] = 1;
    }
    for (int i = total; 1; i++) {
        string cur = to_string(i);
        bool found = true;
        for (char c : cur) {
            if (letters[c-'0'] == 1) {
                found = false;
            }
        }
        if (found) {
            cout << cur << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		if(n==1)
		{
			cout << "Hello World";
		}
		else
		{
			int a,b;
			cin >> a >> b; 
			cout << (a+b);
			
		}
		
	}
	return 0;
	
}

Measured memory_bytes: 256
def twoswiches(a , b , c , d):

    ans = min(b , d) - max(a , c)
    return ans if ans > 0 else 0

def main():
    a , b , c , d = map(int , input().split())
    print(twoswiches(a , b , c , d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> a(N);
  int ans = 0;
  int p = 0;
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      a[s] |= 1 << i;
    }
  }
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    p |= x << i;
  }
  for (int i = 0; i < (1<<N); i++) {
    int t = 0;
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        t ^= a[j];
      }
    }
    if (p == t) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,sum=0,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        lli x,y;
        cin>>x>>y;
        if(x==y)
         cnt++;
        else
         {
             sum=max(sum,cnt);
             cnt=0;
         }
    }
    if(sum>=3 || cnt>=3)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Console.WriteLine(string.Join("", s.Split().Reverse()));


			Console.Out.Flush();
		}
	}
}


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

n = int(input())
tasks = []
for _ in range(n):
    a,b = map(int, input().split())
    tasks.append((a,b))

tasks.sort()
tasks = sorted( tasks, key = lambda a: a[1] )

time = 0
flg = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        print('No')
        break
else:
    print( 'Yes' )

Measured memory_bytes: 71388
N, M = map(int, input().split())
edge = []
for _ in range(M):
    a, b = map(int, input().split())
    edge.append((a, b))

ret = 0

for i in range(M):
    visited = [False for _ in range(N + 1)]

    queue = [1]
    visited[1] = True

    while queue:

        p = queue[0]
        queue.pop(0)

        for j, e in enumerate(edge):
            if i == j:
                continue
            if e[0] != p and e[1] != p:
                continue

            if not visited[e[0]]:
                visited[e[0]] = True
                queue.append(e[0])
            if not visited[e[1]]:
                visited[e[1]] = True
                queue.append(e[1])

    if sum(visited) != N:
        ret += 1

print(ret)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, x;
	cin >> n >> x;
	vi a(n);
	Foz(i, n) cin >> a[i];
	a.pb(x);
	sort(all(a));
	x = a[0];
	Foz(i, sz(a)) a[i] -= x;
	int ans = 0;
	For(i, 1, sz(a)) ans = __gcd(ans, a[i]);
	cout << ans << '\n';
}



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

typedef long long ll;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define all(obj) (obj).begin(), (obj).end()
const ll INF = 1e10;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

ll aN[3000];
// メモ[手番][左端位置][右端位置] = この局面からの結果
ll memo[2][3010][3010];
bool visited[2][3010][3010];

ll rec(int turn, int l, int r) {
	// 全部取り切ったので終了
	if (l > r) return 0;
	// 既に見た局面ならメモの内容を返す
	if (visited[turn][l][r]) return memo[turn][l][r];
	// 先手番
	if (turn == 0) {
		ll mx = -INF;
		mx = max(rec(1, l+1, r) + aN[l], rec(1, l, r-1) + aN[r]);
		// 訪問済にする
		visited[turn][l][r] = true;
		// ここより深い所を探し終わったので結果をメモする
		return memo[turn][l][r] = mx;
	// 後手番
	} else {
		ll mn = INF;
		mn = min(rec(0, l+1, r) - aN[l], rec(0, l, r-1) - aN[r]);
		visited[turn][l][r] = true;
		return memo[turn][l][r] = mn;
	}
}

int main() {
	int N;
	cin >> N;
	rep(i, 0, N) cin >> aN[i];
	cout << rec(0, 0, N-1) << endl;
	return 0;
}


Measured memory_bytes: 158464