akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N, M;
    cin >> N >> M;
    vector<int> cnt(101010), cnt_mod(M);
    REP(i,N){
        int X;
        cin >> X;
        cnt_mod[X%M]++;
        cnt[X]++;
    }
    int ans = 0;
    REP(i,M){
        if(i == 0 || 2 * i == M){
            ans += cnt_mod[i] / 2;
            cnt_mod[i] %= 2;
        }
        else{
            int p = min(cnt_mod[i], cnt_mod[M-i]);
            ans += p;
            cnt_mod[i] -= p, cnt_mod[M-i] -= p;
            for(int j=i;j<101010;j+=M){
                ans += min(cnt_mod[i], cnt[j]) / 2;
                cnt_mod[i] -= min(cnt_mod[i], cnt[j]) / 2 * 2;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 1024
/*
  coded by: mi_ni_
  "LIVE LONG AND PROSPER"
*/
 
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define newl '\n'
#define TEST_CASE(fun) int tc; cin>>tc; while(tc--){ fun(); }
#define TEST_CASE_2 int tc; cin>>tc; for(int i=1;i<=tc;i++)
#define TEST_CASE_3(fun) int tc; cin>>tc; for(int i=1;i<=tc;i++){ cout<<"Case #"<<i<<": "; fun(); }
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forab(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define forabr(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define trav(i,x) for(auto& i:x)

using ll=long long int;
using ull=unsigned long long int;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;

const ld pi=acosl(-1);
const int inf=(int)1e9+7;
const ll llinf=(ll)1e18+7;
const ld eps=1e-7;

//other
template<typename T> inline bool powerof2(T a){ return (a&&(!(a&(a-1)))); }
template<typename T> inline T log_2(T a){ T res=-1; while(a){ a/=2; res++; } return res; }

//make sure to choose TEST_CASE in main for multiple test cases
void solve(){
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<newl;
}

int main(){
	FAST_IO
	cout<<fixed<<setprecision(15);
	cerr<<fixed<<setprecision(10);
	//init_fact();
	//TEST_CASE(solve)
	//TEST_CASE_2{}
	//TEST_CASE_3(solve)
	solve();
	return 0;
}

Measured memory_bytes: 3644
package main
import (
    "fmt"
    "sort"
)

func next_perm(p []int) bool {
    i := len(p) - 1
    for i > 0 && p[i - 1] > p[i] {
        i--
    }
    if i == 0 {
        return false
    }
    i--
    j := len(p) - 1
    for p[j] < p[i] {
        j--
    }
    p[i], p[j] = p[j], p[i]
    i, j = i + 1, len(p) - 1
    for i < j {
        p[i], p[j] = p[j], p[i]
        i, j = i + 1, j - 1
    }
    return true
}



func main() {
    var n, m, r int
    fmt.Scanf("%v %v %v\n", &n, &m, &r)
    dist := make([][]int, n)
    for i := 0; i < n; i++ {
        dist[i] = make([]int, n)
        for j := 0; j < n; j++ {
            dist[i][j] = 1000000000
        }
        dist[i][i] = 0
    }
    rs := make([]int, r)
    for i := 0; i < r; i++ {
        var a int
        fmt.Scanf("%v", &a)
        rs[i] = a - 1
    }
    sort.Ints(rs)
    for i := 0; i < m; i++ {
        var a, b, c int
        fmt.Scanf("%v %v %v\n", &a, &b, &c)
        dist[a - 1][b - 1] = c
        dist[b - 1][a - 1] = c
    }
    for k := 0; k < n; k++ {
        for i := 0; i < n; i++ {
            for j := 0; j < n; j++ {
                if dist[i][j] > dist[i][k] + dist[k][j] {
                    dist[i][j] = dist[i][k] + dist[k][j]
                }
            }
        }
    }
    min_res := 1000000000 

    for true {
        res := 0
        for i := 0; i < len(rs) - 1; i++ {
            res += dist[rs[i]][rs[i + 1]]
        }
        if res < min_res {
            min_res = res
        }
        if !next_perm(rs) {
            break
        }
    }
    fmt.Printf("%v\n", min_res) 
}



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

int main() {
  ll N;
  string s;
  cin >> N >> s;
  const ll MOD = 1000000007;
  map<char,ll> mp;
  for (char c : s) mp[c] += 1;
  ll ans = 1;
  for (auto m : mp) {
    ans = ans * (m.second+1) % MOD;
  }
  cout << (ans-1)%MOD << endl;
}

Measured memory_bytes: 3652
using System;
public class Hello{
  public static void Main(){
    string a = "";
    switch(int.Parse(System.Console.ReadLine())%10)
           {
      case 2 :
      case 4:
      case 5:
      case 7:
      case 9:
        a ="hon";
        break;
      case 0:
      case 1:
      case 6:
      case 8:
        a="pon";
        break;
      default :
        a="bon";
        break;
           }
      System.Console.WriteLine(a);     
  }
}

Measured memory_bytes: 27472
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
ll power(ll a ,ll b)
{
	ll res=1LL;
	while(b>0){
		if(b&1) res=(res*a) % mod;
		a=(a*a) % mod;
		b=b>>1;
	}
	return res % mod;
}

ll inv_mod(ll a) { return (power(a, mod-2) % mod ) ;  }
ll fact[200007];
ll invv[200007];
void factorial()
{
	fact[0]=1;
	invv[0]=inv_mod(fact[0]);
	for(int i=1;i< 200007;i++){
		fact[i]=(fact[i-1]*i)%mod;
		invv[i]=inv_mod(fact[i]);
	}
	
}
ll get_path(int a, int b, int c, int d)
{
    if(a>c|| b>d) return 0;
    ll val=fact[c-a+d-b];
    val=(val*invv[c-a])%mod;
    val=(val*invv[d-b])%mod;
    return val%mod;
}
ll dp[MAX];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    factorial();
    ll n,m,k; cin>>n>>m>>k;
    vector<pair<int,int>> v(k);
    for(int i=0;i<k;i++) cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end());
    ll ans=0;
    for(int i=0;i<k;i++){
        ll sum=0;
        for(int j=0;j<i;j++){
            ll val=(dp[j]*get_path(v[j].first,v[j].second,v[i].first,v[i].second))%mod;
            sum=(sum+val)%mod;
        }
        ll tot=(get_path(1,1,v[i].first,v[i].second)-sum+mod)%mod;
        dp[i]=tot%mod;
        ans=(ans+(dp[i]*get_path(v[i].first,v[i].second,n,m))%mod)%mod;
    }
    ll fin=get_path(1,1,n,m);
    fin=(fin-ans+mod)%mod;
    cout<<fin<<endl;
}



Measured memory_bytes: 3456
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for j in range(H):
        for i in range(W):
            if j == 0 or j == H-1 or i == 0 or i == W-1:
                print('#',end="")
            else:
                print('.',end="")
        print()
    print()


Measured memory_bytes: 7004
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  ll ii=0;
  rep(y, h) {
    vector<ll> v(w);
    rep(x, w){
      ll x_hat = y%2==0?x:w - x -1;
      if(a.at(ii)==0) ++ii;
      v.at(x_hat) = ii + 1;
      --a.at(ii);
    }
    rep(i, w){
      cout << v.at(i);
      if(i!=w-1) cout << " ";

    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

#define SIZE 100000
struct Myconbination {
private:
	ll M = MOD;
	ll fac[SIZE + 1];
	ll ifac[SIZE + 1];
public:
	ll factorial(ll n) {
		return fac[n];
	}
	ll mpow(ll x, ll n) {
		ll ans = 1;
		while (n != 0) {
			if (n & 1) {
				ans = ans * x % M;
			}
			x = x * x % M;
			n = n >> 1;
		}
		return ans;
	}

	ll comb(ll a, ll b) {
		if (a == 0 and b == 0) {
			return 1;
		}
		if (a < b or a < 0) {
			return 0;
		}

		ll temp = ifac[a - b] * ifac[b] % M;

		return temp * fac[a] % M;
	}

	Myconbination() {
		fac[0] = 1; ifac[0] = 1;
		for (ll i = 0; i < SIZE; i++) {
			fac[i + 1] = fac[i] * (i + 1) % M;
			ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M;
		}
	}
};

int main() {
	Myconbination myc;
	int N, M;
	cin >> N >> M;

	if (abs(N - M) >= 2) {
		cout << 0 << endl;
	}
	else if (abs(N - M) == 1) {
		ll ans = myc.factorial(N) * myc.factorial(M) % MOD;
		cout << ans << endl;
	}
	else {
		ll ans = myc.factorial(N) * myc.factorial(M) % MOD;
		ans *= 2;
		ans %= MOD;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1024
N = int(input())

tnum = 0
iter_num = 0

for i in range(N):
    res = 0
    num = i+1
    while num % 2 == 0:
        num /= 2
        res += 1
    if iter_num <= res:
        iter_num = res
        tnum = i+1

print(tnum)


Measured memory_bytes: 2940
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

int main() {
    int k,n;
    cin>>k>>n;
    vector<int> a;
    for (int i =0;i<n;++i){
        int x;
        cin>>x;
        a.push_back(x);
    }
    int maxd = -1;
    maxd = max(maxd, abs(a[0]+k-a.back()));
    for (int i =0;i<n-1;++i){
        maxd=max(maxd,a[i+1]-a[i]);
    }
    cout<<k-maxd;
}

Measured memory_bytes: 1400
/* ***************************************
Author        :Scau.ion
Created Time  :2017/09/23 20:51:07 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

int main()
{
    IOS;
    char cc[2][2] = { { 'R', 'Y' }, { 'G', 'B' } };
    int n, m, d;
    cin>>n>>m>>d;
    for (int j = 1; j <= n; ++ j)
    {
        for (int k = 1; k <= m; ++ k)
        {
            int jj = j + k;
            int kk = n + m + j - k;
            int x = jj / d % 2;
            int y = kk / d % 2;
            cout<<cc[x][y];
        }
        cout<<"\n";
    }
    cout<<flush;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll N, D;
  cin >> N >> D;
  ll w = 1 + 2 * D;
  ll ans = N / w;
  if (N % w != 0) {
    ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   if(a==0)
   cout<<1;
   if(b==0)
   cout<<2;
   if(c==0)
   cout<<3;
   if(d==0)
   cout<<4;
   if(e==0)
   cout<<5;
   return 0;	
} 

Measured memory_bytes: 3616
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int sum = a * b;
        String s = " ";
        if (sum % 2 == 0 ){
            s = "Even";
        }else{
            s = "Odd";  
        }

        System.out.println(s);
        scan.close();
    }
}

Measured memory_bytes: 20820
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll ans=1;
    rep(i,N){
        ll x; cin>>x;
        ans=lcm(ans,x);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int n, sum = 0;
	cin >> n;
	n *= 2;
	vector<int> a(n);
	REP(i, n){
		cin >> a[i];
	}
	sort(all(a));
	REP(i, n){
		if(i % 2 == 0) sum += a[i];
	}

	cout << sum << endl;
}



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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> M(3);
  M = {a, b, c};
  
  sort(M.begin(), M.end());
  
  cout << M.at(0) + M.at(1) << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        a--;
        vec.at(i) = a;
    }
    int j = 0;
    for (int i = 1; i < N + 2; i++)
    {
        if (vec.at(j) == 1)
        {
            cout << i << endl;
            return 0;
        }
        j = vec.at(j);
    }
    cout << -1 << endl;

    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 640
from collections import deque

n, m = map(int, input().split())

g = [set() for _ in range(n)]
for _ in range(m):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add(b)
    g[b].add(a)

par = [-1] * n


def is_bipartite():
    dq = deque()
    dq.append(0)
    par[0] = 0

    while dq:
        v = dq.popleft()
        for u in g[v]:
            if par[u] != -1:
                if par[u] == (par[v] ^ 1):
                    continue
                else:
                    return False
            else:
                par[u] = (par[v] ^ 1)
                dq.append(u)
    return True


if is_bipartite():
    # print('bipartite', par)
    evens = par.count(0)
    odds = n - evens
    print(odds * evens - m)
else:
    # print('not bipartite', par)
    print(n * (n - 1) // 2 - m)

# 全ての奇数路にパスが張れる
# 1 : 既に張られている
# 3 : 張れる
# >= 5 : 途中に長さ3のパスを張ると長さが2減るので、奇数のまま2ずつ減らして3になる

# 二部グラフでない場合、奇サイクルが存在するので、
# 偶数路だったパスには、奇サイクルを挟んだ奇数路がある
# すべての頂点間にパスが張れる


Measured memory_bytes: 35216
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int A,B,C;

int main() {

	scanf("%d%d%d", &A,&B,&C);



	printf("%d\n", max(0,C-(A-B)));

	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>

int main()
{
  int s, w;
  std::cin >> s >> w;
  if (s <= w)
  {
    std::cout << "unsafe" << std::endl;
  }
  else 
  {
    std::cout << "safe" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3636
import fractions

def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def f(x, a, b):
    return x - x // a - x // b + x // lcm(a, b)

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

if __name__ == '__main__':
    main()

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

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


int main(){
  string s;
  int n;
  cin >> s >> n;
  rep(i,n){
    string code;
    cin >> code;
    if(code == "print"){
      int a, b;
      cin >> a >> b;
      for(int i = a; i <= b; i++){
        cout << s[i];
      }
      cout << endl;
    }
    else if(code == "reverse"){
      int a, b;
      cin >> a >> b;
      string sub;
      sub = s.substr(a, b-a+1);
      reverse(sub.begin(), sub.end());
      s.replace(a, b-a+1, sub);
    }
    else if(code == "replace"){
      int a, b;
      string sub;
      cin >> a >> b >> sub;
      s.replace(a, b-a+1, sub);
    }
  }
}






Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int a,b,c;
	while(~getIII(a,b,c)) printf("%s\n",(a==b&&b==c)?"Yes":"No");
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
int n,a,b,c;
  a=0;b=0;c=0;
  scanf("%d",&n);
  int s[n];
  for(int i=0;i<n;++i){
    scanf("%d",&s[i]);
   a+=s[i];
  }
  int B = a;
  int k =0;
while(b<B){
  b+=s[k];
  B -=s[k];
  ++k;
}
  int C = a;
  int l=1;
  while(c<C){
  c+=s[n-l];
    C -=s[n-l];
   ++l;
  }
  if(b-B<c-C)
    printf("%d",b-B);
  else
    printf("%d",c-C);
}


Measured memory_bytes: 128
/*
	Time created : 
	Name :
	Author : Minh Duc Phung - Team4 - ITPTIT
*/
#include<bits/stdc++.h>

#define fi first  
#define se second
#define mp make_pair
#define pb push_back
 
using namespace std;
typedef long long i64;
typedef pair < int,int > pii;
typedef vector <int> vi;
typedef vector <vi> vii;

const int N = 1e5+5;
const i64 mod = 1e9+7;
const i64 inf = LLONG_MAX;

inline i64 Gcd(i64 a, i64 b) {i64 r; while(b){ r = a % b; a = b; b = r;} return a;}
inline i64 modPow(i64 n, i64 k) {i64 r=1; for(;k;k>>=1,n=n*n%mod){if(k&1)r=r*n%mod;}return r;}
inline i64 C(int k, int n){i64 r=1;for(int i=1;i<=k;i++,n--)r=r*n%mod*modPow(i,mod-2)%mod;return r%mod;}

int dx[] = {-1,0,0,1};
int dy[] = {0,-1,1,0};
int n;
pii a[N];

void input(){
	cin >> n;
	for ( int i = 0 ; i < n ; i++){
		cin >> a[i].fi;
		a[i].se = i + 1;
	}
}
 
void solve(){
	auto cmp = [](pii a , pii b){return ( a.fi < b.fi);};
	sort ( a,a + n , cmp);
	for ( int i = 0 ; i < n ; i++)
		cout << a[i].se << ' ';
	
}
int main(){
	//freopen("INPUT.in", "r", stdin);
    //freopen("OUTPUT.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin>>t;
	while(t--){input(); solve();}
	return 0;
}

  

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys

def solve(N: int, X: "List[int]"):
    avg = round(sum(X) / len(X))
    ans = 0
    for i in range(N):
        ans = ans + ((X[i] - avg) ** 2)

    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#!/usr/bin/env python3


def main():
    n = int(input())
    s = ""
    for i in range(n):
        s += input()
    print('AC x ' + str(s.count('AC')))
    print('WA x ' + str(s.count('WA')))
    print('TLE x ' + str(s.count('TLE')))
    print('RE x ' + str(s.count('RE')))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9424
// finish date: 2018/04/07

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    int mi = INF;
    ll sum = 0;
    rep(i, N) {
        sum += A[i];
        if (A[i] > B[i]) mi = min(mi, B[i]);
    }
    if (mi == INF) cout << 0 << endl;
    else cout << sum - mi << endl;

    return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val (N, K) = listOfLong()
    val A = listOfLong().sorted().toLongArray()
    val INF = (1e18).toLong() + 1
    val n = N.toInt()
    var l = -INF
    var r = INF
    while (l + 1 < r) {
        val x = (l + r) / 2
        val ok = {
            var total = 0L
            repeat(n) { i ->
                var l = -1
                var r = n
                if (A[i] >= 0) {
                    while (l + 1 < r) {
                        val c = (l + r) / 2
                        if (A[c] * A[i] < x) l = c else r = c
                    }
                    total += r
                } else {
                    while (l + 1 < r) {
                        val c = (l + r) / 2
                        if (A[c] * A[i] < x) r = c else l = c
                    }
                    total += n - r
                }
                if (A[i] * A[i] < x) total -= 1
            }
            total /= 2
            total < K
        }()
        if (ok) l = x else r = x
    }
    println(l)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


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

int arr[1000000];

int main()
{
	int x, cnt, j, i = 3;
	arr[2] = 1;
	for (; i < 1000000; ++i) {
		cnt = 1;
		for (j = 2; j <= sqrt(i); ++j) {
			if (i%j == 0) {
				arr[i] = arr[i - 1];
				--cnt;
				break;
			}
		}
		arr[i] = arr[i - 1] + cnt;
	}
	while (cin >> x) {
		cout << arr[x] << endl;
	}
	return 0;
}

Measured memory_bytes: 6896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var d = (long)sc.nextInt();
		var x = new long[n];
		var y = new long[n];
		for (var i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();

		var count = 0;
		for (var i = 0; i < n; i++) {
			if (x[i] * x[i] + y[i] * y[i] <= d * d) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

int main() {
  int x, y, z, occ = 0, ans = 0;
  cin >> x >> y >> z;
  
  occ += z;
    
  while(occ <= x){
    occ += y + z;
    ans++;
  }
  
  cout << ans - 1 << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

s = input()
cnt = 0
if s == "RRR":
    print(3)
elif s.count("R") == 1 or s == "RSR":
    print(1)
elif s == "SSS":
    print(0)
else:
    print(2)

Measured memory_bytes: 61668
/*
ID: varunra2
LANG: C++
TASK: code
*/

#include<bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#include "lib/debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#pragma GCC diagnostic ignored "-Wsign-compare"
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#define debug(...) 42
#endif

#define EPS 1e-9
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1234567
#define MP make_pair
#define PB push_back
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define x first
#define y second

const double PI = acos(-1.0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#pragma GCC diagnostic ignored "-Wsign-compare"
// util functions


int main() {
#ifndef ONLINE_JUDGE
  freopen("code.in", "r", stdin);
  freopen("code.out", "w", stdout);
#endif
  cin.sync_with_stdio(0); cin.tie(0);

	int n;
  cin >> n;
  
  cout << (1000 - (n%1000))%1000 << endl;


  return 0;
}


Measured memory_bytes: 3556
n, m = map(int, input().split())

students = []
for _ in range(n):
    x, y = map(int, input().split())
    students.append([x, y])

points = []
for _ in range(m):
    x, y = map(int, input().split())
    points.append([x, y])

for s in students:
    distants = [abs(s[0]-p[0]) + abs(s[1]-p[1]) for p in points]
    print(distants.index(min(distants)) + 1)

Measured memory_bytes: 3064
from itertools import accumulate


def solve_odd(n, aaa):
    INF = 10 ** 18
    p0, p1, p2, a0, a1, a2 = INF, INF, INF, INF, INF, 0
    for a in aaa:
        n2 = min(INF, p2 + a)
        n1 = min(INF, a2 + a, p1 + a)
        n0 = min(INF, a1 + a, p0 + a)
        p0, p1, p2, a0, a1, a2 = a0, a1, a2, n0, n1, n2
    return sum(aaa) - min(p0, a1)


def solve_even(n, aaa):
    fwd = [0] + list(accumulate(aaa[::2]))
    bwd = [0] + list(accumulate(aaa[::-2]))
    bwd.reverse()
    return max(f + b for f, b in zip(fwd, bwd))


n = int(input())
aaa = list(map(int, input().split()))
if n % 2 == 0:
    print(solve_even(n, aaa))
else:
    print(solve_odd(n, aaa))


Measured memory_bytes: 31036
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

void solve() {
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust";
    else cout<<"win";    
}

int main()
{
    fastIO;ll t=1;
    // cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
        int n,k;
        cin>>n>>k;
        string s[100];
        string ans;
        for(int i=0;i<n;i++){
                cin>>s[i];
        }
        sort(s,s+n);
        for(int i=0;i<n;i++){
                ans=ans+s[i];
        }
        cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<queue>

using namespace std;

int main(){
    int n, a;
    map<int, int> m;
    cin >> n;
    queue<int> q;
    for(int i=0;i<n;i++){
        cin >> a;
        m[a]++;
        m[a-1]++;
        m[a+1]++;
        q.push(a);
        q.push(a-1);
        q.push(a+1);
    }

    int mx = 0;
    while(!q.empty()){
        int fr=q.front();q.pop();
        mx = max(mx, m[fr]);
    }
    cout << mx << endl;
}

Measured memory_bytes: 5888
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [readline().strip() for _ in range(N)]

    for s in ['AC', 'WA', 'TLE', 'RE']:
        print(f'{s} x {S.count(s)}')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 73972
N = int(input())
S = [str(x) for x in input()]
alpha_list = [chr(ord('A') + i) for i in range(26)] * 2
for i in range(len(S)):
    S[i] = alpha_list[alpha_list.index(S[i]) + N]
ans = ''.join(S)
print(ans)

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

using namespace std;

typedef long long ll;

vector<ll> v;
string S;

ll grundy(ll x){
	if (x == -1) return 0;
	ll b = 1;
	while (1){
		if (x%b!=0) break;
		b *= 2;
	}
	b /= 2;
	return b;
}

struct trie{
	ll sz;
	trie *left = nullptr, *right = nullptr;
	trie(ll s){
		sz = s;
	}
	void dfs(int idx){
		if (idx == S.size()) return;
		if (S[idx] == '0'){
			if (left == nullptr) left = new trie(sz-1);
			left->dfs(idx+1);
		}
		else{
			if (right == nullptr) right = new trie(sz-1);
			right->dfs(idx+1);
		}
	}
	void cnts(){
		if (left == nullptr && right == nullptr) return;
		if (left == nullptr || right == nullptr) v.push_back(grundy(sz-1));
		if (left != nullptr) left->cnts();
		if (right != nullptr) right->cnts();
	}
} *root;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll N, L;
	cin >> N >> L;
	root = new trie(L+1);
	for (int i = 1; i <= N; ++i){
		cin >> S;
		root->dfs(0);
	}
	root->cnts();
	ll k = 0;
	for (int i = 0; i < v.size(); ++i){
		k ^= v[i];
	}
	if (k == 0){
		cout << "Bob\n";
	}
	else cout << "Alice\n";
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

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

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if(((abs(a-b)<=d)&&(abs(c-b)<=d))||(abs(c-a)<=d))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {

    int n,x;

    cin >> n >> x;

    int m[n];

    int ans = 0;

    for(int i=0; i<n; i++){
        cin >> m[i];
        x -= m[i];
        ans++;
    }

    sort(m,m+n);

    while(x >= m[0]){
        x -= m[0];
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n,k;
	cin >> n >> k;
	lld ans = 0;
	if (k == 0)
	{
		cout << n * n << endl;
		return 0;
	}
	for(int b = 1; b <= n; b++)
	{
		lld m = n/b, r = n%b;
		ans += m*max((lld)0,b-k);
		ans += max((lld)0,r-k+1);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#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, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  atcoder::fenwick_tree<ll> fw(n);
  rep(i, n) fw.add(i, a[i]);
  rep(_, q) {
    int t;
    cin >> t;
    if (t == 0) {
      int p, x;
      cin >> p >> x;
      fw.add(p, x);
    }
    if (t == 1) {
      int l, r;
      cin >> l >> r;
      cout << fw.sum(l, r) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 10180
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    println(problem098c(n, s))
}

fun problem098c(n: Int, s: String): Int {
    val array = Array(n) { Integer.MAX_VALUE to Integer.MAX_VALUE }
    var firstCount = 0
    for (i in 1 until n) {
        val si = s[i]
        if (si == 'E') firstCount++
    }
    array[0] = 0 to firstCount
    for (i in 1 until n) {
        val si = s[i]
        val (prevLeft, prevRight) = array[i - 1]
        val left = prevLeft + if (s[i - 1] == 'W') 1 else 0
        val right = prevRight - if (s[i] == 'E') 1 else 0
        array[i] = left to right
    }
    return array.map { it.first + it.second }.min()!!
}

Measured memory_bytes: 97548
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n,c;cin>>n>>c;
    vp v[c];
    rep(i,n){
        int s,t,c_;
        cin >> s >> t >> c_;
        c_--;
        v[c_].push_back(P(s,t));
    }
    rep(i,c){
        sort(v[i].begin(),v[i].end());
    }

    int ans = 0;
    int flag[c] = {};
    int now[c] = {};

    rep(i,110000){
        int tmp = 0;
        rep(j,c){
            if(now[j]==v[j].size())continue;
            if(flag[j]==0){
                if(v[j][now[j]].first==i){
                    flag[j] = 1;
                    tmp++;
                }
            }else{
                tmp++;
                if(v[j][now[j]].second==i){
                    flag[j] = 0;
                    now[j]++;
                    if(now[j]!=v[j].size()){
                        if(v[j][now[j]].first==i){
                            flag[j] = 1;
                        }
                    }
                }
            }
        }
        ans = max(ans,tmp);
    }

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


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, A, B; cin >> N >> A >> B;
    if(A > B){
        cout << 0 << endl;
    }else if(N == 1 && A != B){
        cout << 0 << endl;
    }else{
        cout << (B*(N-1)+A) - (A*(N-1)+B) + 1 << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
H, W = gets.split.map(&:to_i)

all = H*W

if H % 3 == 0 || W % 3 == 0
    puts 0
    exit
end

min = [H, W].min

[H/3-1, H/3, H/3+1].each do |h1|
    next if h1 <= 0
    a1 = h1 * W
    h2 = H - h1
    [W/2, W/2+1].each do |w2|
        a2 = w2 * h2
        a3 = all - a1 - a2
        dmin = [a1 - a2, a2 - a3, a3 - a1].map(&:abs).max
        min = dmin if min > dmin
    end
end

tmp = H
H = W
W = tmp

[H/3-1, H/3, H/3+1].each do |h1|
    next if h1 <= 0
    a1 = h1 * W
    h2 = H - h1
    [W/2, W/2+1].each do |w2|
        a2 = w2 * h2
        a3 = all - a1 - a2
        dmin = [a1 - a2, a2 - a3, a3 - a1].map(&:abs).max
        min = dmin if min > dmin
    end
end

puts min

Measured memory_bytes: 1788
using System;

namespace _174_c
{
    internal class Repsept
    {
        private static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());

            var seven = "7";
            for (var i = 0; i < k; i++)
            {
                var remainder = long.Parse(seven) % k;
                if (remainder == 0)
                {
                    Console.WriteLine(i + 1);
                    return;
                }

                seven = remainder + "7";
            }

            Console.WriteLine(-1);
        }
    }
}

Measured memory_bytes: 46212
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<int> t(N);
  int tsum;
  REP(i, N) {
    cin >> t[i];
    tsum += t[i];
  }
  vector<int> v(N);
  REP(i, N) cin >> v[i];
  vector<int> vmax(tsum);
  int idx = 0;
  REP(i, N) REP(j, t[i]) {
    vmax[idx] = v[i];
    idx++;
  }
  vector<int> vmaxp(tsum+1);
  FOR(i, 1, tsum) vmaxp[i] = min(vmax[i-1], vmax[i]);
  vector<int> v1(tsum+1);
  FOR(i, 1, tsum+1) v1[i] = min(v1[i-1]+1, vmaxp[i]);
  vector<int> v2(tsum+1);
  IFOR(i, 1, tsum) v2[i] = min(v2[i+1]+1, vmaxp[i]);
  double ans = 0;
  REP(i, tsum) {
    double min1 = min(v1[i], v2[i]);
    double min2 = min(v1[i+1], v2[i+1]);
    if(min1 == min2 && vmax[i] > min1) {
      ans += min1 + 0.25;
    } else {
      ans += (min1 + min2) / 2.0;
    }
  }
  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 640
import scala.io.StdIn.readLine;
object Main {
    def main(args: Array[String]): Unit = {
        val Array(n, w) = readLine.split(" ").map(_.toInt);
        val baggege = new Array[Array[Int]](n);
        for ( i <- (0 until n)) {
            baggege(i) = readLine.split(" ").map(_.toInt); // [value, weight]
        }
        println(knapsackProblem(n, w, baggege));
    }
    def knapsackProblem(n: Int, w: Int, baggege: Array[Array[Int]]): Int = {
        val matrix = Array.ofDim[Int](n + 1, w + 1);
        for (row <- (1 to n); col <- (1 to w)) {
            val currValue = baggege(row - 1)(0);
            val currWeight = baggege(row - 1)(1);
            matrix(row)(col) = if (col >= currWeight) {
                // row番目の荷物を使わない場合 : (row - 1) 番目までの荷物を使って col(weight) に詰め込める価値の最大
                // row番目の荷物を使う場合 : row 番目の荷物の価値 + (col - currWeight) に詰め込める価値の最大
                Math.max(matrix(row - 1)(col), matrix(row - 1)(col - currWeight) + currValue);
            } else {
                matrix(row - 1)(col);
            }
        }
        matrix(n)(w);
    }
}


Measured memory_bytes: 48680
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

string s;
int n;
string to_s(int i){
  stringstream ss;
  ss<<i;
  string res;
  ss>>res;
  return res;
}


string convert(string s){
  string res="";
  int t=s.find_first_not_of(s[0]);
  while(t!=-1){
    res+=to_s(t)+s[0];
    s=s.substr(t);
    t=s.find_first_not_of(s[0]);
  }
  res+=to_s(s.size())+s[0];
  return res;
}

string solve(){
  string res=s;
  for(int i=0;i<n;i++){
    res = convert(res);
  }
  return res;
}

int main(){
  while(cin>>n,n!=0){
    cin>>s;
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1380
N, K = map(int, input().split())

def f():
    L = (N - 1) * (N - 2) // 2
    if K > L:
        print(-1)
        return

    res = ""
    for i in range(1, N):
        res += "{0} {1}\n".format(1, i + 1)

    R = L - K
    M = N - 1 + R

    r = 0
    for i in range(1, N - 1):
        for j in range(i + 1, N):
            if r == R:
                print(M)
                print(res)
                return
            res += "{0} {1}\n".format(i + 1, j + 1)
            r += 1
    print(M)
    print(res)

f()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
    int n;
    cin >> n;
    using pi = pair<int,int>;
    vector<pi> a;
    rep(i, n) {
        int t;
        cin >> t;
        pi tt = make_pair(t, i+1);
        a.push_back(tt);
    }

    sorti(a);

    for (auto itr : a) {
        cout << itr.second << " ";
    }
    END;
}


Measured memory_bytes: 1780
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int a[100] = {};

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

  int N;
  cin >> N;
  REP(i, N) {
    cin >> a[i];
  }
  ll ans = 40000000;
  for (int i = -100; i <= 100; i++) {
    ll c = 0;
    REP(j, N) {
      c += (a[j] - i) * (a[j] - i);
    }
    ans = min(ans, c);
  }

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


Measured memory_bytes: 256
N = int(input())
S = input()

wsum = [0]
bsum = [0]

for s in S:
	wsum.append(wsum[-1] if "." == s else wsum[-1] + 1)
for s in S[::-1]:
	bsum.append(bsum[-1] if "#" == s else bsum[-1] + 1)

#print(wsum)
#print(bsum)

msum = 2**31-1
for i in range(len(S) + 1):
	msum = min(msum, wsum[i] + bsum[-1-i])

print(msum)


Measured memory_bytes: 12952
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

#define INF (1<<31) - 1

int rmq(unsigned int *ary, int a, int b, int k, int left, int right)
{
  if (right <= a || b <= left) return INF;
  if (a <= left && right <= b) return ary[k];

  int vl = rmq(ary, a, b, 2 * k + 1, left, (left + right) / 2);
  int vr = rmq(ary, a, b, 2 * k + 2, (left + right) / 2, right);
  return min(vl, vr);
}

int aryLength(int a, int b)
{
  while (a < b)
  {
    a *= 2;
  }
  return a;
}

void addVal(unsigned int *ary,int n, int index, int val)
{
  int v = (n - 1) + index;
  ary[v] = val;
  
  while (v > 0)
  {
    v = (v - 1) / 2;
    ary[v] = min(ary[v * 2 + 1], ary[v * 2 + 2]);
  }
}

int main()
{
  unsigned int *ary;
  int n, n_, i, q, x, y, com, arySize, min;

  cin >> n_ >> q;

  n = aryLength(1, n_);
  arySize = 2 * n - 1;
  
  ary = (unsigned int*)malloc(sizeof(unsigned int) * arySize);
  for (i = 0; i < arySize; i++) { ary[i] = INF; }

  for (i = 0; i < q; i++)
  {
    cin >> com >> x >> y;
    switch (com)
    {
    case 0:
      addVal(ary, n, x, y);
      break;
    case 1:
      min = rmq(ary, x, y + 1, 0, 0, n);
      cout << min << endl;
      break;
    }
  }

  free(ary);
  
  return 0;
}


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

int main(){
  int n,k; cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  
  sort(h.begin(), h.end());
  ll min = 1000000000;
  rep(i,n-k+1){
    if((h[i+k-1] - h[i]) < min){
      min = h[i+k-1] - h[i];
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 1024
N = int(input())
S = input()
pattern = [False] * 1000

for i in range(1000):
    str_i = str(i)
    str_i = str_i.zfill(3)
    now = 0
    for c in S:
        if c == str_i[now]:
            now += 1
        if now == 3:
            pattern[i] = True
            break
print(sum(pattern))

Measured memory_bytes: 67972