akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//CODE------------------------------------------
ll solve()
{
    ll n; cin>>n;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(ll i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 5160
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val H, W, D = sc.nextInt
    val A = Array.fill(H * W + 1)((0, 0))
    for (i <- Range(0, H)) {
      for (j <- Range(0, W)) {
        A(sc.nextInt) = (i, j)
      }
    }
    val B = Array.fill(H * W + 1)(0)
    for (i <- Range(D + 1, H * W + 1)) {
      B(i) = B(i - D) + math.abs(A(i - D)._1 - A(i)._1) + math.abs(A(i - D)._2 - A(i)._2);
    }
    println(Array.fill(sc.nextInt)((sc.nextInt, sc.nextInt)).map(v => B(v._2) - B(v._1)).mkString("\n"))
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

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


int main() {
  int x, n;
  cin >> x >> n;
  vec<bool> p(101, false);
  rep(i, n){
    int y;
    cin >> y;
    p[y] = true;
  }
  int l = x, r = x;
  int ans = 0;
  while(ans == 0){
    if(l == 0){
      ans = 0;
      break;
    }
    if(p[l] == false && p[r] == false) ans = l;
    else if(p[l] == false && p[r] == true) ans = l;
    else if(p[l] == true && p[r] == false) ans = r;
    l--;
    r++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Expired?
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int c = -a + b;
  if (c <= 0) puts("delicious");
  else if (c <= x) puts("safe");
  else puts("dangerous");
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    Yes(a + b >= c);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll x; cin >> x;
  ll gohyaku = x / 500;
  x -= 500*gohyaku;
  ll goen = x / 5;
  cout << gohyaku*1000 + goen*5 << endl;
  


  return 0;
}


Measured memory_bytes: 256
N,A,B,C = int(input()), input(), input(), input()
ans = 0
for a,b,c in zip(A,B,C):
  if a == b and b ==c: continue
  elif a==b or b==c or c==a: ans += 1
  elif a != b and b != c and c != a: ans += 2
print(ans)

Measured memory_bytes: 38384
s = list(str(input()))
t = list(str(input()))

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            try:
                #print(s[i], i, j)
                dp[i+1][j+1] = dp[i][j] + 1
            except IndexError:
                print(i, j)
        try:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1], dp[i+1][j+1])
        except IndexError:
            print(i,j)

"""
for i in range(len(s)+1):
    print(dp[i])
"""

str = ""
i, j = len(s), len(t)

while(i>0 and j>0):

    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        str = s[i-1] + str
        i -= 1
        j -= 1

print(str)

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    int a = 0, b = 0;
    for (int i = 0; i < n; i ++) {
      int x, y;
      cin >> x >> y;
      if (x > y) a += x + y;
      else if (x < y) b += x + y;
      else a += x, b += y;
    }
    cout << a << " " << b << endl;
  }
}



Measured memory_bytes: 3116
#include <iostream>

using namespace std;

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, K;
	cin >> K;

	for (i = 1; i <= K; i++) {
		if (i % 2)
			j++;
		else
			k++;
	}

	cout << j*k << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		String[] r = new String[n];
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			int p = sc.nextInt();
			r[i] = s + "_" + (1100 - p) + "_" + (i + 1);
		}
		
		Arrays.sort(r);
		
		for (String str : r) {
			System.out.println(str.split("_")[2]);
		}

		sc.close();
	}
	
}




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

#define ll int long long
#define dll double long long
#define forei(i,n,x) for(int i=n;i<=x;i++)
#define fored(i,n,x) for(int i=n;i>=x;i--)
#define forni(i,n,x) for(int i=n;i<x;i++)
#define fornd(i,n,x) for(int i=n;i>x;i--)
#define SQ(a) (a)*(a)
#define MOD 1000000007
#define sortvi(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pv(v) for(auto it: v) cout<<it
#define endl '\n'   //Take care in case of interactive problems
#define MAX1 100005
#define MAX2 200005
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

int co(int n)
{
    int a,b,c;
    a=n%10;
    n=n/10;
    b=n%10;
    n=n/10;
    c=n;
    if(a==7 || b==7 || c==7)
    return true;
    else
    return false;
}

int main() 
{ 
   
    int n;
    cin>>n;
    if(co(n))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0; 
} 


Measured memory_bytes: 3632
#include <iostream>
#include <ostream>
#include <istream>
#include <cmath>
#include <string>
#include <vector>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <vector>
#include <set>
#define pb push_back
#define ppb pop_back
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define forv(i, v) forn(i, v.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"
#define pi 3.1415926535897932
#define NMAX 100005
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int Mod=1e9+7;
const int INF=INT_MAX/2;
vector<int> bfs(int N,vector<vector<int>>& G,int s) {
	vector<int> d(N,INF);
	d[s]=0;
	queue<int> q;
	q.push(s);
	while(q.size()) {
		int u=q.front();
		q.pop();
		for(int v:G[u]) {
			if(d[v]>d[u]+1) {
				d[v]=d[u]+1;
				q.push(v);
			}
		}
	}
	return d;
}
int main() {
	int n;
	cin>>n;
	vector<vector<int>>G(n);
	forn(i,n-1) {
		int u,v;
		scanf("%d%d",&u,&v);
		u--;
		v--;
		G[u].push_back(v),G[v].push_back(u);
	}
	vector<int>d1=bfs(n,G,0);
	vector<int>d2=bfs(n,G,n-1);
	int n1=0,n2=0;
	forn(u,n)if(d1[u]<=d2[u])n1++;
	else n2++;
	cout<<(n1>n2?"Fennec":"Snuke")<<endl;
	return 0;
}



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

int main(){
	int C[16];
	int n,m;
	while(cin >> n >> m && n){
		for(int i = 0 ; i < m ; i++) cin >> C[i];
		unsigned int dp[2][256];
		for(int i = 0 ; i < 2 ; i++)
			for(int j = 0 ; j < 256 ; j++)
				dp[i][j] = INT_MAX;
		dp[0][128] = 0;
		
		for(int j = 1 ; j <= n ; j++){
			int x; cin >> x;
			for(int i = 0 ; i < 256 ; i++) dp[j&1][i] = INT_MAX;
			for(int i = 0 ; i < 256 ; i++){
				for(int k = 0 ; k < m ; k++){
					int y = i + C[k];
					y = min(y,255); y = max(0,y);
					dp[j&1][y] = min(dp[j&1][y],dp[j&1^1][i] + (y-x)*(y-x) );
				}
			}
		}
		cout << *min_element(dp[n&1],dp[n&1]+256) << endl;
	}
}

Measured memory_bytes: 880
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

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

  map<int, bool> from_0;
  vector<int> to_n;

  while (m--) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      from_0[b-1] = true;
    }
    if (b == n) {
      to_n.push_back(a-1);
    }
  }

  for (int i = 0; i < to_n.size(); i++) {
    if ( from_0[ to_n[i] ] ) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 9976
#include <iostream>
#include <vector>

int main(int argc, char** argv) {
  const int N {[](){int a;std::cin >> a;return a;}()};
  std::vector<int> a(N);
  for (auto& e : a) {
    std::cin >> e;
  }
  int sum {};
  int num {1};
  for (const auto& e : a) {
    if (e != num) {
      ++sum;
    } else {
      ++num;
    }
  }
  if (sum == N) sum = -1;
  std::cout << sum << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define P pair<ll,ll>
using namespace std;
vector<P>v;
ll n, m;

int main() {
    cin>>n>>m;
    int x, y;
    for(int i=0;i<n;i++) {
        cin>>x>>y;
        v.pb(mp(x, y));
    }

    sort(v.begin(), v.end());

    ll cost = 0LL;
    for(int i=0;i<n;i++) {
        if(m <= v[i].second) {
            // buy m drinks
            cost += m * v[i].first;
            m = 0;
            break;
        }
        else {
            // buy all v[i].second drinks
            cost += 1LL * v[i].second * v[i].first;
            m -= v[i].second;
        }
    }
    cout<<cost<<"\n";
    return 0;
}

Measured memory_bytes: 2420
import scala.io.Source.stdin

object Main extends App {
  for(s<-stdin.getLines) {
    var t:String = s
    while(!t.contains("this") && !t.contains("the") && !t.contains("that")) {
      t = t map { c => if(c.toInt >= 97 && c.toInt <= 121) (c.toInt+1).toChar else if(c==122) 'a' else c }
    }
    println(t)
  }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  string s, t;
  cin >> s;
  if (s.back() == 's') t = "es";
  else t = "s";
  cout << s+t << endl;
}

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

int main() {
  string raw_pass,key;
  cin >> raw_pass >> key;
  int ans_id=1e9;
  for(int i=raw_pass.size()-key.size();i>-1;i--) {
    bool tflag=true;
    for(int j=0;j<key.size();j++) {
      if(raw_pass.at(i+j)!='?'&&raw_pass.at(i+j)!=key.at(j)) {
        tflag=false;
        break;
      }
    }
    if(tflag) {
      ans_id=i;
      break;
    }
  }
  
  if(ans_id==1e9) {
    cout << "UNRESTORABLE" << endl;
  }
  else {
    for(int i=0;i<raw_pass.size();i++) {
      if(ans_id<=i&&i<ans_id+key.size()) {
        cout << key.at(i-ans_id);
      }
      else if(raw_pass.at(i)=='?') {
        cout << 'a';
      }
      else {
        cout << raw_pass.at(i);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);

const count = parseInt(input[0].split(' ')[0]);
const target = new Array<string>();
let result = '';

for (let i = 1; i < count + 1; i++) {
    target.push(input[i]);
}

target.sort();

target.forEach(text => {
    result += text;
});

console.log(result);

Measured memory_bytes: 7500
#include<cstdio>
const int MAXN=18,MAXS=(1<<15)+10,MOD=1000000007;

int N,M;
int G[MAXN];
int dp[MAXS],pw2[MAXN*MAXN];

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=1;i<=M;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		v--;
		G[u]|=(1<<v);
	}
	
	dp[0]=1;
	pw2[0]=1;
	for(int i=1;i<=M;i++)
		pw2[i]=(pw2[i-1]<<1)%MOD;
	for(int S=1;S<(1<<N);S++)
		for(int U=S;U;U=(U-1)&S)
			if((U&1)==((U>>1)&1))
			{
				int T=S^U;
				int tmp=1;
				for(int i=1;i<=N;i++)
					if(S&(1<<(i-1)))
					{
						if(U&(1<<(i-1)))
							tmp=1LL*tmp*pw2[__builtin_popcount(G[i]&T)]%MOD;
						else
							tmp=1LL*tmp*(pw2[__builtin_popcount(G[i]&U)]-1)%MOD;
					}
				dp[S]=(dp[S]+1LL*dp[T]*tmp%MOD)%MOD;
			}
	int ans=(pw2[M]-dp[(1<<N)-1]+MOD)%MOD;
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 256
def read():
    return [int(x) for x in str.split(raw_input())]

n = int(raw_input())
a, b = [], []

for i in range(n):
    x, y = read()
    a.append(x)
    b.append(y)

ans, cnt = 0, 0
for i in range(n-1, -1, -1):
    add = (b[i]-(ans+a[i])%b[i])%b[i]
    ans = add+ans
    cnt = cnt+add
    
print(cnt)


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	string s;
	cin >> s;

	bool ret = true;
	rep(i, s.size()) {
		if(i % 2 == 0 && s.at(i) == 'L') ret = false;
		if(i % 2 == 1 && s.at(i) == 'R') ret = false;
	}

	Yn(ret);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main(void) {
	int n, a;
	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		++mp[a];
	}
	int cnt = 0;
	for (auto x : mp) {
		if (x.second % 2 == 1) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    int n,f=0;
    cin>>n;
    vector<int>a(1000000);
    vector<string>s(1000000);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(s[i]==s[j]){
                f=1;
            }
        }
    }
    for(int i=0;i<n-1;i++){
        if(s[i][s[i].size()-1]!=s[i+1][0]){
            f=1;
        }
    }
    if(f==1){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }

    return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int N;
int A[210];

int main() {
    cin >> N;
    REP(i,N) cin >> A[i];
  
    int res = 0;
  
    while (true) {
        bool exist_odd = false;
        REP(i,N) {
            if (A[i] % 2 == !0) exist_odd = true;
        }
      
        if (exist_odd) break;
      
        REP(i,N) A[i] /= 2;
        res++;
    }
  
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#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;
    ll n,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n,k-n)<<endl;
    return 0;
}

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

#define LUNCH 0
#define DINNER 1
#define MIDNIGHT 2

#define OK 0
#define NG 1

int main(void){
	int n, i, j, hh, mm, MM, ans[3][2], *p;
	char str_MM[3];


	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}

		memset(ans,0,sizeof(ans));

		for(i = 0;i < n;i++){
			scanf("%d%*c%d%d",&hh,&mm,&MM);
		/*	scanf("%s",str_MM);
			
			MM = 0;
			for(i = 0;i < 2;i++){
				MM = MM * 10 + (str_MM[i] - '0');
			}*/

			if(2 <= hh && hh <= 10 || 15 <= hh && hh <= 17){
				continue;
			}

			if(11 <= hh && hh <= 14){
				p = ans[LUNCH];
			}else if(18 <= hh && hh <= 20){
				p = ans[DINNER];
			}else{
				p = ans[MIDNIGHT];
			}

			if((MM + 60 - mm) % 60 <= 8){
				p[OK]++;
			}else{
				p[NG]++;
			}
		}
		if(ans[LUNCH][OK] != 0 || ans[LUNCH][NG] != 0){
			printf("lunch %d\n",ans[LUNCH][OK] * 100 / (ans[LUNCH][OK] + ans[LUNCH][NG]));
		}else{
			printf("lunch no guest\n");
		}
		if(ans[DINNER][OK] != 0 || ans[DINNER][NG] != 0){
			printf("dinner %d\n",ans[DINNER][OK] * 100 / (ans[DINNER][OK] + ans[DINNER][NG]));
		}else{
			printf("dinner no guest\n");
		}
		if(ans[MIDNIGHT][OK] != 0 || ans[MIDNIGHT][NG] != 0){
			printf("midnight %d\n",ans[MIDNIGHT][OK] * 100 / (ans[MIDNIGHT][OK] + ans[MIDNIGHT][NG]));
		}else{
			printf("midnight no guest\n");
		}
		
	}
	return 0;
}

Measured memory_bytes: 1040
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	vector< int > S(N), T(M);
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];
	vector< vector< int > > dp(N + 1, vector< int >(M + 1, 0));
	vector< vector< int > > sum(N + 1, vector< int >(M + 1, 0));
	dp[0][0] = 0;
	rep(i, N) rep(j, M) {
		if (S[i] == T[j]) {
			dp[i + 1][j + 1] = (sum[i][j] + 1) % MOD;
		}
		sum[i + 1][j + 1] = (sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + dp[i + 1][j + 1] + MOD) % MOD;
	}
	cout << sum[N][M] + 1 << endl;
	return 0;
}

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

long long int dp[100][4][4];
int plan[100], N, K;

long long int solve(int today, int before1, int before2) {
  if( today == N ) return 1;
  if( dp[today][before1][before2] != -1 ) 
    return (dp[today][before1][before2]);
  if( plan[today] ) {
    if( plan[today] == before1 && before1 == before2 ) {
      return 0;
    } 
    else {
      return (solve(today+1, plan[today], before1) % 10000);
    }
  }

  long long int ret = 0;
  for(int i=1; i<=3; i++) {
    if( i != before1 || before1 != before2 ) {
      ret += solve(today+1, i, before1) % 10000;
    }
  }

  return dp[today][before1][before2] = ret;
} 
	      


int main() {
  cin >> N >> K;
  memset(plan, 0, sizeof(plan));
  memset(dp, -1, sizeof(dp));

  for(int i=0; i<K; i++) {
    int a, b;
    cin >> a >> b;
    plan[a-1] = b;
  }

  cout << solve(0,0,0) % 10000 << endl;
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>

using namespace std;

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

  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }

  int max_profit = -2000000000;
  for (int i = 1; i < 1024; i++) {
    int profit = 0;
    for (int n = 0; n < N; n++) {
      int count = 0;
      for (int j = 0; j < 10; j++) {
        if (F[n][j] == 1 && ((i >> j) & 1) == 1) {
          count++;
        }
      }
      profit += P[n][count];
    }
    if (profit > max_profit) {
      max_profit = profit;
    }
  }
  cout << max_profit << endl;
}



Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().strip().split())
  scs = [10]*n

  for _ in range(m):
    s, c = map(int, input().strip().split())
    s -= 1
    if scs[s] != 10 and scs[s] != c:
      print(-1)
      return
    scs[s] = c

  if n >1 and scs[0] == 0:
    print(-1)
    return

  if n==1 and scs[0] in [0, 10] :
    print(0)
    return

  num = ['0'] * n
  for i in range(len(scs)):
    if scs[i] != 10:
      num[i] = str(scs[i])
    if scs[i] == 10 and i == 0:
      num[i] = '1'
  print(int(''.join(num)))

if __name__=='__main__':
  main()



Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const ll NEGINF = LLONG_MIN;
const int N = 18;
const ll MAXN = 1000001;
#define MAX 5


void solve(int t)
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({b * d, a * c, a * d, b * c}) << endl;




}


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




	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
using namespace std;
#define INF (1<<29)
int N;
bool ok(int a,int b,int c){
  if(a*200+b*300+c*500==N) return true;
  return false;
}
int calc(int a,int b,int c){
  return a*380-(a/5)*380 + b*550-(b/4)*330 + c*850-(c/3)*306;
}
int main(){
  while(scanf("%d",&N),N){
    int res = INF;
    for(int a=0;a<251;a++){
      for(int b=0;b<200;b++){
	for(int c=0;c<101;c++){
	  if(ok(a,b,c))
	    res = min(res,calc(a,b,c));
	}
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll inf = (1LL<<60);

int N, R;
ll dist[205][205];
ll ans = (1LL<<60);
bool seen[205];

vector<int> r(10);

void floyd(){
    for(int k=1; k<=N; k++){
        for(int i=1; i<=N; i++){
            if(dist[i][k] == inf) continue;
            for(int j=1; j<=N; j++){
                if(dist[j][k] == inf) continue;

                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
}

void dfs(int now, ll d){
    bool flg = true;
    for(int i=1; i<=R; i++) if(!seen[r[i]]) { flg = false; break; }
    if(flg == true){
        ans = min(ans, d);
        seen[now] = false;
        return ;
    }

    for(int i=1; i<=R; i++){
        if(now == 0){
            seen[r[i]] = true;
            dfs(r[i], 0);
        } else if(!seen[r[i]]){
            seen[r[i]] = true;
            dfs(r[i], d+dist[now][r[i]]);
        }
    }

    seen[now] = false;
}


int main(){
    int M; cin >> N >> M >> R;
    for(int i=1; i<=R; i++) cin >> r[i];

    for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) dist[i][j] = inf;
    for(int i=0; i<M; i++){
        int a, b, c; cin >> a >> b >> c;
        dist[a][b] = dist[b][a] = c;
    }

    floyd();
    dfs(0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 512
n = int(input())
cnt = [[0 for _ in range(11)] for _ in range(11)]
for i in range(1, n + 1):
    x = i
    while x >= 10:
        x //= 10
    cnt[x][i % 10] += 1
ans = 0
for i in range(1, n + 1):
    x = i
    while x >= 10:
        x //= 10
    ans += cnt[i % 10][x]
print(ans)

Measured memory_bytes: 3064
#include<set>
#include<iostream>
using namespace std;
int main(){
	int i=2,N,h,m;
	set<pair<int, int>> t;
	while (i--&&cin>>N)
		while (N--&&cin >> h >> m)
			t.insert(make_pair(h, m));
	for (auto i=t.begin();i!=t.end();)
		printf("%d:%02d",i->first,i->second),cout<<(++i!=t.end()?" ":"");
	cout<<endl;
}

Measured memory_bytes: 1228
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ld a,b;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;ld ans = 1;ll flag = 0;ll flag1 = 0;
		for(ll i=0;i<n;i++)
		{
			cin>>a;
			if(a==0)flag1 = 1;
			ld d = (ld)(1e+18)/(ld)ans;
			if(a<=d)ans *= a;
			else flag = 1;
			
		}
		if(flag1)cout<<0<<endl;
		else if(flag)cout<<-1<<endl;
		else cout<<(ll)ans<<endl;
}		

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    
}


Measured memory_bytes: 6100
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    var a = readLine()!!.split(" ").map { Math.abs(x - it.toInt() * 0.006 - y) }
    println(a.indexOf(a.min()) + 1)
}

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

const int N = 100004;
pair<long long, long long> dp[N];

int main()
{
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> dp[i].first;
	}
	
	dp[2].second = abs(dp[2].first - dp[1].first);
	
	
	for(int i = 3; i <= n; i++)
	{
		dp[i].second = min((dp[i-1].second + abs(dp[i-1].first - dp[i].first)), (dp[i-2].second + abs(dp[i-2].first - dp[i].first)));
	}
	
	cout << dp[n].second;
	
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
int a[6]={};
  for(int i=1;i<=5;i++){
    cin>>a[i];
  }
  for(int i=1;i<=5;i++){
    if(a[i]==0){
      cout<<i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3564
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N;cin>>N;
    map<int,int> m;
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                int ans = pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i;
                if(ans<=10000) m[ans]++;
            }
        }
    }
    for(int i=1;i<=N;i++){
        cout << m[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4068
import java.io.*;
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		Triangle tri = new Triangle(scan.nextInt(),scan.nextInt(),scan.nextInt());
		System.out.println(tri.getArea());
		System.out.println(tri.getPerimeter());
		System.out.println(tri.getHeight());
			
	}

}
class Triangle{
	int a;
	int b;
	int c;
	public Triangle(int a, int b, int c){
		this.a=a;
		this.b=b;
		this.c=c;
	}
	double getArea(){
		return a*b*Math.sin(Math.toRadians(c))/2;
	}
	double getPerimeter(){
		return a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c)));
	}
	double getHeight(){
		return b*Math.sin(Math.toRadians(c));
	}

}

Measured memory_bytes: 17180
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Control.Monad.ST
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

newUF n = VUM.replicate n (-1 :: Int)

root uf x = do
    p <- VUM.read uf x
    if p < 0
        then return x
        else do
            r <- root uf p
            VUM.write uf x r
            return r

same uf x y = liftM2 (==) (root uf x) (root uf y)

unite uf x y = do
    px <- root uf x
    py <- root uf y
    when (px /= py) $ do
        sx <- VUM.read uf px
        sy <- VUM.read uf py
        let (par, chld) = if sx < sy then (px, py)　else (py, px)
        VUM.write uf chld par
        VUM.write uf par (sx + sy) 

size uf x = do
    px <- root uf x
    s <- VUM.read uf px
    return $ abs s


readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    xy <- replicateM m $ do
        [x,y,_] <- getIntList
        return (x-1,y-1)
    let ufvec = VU.create $ do
            uf <- newUF n
            forM_ xy $ \(x,y) -> do
                unite uf x y
            return uf
    let ans = VU.length $ VU.filter (< 0) ufvec
    print ans

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

int main(){
    int n;
    long double ans=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        ans+=1.00000/a[i];
    }
    ans=1.00000/ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#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)
{
    unsigned long long a, k;
    double b;
    cin >> a >> b;
    if (a != 0 && b != 0)
    {
        k = b * 1000;
        a *= k;
        a /= 1000;
        cout << a << endl;
    }
    else
        cout << 0 << endl;
}

Measured memory_bytes: 3728
H, W = map(int, input().split())
S = ['.'*(W+2)] + ['.' + input() + '.' for _ in range(H)] + ['.'*(W+2)]
flg = False
for i in range(1, H+1):
  for j in range(1, W+1):
    if S[i][j] == '#':
      cnt = 0
      if S[i][j-1] == '.':
        cnt += 1
      if S[i][j+1] == '.':
        cnt += 1
      if S[i-1][j] == '.':
        cnt += 1
      if S[i+1][j] == '.':
        cnt += 1
      flg = (cnt == 4)
      if flg:
        break
  if flg:
    break
if flg:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	if N >= 30:
		print("Yes")
	else:
		print("No")

	#print(N)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 76864
use std::cmp::{max, min};
fn keta(x: u64) -> u64 {
    let mut x = x;
    let mut keta = 0;
    if x == 0 {
        return 0;
    }
    while x > 0 {
        keta += 1;
        x /= 10;
    }
    keta
}

fn main() {
    let n = read::<u64>();
    let mut max_i = 0;
    for i in 1..n + 1 {
        if i * i >= n {
            max_i = i;
            break;
        }
    }

    let mut ans = 10;
    for i in 1..max_i + 1 {
        if n % i == 0 {
            ans = min(ans, max(keta(i), keta(n / i)));
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
 
int main()
{
	char a;
	cin >> a;
	a++;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    vector <int> a;
    cin >> n >> m;
    for (int i = 0; i<m;i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    int sum = 0;
    for(int i = 0 ; i < a.size(); i++){
        sum+=a[i];
    }
    if(sum>n){
        cout << -1 << endl;
    }else{
        cout << (n-sum) << endl;
    }
    return 0;
}

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

int main(){
    int N; cin >> N;
    set<int> A;
    bool flag = false;
    int input;
    for(int i=0; i<N; i++){
        cin >> input;
        if(A.find(input) != A.end()) flag = true;
        else A.insert(input);
    }
    if(flag) cout << "NO" << endl;
    else cout << "YES" << endl;

}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 10000000007;

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

int main() {
  int N,K;
  cin >> N >> K;
  int x[N];
  for(int i = 0; i < N; i++) {
    cin >> x[i];
  }
  int sum = 0;
  for(int i = 0; i < N; i++) {
    sum += min(x[i]*2,(K - x[i])*2);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int N,data[200]={0},h,m,cou=0,sum=0;
	for (int B=0;B<2;B++){
		cin>>N;
		sum+=N;
		for (int A=0;A<N;A++){
			cin>>h>>m;
			h*=100;
			h+=m;
			data[cou]=h;
			cou++;
		}
	}
	sort(data,data+sum);
	for (int A=0;A<sum-1;A++){
		if(data[A]==data[A+1]) continue;
		if (data[A]%100<10) cout<<(data[A]-data[A]%100)/100<<":"<<0<<data[A]%100<<" ";
		else cout<<(data[A]-data[A]%100)/100<<":"<<data[A]%100<<" ";
	}
	sum--;
	if (data[sum]%100<10) cout<<(data[sum]-data[sum]%100)/100<<":"<<0<<data[sum]%100<<endl;
	else cout<<(data[sum]-data[sum]%100)/100<<":"<<data[sum]%100<<endl;
	return 0;
}


Measured memory_bytes: 3164
import sys
sys.setrecursionlimit(10**7)

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)
def solve():
    N = int(input())
    d_list = list(map(int, input().split()))
    d_list.sort()

    dprint(d_list)


    if N % 2 != 0:
        print(0)
        return

    cnt = 0

    left = d_list[N//2-1]
    right = d_list[N//2]
    dprint(left, right)
    print(right-left)

solve()

Measured memory_bytes: 14120
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s;
  cin >> s;

  if(s[0] != s[1] || s[1] != s[2])
    cout << "Yes";
  else cout << "No";

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  h,w,i,j,count,x,y,a,b,sw:Integer;
  s:array of string;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(w);
    Read(a);
    Readln(b);

    Writeln(((abs(a-b)-w)+abs(abs(a-b)-w))div 2);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


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

int main() {
  int N;
  cin >>N;
  vector<int>a(N);
  int C=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int i=0;i<N;i+=2){
    if(a[i]%2!=0){
      C+=1;
    }
  }

  cout << C << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
#define fi first
#define se second
int q(int x){
    if(x==0||x==9)return 2;
    return 3;
}
int mi(int x){
    if(x==0)return 0;
    return x-1;
}
int ma(int x){
    if(x==9)return 9;
    return x+1;
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    if(k<=10){
        cout<<k;
        return 0;
    }
    vector<int> v;
    k-=10;
    v.pb(0);v.pb(1);
    while(k>0){
        int z=v[1];
        if(q(z)>k)break;
        k-=q(z);
        // bool f=0;
        // if(v[v.size()-1]==9){
        //     v.push_back(1);
        //     for(int i=0;i<v.size()-1;i++)v[i]=0;
        //     continue;
        // }
        int i=1;
        while(i+1<v.size()&&ma(v[i+1])==v[i]){
            i++;
        }
        if(i+1==v.size()){
            if(v[i]==9){
                v.pb(1);
                i++;
            }
            else v[i]+=1;
        }
        else v[i]+=1;
        for(int j=i-1;j>=0;j--){
            v[j]=mi(v[j+1]);
        }
        // for(auto it: v)cerr<<it;
        // cerr<<'\n';
    }
    v[0]+=k;
    reverse(v.begin(),v.end());
    for(int i=0;i<v.size();i++)cout<<v[i];
}

Measured memory_bytes: 256
inputs = [int(input()) for _ in range(5)]
inputs_mod10 = [i%10 for i in inputs]
ans = 0
min_mod = 10
for i in range(5):
    if inputs_mod10[i]==0:
        ans += inputs[i]
    else:
        ans += (inputs[i]//10 +1 )*10
        min_mod = min(min_mod,inputs_mod10[i])
ans -= (10-min_mod)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <list>

const int MOD = 1e9 + 7;
const int MAX = 100000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using ll = long long int;
using namespace std;

vector<int> graph[MAX];
list<int> out;
bool visited[MAX];
int N, M, cnt = 0;

void dfs(int u)
{
    visited[u] = true;
    for (int i = 0; i < graph[u].size(); i++)
    {
        int v = graph[u][i];
        if (!visited[v])
            dfs(v);
    }

    out.push_front(u);
}

int main()
{
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
    }

    for(int i = 0; i < N; i++)
        visited[i] = false;

    for (int i = 0; i < N; i++)
        if (!visited[i])
            dfs(i);

    for(auto x : out)
        cout << x << endl;

    return 0;
}


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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            // 整数の入力
            int n = int.Parse(Console.ReadLine());

            // 文字列の入力
            string s = Console.ReadLine();

            char current = '%';
            long result = 0;
            foreach(char c in s)
            {
                if(c == current)
                {
                    continue;
                }
                result++;
                current = c;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11232