akhauriyash/Code-Regression huggingface dataset:
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 1005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int k;
int a[maxn];
int b[maxn];
int tp[maxn];
int s = 0;
int x[maxn];
int hv[105];
int ltp[maxn];
int check(int pl) {
	for (int i = 1; i <= k; i++)
		b[i] = a[i];
	for (int i = 1; i <= pl; i++) {
		b[x[i]]--;
		if (b[x[i]] < 0) return 0;
	}
	for (int i = 1; i < pl; i++)
		if (x[i] == x[pl] && !tp[i]) return 0;
/*	cout << "CUR_CHECK" << endl;
	for (int i = 1; i <= pl; i++)
		cout << x[i] << ' ';
	cout << endl;
*/	
	// update tp
	for (int i = 1; i <= pl; i++)
		ltp[i] = tp[i];
	// before return 0 : 
	if (pl >= k) {
		memset(hv, 0, sizeof(hv));
		int fl = 1;
		for (int i = pl; i >= pl - k + 1; i--)
			if (hv[x[i]]) fl = 0;
			else hv[x[i]] = 1;
		if (fl)
			for (int i = pl; i >= pl - k + 1; i--)
				tp[i] = 1;
	}
	memset(hv, 0, sizeof(hv));
	for (int i = pl; i >= 1; i--)
		if (hv[x[i]]) break;
		else hv[x[i]] = i;
	int nd[105] = {0};
	for (int i = 1; i <= k; i++) {
		int cr = b[i];
		int ud[2] = {0, 0};
		for (int t = 1; t <= k; t++)
			if (hv[t] > hv[i]) chkmax(nd[t], cr / 2);
			else chkmax(nd[t], (cr + 1) / 2);
	}
	int res = 1;
	for (int i = 1; i <= k; i++) {
		if (b[i] < nd[i]) res = 0;//, cout << "!!!" << i << ' ' << b[i] << ' ' << nd[i] << endl;
	}
	if (!res) {
		for (int i = 1; i <= pl; i++)
			tp[i] = ltp[i];
		return 0;
	}
	return 1;
}
int main() {
	cin >> k;
	for (int i = 1; i <= k; i++)
		cin >> a[i], s += a[i];
	if (!check(0)) cout << -1 << endl;
	else {
		for (int p = 1; p <= s; p++) {
			for (int i = 1; i <= k; i++) {
				x[p] = i;
				if (!check(p)) continue;
				else break;
			}
		}
		for (int p = 1; p <= s; p++)
			cout << x[p] << ' ';
		cout << endl;
	}
			 
	return 0;
}


Measured memory_bytes: 3652
local s = io.read()
local mul = 1
local t = {}
for i = 0, 2018 do
  t[i] = 0
end
t[0] = 1
local cur = 0
local ret = 0
for i = #s, 1, -1 do
  local v = s:sub(i, i):byte() - 48
  cur = (cur + mul * v) % 2019
  ret = ret + t[cur]
  t[cur] = t[cur] + 1
  mul = (mul * 10) % 2019
end
print(ret)


Measured memory_bytes: 2780
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n; int a[n]; rep(i,n)cin>>a[i]; Int ans=0;
  rep(i,n-1)rer(j,i+1,n-1)ans+=a[i]*a[j];
  END
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    map<char,ll> m;
    rep(i,3){
        m[s[i]]++;
        if(m[s[i]]>1){
            Yes(false);
            return 0;
        }
    }
    Yes(true);
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

int main() {
	for(int N; cin >> N, N;) {
		vector<int> v(N);
		for(int i = 0; i < N; i++)
			cin >> v[i];
		sort(all(v));
		vector<pair<int, int> > vv;
		int i = 0;
		while(i < N) {
			int p = v[i];
			while(i + 1 < N && v[i] + 1 == v[i + 1]) i++;
			int q = v[i];
			vv.push_back(mp(p, q));
			i++;
		}
#if 0
		for(int j = 0; j < vv.size(); j++)
			cerr << vv[j].first << ":" << vv[j].second << endl;
#endif
		bool isFirst = true;
		for(int j = 0; j < vv.size(); j++) {
			if(isFirst == false) {
				cout << " ";
			}
			if(vv[j].first == vv[j].second) cout << vv[j].first;
			else cout << vv[j].first << "-" << vv[j].second;
			isFirst = false;
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	int n;
	cin>>n;
	pair<ll,ll> p[n];
	fr(i,0,n,1){
		cin>>p[i].f>>p[i].s;
	}
	pair<ll,ll> p1=p[0],p2=p[0],p3=p[0],p4=p[0];
	ll a1=-2*1e9,a2=2*1e9,a3=a1,a4=a4;
	fr(i,0,n,1){
		a1=max(a1,p[i].f+p[i].s);
		a2=min(a2,p[i].f+p[i].s);
		a3=max(a3,p[i].f-p[i].s);
		a4=min(a4,p[i].f-p[i].s);
	}
	cout<<max(a1-a2,a3-a4)<<endl;
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){

    string s,t;
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0;i<s.length();i++){
        if(s[i] != t[i])cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll c[3] = {};
  for (int i = 0; i < n; i++){
    ll p;
    cin >> p;
    
    if (p <= a)
      c[0]++;
    else if (p <= b)
      c[1]++;
    else
      c[2]++;
  }

  cout << min(c[0], min(c[1], c[2])) << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e11;

int main() {
  int N; cin >> N;
  double res;
  for (int i = 0; i < N; i++) {
    double x; string u; cin >> x >> u;
    if (u == "JPY") {res += x;}
    else {res += 380000.0*x;}
  }
  cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
int main()
{
  int x = -1, y = 10000;
  double z = 0.2;
  string s = "beginner1010";
  long long b = 1LL << 60;
    
  // debug(x, y, z, s, b);
    
  double aux = 1010.0;
  string code = "code";
    
  // debug(code + "forces",-aux / 10 * 2.3);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  bool p[n+100];
  memset(p,true,sizeof(p));
  vector<int>v;
  for (int i = 2; i*i <= n+100; ++i)
  {
    if(p[i] == true)
      for (int j = i*i; j <= n+100; j += i)
      {
        p[j] = false;
      }
  }
  for (int i = 2; i <= n+100; ++i)
  {
    if (p[i])
      v.pb(i);
  }
  for (int i = 0; i < n+100; ++i)
  {
    if (v[i]>=n)
    {
      cout << v[i];
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 384
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int height = 0;
        int tmp = b - a;
        while (tmp >= 1)
        {
            height += tmp--;
        }
        Console.WriteLine(height - b);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int N;
   cin >> N;
   int s[N + 1];
   s[0] = 0;
   int tmp;
   for (int i = 1; i <= N; i++) {
      cin >> tmp;
      s[i] = s[i - 1] + tmp;
   }
   int ans = s[N];
   for (int i = 0; i <= N; i++) {
      int A = s[i];
      int B = s[N] - A;
      ans = min(ans, abs(A - B));
   }
   cout << ans << endl;
   return 0;
}


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

int main(void){

  char s[4], t[4];
  int count = 0;
  scanf("%s", s);
  scanf("%s", t);

  for(int i=0; i<3;i++){
    if(s[i]==t[i]){
      count++;
    }
  }
  

  printf("%d", count);

  return 0;
}

  

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  int n; cin >> n;
  vector<ull> a(1000001);
  ull ans = 0;
  rep(i,n){
    int aa; cin >> aa;
    ans += aa;
    a[aa]++;
  }
  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int b,c; cin >> b >> c;
    ans -= b * a[b];
    ans += c * a[b];
    a[c] += a[b];
    a[b] = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 11120
#include <bits/stdc++.h> 
#define ll long long
using namespace std;
int main()
{

ll int a,b,c,k;
cin>>a>>b>>c>>k;
ll int ans = min(k,a);
k=k-a-b;
if(k>0)
{
	ans=ans-k;
}
cout<<ans;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = 0;
  
  if (a > b){ 
    int j = 1;
    for (int i = 0; i < a; i++){
    c = c + j * b;
      j = j * 10;
    }
  } else {
    int j = 1;
    for (int i = 0; i < b; i++){
    c = c + j * a;
      j = j * 10;
    }
  } 
  
  cout << c << endl;
  
}

Measured memory_bytes: 256
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, M = read_values()
    Q = [tuple(read_index()) for _ in range(M)]
    S = [N - 1] * N
    T = [N - 1] * N
    W, H = N - 1, N - 1
    res = (N - 2) ** 2
    for d, x in Q:
        if d == 0:
            if x < W:
                for i in range(x, W):
                    S[i] = H
                W = x
            res -= S[x] - 1
        if d == 1:
            if x < H:
                for i in range(x, H):
                    T[i] = W
                H = x
            res -= T[x] - 1
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 104884
#include <stdio.h>

int main() {
    char s[100000];
    int n, c = 0, m;
    scanf("%d", &n);
    scanf("%s", s);
    while(1){
        if(s[c] == '\0'){
            break;
        }
        c++;
    }
    for(int i = 0; i < c; i++){
        m = (int)(s[i]+n);
        if(m <= 90){
            printf("%c", s[i] + n);
        }else{
            printf("%c", 64 + (m - 90));
        }

    }

    return 0;
}

Measured memory_bytes: 128
(defn ^:dynamic LucasNumber [N]
  (case N
    0 (bigint 2)
    1 (bigint 1)
     (+ (#'LucasNumber (dec N)) (#'LucasNumber (dec (dec N))))))

(binding [LucasNumber (memoize LucasNumber)]
  (->> (read)
    int
    LucasNumber
    (printf "%s\n")))

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

typedef long long ll;
#define fr(i,n) for(int i = 0;i<n;i++)
#define frr(i,a,b) for(int i = a;i<=b;i++)

#define prin(a) cout << #a << " = " << a << endl

#define eb emplace_back
#define all(v) (v).begin(),(v).end()

vector<ll> v;

int main(){
    ll  a, b, k;
    cin >> a >> b >> k;
    
    int cnt = 1;
    
    frr(i,1,min(a,b)){
        if(a%i==0 and b%i==0){
                v.eb(i);
        }
    }
    
    reverse(all(v));
    
    cout << v[k-1] << endl;
}

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

int main(){
   int n;
   cin >> n;
   cout << n/3 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e6 + 7;
const ll mod = 1e9 + 7;
const int maxx = 5005;
ll q, t, n, m, k, ans, mx , a[maxn], b[maxn], f[maxx][maxx];
priority_queue<ll> pr;
string s, ss[maxn], str, s1, s2;
map<ll, ll> mp;
ll dp(ll i, ll j)
{
    if(i == 0)return f[0][j] = j;
    if(j == 0)return f[i][0] = i;
    if(f[i][j] != 1e5)return f[i][j];
    if(s1[i] == s2[j])return f[i][j] = min(f[i][j], dp(i-1, j-1));
    return f[i][j] = min(min(dp(i-1, j) + 1, dp(i, j-1) + 1), dp(i-1, j-1) + 1);
}
void sol()
{
    cin >> s2 >> s1;
    n = s1.length();
    s2 = s2 + s1[n-1];
    if(s1 == s2)cout << "Yes";
    else cout << "No";
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    sol();
}


Measured memory_bytes: 34868
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	int h[n], sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		sum += h[i];
	}
	int ans = 0;
	while (true) {
		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				if (h[i]) {
					h[i]--;
					sum--;
					ans++;
				}
			} else {
				if (h[i] and !h[i + 1]) ans++;
				if (h[i]) {
					h[i]--;
					sum--;
				}
			}
		}
		if (!sum) break;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<string, int> touhyou;
  for (int i=0; i<N; i++) {
    string s;
    cin >> s;
    if (touhyou.count(s)) touhyou[s]++;
    else touhyou[s] = 1;
  }
  vector<string> kekka;
  kekka.emplace_back("");
  int max_hyou = 0;
  for (auto p : touhyou) {
    if (p.second > max_hyou) {
      max_hyou = p.second;
      for (int i=0; i<kekka.size()-1; i++) kekka.pop_back();
      kekka.at(0) = p.first;
    }
    else if (p.second == max_hyou) {
      kekka.emplace_back(p.first);
    }
  }
  for (auto v : kekka) {
    cout << v << endl;
  }
}

Measured memory_bytes: 26868
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
ll Mod = 998244353;

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	if (d[0] != 0) { 
		cout << 0 << endl; return 0;
	}
	sort(d.begin(), d.end());
	rep2(i, 1, n) {
		if (d[i] == 0|| d[i] - d[i - 1] > 1) { cout << 0 << endl; return 0; }
	}

	ll ans = 1;
	vector<int> s(n, 0);
	int j = 0;
	int count = 1;
	
	rep2(i, 2, n) {
		if (d[i] != d[i - 1]) {
			s[j] = count;
			++j;
			count = 1;
		}
		else count++;
		if (i == n - 1) s[j] = count;
	}
	rep2(i, 1, n) {
		if (s[i] == 0) break;
		rep(j, s[i]) {
			ans *= s[i - 1];
			ans %= Mod;
		}
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 1024
#define ll long long int
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int cnt = 0;
	while (b <= a) { b *= 2; cnt++; }
	while (c <= b) { c *= 2; cnt++; }
	if (cnt <= k) { cout << "Yes"; }
	else cout << "No";
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#define PREFIX_MAX 200

int n;
long long m;
std::vector<int> primes;
bool* is_prime;

void euler_sieve()
{
    // init
    for (int i=2;i<=n;i++) is_prime[i] = true;
    is_prime[0] = false, is_prime[1] = false;
    
    // sieve
    for (int i=2;i<=n;i++)
    {
        if (is_prime[i]) primes.push_back(i);
        for (auto pr : primes)
        {
            if (i*pr > n) break;
            
            is_prime[i*pr] = false;
            if (i%pr == 0) break;
        }
    }
}

int main()
{
    scanf("%lld", &m);
    if (m == 1LL)
    {
        printf("0");
        return 0;
    }
    n = 7 + sqrt(m);
    is_prime = (bool*)malloc(sizeof(bool) * (n+3));
    euler_sieve();

    long long ops = 0;
    for (auto prime : primes)
    {
        long long current_sum = 0, current_z = prime;
        for (int i=1;i<=PREFIX_MAX;i++)
        {
            current_sum += i;
            if (m >= current_z && m % current_z == 0)
            {
                //printf("%lld / %lld ops++\n", m, current_z);
                ops++;
                m = m / current_z;
            }
            else
            {
                while (m % prime == 0)
                    m /= prime;
                break;
            }
            current_z *= prime;
        }
    }
    printf("%lld", m == 1LL ? ops : ops + 1);

    return 0;
}


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

int main () {
  int N;
  cin >> N;
  long ans = 1;
  for (int i = 1; i <= N; i++) {
    ans *= i;
    ans %= (10*10*10*10*10*10*10*10*10 + 7);
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

int main(void)
{
	ll N, x;
	cin >> N >> x;
	ll ans = 0;

	ll m, n;
	m = x;
	n = N - m;
	ans += m + n;

	while(1) {
		ans += n * (m / n) * 2;
		ll temp = m % n;
		if (temp == 0) break;
		m = n;
		n = temp;
	}
	cout << ans - n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

const int N = 110;
int a[N][N];
int dp[N][N];
int n;

int main () {
	n = read();
	For (i, 1, 2)
		For (j, 1, n)
			a[i][j] = read();
	For (i, 1, 2)
		For (j, 1, n)
			dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) + a[i][j];
	cout << dp[2][n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST int inox,t;cin>>t; for(inox=1;inox<=t;inox++)
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,n) for(i=n-1;i>=0;i--)
#define FAST    ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
#define modd 998244353 
 
 
int main(){
FAST;
string s,t; cin>>s>>t;
t.pop_back();
if(s==t)cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 3612
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

llint n, m;
vector<E> vec;
bool used[20005];

int main(void)
{
	while(1){
		cin >> n >> m;
		if(n == 0) break;
		
		vec.clear();
		llint t, s, d;
		for(int i = 1; i <= m; i++){
			cin >> t >> s >> d;
			vec.push_back(E(t, P(s, d)));
		}
		sort(vec.begin(), vec.end());
		
		for(int i = 1; i <= n; i++) used[i] = false;
		used[1] = true;
		
		for(int i = 0; i < vec.size(); i++){
			llint s = vec[i].second.first, t = vec[i].second.second;
			used[t] |= used[s];
		}
		
		llint ans = 0;
		for(int i = 1; i <= n; i++){
			if(used[i]) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3808
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; ++i) cin >> p[i];
    int c = 0;
    for (int i = 1; i < n - 1; ++i)
        if (!(p[i - 1] > p[i] && p[i + 1] > p[i])&&!(p[i - 1] < p[i] && p[i + 1] < p[i])) ++c;
    cout << c << endl;
}


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

using namespace std;
using ll = long long;

int main(){

string S;

cin >> S;

ll x = 1;
ll tot = 0;
ll ans=0;
ll mod = 2019;
vector<ll> cnt(2019);

cnt[0] = 1;

reverse(S.begin(),S.end());

for(ll i = 0;i < S.size();++i){

    ll num = S[i] - '0';
    tot = (tot + (num*x)) % mod;
    cnt[tot] = cnt[tot] + 1;
    x = (10 * x) % mod;

}

for(ll n : cnt) ans += (n * (n - 1)) / 2;

cout << ans << endl;

return 0;

}

Measured memory_bytes: 3724
from collections import defaultdict

S = input()
N = len(S)
dp = [0 for _ in range(N+1)]

MOD = 2019

dp[-1] = int(S[-1])
tmp = 10
for i in range(N-1, 0, -1):
    m = int(S[i-1])
    dp[i] = (dp[i+1]+tmp*m)%MOD
    tmp = tmp*10%MOD

d = defaultdict(int)

for i in range(N+1):
    d[dp[i]] += 1

ans = 0
for k in d.keys():
    ans += d[k]*(d[k]-1)//2

print(ans)


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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 1e3 + 10;
const int M = (int) 2e5 + 10;
const int K = (int) 350;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

int n, m;
vec v[N];
int from[M], to[M];
int used[N][N], u[N][N];

void dfs(int st, int x) {
  used[st][x] = 1;
  for (auto it : v[x]) {
    if (!used[st][it]) {
      dfs(st, it);
    }
  }
}

int tmp[N];

void dfs1(int st, int x) {
  tmp[x] = 1;
  for (auto it : v[x]) {
    if (st == it) 
      continue;
    if (!tmp[it]) {
      dfs1(st, it);
    }
  }
}

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> from[i] >> to[i];
    v[from[i]].pb(to[i]);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, i);
    memset(tmp, 0, sizeof(tmp));
    for (int j = 0; j < sz(v[i]); j++) {
      if (tmp[v[i][j]]) {
        u[i][v[i][j]] = 1;
      }
      dfs1(i, v[i][j]);
    }
    memset(tmp, 0, sizeof(tmp));
    for (int j = sz(v[i]) - 1; j >= 0; j--) {
      if (tmp[v[i][j]]) {
        u[i][v[i][j]] = 1;
      }
      dfs1(i, v[i][j]);
    }
  }
  for (int i = 1; i <= m; i++) {
    //cout << u[from[i]][to[i]] << ' ' << used[to[i]][from[i]] << "\n";
    if (u[from[i]][to[i]] + used[to[i]][from[i]] == 1) {
      cout << "diff\n";
    } else {
      cout << "same\n";
    }
  }
  return 0;
}

Measured memory_bytes: 12288
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, R);
    IN(ll, G);
    IN(ll, B);
    IN(ll, N);
    ll ans = 0;
    REP(r, N + 1)
    {
        REP(g, N + 1)
        {
            ans += N >= r * R + g * G and (N - r * R - g * G) % B == 0;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long
using Graph = vector<vector<int>>;
vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0) {
	color[v] = cur;
	for (auto next_v : G[v]) {
		// 隣接頂点がすでに色確定していた場合
		if (color[next_v] != -1) {
			if (color[next_v] == cur) return false; // 同じ色が隣接したらダメ
			continue;
		}

		// 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
		if (!dfs(G, next_v, 1 - cur)) return false;
	}
	return true;
}
int d[210][210];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	rep(i, n) {
		rep(j,n)d[i][j] = INF;
		d[i][i] = 0;
	}
	vector<string>grid(n),tmp(n);
	rep(i, n)cin >> grid[i];
	rep(i, n)tmp[i] = grid[i];
	Graph G(n);
	int m = 0;
	rep(i, n) {
		rep(j, n) {
			if (grid[i][j] == '1') {
				G[i].push_back(j);
				d[i][j] = 1;
				m++;
			}
		}
	}
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	color.assign(n, -1);
	bool is_bipartite = true;
	for (int v = 0; v < n; ++v) {
		if (color[v] != -1) continue; // v が探索済みだったらスルー
		if (!dfs(G, v)) is_bipartite = false;
	}

	if (is_bipartite) {}
	else {
		cout << -1 << endl; return 0;
	}
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			chmax(ans, d[i][j]);
		}
	}
	cout << ans +1<< endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

long long com(int n,int r){
    long long com=1;
    r = min(r,n-r);
    for(int i=n;i>n-r;i--){
        com *= i;
    }
    for(int i=r;i>0;i--){
        com /= i;
    }
    return com;
}

int main(){
    int N,P;
    cin >> N >> P;
    int r0=0,r1=0;
    long long ans=0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a%2==0) r0++;
        else r1++;
    }
    if(P==0){
        for(int i=0;i<=r1;i+=2){
            ans += com(r1,i);
        }
        for(int i=0;i<r0;i++){
            ans *= 2;
        }
        cout << ans << endl;
    }
    else{
        for(int i=1;i<=r1;i+=2){
            ans += com(r1,i);
        }
        for(int i=0;i<r0;i++){
            ans *= 2;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=10000000000000007;int inf=MOD;
int calc(vector<int> const& p,vector<int> const& s,int x){
    int res=inf;
    auto itp=lower_bound(p.begin(),p.end(),x);
    auto its=lower_bound(s.begin(),s.end(),x);
    vector<int> bufp(4);
    //vector<int> bufs(4);
    itp--;
    rep(i,2){
        bufp[i]=*itp;
        //bufs[i]=*its;
        ++itp;++its;
        //printf("bufp[%lld]=%lld\n",i,bufp[i]);
    }
    int tmp=abs(x-bufp[0]);
    tmp+=min(abs(*lower_bound(s.begin(),s.end(),bufp[0])-bufp[0]),abs(*(lower_bound(s.begin(),s.end(),bufp[0])-1)-bufp[0]));
    if(tmp<res)res=tmp;
    tmp=abs(x-bufp[1]);
    tmp+=min(abs(*lower_bound(s.begin(),s.end(),bufp[1])-bufp[1]),abs(*(lower_bound(s.begin(),s.end(),bufp[1])-1)-bufp[1]));
    if(tmp<res)res=tmp;
    return res;
}
signed main(){
    int a,b,q;cin>>a>>b>>q;
    vector<int> s(a+2);rep(i,a)cin>>s[i+2];
    vector<int> t(b+2);rep(i,b)cin>>t[i+2];
    vector<int> x(q);rep(i,q)cin>>x[i];
    s[0]=-inf;s[1]=-inf+1;t[0]=-inf;t[1]=-inf+1;
    s.push_back(inf);t.push_back(inf);
    s.push_back(inf+1);t.push_back(inf+1);
    rep(i,q){
        int min=inf;int buf=0;
        buf=calc(s,t,x[i]);
        if(buf<min)min=buf;
        buf=calc(t,s,x[i]);
        if(buf<min)min=buf;
        cout<<min<<endl;
    }
    //printf("s[0]=%lld\n",s[0]);
    return 0;
}

Measured memory_bytes: 5216
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    ll ans = 0;
    vector <int> vec(2019, 0);
    vec[0]++;
    int cur = 0;
    for (char c : s) {
        cur *= 10;
        cur += c - '0';
        cur %= 2019;

        vector <int> vec2(2019);
        for (int i = 0; i < 2019; i++) vec2[i * 10 % 2019] += vec[i];
        for (int i = 0; i < 2019; i++) vec[i] = vec2[i];

        ans += vec[cur];
        vec[cur]++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
string S, T; cin >> S >> T; int c=0, ans=T.size();
REP(i, S.size()-T.size()+1){ 
  c=0;
  REP(j, T.size()){ if(S[i+j]!=T[j]){ c++; } }
  ans=min(c, ans);
}
cout << ans << "\n";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,k;
    cin >> n >> k;
    intl a = n / k * k;
    intl b = a + k;
    cout << min(abs(n-a),abs(n-b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>

using namespace std;

int main(){
    int siz;
    scanf(" %d",&siz);
	string re;
	cin >> re;
	vector<set<int>> let(26);
	for(int i = 0; i < int(re.size());++i)
		let[re[i]-'a'].insert(i);

	int q;
	scanf(" %d",&q);
	while(q--){
		int t;
		scanf(" %d",&t);
		if(t == 1){
			int pl;
			scanf(" %d",&pl);
			--pl;
			char add;
			scanf(" %c",&add);
			let[re[pl] - 'a'].erase(pl);
			re[pl] = add;
			let[re[pl]-'a'].insert(pl);
		}
		else{
			int ans = 0;
			int l,r;
			scanf(" %d %d",&l,&r);
			--l,--r;
			for(int i = 0; i < 26;++i){
				auto it = let[i].lower_bound(l);
				if(it != let[i].end() && *it <= r) ++ans;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}


Measured memory_bytes: 26244
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int x, y;
    cin >> x >> y;

    int g1[7] = {1, 3, 5, 7, 8, 10, 12};
    int g2[4] = {4, 6, 9, 11};

    int xs;
    int ys;
    for(int i = 0; i < 7; i++){
        if(x == g1[i]) xs = 1;
        if(y == g1[i]) ys = 1;
    }
    for(int i = 0; i < 4; i++){
        if(x == g2[i]) xs = 2;
        if(y == g2[i]) ys = 2;
    }
    if(x == 2) xs = 3;
    if(y == 2) ys = 3;

    if(xs == ys){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int count = 0;
    
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      int count_ = 0;
      while (a % 2 == 0) {
        a /= 2;
        count_++;
      }
      count += count_;
    }

    sc.close(); 

    System.out.println(count);
  
  }

}

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

using namespace std;

int island[100001];
int nums[100001];
int main(void) {
  int N, M;
  while (cin >> N >> M && N + M) {
    auto ab = vector<pair<int,int>>(M);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      ab[i] = make_pair(a, b);
    }

    for (int i = 0; i < N; i++) island[i] = i;
    for (int i = 0; i < N; i++) nums[i] = 1;

    auto ans = vector<long long>(M+1);
    ans[0] = (long long)N*(N-1)/2;
    for (int i = 0; i < M; i++) {
      auto p = ab[M-1-i];
      ans[i+1] = ans[i];

      int pf = island[p.first];
      while (island[pf] != pf) pf = island[pf];
      island[p.first] = pf;

      int ps = island[p.second];
      while (island[ps] != ps) ps = island[ps];
      island[p.second] = ps;

      //cout << p.first+1 << ", " << p.second+1 << " -> " << pf+1 << ", " << ps+1 << endl;
      if (ps != pf) {
        int num_a = nums[pf];
        int num_b = nums[ps];
        //cout << i << ": " << num_a << ", " << num_b << endl;
        ans[i+1] -= num_a * num_b;
        nums[pf] = num_a + num_b;
      }

      island[ps] = pf;
    }
    for (int i = 1; i <= M; i++) {
      cout << ans[M-i] << endl;
    }
  }
}


Measured memory_bytes: 3712
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	cin >> s;
	int l = s.size();
	map<char, int> mp;
	rep(i, l) {
		mp[s[i]]++;
	}
	for (auto x : mp) {
		if (x.second % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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


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

int main(){
  int k;
  cin >> k;
  
  int even, odd;
  if (k%2 == 0){
    even = k/2;
    odd = k/2;
  }
  else{
    even = (k-1)/2;
    odd = (k+1)/2;
  }
  
  cout << even * odd << endl;
}

Measured memory_bytes: 3592
M=40
N,K=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)
f=Hash.new{|h,k|h[k]=0}
t=Hash.new{|h,k|h[k]=0}
A.each do |a|
  M.times do |i|
    a[i].zero? ? (f[i]+=1) : (t[i]+=1)
  end
end

dp0=*dp1=Array.new(M+1){0}
M.times do |i|
  c=2**i
  dp1[i+1] = c*[f[i],t[i]].max + dp1[i]
  if K[i].zero?
    dp0[i+1] = c*t[i] + dp0[i]
  else
    t0 = c*t[i] + [dp0[i],dp1[i]].max
    t1 = c*f[i] + dp0[i]
    dp0[i+1] = [t0,t1].max
  end
end
p dp0[M]


Measured memory_bytes: 10916
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
enum class Move
{
    NotDecided,
    Increase,
    Decrease
};

void _main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    int ans = 1;
    Move move = Move::NotDecided;
    rep(i, 1, N)
    {
        if (A[i] == A[i - 1])
        {

        }
        else if (A[i] > A[i - 1])
        {
            switch (move)
            {
                case Move::NotDecided:
                {
                    move = Move::Increase;
                    break;
                }
                case Move::Decrease:
                {
                    ++ans;
                    move = Move::NotDecided;
                    break;
                }
            }
        }
        else
        {
            switch (move)
            {
                case Move::NotDecided:
                {
                    move = Move::Decrease;
                    break;
                }
                case Move::Increase:
                {
                    ++ans;
                    move = Move::NotDecided;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640