akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdint>
#include<vector>
#include<map>
typedef long long ll;

ll combination(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main() {
	ll n = 0, m = 0, ans = 0;
	int a[100000] = {}, accu[100000] = {};
	std::map<ll, ll> amari;
	std::vector<ll> num_type;
	std::cin >> n >> m;
	accu[0] = 0;
	for (ll i = 0; i < n; i++) {
		std::cin >> a[i];
		if (i == 0) {
			accu[1] = a[i]%m;
		}
		else {
			accu[i + 1] = (accu[i] + a[i])%m;
		}
	}
	for (ll i = 0; i < n + 1; i++) {
		amari[accu[i] % m]++;
		if (amari[accu[i] % m] == 1) {
			num_type.push_back(accu[i] % m);
		}
	}
	for (ll i = 0; i < num_type.size(); i++) {
		ans += combination(amari[num_type[i]], 2);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 5496
#include <cstdio>


int main() {
    int a, b, c, n;
    scanf("%d%d%d", &a, &b, &c);
    if (a == b && b == c) n = 1;
    else if (a == b) n = 2;
    else if (a == c) n = 2;
    else if (b == c) n = 2;
    else n = 3;
    printf("%d", n);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 
#define MOD 1000000007;

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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

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

	string S;

	cin >> S;

	ll max = 0;
	ll count = 0;

	rep(i, S.size()) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			count++;
		}
		else {
			count = 0;
		}

		if (max < count) {
			max = count;
		}
	}


	cout << max;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL n,i;cin>>n;
      LL a[n],b[n-1];
      fo(i,0,n-1) cin>>b[i];
      fo(i,0,n) a[i]=0;
      fo(i,1,n-1){
        a[i]=min(b[i-1],b[i]);
      }
      a[0]=max(a[1],b[0]);
      a[n-1]=max(b[n-2],a[n-2]);
      LL sum=0;
      fo(i,0,n) sum+=a[i];
      cout<<sum;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long int li;
typedef long long int lli;
typedef pair<lli, int> P;
const lli INF = 0xfffffffffff;
int main(){
	int a;
	cin >> a;
	int ans;
	if (a % 2 == 0) ans = a * a / 4;
	else ans = (a / 2)*((a / 2) + 1);
	cout << ans << endl;
}

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

int main(){
  int n, x;
  cin>>n;
  if(n % 1000 == 0) cout<<"0";
  else{
  x=1000- (n % 1000);
  cout<<x;
}}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    long long N, a, b;

    cin >> N >> a >> b;

    long long d = b - a;
    if( d % 2 == 0 ){
        cout << d / 2 << endl;
    }
    else{
        cout << (d - 1) / 2 + min(a-1, N-b) + 1 << endl;
    }
}

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

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        int n,m;
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        if(n==m){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35740
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A[100000];
i64 B[100000];

int main()
{
	i64 cnt = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld%lld", A+i, B+i);
#ifdef DEBUG
	for (int i = 0; i < N; ++i){
		printf("%lld %lld\n", A[i], B[i]);
	}
#endif
	for (int i = N-1; i >= 0; --i){
		A[i] = (A[i]+cnt)%B[i];
		if( A[i] ){
			cnt += B[i]-A[i];
		}
#ifdef DEBUG
		printf("%lld\n", B[i]-A[i]);
#endif
	}
	printf("%lld\n", cnt);

	return 0;
}


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

using namespace std;

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

int bubbleSort(int A[], int N) {
    int cnt = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = true;
                cnt++;
            }
        }
    }
    return cnt;
}

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

    int n;
    cin >> n;
    int A[n];
    REP(i, n) cin >> A[i];

    int ans = bubbleSort(A, n);
    REP(i, n) {
        cout << (i == 0 ? "" : " ") << A[i];
    }
    cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 100005
#define P pair<int,int>
using namespace std;
int main()
{
	int n, q;
	cin >> n >> q;
	int a[100005];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	int max1 = 0;
	int temp = INF;
	for (int i = 0; i <n; i++)
	{
		temp = min(temp, a[i]);
		max1 = max(a[i]-temp, max1);
	}
	temp = INF;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		temp = min(temp, a[i]);
		if (max1 == a[i] - temp)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	vector<int > A(M);
	LL sum = 0;
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum > N) {
		cout << -1 << endl;
	}
	else {
		cout << N - sum << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 3684
import itertools

n = int(input())
list_3_5_7 = ["3", "5", "7"]

res = 0
for i in range(3, 10):
    tmp_product_list = list(itertools.product(list_3_5_7, repeat = i))
    for tmp_list in tmp_product_list:
        tmp_str = "".join(tmp_list)
        if len(set(tmp_str)) == 3 and int(tmp_str) <= n:
            res += 1

print(res)

Measured memory_bytes: 12272
//#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
 
template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=2e6+10;
LL t,n,m,ans,cnt;
LL MOD=1e9+7,inf=1e10;
db eps=1e-5;

LL f[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>n;
	repu(i,1,n){
		cin>>k;
		f[i]=k;
		if(f[k]==i)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int MOD = 100000000 + 7;

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

    int n;
    cin >> n;

    int min_x = 1, min_y = n;
    int sq_n = sqrt(n);
    for (int i = 2; i < sq_n + 10; i++)
    {
        if (n % i == 0)
        {
            int x = i, y = n / i;
            if (x + y < min_x + min_y)
            {
                min_x = x, min_y = y;
            }
        }
    }
    cout << min_x + min_y - 2 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
	char a;
	while(1){
		scanf("%c",&a);
		if(isalpha(a)){
			if(islower(a))cout<<(char)toupper(a);
			else if(isupper(a))cout<<(char)tolower(a);
		}
		else {cout<<a;}
		if(a=='\n')break;
	}
return 0;
}


Measured memory_bytes: 3140
def calc_order(nums):
  n = len(nums)
  order = 1
  ls = sorted(nums)
  for i, v in enumerate(nums[:-1]):
    c = (ls.index(v) - 1) * level_mat(n) // level_mat(n, i+1)
    order += c
    ls.remove(v)
  return order


def level_mat(n, m=None):
  if m is None:
    m = n
  assert n >= m

  if m == 0:
    return 1
  if n == 1:
    return 1
  else:
    return n * level_mat(n-1, m-1)


if __name__ == '__main__':
  n = int(input())
  ps = [int(i) for i in input().split()]
  qs = [int(i) for i in input().split()]
  print(abs(calc_order(ps) - calc_order(qs)))

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

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int X;
    cin>>X;
    int ans=0;
    for (int b=1; b<=1000; b++) {
        for (int p=2; p<=1000; p++) {
            if (ans<=pow(b,p)&&pow(b,p)<=X) {
                ans=pow(b,p);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

void selection_sort(int *a, int *a_str, int n) {
    int i, j, tmp1, tmp2, mini;

    for (i=0;i<n;i++) {
        mini=i;
        for (j=i;j<n;j++) {
            if (a[j]<a[mini]) {
                mini=j;
            }
        }
        tmp1=a[i];
        a[i]=a[mini];
        a[mini]=tmp1;
        tmp2=a_str[i];
        a_str[i]=a_str[mini];
        a_str[mini]=tmp2;
        // if (i!=mini) count++;
    }
    // return count;
}

void bubble_sort(int *a, int *a_str, int m) {
    int i, j, tmp1, tmp2;

    for (i=0;i<m;i++) {
        for (j=m-1; j>i; j--) {
            if (a[j]<a[j-1]) {
                tmp1=a[j];
                tmp2=a_str[j];
                a[j]=a[j-1];
                a_str[j]=a_str[j-1];
                a[j-1]=tmp1;
                a_str[j-1]=tmp2;
                // n++;
            }
        }
    }

    // return n;
}

void stable(int *a_str, int *a, int *b_str, int *b, int n) {
    int i, check=1;

    for (i=0; i<n; i++) {
            if (a[i]==b[i] && a_str[i]!=b_str[i]) check=0;
    }

    for (i=0;i<n;i++) {
        printf("%c%c", b_str[i], b[i]);
        if (i<n-1) printf(" ");
    }
    printf("\n");
    if (check==1) printf("Stable\n");
    else printf("Not stable\n");
}

int main(void) {
    int i, n, B_str[36], B[36], S_str[36], S[36];
    char str[3]={'\0'};

    scanf("%d", &n);
    for (i=0;i<n;i++) {
        scanf("%s", str);
        // printf("%s\n", str);
        B_str[i]=str[0];
        S_str[i]=str[0];
        B[i]=str[1];
        S[i]=str[1];
    }
    bubble_sort(B, B_str, n);
    selection_sort(S, S_str, n);
    stable(B_str, B, B_str, B, n);
    stable(B_str, B, S_str, S, n);

    return 0;
}



Measured memory_bytes: 2076
from itertools import product
n = int(input())
L = ["3","5","7"]

l = len(str(n))

cnt = 0
for i in range(1,l+1):
    p = product(L,repeat = i)
    for j in p:
        d = "".join(j)
        if ("3" in d) and ("5" in d) and ("7" in d) and int(d) <= n:
            cnt += 1
print(cnt)

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

using namespace std;

int main() {
    int N, X, bounces = 1, sum = 0, input;
    cin >> N >> X;

    for (int i = 0; i < N; i++)
    {
        cin >> input;
        sum += input;
        if (sum <= X)
        {
            bounces++;
        } else {
            break;
        }
    }
    
    cout << bounces;
}


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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        final Solver solver = new Solver();
        solver.solve(A, B);
    }
}

class Solver {
    public void solve(int A, int B) {
        System.out.println(6 - A - B);
    }
}



Measured memory_bytes: 23636
/*
AizuOnline A2018
Princess's Gamble
*/
#include <stdio.h>
#include <float.h>

int M,N,P;
int hyousuu[100];
long int sousuu;
long int haitou;

main()
{
  int i;

  while(EOF!=scanf("%d %d %d",&N,&M,&P) && (N || M || P))
    {
      sousuu=0;
      for(i=0;i<N;i++)
	{
	  scanf("%d",&hyousuu[i]);
	  sousuu += hyousuu[i];
	}
      if(hyousuu[M-1])
	haitou = (double)sousuu / (double)hyousuu[M-1] * (double)(100-P);
      else
	haitou=0;
      printf("%ld\n",haitou);
    }
return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl


int main(){
  ll n;cin>>n;
  vector<ll> a(n+2);
  ll sum=0;
  vector<ll> cost(n+3);
    
  rep(i,n){
    cin>>a[i+1];
  }
  FOR(i,1,n+2){
  	cost[i]=abs(a[i]-a[i-1]);
  	sum+=cost[i];
  }

  FOR(i,1,n+1){
  	cout<<sum-cost[i]-cost[i+1]+abs(a[i+1]-a[i-1])<<endl;
  }
  return 0;
}

Measured memory_bytes: 2816
//@source : 
//@create : 19:02:26 Sunday 05/07/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

#define fastio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template<typename T> void write(const T&x) { cout << x; }
template<typename T, typename... Args> void write(const T&x, Args... args) { cout << x; write(args...); }
template<typename... Args> void writeln(Args... args) { write(args..., "\n"); }
template<typename T> void read(T&x) { cin >> x; }
template<typename T, typename... Args> void read(T&x, Args&... args) { cin >> x; read(args...); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << "\n"; err(++it, args...); }

void solve() {
    map<string, int> cnt;
    int n;
    read(n);
    for (int i = 0; i < n; ++i) {
        string t;
        read(t);
        cnt[t]++;
    }
    writeln("AC x ",cnt["AC"]);
    writeln("WA x ",cnt["WA"]); 
    writeln("TLE x ",cnt["TLE"]); 
    writeln("RE x ",cnt["RE"]);
}

int main() {
    fastio();
    int t = 1;
    for (int it = 1; it <= t; ++it) {
        solve();
    }
    return 0;
}

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

int main()
{
  int w,a,b;
  cin >> w >> a >> b;
  
  if(a+w < b){
    cout << b - (a+w) << endl;
  }else if(b+w < a){
    cout << a - (b+w) << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3528
#include <stdio.h>
#
int main()
{
    long long int a,b,n,ans,x;
    scanf("%lld%lld%lld",&a,&b,&n);
    x=b-1<=n?b-1:n;
    ans=(a*x/b)-a*(x/b);
    printf("%lld",ans);

    return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int sum=a+b;
		int dif=a-b;
		int pro=a*b;
		
		int max=sum;
		
		if(max<dif) {
			max=dif;
		}
		if(max<pro) {
			max=pro;
		}
		
		System.out.println(max);
		
		
	}
}


Measured memory_bytes: 23764
var
    i,j,k : integer;
    n : integer;
    sum : longint;
    dp : array [1..200,1..200] of integer;
function gcd(a,b : integer):integer;
var cur,wth:integer;
begin
    wth:=1;
    for cur:=2 to 200 do begin
        while ((a mod cur) = 0) and ((b mod cur) = 0) do begin
            a:=(a div cur);
            b:=(b div cur);
            wth:=wth*cur;
        end;
    end;
    gcd:=wth;
end;
begin
    for i:=1 to 200 do
        for j:=1 to 200 do
            dp[i][j]:=gcd(i,j);
    readln(n);
    sum:=0;
    for i:=1 to n do 
        for j:=1 to n do 
            for k:=1 to n do sum:=sum+dp[dp[i][j]][k];
    writeln(sum);
end.

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

int main() {
	vector<double> tall;
	double t;
	while (cin >> t) {
		tall.push_back(t);
	}
	sort(tall.begin(), tall.end());
	cout << (tall[tall.size()-1] - tall[0]) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int a, b, t;
	cin >> a >> b >> t;
	cout << t/a * b << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,X,Y;

  cin >> N >> X >> Y;

  vector<int> d_count(N,0); //0は使わない
  int d;
  int dxy;

  for(int i = 1; i < N; i++) {
    for(int j = i + 1; j < N + 1; j++) {
      d = j - i;
      dxy = abs(X - i) + 1 + abs(j - Y);

      d = min(d,dxy);

      d_count.at(d)++;
    }
  }

  for(int i = 1; i < N; i++) {
    cout << d_count.at(i) << endl;
  }
  
}

Measured memory_bytes: 256
# AGC020B - Ice Rink Game
def main():
    K, *A = map(int, open(0).read().split())
    if A.pop() != 2:
        print(-1)
        return
    mn, mx = 2, 3
    for i in A[::-1]:
        if i > mx:
            print(-1)
            return
        mx = mx // i * i + i - 1
        mn = ((mn + i - 1) // i) * i
    if mn > mx:
        print(-1)
    else:
        print(mn, mx)


if __name__ == "__main__":
    main()

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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

const long long MOD = 1e9 + 7;
const long long MAXN = 2e5 + 10;

long long N, A, B, C;
long long INVF[MAXN], F[MAXN];
long long pa, pb;
long long mod_pow(long long a, long long b) {
   long long ret = 1;
   while (b) {
      if (b & 1) ret = (ret * a) % MOD;
      a = a * a % MOD;   b >>= 1;
   }
   return ret;
}

long long mod_inv(long long a) {
   return mod_pow(a, MOD - 2);
}

long long comb(long long a, long long b) {
   return F[a] * INVF[b] % MOD * INVF[a - b] % MOD;
}

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

   cin >> N >> A >> B >> C;

  F[0] = 1;
   for (int i = 1; i <= 200000 ; i++) F[i] = (F[i - 1] * i) % MOD;

   INVF[200000] = mod_inv(F[200000]);
   for (int i = 200000; i >= 1 ; i--) INVF[i - 1] = (INVF[i] * i) % MOD;
 
   pa = A * mod_inv(A + B) % MOD;    pb = B * mod_inv(A + B) % MOD;

   long long res = 0;
   for (int i = N; i <= 2 * N - 1; i++) {
      res = (res + comb(i - 1, N - 1) * mod_pow(pa, N - 1) % MOD * mod_pow(pb, i - N) % MOD * pa % MOD * i % MOD) % MOD;
      res = (res + comb(i - 1, N - 1) * mod_pow(pa, i - N) % MOD * mod_pow(pb, N - 1) % MOD * pb % MOD * i % MOD) % MOD;
   }

   res = res * 100 % MOD * mod_inv(A + B) % MOD;

   cout << res << '\n';
   return 0;
}

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

int main(){ 
  int n,cnt=0;
  string result;
  cin >> n;
  for(int i=9;i>=1;i--){
    if(n%i==0){
//      cout << n << "/" << i << " = " << n/i << endl;
      n/=i;
      cnt++;
      break;
    }
  }
  for(int i=9;i>=1;i--){
    if(n%i==0){
//      cout << n << "/" << i << " = " << n/i << endl;
      n/=i;
      cnt++;
      break;
    }
  }
  if(cnt==2 and n==1) result = "Yes";
  else result = "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        int[] a = IntStream.range(0, N).map(i -> Integer.parseInt(sc.next())).toArray();
        int[] b = IntStream.range(0, N).map(i -> Integer.parseInt(sc.next())).toArray();
        int ans = 0;

        for (int j = 0; j < N; j++) {
            int asum = IntStream.rangeClosed(0, j).map(i -> a[i]).sum();
            int bsum = IntStream.range(j, N).map(i -> b[i]).sum();
            ans = Math.max(ans, asum + bsum);
        }

        out.println(ans);

        out.flush();
    }
}

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


def solve(X: int):
    t = 1
    while True:
        if t * (t + 1) // 2 >= X:
            print(t)
            return
        t += 1
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
string s;

int main(){
	io;
	cin>>s;
	if(s=="SUN")cout<<7<<endl;
	else if(s=="MON")cout<<6<<endl;
	else if(s=="TUE")cout<<5<<endl;
	else if(s=="WED")cout<<4<<endl;
	else if(s=="THU")cout<<3<<endl;
	else if(s=="FRI")cout<<2<<endl;
	else cout<<1<<endl;
	return 0;
}

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

int main(){
    int x, y, s;
    while(cin >> x >> y >> s, x && y && s){
        int MAX = -1;
        rep(i, 1, s){
            rep(j, 1, s){
                int a = i * (100 + x) / 100;
                int b = j * (100 + x) / 100;
                if(a + b != s) continue;
                int na = i * (100 + y) / 100;
                int nb = j * (100 + y) / 100;
                MAX = max(MAX, na + nb);
            }
        }
        cout << MAX << endl;
    }
}

Measured memory_bytes: 2960
#include <stdio.h>

void swap(int *x, int *y)
{
    int t;
    
    t = *x;
    *x = *y;
    *y = t;
}

int main(void)
{
    int N, A[100], i, j = 0, n = 0, *min;
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    while (j < N - 1) {
        min = &A[j];
        for (i = j + 1; i < N; i++) {
            if (*min > A[i]) {
                min = &A[i];
            }
        }
        if (*min != A[j]) {
                swap(min, &A[j]);
                n++;
        }
        j++;
    }
    for (i = 0; i < N; i++) {
        printf("%d", A[i]);
        if (i != N - 1) {
            printf(" ");
        } else {
            printf("\n");
        }
    }
    printf("%d\n", n);
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
using namespace std;
int main(void){
    int a=0, N;
    cin>>N;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(N==i*j){
                a++;
            }
        }
    }
    if(a==0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N;cin >> N;
    vi cnt(1001,1);
    for(int i=1;i<=N;i++){
        int v = i;
        for(int j=2;j<=N;j++){
            while(v%j==0){
                cnt[j]++;
                v/=j;
            }
        }
    }
    ll ans = 1;
    for(int i=2;i<=1000;i++){
        ans = (ans * cnt[i]) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int tag[maxn << 2], tree[maxn << 2];
int n, m;
inline void put(int x,int v) {
	tag[x] += v, tree[x] += v;
}
inline void down(int x) {
	put(x << 1, tag[x]);
	put(x << 1 | 1, tag[x]);
	tag[x] = 0;
}
inline void add(int ql,int qr,int v,int cur = 1,int l = 0,int r = m + 1) {
	if(ql <= l && r <= qr) return put(cur, v);
	int mid = l + r >> 1; down(cur);
	if(ql <= mid) add(ql, qr, v, cur << 1, l, mid);
	if(mid < qr) add(ql, qr, v, cur << 1 | 1, mid + 1, r);
	tree[cur] = std::max(tree[cur << 1], tree[cur << 1 | 1]);
}
inline int qry(int ql,int qr,int cur = 1,int l = 0,int r = m + 1) {
	if(ql <= l && r <= qr) return tree[cur];
	int mid = l + r >> 1, ans = -1e9; down(cur);
	if(ql <= mid) ans = std::max(ans, qry(ql, qr, cur << 1, l, mid));
	if(mid < qr) ans = std::max(ans, qry(ql, qr, cur << 1 | 1, mid + 1,r));
	return ans;
}
std::vector<int> v[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	rep(i, 1, n) {
		int l, r;
		cin >> l >> r;
		v[l].push_back(r);
	}
	rep(i, 1, m + 1) add(i, i, i);
	int ans = std::max(n - m, 0);
	rep(i, 0, m) {
		for(int j : v[i]) add(0, j, 1);
		ans = std::max(ans, qry(i + 1, m + 1) - i - m - 1);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 14080
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    int cnt = 0;
    bool ok = false;
    rep(i, n) {
        if (a[i] == b[i])
            ++cnt;
        else
            cnt = 0;
        if (cnt >= 3) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3616
#include"bits/stdc++.h"
using namespace std;
#define ll long long 


int main()
{
    ll n;
    cin>>n;
    ll p, q;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            p=i;
            q=n/i;
        }
    }

    //cout<<p<<" "<<q<<endl;
        cout<<(p-1)+(q-1)<<endl;

   
    return 0;
    
}

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

int N, K;
vector<int> P, Q;

void mergesort(vector<int> &a, int left, int right) {
	if (right - left <= 1) return;
	int mid = (left + right) / 2;
	mergesort(a, left, mid);
	mergesort(a, mid, right);

	vector<pair<int, int> > rs;
	for (int i = mid; i < right; ++i) rs.push_back({ a[i], i - mid });
	sort(rs.begin(), rs.end(), greater<pair<int,int> >());

	vector<int> pl(right - mid);
	int pointer = mid;
	for (auto pa : rs) {
		int val = pa.first;
		int id = pa.second;
		while (pointer > left && a[pointer - 1] >= val + K) --pointer;
		pl[id] = pointer;
	}
	vector<int> res;
	int last = left;
	for (int i = 0; i < pl.size(); ++i) {
		for (int j = last; j < pl[i]; ++j) {
			res.push_back(a[j]);
		}
		last = max(last, pl[i]);
		res.push_back(a[i + mid]);
	}
	for (int i = last; i < mid; ++i) res.push_back(a[i]);
	for (int i = 0; i < res.size(); ++i) a[i + left] = res[i];
}

int main() {
	cin >> N >> K;
	P.resize(N); Q.resize(N);
	for (int i = 0; i < N; ++i) cin >> P[i], --P[i];
	for (int i = 0; i < N; ++i) Q[P[i]] = i;
	mergesort(Q, 0, N);
	vector<int> res(N);
	for (int i = 0; i < N; ++i) res[Q[i]] = i;
	for (int i = 0; i < N; ++i) cout << res[i]+1 << endl;
}


Measured memory_bytes: 10216
import math
H, W, A, B = map(int,input().split())
e = 10**9 + 7
def power(a,b):
    if b == 0:
        return 1
    elif b == 1:
        return a % e
    elif b%2 == 0:
        return power(a,b//2)**2 % e
    else:
        return power(a,b//2)**2*a % e
    
M = [1]
for i in range(1,H+W):
    a = M[i-1]*i%e
    M.append(a)
N= [0]*(H+W)
N[H+W-1] = power(M[H+W-1], e-2)
for i in range(H+W-2, -1, -1):
    N[i] = N[i+1] * (i+1) % e

def c(a,b):
    return M[a]*N[b]*N[a-b]%e

T = 0
for i in range(W-B):
    P = c(H+W-A-i-2,H-A-1)
    Q = c(A+i-1,i)
    T = (T + P*Q)
print(T%e)

Measured memory_bytes: 18992
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1e9 + 7;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N, M;
    cin >> N >> M;
    if(2LL * N >= M) {
        // cが足りないとき
        cout << M / 2LL << endl;
        return 0;
    }
    // sが足りないとき
    // s を作れる
    M -= 2LL * N;
    cout << N + M / 4LL << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    ll Q, H, S, D;
    cin >> Q >> H >> S >> D;
    ll n;
    cin >> n;

    ll ans = 1e18;
    ll half = H;
    chmin(half, Q*2LL);
    ll one = S;
    chmin(one, half*2LL);
    ll two = D;
    chmin(two, one*2LL);

    chmin(ans, one*n);
    chmin(ans, two*(n/2LL)+one*(n%2));

    cout << ans << endl;
}

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

int main()
{
    int n,i,j,len,backet[50][26] = {0},min = 100;
    char s[50][51];

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%s",s[i]);
        len = strlen(s[i]);
        for (j = 0; j < len; j++)
        {
            backet[i][s[i][j] - 'a']++;
        }
    }

    for (i = 0; i < 26; i++)
    {
        min = 100;
        for (j = 0; j < n; j++)
        {
            if(min > backet[j][i])
            {
                min = backet[j][i];
            }
        }
        for (j = 0; j < min; j++)
        {
            printf("%c",'a' +i);
        }
    }
    
}

Measured memory_bytes: 128
import sys
from itertools import combinations_with_replacement

input = sys.stdin.readline


def main():
    N, M, Q = map(int, input().split())
    abcd = [None] * Q
    for i in range(Q):
        abcd[i] = list(map(int, input().split()))
        abcd[i][0] -= 1
        abcd[i][1] -= 1

    ans = 0
    for A in combinations_with_replacement(range(1, M + 1), N):
        score = 0
        for a, b, c, d in abcd:
            if A[b] - A[a] == c:
                score += d
        if score > ans:
            ans = score

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9112
n, x = gets.split.map(&:to_i)

@length_map = {}

def b_length n
  if n == 0
    1
  else
    @length_map[n] ||= ( 3 + (2 * b_length(n - 1)) )
  end
end

def answer n , x
  if n == 0
    if x >= 1
      1
    else
      0
    end
  else
    if x == 1
      0
    elsif (1 + b_length(n-1)) >= x
      answer(n - 1, x - 1)
    elsif (2 + b_length(n-1)) == x
      1 + answer(n - 1, x - 2)
    elsif (2 + (2 * b_length(n-1))) >= x
      1 + answer(n - 1, b_length(n-1)) + answer(n - 1, x - 2 - b_length(n-1))
    else
      1 + (2 * answer(n - 1, b_length(n-1)))
    end
  end
end
puts(answer n, x) 


Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N), c(M), d(M);
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, M) cin >> c[i] >> d[i];
    rep(i, N) {
        int dmin = 1e9, ans = 0;
        rep(j, M) {
            int s = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (s < dmin) {
                dmin = s;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
res = [-1 for _ in range(n)]
for _ in range(m):
  a, b = [int(i) for i in input().split()]
  if res[a-1] >= 0 and res[a-1] != b:
    print(-1)
    exit()
  elif n > 1 and a == 1 and b == 0:
    print(-1)
    exit()
  res[a-1] = b
if res[0] == -1:
  if n > 1:
    res[0] = 1
  else:
    res[0] = 0
for i in range(1,n):
  if res[i] == -1:
    res[i] = 0
print(''.join([str(r) for r in res]))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int a[505][505];
    int H, W;

    vector<string> ans;

    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }
    int x = 0, y = 0;
    int dx = 1;

    while (true) {
        int nx, ny;
        if (x+dx < 0 || W <= x+dx) {
            nx = x;
            ny = y + 1;
            dx *= -1;
        } else {
            nx = x+dx;
            ny = y;
        }

        if ( H <= ny ) {
            break;
        }
        if ( a[y][x] % 2 == 1 ) {
            a[y][x]--;
            a[ny][nx]++;
            ans.push_back( to_string(y+1) + " " + to_string(x+1) + " "
                    + to_string(ny+1) + " " + to_string(nx+1) );
        }
        x = nx; y = ny;
    }

    cout << ans.size() << endl;

    for (auto i: ans) {
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 11892
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int P = 1000 * 1000 * 1000 + 7;

int Sum(int a, int b) {
    return (a + b) % P;
}

int Mult(int a, int b) {
    return (a * (long long) b) % P;
}

int Pow(int a, int n) {
    if (n == 0) {
        return 1;
    }

    int res = Pow(a, n / 2);
    res = Mult(res, res);
    if (n % 2 == 1) {
        res = Mult(res, a);
    }

    return res;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int n, a, b;
    cin >> n >> a >> b;

    if (a > b) {
        swap(a, b);
    }

    vector<vector<int>> d1(n + 1, vector<int>(b));
    vector<vector<int>> d0(n + 1, vector<int>(b));
    vector<int> total1(n + 1);

    d1[0][0] = 1;
    total1[0] = 1;
    for (int i = 1; i <= n; ++i) {
        d1[i][0] = 0;
        for (int j = 1; j < b; ++j) {
            d1[i][j] = Sum(d1[i - 1][j - 1], d0[i - 1][j - 1]);
        }
        
        d0[i][0] = 0;
        for (int j = 1; j < min(a, i + 1); ++j) {
            d0[i][0] = Sum(d0[i][0], total1[i - j]);
        }
        
        if (i >= a) {
            for (int j = a; j < b; ++j) {
                d0[i][j] = Sum(d1[i - a][j - a], d0[i - 1][j - 1]);
            }
        }

        total1[i] = 0;
        for (int j = 0; j < b; ++j) {
            total1[i] = Sum(total1[i], d1[i][j]);
        }
    }

    int res = 0;
    for (int i = 0; i < b; ++i) {
        res = Sum(res, Sum(d0[n][i], d1[n][i]));
    }

    cout << Sum(Pow(2, n), P - res) << "\n";

    return 0;
}


Measured memory_bytes: 199144
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            List<String> input = Arrays.<String>asList(sc.nextLine().split(""));
            // List<String> input =
            // Arrays.<String>asList("@99+1=1@90".split(""));
            System.out.println(decoding(input));
        }
    }

    private static String decoding(List<String> list) {
        StringBuilder sb = new StringBuilder();

        String s = "";
        int roop = 0;
        for (int i = 0; i < list.size(); i++) {
            s = list.get(i);
            if ("@".equals(s)) {
                roop = Integer.parseInt(list.get(i + 1));
                i++;
                for (int j = 0; j < roop; j++) {
                    sb.append(list.get(i + 1));
                }
                i++;
            } else {
                sb.append(s);
            }
        }
        return sb.toString();
    }
}

Measured memory_bytes: 26064
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

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

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll ans = a[0];
	repn(i, n - 1) ans = gcd(ans, a[i]);
	co(ans);

	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	ps := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ps[i])
	}

	p0 := ps[0]
	p1 := 0
	p2 := 0
	cnt1 := 0
	cnt2 := 0
	for i := 1; i < n-1; i++ {
		p1 = ps[i]
		p2 = ps[i+1]

		if p1 < p0 {
			cnt1++
		}

		if p1 < p2 {
			cnt1++
		}

		if cnt1 == 1 {
			cnt2++
		}
			cnt1 = 0

		p0 = ps[i]
	}

	fmt.Print(cnt2)
}


Measured memory_bytes: 512