akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int N, M;
int T[100], X[100], P[100];

void init()
{
	cin >> N;
	rep(i, N) cin >> T[i];
	cin >> M;
	rep(i, M) cin >> P[i] >> X[i];
}



void solve()
{
	int sum = 0;
	rep(i, N) sum += T[i];
	rep(i, M) cout << sum - T[P[i]-1] + X[i] << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#define Un 100000
#define Uq 50000
int main(){
  int s[Un],t[Uq],Sn,Tn,i,j,L,R,C,count=0;
  scanf("%d\n",&Sn);
  for(i=0;i<Sn;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&Tn);
  for(i=0;i<Tn;i++){
    scanf("%d",&t[i]);
  }
  for(j=0; j<Tn; j++){
    L=0;
    R=Sn;
    while(L<R){
      C=(L+R)/2;
      if(t[j]==s[C]){
	count++;
	break;
      }
      if(t[j]>s[C]){
	L=C+1;
      }
      else if(t[j]<s[C]){
	R=C;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

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

using namespace std;

int main(){

int m,n,c;
	cin>>m>>n>>c;
		
int x = m*100+n*10+c;
				
if(x%4==0) cout<<"YES"<<endl;
				
else cout<<"NO"<<endl;
				
//for(int i=0;i<3;i++)cout<<f;

//cout<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

// mapのなかにpairのpriority_queue入れるのは流石にやばいので賢くスッキリver

int main() {
    int n;
    cin >> n;
    string s[n];
    int p[n];
    for (int i=0; i<n; i++) cin >> s[i] >> p[i];
    int idx[n]; 
    iota(idx, idx+n, 0); // 0, 1, 2, 3, 4, ...
    sort(idx, idx+n, [&](int l, int r) {
        return s[l] < s[r] || (s[l] == s[r] && p[l] > p[r]);
    });
    for (auto i:idx) cout << i + 1 << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            int Q = scanner.nextInt();

            NavigableSet<Long> temples = new TreeSet<>();
            NavigableSet<Long> shrines = new TreeSet<>();
            for (int i = 0; i < A; i++) {
                shrines.add(scanner.nextLong());
            }
            for (int i = 0; i < B; i++) {
                temples.add(scanner.nextLong());
            }
            for (int i = 0; i < Q; i++) {
                long startPos = scanner.nextLong();
                long min = Math.min(dist(shrines, temples, startPos), dist(temples, shrines, startPos));
                System.out.println(min);
            }
        }
    }

    static long dist(NavigableSet<Long> set1, NavigableSet<Long> set2, long pos) {
        long min = Long.MAX_VALUE;
        Pair pair1 = closestDist(set1, pos);
        if (pair1.left != null) {
            Pair second = closestDist(set2, pair1.left);
            long firstStep = Math.abs(pos - pair1.left);
            if (second.left != null) {
                long dist = firstStep + Math.abs(second.left - pair1.left);
                min = Math.min(dist, min);
            }
            if (second.right != null) {
                long dist = firstStep + Math.abs(second.right - pair1.left);
                min = Math.min(dist, min);
            }
        }
        if (pair1.right != null) {
            Pair second = closestDist(set2, pair1.right);
            long firstStep = Math.abs(pos - pair1.right);
            if (second.left != null) {
                long dist = firstStep + Math.abs(second.left - pair1.right);
                min = Math.min(dist, min);
            }
            if (second.right != null) {
                long dist = firstStep + Math.abs(second.right - pair1.right);
                min = Math.min(dist, min);
            }
        }
        return min;
    }

    static Pair closestDist(NavigableSet<Long> set, long pos) {
        Long ceiling = set.ceiling(pos);
        Long floor = set.floor(pos);
        return new Pair(floor, ceiling);
    }

    static class Pair {
        final Long left;
        final Long right;

        Pair(Long left, Long right) {
            this.left = left;
            this.right = right;
        }
    }

}


Measured memory_bytes: 108908
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
ll dp[3001][3001];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);

   int n;
   cin >> n;
   vector<int> a(n);
   rep(i,n) cin>>a[i];

   rep(i,n) dp[i][i] = (n%2==1) ? a[i] : -a[i];

   for (int i = 1; i < n; i++){
      for (int j = 0; j+i < n; j++){
         if ((n-i)%2==1)
            dp[j][j+i] = max(dp[j+1][j+i]+a[j]
                           , dp[j][j+i-1]+a[j+i]);
         else
            dp[j][j+i] = min(dp[j+1][j+i]-a[j]
                           , dp[j][j+i-1]-a[j+i]);
      }
   }

   cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 49740
from collections import*
from heapq import*
def main():
  n,m,*a=map(int,open(0).read().split())
  table=[-1]*n
  def root(x):
    while table[x]>=0:x=table[x]
    return x
  def unite(x,y):
    s1=root(x)
    s2=root(y)
    if s1!=s2:
      if table[s1]>table[s2]:s1,s2=s2,s1
      table[s1]+=table[s2]
      table[s2]=s1
  d=defaultdict(list)
  for x,y in zip(*[iter(a[n:])]*2):unite(x,y)
  for i,v in enumerate(a[:n]):d[root(i)]+=v,
  if len(d)<2:
    print(0)
    return
  *d,=map(sorted,d.values())
  c=sum(heappop(t)for t in d)
  l=[]
  for t in d:l+=t
  i=len(d)-2
  if len(l)<i:
    print('Impossible')
  else:
    print(c+sum(sorted(l)[:i]))
main()

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

int main()
{
    int n,m,x,ans=1000000000,p;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];

    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            x = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(ans>x){
                ans = x;
                p = j+1;
            }
        }
        cout << p << endl;
        ans = 1000000000;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int gcd(int x, int y) {
	while (y) {
		x %= y;
		swap(x, y);
	}
	return x;
}

int main() {
	int K;
	cin >> K;
	int ans = 0;
	for (int i = 1;i <= K;i++) {
		for (int j = 1;j <= K;j++) {
			for (int k = 1;k <= K;k++) {
				ans += gcd(gcd(i, j), k);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,ans;
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(int i=0;i<=a;i++)
    {
    	for(int j=0;j<=b;j++)
    	{
    		for(int k=0;k<=c;k++)
    		{
    			if(500*i+100*j+50*k==d)
    			ans++;
			}
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll w_f = 0;
    ll r_b = n-1;
    while(s[w_f] == 'R')w_f++;
    while(s[r_b] == 'W')r_b--;

    ll ans = 0;
    while(w_f < r_b){
        ans++;
        w_f++, r_b--;
        while(s[w_f] == 'R')w_f++;
        while(s[r_b] == 'W')r_b--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3744
object Main extends App {
    val scanner = new java.util.Scanner(System.in)
    val n = scanner.next().toInt
    val d = scanner.next().toInt
    val x = scanner.next().toInt
    val as = for (_ <- 1 to n) yield scanner.next().toInt
    println(as.map(ai => 1 + (d-1) / ai).sum + x)
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> cnt(3);
    for (int i=0; i<n; ++i) cnt[s[i] - 'a']++;
    int M = 0, m = 101010;
    for (int i=0; i<3; ++i) {
        M = max(M, cnt[i]);
        m = min(m, cnt[i]);
    }
    if (M - m <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
// Copyright 2020 yaito3014
#pragma GCC optimize("avx")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  using namespace chrono_literals;
  chrono::high_resolution_clock clock;
  auto be = clock.now();
  int D;
  cin >> D;
  array<int, 26> c;
  for (auto& e : c) cin >> e;
  vector<array<int, 26>> d(D);
  for (auto& r : d)
    for (auto& e : r) cin >> e;
  auto eval = [&](vector<int> t) {
    int S = 0;
    array<int, 26> last = {};
    for (int i = 0; i < D; ++i) {
      S += d[i][t[i]];
      last[t[i]] = i + 1;
      for (int j = 0; j < 26; ++j) S -= c[j] * (i + 1 - last[j]);
    }
    return S;
  };
  mt19937 mt(random_device{}());
  uniform_int_distribution<int> dist_type(0, 25), dist_day(0, D - 1);
  vector<int> t(D);
  for (int i = 0; i < D; ++i) t[i] = i % 26;
  int S = eval(t);
  while (clock.now() - be < 1950ms) {
    int day = dist_day(mt);
    int prv = t[day];
    t[day] = dist_type(mt);
    int score = eval(t);
    if (score > S) {
      S = score;
      continue;
    }
    t[day] = prv;
  }
  for (const auto& e : t) cout << (e + 1) << '\n';
}


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll n;
    cin >> n;
    vll a(n), b(n);
    ll suma = 0, sumb = 0;
    rep(i, 0, n) cin >> a[i], suma += a[i];
    rep(i, 0, n) cin >> b[i], sumb += b[i];

    ll cnt = sumb - suma;
    ll sum = 0;
    rep(i, 0, n) sum += max((b[i] - a[i] + 1) / 2, 0ll);
    print(sum <= cnt);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-5
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int main() 
{
    fastio
    int n, m;
    cin>>n>>m;
    ll x;
    cin>>x;
    vector<pair<int, vi>> vec(n);
    for(int i = 0; i<n; ++i) {
        ll c;
        cin>>c;
        vec[i].first = c;
        vector<int> v(m);
        for(int j = 0; j<m; ++j) 
            cin>>v[j];
        vec[i].second = v;
    }

    ll ans = 2e9;
    for(int i = 1; i<(1<<n); ++i) {
        int temp = i;
        int cnt = 0;
        vector<ll> val(m);
        ll cost = 0;
        while(cnt<n) {
            if(temp&1){
                for(int j = 0; j<m; ++j) {
                    val[j] += vec[cnt].second[j];
                }
                cost += vec[cnt].first;
            }

            temp>>=1;
            cnt++;
        }

        bool flag = false;
        for(int j = 0; j<m; ++j) {
            if(val[j]<x) flag = true;
        }
        if(!flag) {
            ans = min(ans, cost);
        }
    }
    if(ans==2e9) {
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}

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

ll solve(string s,string t){
    int len=s.size();
    s='@'+s;
    vector < int > nxt[26];
    int p[26]={0};
    for(char x=0;x<26;++x){
        nxt[x].insert(nxt[x].end(),len+1,0);
    }
    for(int j=1;j<=len;++j){
        char x=s[j]-'a';
        while(p[x]!=j){
            nxt[x][p[x]++]=j;
        }
    }
    
    ll i=0,dup=0;
    for(int j=0;j<t.size();++j){
        char x=t[j]-'a';
        //printf("t[%d] %c\n",j,x+'a');
        if(nxt[x][i]==0){
            i=0;
            dup+=1;
        }
        if(nxt[x][i]==0){
            return -1;
        }
        i=nxt[x][i];
        //printf("then dup=%lld i=%lld\n",dup,i);
    }
    return dup*len+i;
}
int main(){
    string s,t;cin>>s>>t;
    cout<<solve(s,t)<<endl;
    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int		long long
#define mp		make_pair
#define pb		push_back
#define pf		push_front
#define fi 		first
#define se		second
#define sz(x)	((int)(x).size())
#define w(x)		int x; cin>>x; while(x--)
#define rep(i,a,n)		for (int i=a;i<n;i++)
#define per(i,a,n)		for (int i=n-1;i>=a;i--)
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod		1000000007
#define inf		1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main(){
	c_p_c(); 
	int r;
	cin>>r;
	double pi=3.14285714286;
	double circum=2*pi*(double)r;
	printf("%.8f",circum);
	return 0;
}



Measured memory_bytes: 3740
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

#define int long long

const int CN = 2e5 + 5;

int read(){
    int s = 0,ne = 1; char c = getchar();
    while(c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar();
    while(c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar();
    return s * ne;
}

class fs {public: int u, v, w; bool operator < (const fs &a) const {return w < a.w;}} E[CN << 2];
int ecnt = 0; void add(int x, int y, int z) {E[++ecnt].u = x, E[ecnt].v = y, E[ecnt].w = z;}

class dsu {
  public: int fa[CN]; dsu() {for(int i = 0; i <= 200000; i++) fa[i] = i;}
    int fd(int x) {return fa[x] ^ x ? fa[x] = fd( fa[x] ) : x;}
    bool mg(int x, int y) {int fx = fd(x), fy = fd(y); return fx ^ fy ? fa[fx] = fy, true : false;}
} D;

int n, q, val[CN];

signed main()
{
    // freopen("_in.in", "r", stdin);

    n = read(), q = read(), memset(val, 0x3f, sizeof(val));
    while(q--){
        int a = read(), b = read(), c = read();
        add(a, b, c);
        val[a] = min(val[a], c + 1), val[b] = min(val[b], c + 2);
    }
    for(int i = 0; i < n; i++) val[i] = min(val[i], val[(i - 1 + n) % n] + 2);
    for(int i = 0; i < n; i++) val[i] = min(val[i], val[(i - 1 + n) % n] + 2);

    for(int i = 0; i < n; i++) add(i, (i + 1) % n, val[i]);

    sort(E + 1, E + ecnt + 1); int cnt = 0, ans = 0;
    for(int i = 1; i <= ecnt; i++){
        int u = E[i].u, v = E[i].v, w = E[i].w;
        if(!D.mg(u, v)) continue;
        ans += w; if(++cnt == n - 1) break;
    }

    printf("%lld", ans);
}

Measured memory_bytes: 16544
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using LP = pair<int, int>;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const double PI=3.14159265358979323846;

int mod = 1e9+7;

int INF = 1e9+7;

int main(){
  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];

  vector<ll> COST(N, INF); 
  COST[0] = 0;
  rep(here, N){
    rep(diff, K){
      int next_idx = here + diff + 1;
      if(next_idx>N-1) break;

      COST[next_idx] = min(COST[next_idx], COST[here] + abs(H[next_idx] - H[here]));
    }
  }

  cout << COST[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String[] lineString = sc.nextLine().split(" ");
		int[] sunuke = new int[Integer.parseInt(lineString[0])];
		int numberOfCandy = Integer.parseInt(lineString[1]);

		int noCandyCount = sunuke.length;
		for (int candy = 0; candy < numberOfCandy; candy++) {
			int hasCandy = Integer.parseInt(sc.nextLine());
			lineString = sc.nextLine().split(" ");
			while (hasCandy-- > 0) {
				if (sunuke[Integer.parseInt(lineString[hasCandy]) - 1] == 0) {
					noCandyCount--;
				}
				sunuke[Integer.parseInt(lineString[hasCandy]) - 1]++;
			}
		}

		// 出力
		System.out.println(noCandyCount);
		sc.close();
	}
}


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

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

	auto f = []( long long n ) -> int
	{
		int d = 0;
		while( n > 0 ) {
			d++;
			n /= 10;
		}
		return d;
	};
	vector<long long> vec;
	for( long long i = 2; i * i <= N; i++ ) {
		if( N % i == 0 ) {
			vec.push_back( i );
			if( N / i != i ) vec.push_back( N / i );
		}
	}
	vec.push_back( 1 );
	vec.push_back( N );
	sort( vec.begin(), vec.end() );
	long long A = vec[vec.size() / 2];
	long long B = N / A;
	int ans = max( f( A ), f( B ) );

	cout << ans << endl;
}


Measured memory_bytes: 3608
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}
 
signed main()
{
    tezz

    int n;
    cin>>n;

    vi a(n), b(n), c(n-1);
    int ans = 0;
    for(int &x:a) cin>>x;
    for(int &x:b) {cin>>x; ans+=x;}
    for(int &x:c) cin>>x;
        // cout<<ans<<endl;

    for(int i=0;i<n-1;i++){
        if(a[i]+1 == a[i+1]) {ans += c[a[i]-1];}
    }

    cout<<ans;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;

int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  rep(i,h) cin >> s[i];
  
  string frame="";
  rep(i,w+2) frame += '#';
  
  cout << frame << endl;
  rep(i,h) cout << '#' << s[i] << '#' << endl;
  cout << frame << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>

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

int main()
{
	ll r,D,x;
	cin>>r>>D>>x;
	for(int i=1;i<=10;i++)
	{
		x=r*x-D;
		cout<<x<<endl;
	}

}

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

using namespace std;

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

ll MAX = 1000000000000;

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

    int N, W;
    cin >> N >> W;

    vi w(N);
    vll v(N);

    for(int i=0;i<N;i++) cin >> w[i] >> v[i];

    vll dp(W+1, 0);

    for(int i=0;i<N;i++) {
        int cw = w[i];
        ll cv = v[i];
        for(int j=W;j >= cw; j--) {
            dp[j] = max(dp[j], dp[j-cw] + cv);
        }
    }

    cout << dp[W] << endl;


    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define For(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define sz(x) ((int)(x).size())
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef long long ll;
typedef unsigned long long ull;

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

  int n,k,q;
  cin>>n>>k>>q;
  vector<ll> a(n,k);
  ll minus = 0;
  rep(_,q) {
    int x; cin>>x; x--;
    a[x]++;
    minus--;
  }
  rep(i,n) {
    ll val = a[i]+minus;
    cout<<(val>0?"Yes":"No")<<endl;
  }
}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s, t;
  cin >> s >> t;
  int l1 = s.size(), l2 = t.size();
  if(l1!=l2-1){
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0; i<l1; i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3644
s = input()
res = 0

for i in range(len(s)):
	if s[0:i] == s[i:2*i]:
		if (len(s[0:i])*2 != 0 and len(s[0:i])*2 != len(s)) and len(s[0:i])*2 > res:
			res = len(s[0:i])*2
s = s[::-1]
for i in range(len(s)):
	if s[0:i] == s[i:2*i]:
		if (len(s[0:i])*2 != 0 and len(s[0:i])*2 != len(s)) and len(s[0:i])*2 > res:
			res = len(s[0:i])*2

print(res)


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

int main() {

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;

  if(L > R){
    cout << "Left" << endl;
  }
  else if(L == R){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

char s[maxn];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  cin >> s + 1;
  int n = strlen(s + 1);
  vector<int> cnt(2, 0);
  for (int i = 1; i <= n; ++i){
    cnt[s[i] - '0']++;
  }
  cout << min(cnt[0], cnt[1]) * 2;
}



Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Graph = vector<vector<int> >;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;


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

	int t = 0;
	if (a + b >= 2 * c) {
		if (x > y) {
			t += y * 2 * c;
			if (a >= 2 * c) t += 2 * c * (x - y);
			else  t += a * (x - y);
		}
		else {
			t += x * 2 * c;
			if (b >= 2 * c)  t += 2 * c * (y - x);
			else  t += b * (y - x);
		}
	}
	else {
		t += a * x + b * y;
	}
	cout << t << endl;
}


Measured memory_bytes: 256
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 >= 13) {
        	System.out.println(B);
        }else if(6 <= A && A <= 12) {
        	System.out.println(B / 2);
        }else {
        	System.out.println(0);
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define M 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
void input(vector<ll>& v,ll n){ ll i,io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<ll> v) { ll i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<ll,int>  frequency(vector<ll> v){ ll i; map<ll,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	string s;
	cin >> s;
	int i,n = s.length(),sum = 0;
	rep(i,n)
		sum += s[i] - '0';
	if ((sum % 9) == 0)
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;	
}
// Check for corner cases
// Check for special case like n = 0 or n = INT_MAX
// Check for Buffer Overflow or use of unsigned variable if any
// Check if problem can be solved mathematically 



Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int X;
    cin >> X;
    int ans = 0;
    for(int i = 0;i < 100;i++){
        for(int j = 2;j < 15;j++){
            int a = 1;
                if(pow(i,j) <= X){
                a = pow(i,j);
                ans = max(ans,a);
                } 
                else break;   
        }
    }
    cout << ans << endl;
}   

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 10007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s;
  cin >> s;
  ll n = (ll)s.size();
  map<char, ll> m;
  rep(i, n) {
    if(m.find(s[i]) == m.end()) m[s[i]] = 0;
    ++m[s[i]];
  }
  ll ans = n*(n-1)/2;
  for(auto x : m) ans -= x.second*(x.second-1)/2;
  cout << ans+1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int n,a,b;

    cin >> n >> a >> b;
    if(n*a < b)
    {
        cout << n*a;
    }
    else
    {
        cout << b;
    }


    return 0;
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N,K = imn()
p = iln()

ans = 0
total = 0
c = [0 for _ in range(N+1)]
for i in range(N):
    c[i] = ((p[i] * (p[i] + 1)) // 2 / p[i])
    total += c[i]
    if i+1 >= K:
        ans = max(ans, total)
        total -= c[i-K+1]
print(ans)

Measured memory_bytes: 27156
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

// グラフを隣接行列で管理する
bool G[10][10];

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a][b] = G[b][a] = true;
    }

    // 順列
    vector<int> ord(N);
    for (int i = 0; i < N; ++i) ord[i] = i;

    // 順列を全部試すa
    int res = 0;
    do {
        if (ord[0] != 0) break;

        bool ok = true;
        for (int i = 0; i + 1 < N; ++i) {
            int from = ord[i];
            int to = ord[i+1];
            if (!G[from][to]) ok = false;
        }
        if (ok) ++res;
    } while (next_permutation(ord.begin(), ord.end()));

    cout << res << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> vec(n);
  rep(i, n) cin >> vec[i];
  sort(vec.begin(), vec.end());
  ll ans = 0;
  rep(i, n - k)  ans += vec[i];
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 4720
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int k = sc.nextInt();
	String s = sc.next();
	
	for(int i = 0; i < n; i++){
		if(i != k-1){
			System.out.printf(s.substring(i,i+1));
		}else{
			System.out.printf(s.substring(i,i+1).toLowerCase());
		}
	}
}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		int  k = scan.nextInt();
		String  s = scan.next();
		String ans = null;

		if(s.length() <= k) {
			ans = s;
		} else {
			ans = s.substring(0,k) + "...";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27084
#include<stdio.h>

#define N 100

int main(){

  int n,i,flag=1,tmp,cnt=0;
  int Sort[N];

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&Sort[i]);

  while(flag){

    flag = 0;

    for(i = 0;i < n;i++){

      if(Sort[i] < Sort[i-1]){
	tmp = Sort[i];
	Sort[i] = Sort[i-1];
	Sort[i-1] = tmp;
	flag = 1;
	cnt++;
      }
    }
  }
  for(i = 0;i < n-1;i++){
    printf("%d ",Sort[i]);
  }
  printf("%d\n",Sort[n-1]);
  printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 10

int cntR[10];
int cntC[10];;
void solve(){
	
	int n;
	cin>>n;
	int arr[n];
	rep(i,0,n)
		cin>>arr[i];
	sort(arr,arr+n);

	int sum=arr[n-1];
	int i=n-2;
	int cnt=2;
	while(cnt<n){
		sum+=arr[i];
		cnt++;
		if(cnt>=n)
			break;
		sum+=arr[i];
		cnt++;
		i--;
	}
	cout<<sum<<endl;

}

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5220
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (a, b) = nextIntList()
    println((a + b + 1) / 2)
}

Measured memory_bytes: 36012
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	l := scanInts(n)

	sort.Ints(l)

	ans := 0

	for i := 0; i < n; i++ {
		for j := i+1; j < n; j++ {
			bars := l[i]+l[j]
			c := bs(bars, l[j+1:])
			// fmt.Println(c,l[j+1:],len(l[j+1:]))

			ans += c+1
		}
	}
	fmt.Println(ans)
}

func bs(a int, arr []int) int {
	l,r := -1, len(arr)
	c := (r+l)/2
	for r-l > 1 {
		if a > arr[c] {
			l = c
		} else {
			r = c
		}
		c = (r+l)/2
	}

	return l

}


Measured memory_bytes: 640
#include <stdio.h>

void quicksort(int number[],int first,int last)
{
   int i, j, pivot, temp;

   if(first < last){
      pivot = first;
      i = first;
      j = last;

      while(i < j){
         while((number[pivot] >= number[i]) && (i < last))
         {
            i++;
         }
         while(number[pivot] < number[j])
         {
            j--;
         }
         if(i < j){
            temp = number[i];
            number[i] = number[j];
            number[j] = temp;
         }
      }

      temp = number[pivot];
      number[pivot] = number[j];
      number[j] = temp;
      quicksort(number,first,j - 1);
      quicksort(number,j+1,last);

   }
}


int main()
{
    int n,d[100];

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&d[i]);
    }
    quicksort(d,0,n - 1);

    int ans = n;
    for (int i = 0; i < n - 1; i++)
    {
        if (d[n - i - 1] == d[n - i - 2])
        {
            ans --;
        }
    }
    printf("%d",ans);
}

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

int main(){
    int n, m;
    cin >> n >>m;
    int A[n][m], B[m], C[n];
    for (int i=0; i<n; i++){
        C[i]=0;
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            cin >> A[i][j];
        }
    }
    for (int i =0; i<m; i++){
        cin >> B[i];
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            C[i]+=A[i][j]*B[j];         
        }
    }  
    
    for (int i =0; i<n; i++){
        cout << C[i]<< endl;
    }


}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code


int main()
{
  string s, t;
  cin>>s>>t;
  reverse(t.begin(), t.end());
  if(s == t) puts("YES");
  else puts("NO");
}


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

int main() {

  int N, K, xi, d;
  cin >> N >> K;
  d = 0;

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

    cin >> xi;

    if(xi < K - xi)
      d += 2 * xi;

    else
      d += 2 * (K - xi);
  
  }

  cout << d;
      
}

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

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    if (n % k == 0) {
        cout << 0 << '\n';
    } else {
        cout << 1 << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
int tatecou[400000];
int yokocou[400000];
map<long long int,int>lislis;
int main(){
    int H,W,M;
    cin>>H>>W>>M;
    for(int i=0;i<M;i++){
        long long int a,b;
        cin>>a>>b;
        lislis[a*500000+b]=1;
        tatecou[a]++;
        yokocou[b]++;
    }
    int tatemax=0;
    int yokomax=0;
    vector<long long int> tatelis,yokolis;
    for(int i=1;i<=H;i++){
        if(tatecou[i]==tatemax){
            tatelis.push_back(i);
        }
        else if(tatecou[i]>tatemax){
            tatelis.clear();
            tatelis.push_back(i);
        }
        tatemax=max(tatecou[i],tatemax);
    }
    for(int i=1;i<=W;i++){
        if(yokocou[i]==yokomax){
            yokolis.push_back(i);
        }
        else if(yokocou[i]>yokomax){
            yokolis.clear();
            yokolis.push_back(i);
        }
        yokomax=max(yokocou[i],yokomax);



        //for(int i=0;i<yokolis.size();i++)printf("[%lld]",yokolis[i]);
    //puts("");




    }

    //for(int i=0;i<tatelis.size();i++)printf("[%lld]",tatelis[i]);
    //puts("");
    //for(int i=0;i<yokolis.size();i++)printf("[%lld]",yokolis[i]);
    //puts("");


    int flg=1;
    if((long long int)tatelis.size()*(long long int)yokolis.size()>500000)flg=0;
    else{
        for(int i=0;i<tatelis.size();i++){
            for(int j=0;j<yokolis.size();j++){
                if(lislis[tatelis[i]*500000+yokolis[j]]==0)flg=0;
            }
        }
    }


    cout<<tatemax+yokomax-flg<<endl;
    return 0;
}


Measured memory_bytes: 32196
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let s: String = read();

    let v: Vec<usize> = s.chars().rev().map(|c| ((c as u8) - b'0') as usize).collect();

    let n = s.len() - 1;

    //let mut sum = 0;
    // for bit in 0..(1 << n) {
    //     let mut ten = 1;
    //     sum += v[0];
    //     for i in 0..n {
    //         if bit & (1 << i) != 0{
    //             ten = 1;
    //         } else {
    //             ten *= 10;
    //         }
    //         sum += v[i+1] * ten;
    //     }
    // }

    let sum = rec(&v, n, 0, 1, 0);

    println!("{}", sum);
}

fn rec(v: &Vec<usize>, n: usize, i: usize, ten: usize, mut sum: usize) -> usize {
    sum += v[i] * ten;
    if i == n {
        return sum;
    }

    return rec(v, n, i + 1, ten*10, sum) + rec(v, n, i + 1, 1, sum);
}

Measured memory_bytes: 4352
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	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 long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main()
{
	ll  i, j, k, l, m, sum, flag, N,  M, K, H, W, B,T;
	sum = 0;
	flag = 0;
	cin >> N >> T;
	vector<pair<int,int>>c(N);
	REP(i, 0,N) {
		cin >> c[i].first >> c[i].second;
	}
	sort ( c.begin(), c.end());
	REP(i, 0, N) {
		if (c[i].second <= T) {
			flag = 1;
			break;
		}
	}
	if (flag) {
		output(c[i].first);
	}
	else {
		output("TLE");
	}


	
}













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

using i64 = long long int;

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> st;
    for(int i=0;i<s.size();++i){
        string str = "";
        for(int j=0;j<5;++j){
            if(i+j >= s.size())break;
            str.push_back(s[i+j]);
            st.insert(str);
        }
    }

    string ans;
    int cnt = 0;
    for(auto e : st){
        cnt++;
        if(cnt == k){
            ans = e;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
int main(){
  int W, H, N;
  scanf("%d %d %d", &W, &H, &N);
  
  int x[N], y[N], a[N];
  for(int i=0; i<N; i++)
    scanf("%d %d %d", &x[i], &y[i], &a[i]);
  
  int k=W, l=0, m=W, n=0;
  for(int i=0; i<N; i++){
    if(a[i]==4){
      if(k>y[i])
        k = y[i];
    }
    else if(a[i]==3){
      if(l<y[i])
        l = y[i];
    }
    else if(a[i]==2){
      if(m>x[i])
        m = x[i];
    }  
    else{
      if(n<x[i])
        n = x[i];
    }
  }
  if(k>l && m>n)
    printf("%d", (k-l)*(m-n) );
  else
    printf("%d", 0);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,a[N],dp[N];
vector<ll> vt[N],vp;
void dfs(ll x,ll lst)
{
	ll pos=lower_bound(vp.begin(),vp.end(),a[x])-vp.begin(),tt,i;
	bool hs=false;
	if(pos>=vp.size())
	{
		vp.push_back(a[x]);
		hs=true;
	}
	else
	{
		tt=vp[pos];
		vp[pos]=a[x];
	}
	dp[x]=vp.size();
	for(i=0;i<vt[x].size();i++)
	{
		if(vt[x][i]!=lst)
		{
			dfs(vt[x][i],x);
		}
	}
	if(hs)
	{
		vp.erase(vp.begin()+vp.size()-1);
	}
	else
	{
		vp[pos]=tt;
	}
	return;
}
int main(){
	ll i,x,y;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		x--;
		y--;
		vt[x].push_back(y);
		vt[y].push_back(x);
	}
	dfs(0,-1);
	for(i=0;i<n;i++)
	{
		printf("%lld\n",dp[i]);
	}
	return 0;
}

Measured memory_bytes: 32064
S=input()
if S=="SUN":
  print(7)
if S=="MON":
  print(6)
if S=="TUE":
  print(5)
if S=="WED":
  print(4)
if S=="THU":
  print(3)
if S=="FRI":
  print(2)
if S=="SAT":
  print(1)

Measured memory_bytes: 9128
# -*- coding: utf-8 -*-
N=input()

#約数列挙
def make_divisors(n):
    divisors=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n/i:
                divisors.append(n/i)
    return divisors

#整数N-1の約数は全て答えにカウントして良い
ans=set(make_divisors(N-1))
wrong_ans=set(make_divisors(N-1))

K=make_divisors(N)  #Nの約数の集合
#整数Nの約数について条件にマッチングするかを1つ1つ調べる
for k in K:
    if k==1: continue
    n=N
    while n%k==0:
        n/=k
    else:
        #if n==1 or n%k==1:   #AC
        if n%k==1:
            ans.add(k)
print len(ans)-1


Measured memory_bytes: 30316