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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
#define log2(x) (log(x)/log(2))
#define ln '\n'
#define bln(i,n) ((i==n-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int q, a, b, t, r;

signed main() {
	cin >> q;
	while (q--) {
		cin >> a >> b;
		t = sqrt(a*b), r = t*2-1;
		if (t*t==a*b && a!=b) r--;
		if (t*(t+1)>=a*b) r--;
		cout << r << ln;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
using namespace std;

long long N, P; vector<pair<long long, long long>>V;

int main() {
	cin >> N >> P;
	for (long long i = 2; i*i <= P; i++) {
		int cnt = 0;
		while (P%i == 0) { P /= i; cnt++; }
		if (cnt >= 1) V.push_back(make_pair(i, cnt));
	}
	if (P >= 2) V.push_back(make_pair(P, 1));

	long long rem = 1;
	for (int i = 0; i < V.size(); i++) {
		while (V[i].second >= N) { rem *= V[i].first; V[i].second -= N; }
	}
	cout << rem << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
static char s[100001], *p;
static int i, ints[256];
int main(void) {
    p = s;
    scanf("%s", s);
    while (*p)
        ++ints[*p++];
    for (i = 'a'; i <= '{'; ++i)
        if (!ints[i]) {
            if (i == '{')
                puts("None");
            else
                printf("%c\n", i);
            break;
        }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 1000453
#define L 20
char H[M][L];
int getchar2(char fu)
{
    if(fu=='A')
        return 1;
    if(fu=='C')
        return 2;
    if(fu=='G')
        return 3;
    if(fu=='T')
        return 4;
}

int getchar(char zhi[])
{
 long long n,sum=0,p=1;
 n=strlen(zhi);
 for (int i=0;i<n;i++)
        {
            sum+=p*(getchar2(zhi[i]));
            p*=6;
        }
    return sum;
}

int myfind(char zhi[])
{
    long long key,h;
    key=getchar(zhi);
    for (long long  i=0;;i++)
    {
     h=(key%M+i*(1+(key%(M-1))))%M;
     if(strcmp(H[h],zhi)==0) return 1;
     else if(strlen(H[h])==0) return 0;
    }
    return 0;
}

int myinsert(char zhi[])
{
    long long key,h;
    key=getchar(zhi);
    for(long long i=0;;i++)
    {
        h=(key%M+i*(1+(key%(M-1))))%M;
        if(strcmp(H[h],zhi)==0) return 1;
        else if(strlen(H[h])==0)
        {
            strcpy(H[h],zhi);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int n;
    char ml[20],zhi[20];
    for (int i=0;i<M;i++)
        H[i][0]='\0';
    scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        scanf("%s %s",ml,zhi);
    if(ml[0]=='i')
        myinsert(zhi);
    else {
        if (myfind(zhi)==1)
            printf("yes\n");
            else printf("no\n");
         }
    }
    return 0;
}

Measured memory_bytes: 22216
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
    int n = scan!int;
    int[] as = scan!int(n);

    int amax = as[0];
    foreach(a; as) amax.raiseTo(a);

    int[] acnt = new int[](amax + 1);
    foreach(a; as) acnt[a] += 1;

    string ans = "Possible";
    foreach(a, cnt; acnt){
        if(a * 2 < amax){
            if(cnt > 0) ans = "Impossible";
        }
        if(a * 2 == amax){
            if(cnt != 1) ans = "Impossible";
        }
        if(a * 2 == amax + 1){
            if(cnt != 2) ans = "Impossible";
        }
        if(a * 2 > amax + 1){
            if(cnt <= 1) ans = "Impossible";
        }
    }
    ans.writeln;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

double f (double a, double b, double theta) {
  if (theta > M_PI/2) return 0;

  double ret;
  if (a*tan(theta) <= b) ret = a*a*b - a*a*a*tan(theta)/2;
  else ret = b*b/tan(theta)*a/2;

  return ret;
}

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

  double ok = M_PI/2;
  double ng = 0;
  for (int _ = 1; _ <= 100000; ++_) {
    double mid = (ok + ng)/2;
    if (f(a,b,mid) < x) ok = mid;
    else ng = mid;
  }

  printf("%.10f\n", ok/M_PI*180);
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys

read = sys.stdin.read
readline = sys.stdin.readline

h, w, k = map(int, readline().split())
x1, y1, x2, y2 = map(int, readline().split())
x1, y1, x2, y2 = x1 - 1, y1 - 1, x2 - 1, y2 - 1

field = [readline() for _ in range(h)]
costs = [[-1] * w for _ in range(h)]

q = deque([(x1, y1)])
costs[x1][y1] = 0

while q:
    x, y = q.popleft()
    for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        for i in range(1, k + 1):
            px, py = x + dx * i, y + dy * i
            if not(0 <= px < h and 0 <= py < w) or field[px][py] == '@':
                break
            if 0 <= costs[px][py] < costs[x][y] + 1:
                break
            if costs[px][py] == -1:
                q.append((px, py))
            costs[px][py] = costs[x][y] + 1

print(costs[x2][y2])


Measured memory_bytes: 98448
#include<stdio.h>
int main(){
    int a,b,i,j,h1=0,h2=0,h3=0;
    for(i=0;i<10;i++){
        scanf("%d",&a);
        if(a>h1){
                h3=h2;
                h2=h1;
                h1=a;
        }
        else if(a>h2){
                h3=h2;
                h2=a;
        }
        else if(a>h3){
                h3=a;
        }
    }
    printf("%d\n%d\n%d\n",h1,h2,h3);
    return 0;
}

Measured memory_bytes: 600
import sys
from collections import defaultdict, deque
n = int(sys.stdin.readline().split()[0])
A = defaultdict(deque)
ans = []
for query in sys.stdin:
    if query[0] == '0':
        t, x = query[2:].split()
        A[t].append(x)
    elif query[0] == '1':
        if A[query[2:-1]]:
            ans.append(A[query[2:-1]][-1] + '\n')
    else:
        if A[query[2:-1]]:
            A[query[2:-1]].pop()
sys.stdout.writelines(ans)



Measured memory_bytes: 20128
from itertools import accumulate
import math

N =int(input())
list_aaa = list(map(int,input().split()))

ans = 10**10

sum_list_aaa =list(accumulate(list_aaa))

for i in range(N):
    zen = sum_list_aaa[i]
    go = sum_list_aaa[-1]-sum_list_aaa[i]
    ans = min(ans,abs(zen-go))

print(ans)

Measured memory_bytes: 25740
uses math;
var n,m,ans,p,ppp,i:int64;
 
begin
readln(n,m);
ppp:=1000000007;
if n=m then ans:=2;
if n=m+1 then ans:=1;
if n+1=m then ans:=1;
if ans=0 then begin writeln(0);halt;end;
p:=1;
while i<min(n,m) do begin inc(i);p:=(p*i)mod ppp;end;
p:=(p*p)mod ppp;
if n=m then writeln((p*2)mod ppp);
if n=m+1 then writeln((p*n)mod ppp);
if n+1=m then writeln((p*m)mod ppp);
end.

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

void cc_env(){
	#ifndef ONLINE_JUDGE
		freopen("input", "r", stdin);
		freopen("output", "w", stdout);
		// 
	#endif
}

void self_max(int &a, int b){
	a = max(a, b);
}


int main(){
	// cc_env();
	// input part
	int N;
	cin>>N;
	vector<int > temp(3), local_dp(3, 0), global_dp(3, 0);

	// output part also started

	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++)
			cin>>temp[j];

		// processng

		for(int k=0;k<3;k++){
			for(int l=0;l<3;l++){
				if(k != l){
					self_max(local_dp[k], global_dp[l]+temp[k]);
				}
			}
		}
		

		global_dp.swap(local_dp);
		// for(int m =0;m<3;m++)
		// 	cout<<global_dp[m]<<" ";
		// cout<<endl;
		local_dp = vector<int>(3, 0);
	}

	int maxVal = *max_element(global_dp.begin(), global_dp.end());
	cout<<maxVal<<endl;
}


Measured memory_bytes: 256
N = int(input())
if N<10:
  print(N)
elif N<100:
  print(9)
elif N<1000:
  print(9+N-99)
elif N<10000:
  print(909)
elif N<100000:
  print(9+900+N-9999)
elif N==100000:
  print(90909)

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d; cin>>a>>b>>c>>d;
    if(abs(c-a)>d){
        if(abs(c-b)>d || abs(b-a)>d ) print("No");
        else print("Yes");
    }
    else print("Yes");
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	rep(i,n) cin >> w[i];
	int s1 = 0;
	int s2 = 0;
	rep(i,n) s2 += w[i];
	int mn = 100000000;
	rep(i,n){
		s1 += w[i];
		s2 = s2 - w[i];
		mn = min(abs(s2-s1),mn);
	}
	cout << mn << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3608
n, m, x, y = map(int, input().split())
xi = list(map(int, input().split()))
yi = list(map(int, input().split()))
ok = False
for zi in range(-100,101):
  if x < zi <= y:
    if max(xi)<zi and min(yi)>=zi:
      ok = True
if ok:
  print("No War")
else:
  print("War")

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

int main() {

  int64_t X; cin >> X;

  int64_t money = 100; 
  int64_t year = 0;
  
  while (money < X){
   money *=1.01;
    year++;
  }
  
 cout << year << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String args[]){
		int a,b;
		int S,L;
		//System.out.println("Please input a,b:");
		sc = new Scanner(System.in);
		
		a = sc.nextInt();
		b = sc.nextInt();
		S=a*b;
		L=2*(a+b);
		
		System.out.println(S+" "+L);
		
	}
}


Measured memory_bytes: 26352
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>
#include <stack>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8
#define MOD (1000003)
#define IOS ios::sync_with_stdio(false)

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

int n,m;
vector<int> v[100005];
bool visit[100005],col[100005];
int w,b;

void dfs(int x,int c)
{
	visit[x]=1;
	col[x]=c;
	for(int i=0;i<v[x].size();i++)
	{
		if(visit[v[x][i]]) continue;
		dfs(v[x][i],!c);
	}
}

int main()
{
	IOS;
	cin>>n>>m;
	for(int i=1;i<=m;i++) 
	{
		int a,b;
		cin>>a>>b;
		v[a].PB(b);
		v[b].PB(a);
	}
	dfs(1,0);
	bool bin=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<v[i].size();j++)
		{
			if(col[i]==col[v[i][j]]) 
			{
				bin=1;
				break;
			}
		}
		if(bin) break;
	}
	if(bin)
	{
		ll ans=((ll)n*(ll)(n-1))/2ll-(ll)m;
		cout<<ans;
		return 0;
	}
	else 
	{
		for(int i=1;i<=n;i++) 
		{
			if(col[i]) w++; else b++;
//			cout<<col[i]<<" ";
		}
//		cout<<endl;
		ll ans=(ll)w*(ll)b-(ll)m;
		cout<<ans;
		return 0;
	}
}

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

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

    vector<int> dist(K, 1e9+1); dist[1] = 1;
    deque<int> que; que.push_back(1);
    while(!que.empty()) {
        int now = que.front(); que.pop_front();
        int nxt1 = now + 1 >= K ? 0 : now + 1;
        if(dist[nxt1] > dist[now] + 1) {
            dist[nxt1] = dist[now] + 1;
            que.push_back(nxt1);
        }
        int nxt0 = now * 10 % K;
        if(dist[nxt0] > dist[now]) {
            dist[nxt0] = dist[now];
            que.push_front(nxt0);
        }
    }

    cout << dist[0] << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == i+1) {
            ans++;
            if (i < n-1 && a[i+1] == i+2) i++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    int ans = INT_MAX;
    for (int score = -100; score <= 100; score++) {
        int tmp = 0;
        for (auto e : a) tmp += (score - e) * (score - e);
        ans = min(ans, tmp);
    }

    cout << ans << '\n';

}

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

    solve();

    return 0;
}

Measured memory_bytes: 3664
use std::cmp::min;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        k:i32,
        x:[i32;n]
    }
    let mut ans:i32 = 0;
    for i in 0..n{
        let distance = min((k-&x[i]).abs(),(&x[i]).abs());
        ans += distance * 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    h, w = input_int_list()
    grid = []
    grid.append(["."] * (w + 2))
    for _ in range(h):
        grid.append(["."] + list(input()) + ["."])
    grid.append(["."] * (w + 2))

    directions = ((1, 1), (0, 1), (1, 0), (-1, 0), (0, -1), (-1, -1), (-1, 1), (1, -1))

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            cnt = 0
            # 周辺の爆弾を数える
            if grid[i][j] == ".":
                for x, y in directions:
                    if grid[i + x][j + y] == "#":
                        cnt += 1
                grid[i][j] = cnt

    for i in range(1, h + 1):
        print("".join(str(i) for i in grid[i][1:-1]))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 74124
#include<iostream>
#include<vector>
#include<algorithm>
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
using namespace std;
int main()
{
    ios;
    ll x;
    cin >> x;
    ll curr = 100;
    int ans = 0;
    while (curr < x)
    {
        curr += (curr/100);
        ans += 1;
    }
    cout << ans << '\n';
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	int a,b;
	int is_max{0};
};

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

	int N=in(),H=in();
	vector<Data> S(N);
	int MA = 0;
	REP(i,N){
		S[i].a=in();
		MA = max(MA,S[i].a);
		S[i].b=in();
	}
	sort(ALL(S),[](Data& l,Data& r){return l.b==r.b ? l.a>r.a : l.b>r.b;});
	S.erase(find_if_not(ALL(S),[&](Data& d){return d.b>=MA;}),S.end());
	reverse(ALL(S));
	Data last;
	int ss = S.size();
	REP(i,ss){
		if(S[i].a==MA){
			last = S[i];
			S.erase(S.begin()+i);
			break;
		}
	}
	reverse(ALL(S));
	ss = S.size();
	int num = 0;
	REP(i,ss){
		num++;
		H -= S[i].b;
		if(H<=0){
			out(num);
			return 0;
		}
	}
	num++;
	H -= last.b;
	if(H<=0){
		out(num);
		return 0;
	}

	int plus = ceil((double)H/(double)last.a);

	out(num+plus);
	return 0;
}


Measured memory_bytes: 1408
N = int(input())
L = list(map(int, input().split()))

L.sort()
cnt = 0
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[k] < (L[j] + L[i]) and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                cnt = cnt + 1
print(cnt)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <x86intrin.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4,sse4.1,sse4.2,tune=native")

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	string s;
	cin >>n >>s;
	
	rep( i, 1000){
		string p= to_string(i);
		if(i<10) p="00"+p;
		else if(i<100) p="0"+p;
		//cout <<p <<" ";
		int ps=0;
		bool ng=false;
		rep(j ,3){
			ps = s.find(p[j], ps);
			if(ps==-1){ng=true; break;}
			ps++;
		}
		if(!ng) ans++;
	}
	
	cout << ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<queue>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<deque>
#include<algorithm>
#include<algorithm>
#include<stdint.h>
#include<cmath>
#include<set>
#include<stack>
#include<cstdlib>
#include<vector>
#include<cstring>
#include<ctime>
#include<map>
using namespace std;
int n,m,i,j,st[105][105];
int main()
{
	cin>>n>>m;
	for (i=1;i<=100;i++)
	{
		for (j=1;j<=50;j++)
		{
			st[i][j]='#';
		}
		for (j=51;j<=100;j++)
		{
			st[i][j]='.';
		}
	}
	for (i=2;i<100;i+=2)
	{
		for (j=2;j<50;j+=2)
		{
			if (n>1)
			{
				st[i][j]='.';
				n--;
			}
		}
	}
	for (i=2;i<100;i+=2)
	{
		for (j=52;j<100;j+=2)
		{
			if (m>1)
			{
				st[i][j]='#';
				m--;
			}
		}
	}
	puts("100 100");
	for (i=1;i<=100;i++)
	{
		for (j=1;j<=100;j++)
		{
			putchar(st[i][j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll a[5]={};
for(ll i=0; i<5; i++){
cin>>a[i];}
sort(a,a+5);
ll mi=a[0];
ll t=4+n/mi;
if(n%mi!=0) t++;
cout<<t<<endl;}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll r, g, b;
    cin >> r >> g >> b;
    if((100 * r + 10 * g + b) % 4){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//A=65,a=97

int main() {
    int n;cin >> n;
    vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    int l=-1,r=n;
    while(r-l!=1){
        int x=(r+l)/2;
        bool f=true;
        ll sum = a[x];
        for(int i = 0; i < n; i++) {
            if(i==x) continue;
            if(sum*2>=a[i]){
                sum += a[i];
            }
            else {
                f=false;
                break;
            }
        }
        if(f) r=x;
        else l=x;
    }   

    cout << n-r << endl;

    return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>                                                                     
 
int main ( void ) 
{ 
    int i,j; 
    for ( i = 1; i < 10; i++ ) 
    {   
        for ( j = 1; j < 10; j++ ) 
        {   
            printf( "%dx%d=%d\n", i, j, i*j );  
        }   
    }   
    return 0;  
} 

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



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


Measured memory_bytes: 3652
#include<stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while(A[i] != key) i++;
	return i != n;
}

int main() {
	int i, n, A[10000+1], q, key, sum = 0;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &A[i]);
	
	scanf("%d", &q);
	for(i = 0; i < q; i++) {
		scanf("%d", &key);
		if(search(A, n, key)) sum++;
	}
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 636
import math
n, m, k = map(int, input().split())

p = 998244353

def comb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % p

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, n+1):
    fact.append(fact[-1]*i%p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1]*inv[i])%p)
ans = 0

for i in range(k+1):
    row = comb(n-1, i, p)
    column = m * pow(m-1, n-i-1, p)
    ans += row * column
    
print(ans % p)

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

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

    vector<int> a(N + 1), b(N + 1);
    for (int i = 1; i <= N; ++i) a[i] = b[i] = N;

    ll black = ll(N - 2) * (N - 2);

    int H = N, W = N;

    while (Q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            if (x < W) {
                for (int i = x; i < W; ++i) {
                    b[i] = H;
                }
                W = x;
            }
            black -= b[x] - 2;

        } else {
            if (x < H) {
                for (int i = x; i < H; ++i) {
                    a[i] = W;
                }
                H = x;
            }
            black -= a[x] - 2;
        }
    }
    cout << black << endl;

    return 0;
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	int h,w, tt; cin>>tt>>h>>w;
	int answer = 0;
	while(tt--){
		int a, b; cin>>a>>b;
		answer += (a >= h && b >= w);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	int H,W,x,y;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

Measured memory_bytes: 25752
makeSquare :: [Int] -> String
makeSquare [h,w] = unlines $ makeSquare' [h,w]
  where 
    makeSquare' [h,w]
      | w <  3  = replicate h $ ws
      | h == 1  = [ws]
      | True    = [ws] ++ (replicate (h-2) ws') ++ [ws]
      where
        ws  = replicate w '#'
        ws' = "#" ++ ( replicate (w - 2) '.' ) ++ "#"
    
main :: IO () 
main = do
  s' <- getLine
  let s = (map read . words) s'
  
  if s == [0,0] then return ()
  else do
    putStrLn $ makeSquare s 
    main

Measured memory_bytes: 4044
#include <iostream>

int main()
{
    int n, m, c;
    int b[20];
    std::cin >> n >> m >> c;
    for (int j = 0; (j < m); ++j) {
        std::cin >> b[j];
    }
    int count = 0;
    for (int i = 0; (i < n); ++i) {
        int sum = 0;
        for (int j = 0; (j < m); ++j) {
            int a;
            std::cin >> a;
            sum += a * b[j];
        }
        sum += c;
        if (sum > 0) ++count;
    }
    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int a,b;
    cin>>a>>b;
    rep2(i,1,10000000){
        int hachi=i*0.08;
        int ten=i*0.1;
        if(hachi==a&&ten==b){cout<<i<<endl;return 0;}
    }
    cout<<"-1"<<endl;
    return 0;
}




Measured memory_bytes: 256
import sys
h,w,d = map(int, sys.stdin.readline().split())

x = [[0]*1600 for i in range(1600)]
for i in range(1600):
    for j in range(1600):
        a = i//d 
        b = j//d
        if (a%2 ==0 and b%2 == 0):
            x[i][j] = "R"
        elif (a%2 ==1 and b%2 == 0):
            x[i][j] = "Y"
        elif (a%2 ==1 and b%2 == 1):
            x[i][j] = "G"
        else:
            x[i][j] = "B"
for i in range(h):
    result = ""
    for j in range(w):
        result+= x[800+j-i][0+j+i] 
    print(result)

Measured memory_bytes: 85468
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    vector<vector<ll>> dp(n+1, vector<ll>(5, INF));
    dp[0][0] = 0;

    int cost;
    for(int i=0; i<n; i++){
        cost = a[i];
        dp[i+1][0] = min(dp[i+1][0], dp[i][0] + cost);

        cost = (a[i] == 0 ? 2 : (a[i] % 2));
        dp[i+1][1] = min(dp[i+1][1], min(dp[i][0], dp[i][1]) + cost);

        cost = (a[i] + 1) % 2;
        dp[i+1][2] = min(dp[i+1][2], min({dp[i][0], dp[i][1], dp[i][2]}) + cost);

        cost = (a[i] == 0 ? 2 : (a[i] % 2));
        dp[i+1][3] = min(dp[i+1][3], min({dp[i][0], dp[i][1], dp[i][2], dp[i][3]}) + cost);

        cost = a[i];
        dp[i+1][4] = min(dp[i+1][4], min({dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]}) + cost);
    }

    ll ans = INF;
    for(int i=0; i<5; i++){
        chmin(ans, dp[n][i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 15232
n,l = map(int,input().split())
aji = [x+l-1 for x in range(1,n+1)]

if max(aji) < 0:
    aji.remove(max(aji))
    print(sum(aji))
elif 0 in aji:
    print(sum(aji))
else:
    aji.remove(min(aji))
    print(sum(aji))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int gcd(int a, int b){
	return (b > 0)? gcd(b, a % b) : a ;
}

int main(void) {
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    for(int i=0; i<N; i++) {
        cin >> x.at(i);
    }
    x.push_back(X);
    sort(x.begin(), x.end());
    adjacent_difference(x.begin(), x.end(), x.begin());
    int ans = x.at(1);
    for(int i=2; i<=N; i++) {
        ans = gcd(ans, x.at(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
phy=int(input())
che=int(input())
bio=int(input())
geo=int(input())
rek=int(input())
tir=int(input())

rika=[phy,che,bio,geo]
rika.sort()
a=rika[1]+rika[2]+rika[3]

if rek>tir:
    b=rek
else:
    b=tir
print(a+b)


Measured memory_bytes: 5596
using System;
using System.Linq;
#if !DEBUG
    using System.IO;
#endif

public class Program {
    public static void Main() {
        #region SetAutoFlushIsFalse
#if !DEBUG
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
#endif
        #endregion
        var arr = ReadLib.ReadAsIntArray();
        var n = arr[0];
        var c = arr[1];
        var k = arr[2];

        var ts = ReadLib.ReadNTimesAsInt(n).OrderBy(i => i);
        var nBus = 0;
        var nCurrentCustomers = 0;

        var upLimitT = ts.First() + k;

        foreach (var t in ts) {
            if (t > upLimitT || nCurrentCustomers >= c) {
                nBus++;
                upLimitT = t + k;
                nCurrentCustomers = 0;
            }
            nCurrentCustomers++;
        }

        if (nCurrentCustomers > 0) {
            nBus++;
        }

        Console.WriteLine(nBus);

        #region Flush
#if !DEBUG
        Console.Out.Flush();
        sw.Close();
#endif
        #endregion
    }
}


static class ReadLib {
    public static long ReadAsLong() {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt() {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadAsIntArray() {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    public static string[] ReadAsStringArray() {
        return Console.ReadLine().Split(' ');
    }

    public static int[] ReadNTimesAsInt(int n) {
        return Enumerable.Range(1, n).Select(s => int.Parse(Console.ReadLine())).ToArray();
    }

    public static int[][] ReadNTimesAsIntArray(int n) {
        return Enumerable.Range(1, n).Select(s => ReadAsIntArray()).ToArray();
    }

}

Measured memory_bytes: 19164
import java.util.Comparator;
import java.util.Scanner;

import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Arrays;
/* static int java.util.Arrays.binarySearch(int[] a, int key); */
import java.math.BigDecimal;
/* static int java.util.Arrays.binarySearch(int[] a, int key); */


public class Main {
    Scanner sc = new Scanner(System.in);
    long n;
    public void run(){
        n = sc.nextLong();
        solve();
    }
    public void solve(){
        if(n % 2 == 0){
            System.out.println(n);
        }
        else{
            System.out.println(n * 2);
        }
    }

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

    static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }
    static class Edge{
        int to, cost;
        public Edge(int a, int b){
            this.to = a;
            this.cost = b;
        }
    }
    class MyComparator implements Comparator {
        @Override
        public int compare (Object arg0, Object arg1) {
            int x = ((Pair)arg0).first;
            int y = ((Pair)arg1).first;

            if (x < y) {
                return 1;
            } else if (x > y) {
                return -1;
            } else{
                return 0;
            }
        }
    }
    static class UnionFind{
        int par[];
        int rank[];

        //n要素で初期化
        public UnionFind(int maxn){
            par = new int[maxn];
            rank = new int[maxn];

            for(int i = 0; i < maxn; i++){
                par[i] = i;
                rank[i] = 0;
            }
        }

        //木の根を求める
        int find(int x){
            if(par[x] == x){
                return x;
            }
            else {
                return par[x] = find(par[x]);
            }
        }

        // xとyの属する集合を併合
        void unite (int x, int y){
            x = find(x);
            y = find(y);
            if(x == y){
                return;
            }

            if(rank[x] < rank[y]){
                par[x] = y;
            }
            else{
                par[y] = x;
                if(rank[x] == rank[y]) rank[x]++;
            }
        }

        // xとyが同じ集合に属するか否か
        boolean same(int x, int y){
            return find(x) == find(y);
        }
    }

}

Measured memory_bytes: 22612
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	fast();
	ll n,k;
	cin>>n>>k;
	n%=k;
	n=min(n,k-n);
	cout<<n;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int a[2][105],b[2][105];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[0][i];
	}
	for(int i=1;i<n;i++)
	{
		a[0][i]+=a[0][i-1];
	}
	for(int i=0;i<n;i++)
	{
		cin>>a[1][i];
	}
//	cout<<a[1][4]<<endl;
	for(int i=n-2;i>=0;i--)
	{
		a[1][i]+=a[1][i+1];
	}
	int ma=0;
	for(int i=0;i<n;i++)
	{
		ma=max(ma,a[0][i]+a[1][i]);
//		cout<<i<<" "<<a[0][i]<<" "<<a[1][i]<<endl;
	}
	cout<<ma;
}

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, b;
		a = sc.nextInt();
		b = sc.nextInt();
		
		int ans = 0;
		for(int i = 0; i < 2; ++i) {
			if(a >= b) {
				ans += a;
				--a;
			}else {
				ans += b;
				--b;
			}
		}
		
		System.out.println(ans);
	}
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[1111];
int rem[1111];
bool used[1111] = {};
int ord[1111];
int pos = 0, pp = 0;
int ans[505 * 505];

inline bool cmp(const int &lhs, const int &rhs) {
    return a[lhs] < a[rhs];
}

int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        --a[i];
        rem[i] = i - 1;
        rem[n + i] = n - i;
    }
    forn(i, n) ord[i] = i + 1;
    sort(ord, ord + n, cmp);
    forn(i, n) ord[n + i] = n + ord[i];
    forn(i, n * n) {
        if (pos < n && a[ord[pos]] == i) {
            if (rem[ord[pos]] > 0 || used[ord[pos] + n]) {
                cout << "No" << endl;
                return 0;
            }
            ans[i] = ord[pos];
            ++pos;
        } else {
            while (pp < 2 * n && rem[ord[pp]] == 0) {
                ++pp;
            }
            if (pp == 2 * n) {
                cout << "No" << endl;
                return 0;
            }
            ans[i] = ord[pp];
            if (ans[i] > n) {
                ans[i] -= n;
            }
            --rem[ord[pp]];
            used[ord[pp]] = true;
        }
    }
    cout << "Yes" << endl;
    forn(i, n * n) {
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 2176
n = int(input())
s = list(str(input()))

if n == 1 or n == 2:
    print(0)
    exit()

l = [[0, 0, 0] for i in range(n+1)]
r = [[0, 0, 0] for i in range(n+1)]
for i in range(n):
    if s[i] == 'R':
        l[i+1][0] = l[i][0] +1
        l[i+1][1] = l[i][1]
        l[i+1][2] = l[i][2]
    elif s[i] == 'G':
        l[i+1][0] = l[i][0]
        l[i+1][1] = l[i][1] +1
        l[i+1][2] = l[i][2]
    else:
        l[i+1][0] = l[i][0]
        l[i+1][1] = l[i][1]
        l[i+1][2] = l[i][2] +1

s.reverse()
for i in range(n):
     if s[i] == 'R':
         r[i+1][0] = r[i][0] +1
         r[i+1][1] = r[i][1]
         r[i+1][2] = r[i][2]
     elif s[i] == 'G':
         r[i+1][0] = r[i][0]
         r[i+1][1] = r[i][1] +1
         r[i+1][2] = r[i][2]
     else:
         r[i+1][0] = r[i][0]
         r[i+1][1] = r[i][1]
         r[i+1][2] = r[i][2] +1

#print(l)
r.reverse()
#print(r)

s.reverse()
ans = 0
for i in range(1, n-1):
    if s[i] == 'R':
        ans += l[i][1]*r[i+1][2]
        ans += l[i][2]*r[i+1][1]
    elif s[i] == 'G':
        ans += l[i][0]*r[i+1][2]
        ans += l[i][2]*r[i+1][0]
    else:
        ans += l[i][0]*r[i+1][1]
        ans += l[i][1]*r[i+1][0]
    for j in range(1, i+1):
        if i+j <= n-1:
            if s[i-j] != s[i] and s[i+j] != s[i] and s[i-j] != s[i+j]:
                ans -= 1
print(ans)

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

int main(){
    int H,W;
    
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0)break;
        
        for ( int i = 0; i < H; i++){
            if (i % 2 == 0){
                for ( int j = 0; j < W; j++){
                    if (j % 2 == 0) cout << "#";
                    else cout << ".";
                }
            
            }
            else {
                for (int k = 0; k < W; k++){
                    if (k % 2 == 0) cout << ".";
                    else cout << "#";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        
        if (x == 0) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
        
    }
}

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

int main(){
	int p[3],j[2],t,p2,j2;
	for(int i=0;i<3;i++)
		cin >>p[i];
	for(int i=0;i<2;i++)
		cin >>j[i];
	

	for(int i=0;i<3;i++){
		for(int k=0;k<2;k++)
		if(p[k]>p[k+1]){
			t=p[k];
			p[k]=p[k+1];
			p[k+1]=t;
			
			}
		}
	p2=p[0];

	if(j[0]>j[1])
		j2=j[1];
	if(j[0]<=j[1])
		j2=j[0];
	cout <<j2+p2-50 <<endl;


	return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 998244353;

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

  string s;
  cin >> s;
  ll n = s.size();

  bool flag = true, cons = false;
  FOR(i, 1, n) {
    if(s[i] != s[0]) flag = false;
    if(s[i] == s[i-1]) cons = true;
  }
  if(flag) {
    cout << 1 << endl;
    return 0;
  }

  if(n == 2) {
    cout << 2 << endl;
    return 0;
  }

  if(n == 3) {
    if(s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
      cout << 3 << endl;
    } else if(s[2] == s[0]) {
      cout << 7 << endl;
    } else if(s[0] == s[1] || s[1] == s[2]){
      cout << 6 << endl;
    }
    return 0;
  }

  ll su = 0;
  REP(i, n) (su += (s[i]-'a')) %= 3;

  // dp[i番目][最後がj][mod3がk][連続があるか]
  auto dp = make_v<ll>(n+1, 3, 3, 2);
  dp[0][0][0][0] = dp[0][1][1][0] = dp[0][2][2][0] = 1;
  REP(i, n-1) REP(j, 3) REP(k, 3) REP(l, 3) {
    (dp[i+1][(j+l)%3][l][k==l] += dp[i][j][k][0]) %= MOD;
    (dp[i+1][(j+l)%3][l][1] += dp[i][j][k][1]) %= MOD;
  }

  ll ret = 0;
  if(!cons) ret++;
  REP(i, 3) (ret += dp[n-1][su][i][1]) %= MOD;
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 125972