akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int N; 
long long a[200200]; 

long long kanashisa(long long b) {
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        res += abs(a[i] - (b + i + 1));
    }
    return res;
}
long long search(long long start, long long end) {
    long long mid = (start + end) / 2;
    if(kanashisa(mid) <= kanashisa(mid-1) && kanashisa(mid) <= kanashisa(mid+1)) {
        return mid;
    } else if (kanashisa(mid-1) < kanashisa(mid))  {
        return search(start, mid);
    } else {
        return search(mid, end);
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    long long b = search(-1000000000, 1000000000);
    cout << kanashisa(b) << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <complex>
using namespace std;
typedef complex<int> point;

string ccw(point p0,point p1,point p2){
  point temp;
  p1-=p0;
  p2-=p0;
  temp=p1;
  p1*=conj(temp);
  p2*=conj(temp);
  if(abs(temp)==0) return "ON_SEGMENT";
  p1/=abs(temp);
  if(p2.imag()>0) return "COUNTER_CLOCKWISE";
  if(p2.imag()<0) return "CLOCKWISE";
  p2/=abs(temp);
  if(p2.real()<0) return "ONLINE_BACK";
  if(p1.real()<p2.real()) return "ONLINE_FRONT";
  return "ON_SEGMENT";
}

int main(){
  int p0x,p0y,p1x,p1y,q,p2x,p2y;
  cin>>p0x>>p0y>>p1x>>p1y;
  point A = point(p0x,p0y);
  point B = point(p1x,p1y);
  cin>>q;
  while(q--){
    cin>>p2x>>p2y;
    cout << ccw(  A, B , point(p2x,p2y) ) <<endl;    
  }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main (){

  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  
  cout<<((s<t) ? "Yes" : "No")<<endl;


  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
using namespace std;
struct Team{int I,U,A,P;};
bool operator<(Team a,Team b){
  return a.A!=b.A?a.A>b.A:(a.P!=b.P?a.P<b.P:a.I<b.I);
}
int main()
{
  int n,I,U,A,P;
  int num;
  while(cin>>n,n){
    map<int,int>dup;
    multiset<Team>record;
    multiset<Team>::iterator it;
    for(int i=0;i<n;i++){
      cin>>I>>U>>A>>P;
      Team t={I,U,A,P};
      record.insert(t);
    }
    num=0;
    for(it=record.begin();it!=record.end();it++){
      if(num<10&&dup[it->U]<3){
	num++;
	dup[it->U]++;
	cout<<it->I<<endl;
      }else if(num<20&&dup[it->U]<2){
	num++;
	dup[it->U]++;
	cout<<it->I<<endl;
      }else if(num<26&&dup.count(it->U)==0){
	num++;
	dup[it->U]++;
	cout<<it->I<<endl;
      }
    }
  }
}

Measured memory_bytes: 0
def main():
    n = int(input())
    data = input().split()
    
    for i in range(n):
        data[i] = int(data[i])
        if data[i] == 0:
            print(0)
            return
        
    res = 1
    for i in range(n):
        res *= data[i]
        if res > 10**18:
            print(-1)
            return
    print(res)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 19376
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 6 + 10];
	int K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[0] = 0;
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
		*di++ = '0' + X % 10;
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		
		int[] nums = {a,b,c,d,e};
		
		for(int i=0; i<nums.length; i++) {
			for(int j=i+1; j<nums.length; j++) {
				if(Math.abs(nums[i]-nums[j])>k) {
					System.out.println(":(");
					return;
				}else {
					continue;
				}
			}
		}
		System.out.println("Yay!");
		
    }
}


Measured memory_bytes: 21716
N = int(input())
word = input()
word_list=[]
word_num = int(input())

for i in range(len(word)):
    word_list.append(word[i])
    if str(word[i]) != str(word[word_num -1]):
         word_list[i] = '*'

print("".join(list(map(str,word_list))))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

   int n,m; cin>>n>>m;

   vll v(n+1);
   for(int i=1;i<=n;i++) cin>>v[i];
   vector<ll>vv[n+3];

   for(int i=0;i<m;i++) {
    ll a,b; cin>>a>>b;
    vv[a].pb(b);
    vv[b].pb(a);
   }
   ll res=0;
   for(int i=1;i<=n;i++)    {
    bool fl=1;

    for(ll u: vv[i])   {
        if(v[i]<=v[u]) fl=0;
    }
    if(fl) res++;
   }
   cout<<res<<endl;
   End;
}


Measured memory_bytes: 9796
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));
    String o = br.readLine();
    char[] arr1 = o.toCharArray();
    System.out.println("");
    String e = br.readLine();
    char[] arr2 = e.toCharArray();
    
    int size = arr1.length + arr2.length; 
    char[] arr3 = new char[size];

    int j=0;
    for(int i=0; i<size; i++){
      if(i%2 == 0){
      arr3[i] = arr1[j];
      }else if(i%2==1){
        arr3[i] = arr2[j];
        j++;
      }  
    }
    String res = new String(arr3);
    System.out.println(res);
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

int main(){
    int h,w;
    cin >> h >> w;
    int a[h][w];
    int sum = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
            sum += a[i][j];
        }
    }
    vector< vector<int> > v;
    for(int i=0;i<h;i++){
        for(int j=0;j<w-1;j++){
            if(a[i][j]%2!=0){
                vector<int> curr;
                a[i][j]--;
                a[i][j+1]++;
                curr.pb(i);
                curr.pb(j);
                curr.pb(i);
                curr.pb(j+1);
                v.pb(curr);
            }
        }
    }
    for(int i=0;i<h-1;i++){
        if(a[i][w-1]%2!=0){
            a[i][w-1]--;
            a[i+1][w-1]++;
            vector<int> curr;
            curr.pb(i);
            curr.pb(w-1);
            curr.pb(i+1);
            curr.pb(w-1);
            v.pb(curr);
        }
    }
    cout << v.size() << "\n";
    for(int i=0;i<v.size();i++)
        cout << v[i][0]+1 << " " << v[i][1]+1 << " " << v[i][2]+1 << " " << v[i][3]+1 << "\n";
}

Measured memory_bytes: 10032
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> P;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, pre = -1, ans = 0; cin >> N;
    for(int i=0;i<N;i++){
        int h; cin >> h;
        if(h>=pre) ans++;
        pre = max(pre, h);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		StringBuilder ans = new StringBuilder();

		while(0 < n) {
			n--;
			ans.append((char) (n % 26 + 97));
			n /= 26;
		}

		System.out.println(ans.reverse());
		sc.close();
	}

}

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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;


int main() {
    //SYNC
    int n, ans = 0;
    vector<int> gems, cost;
    cin >> n;
    gems.assign(n, 0);
    cost.assign(n, 0);
    for (auto &k : gems) {
        cin >> k;
    }
    for (auto &j : cost) {
        cin >> j;
    }
    for (int i = 0; i < n; ++i) {
        if (gems[i] > cost[i]) {
            ans += gems[i] - cost[i];
        }
    }
    //cout << gems[0] << ' ' << cost[0] << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {

	std::string s;
	int a;

	std::cin >> s >> a;

	for (size_t i = 0; i < s.length(); i++) {
		if (i % a == 0) {
			std::cout << s[i];
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a=1,b=0,c=0;
  char mo,mo2;
  int tmp;
  int i;
  while(scanf("%c,%c",&mo,&mo2)!=EOF){
    if(mo=='A' && mo2=='B'|| mo=='B' && mo2=='A'){
      tmp=a;
      a=b;
      b=tmp;
    }
    else if(mo=='A' && mo2=='C'|| mo=='C' && mo2=='A'){
      tmp=a;
      a=c;
      c=tmp;
    }
    else if(mo=='B' && mo2=='C'|| mo=='C' && mo2=='B'){
      tmp=b;
      b=c;
      c=tmp;
    }
  }
  if(a==1) printf("A\n");
  else if(b==1) printf("B\n");
  else if(c==1) printf("C\n");
  return 0;
}
    

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




int A, B;
//-----------------------------------------------------------------
string sol() {
	if (A == B) return "Draw";
	if (A == 1) return "Alice";
	if (B == 1) return "Bob";
	if (A < B)
		return "Bob";
	return "Alice";
}
//-----------------------------------------------------------------
int main() {
	cin >> A >> B;
	cout << sol() << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left
N = int(input())
x = [int(i) for i in input().split()]
sorted_x = sorted(x)

mid = N // 2
for i in range(N) :
    if bisect_left(sorted_x, x[i]) < mid :
        print(sorted_x[N//2])
    else :
        print(sorted_x[N//2-1])

Measured memory_bytes: 95700
#!/usr/bin/env python3
import math


def main():
    N = int(input())
    digit = math.floor(math.log10(N)) + 1
    if digit == 1:
        print(N)
    elif digit == 2:
        print(9)
    elif digit == 3:
        print(9 + N - 100 + 1)
    elif digit == 4:
        print(909)
    elif digit == 5:
        print(909 + N - 10000 + 1)
    elif digit == 6:
        print(90909)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef long long ll;
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mod=1000000007;

long long max(long long A,long long B){
    return A>B?A:B;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

void swap(long long *A,long long *B){
    long long T;
    T=*A;
    *A=*B;
    *B=T;
}
int asort(const void *A,const void *B){return *(ll*)A>*(ll*)B?1:0;}
int main(void){
    ll n[4];
    scanf("%lld%lld%lld%lld",&n[0],&n[1],&n[2],&n[3]);
    qsort (n,4,sizeof(ll),asort); //昇順ソート
    if (n[0]==1 && n[1]==4 && n[2]==7 && n[3]==9){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
object Main {
  def main(args: Array[String]) {
    val input = io.Source.stdin.getLines().mkString("\n")
    println(kagamiMochi(input).trim())
  }

  def kagamiMochi(input: String) :String = {
    //奇数と偶数のindex
    val ziparray = input.split("\n")(1).split(" ").map(_.toInt).sorted.reverse.zipWithIndex.partition(n => n._2 % 2  ==0)
    (ziparray._1.unzip._1.sum - ziparray._2.unzip._1.sum).toString
  }

}

Measured memory_bytes: 25392
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.bitmanip;  // BitArray

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], k = rd[1];
  auto a = readln.split.to!(int[]);

  auto dp1 = new BitArray[](n+1), dp2 = new BitArray[](n+1);
  dp1[0].length = dp2[0].length = k;
  dp1[0][0] = dp2[0][0] = true;
  foreach (i; 0..n) {
    dp1[i+1] = dp1[i].dup;
    dp1[i+1].lshift(a[i]);
    dp1[i+1] |= dp1[i];

    dp2[i+1] = dp2[i].dup;
    dp2[i+1].lshift(a[$-i-1]);
    dp2[i+1] |= dp2[i];
  }

  auto check(int ai, BitArray dpi1, BitArray dpi2)
  {
    if (ai >= k) return true;
    auto mi = k-ai, cs = new int[](k);

    cs[0] = dpi2[0];
    foreach (j; 1..k) cs[j] = cs[j-1] + dpi2[j];

    foreach (j; 0..k) {
      auto mj = max(0, mi-j), c = cs[k-j-1] - cs[mj] + dpi2[mj];
      if (dpi1[j] & (c > 0)) return true;
    }

    return false;
  }

  auto ans = 0;
  foreach (i; 0..n) {
    auto dpi1 = dp1[i], dpi2 = dp2[n-i-1];
    ans += check(a[i], dpi1, dpi2);
  }

  writeln(n-ans);
}

auto lshift(ref BitArray ba, size_t n)
{
  if (n % 64 == 0) {
    if (n > 0) {
      ba <<= 1;
      ba <<= n-1;
    }
  } else {
    ba <<= n;
  }
}


Measured memory_bytes: 16892
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
N=int(input())
S = [int(input()) for _ in range(N)]

tmp = sum(S)

if tmp%10 != 0:
    print(tmp)
else:
    S.sort()
    for i in range(N):
        if S[i]%10 != 0:
            print(tmp-S[i])
            sys.exit()
    print(0)

Measured memory_bytes: 77288
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;

 int main()
 {
   string s;
   int total=0;
   while(cin>>s)
   {
     //if(s=="0") break;
     int num=0;
     for(int i=0;i<s.length();i++)
     {
       while((i<s.length())&&isdigit(s[i]))
       {
         num=10*num+(s[i]-'0');
         i++;                   
       }        
       total+=num;
       num=0;
     }             
   }
   cout<<total<<endl;
   //while(1);
   return 0;
 }

Measured memory_bytes: 2984
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var a = s[0].ToCharArray();
            var b = s[1].ToCharArray();
            var c = s[2].ToCharArray();

            if(a.Last() == b.First() && b.Last() == c.First()){
                Console.WriteLine("YES");
            }else{
                Console.WriteLine("NO");
            }
        }
    }
}


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

struct susi {
	int t;
	long long d;
	susi(int t, long long d) {
		this->t = t;
		this->d = d;
	}
	susi(const susi &o) {
		this->t = o.t;
		this->d = o.d;
	}
};

int n, k;
set<int> types;
vector<susi> primes;
map<int, int> typeCounterMap;

int main(void) {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int t; long long d;
		cin >> t >> d;
		primes.push_back(susi(t, d));
	}
	sort(primes.begin(), primes.end(), [&](const susi &s1, const susi &s2) {return s1.d > s2.d;});

	long long primeCount = 0;
	for (int i = 0; i < k; i++) {
		susi &s = primes.at(i);
		primeCount += s.d;
		types.insert(s.t);
		typeCounterMap[s.t]++;
	}
	unsigned long long total = 0;
	total = max(total, primeCount + types.size() * types.size());

	for (int i = k, j = k - 1; i < n && j >= 0; i++, j--) {
		while (true) {
			susi &s = primes.at(i);
			auto it = typeCounterMap.find(s.t);
			if (it == typeCounterMap.end()) {
				primeCount += s.d;
				typeCounterMap[s.t] = 1;
				types.insert(s.t);
				break;
			}
			i++;
			if (i == n) {
				break;
			}
		}
		if (i == n) {
			break;
		}

		while (true) {
			susi &s2 = primes.at(j);
			auto it = typeCounterMap.find(s2.t);
			if (it->second > 1) {
				it->second--;
				primeCount -= s2.d;
				break;
			}
			j--;
			if (j < 0) {
				break;
			}
		}
		if (j < 0) {
			break;
		}
		total = max(total, primeCount + types.size() * types.size());
	}
	cout << total << endl;
}


Measured memory_bytes: 7792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   vector< pair<int,int> > v;
   int n;
   cin >> n;
   for(int i = 0; i < n; i++){
	  int x, y;
	  cin >> x >> y;
	  v.push_back(make_pair(x, y));   
	}
  sort(all(v));
  for(auto it : v) cout << it.f << " " << it.s << endl;	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 4932
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<=(b);++(i))
#define rep(i, n)  FOR(i,0,n-1)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define int long long
#define double long double
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<ll, ll> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;


signed main(){

	int a=0,b=1000;
	rep(i,3)
	{
		int x;cin>>x;
		a=max(a,x),b=min(b,x);
	}

	cout << a-b << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define re register
#define il inline
#define fp(i,a,b) for(re int i=a;i<=b;++i)
#define fq(i,a,b) for(re int i=a;i>=b;--i)
using namespace std;
const int N=2010,mod=1e9+7;
int n,k,f[N][N],jc[N*N],inv[N*N],gu;
il int gi()
{
  re int x=0,t=1;
  re char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
  if(ch=='-') t=-1,ch=getchar();
  while(ch>='0'&&ch<='9') x=x*10+ch-48,ch=getchar();
  return x*t;
}
il ll ksm(re ll S,re ll n)
{
	re ll T=S;S=1;
  while(n)
	{
		if(n&1) S=S*T%mod;
		T=T*T%mod;
		n>>=1;
	}
  return S;
}
il ll C(re int x,re int y)
{
	if(x<0||y<0||x<y) return 0;
	return 1ll*jc[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
  n=gi();k=gi();gu=N*N;
	if(k==1) {puts("1");return 0;}
	jc[0]=inv[0]=1;
	fp(i,1,gu) jc[i]=1ll*jc[i-1]*i%mod;inv[gu]=ksm(jc[gu],mod-2);
	fq(i,gu-1,1) inv[i]=1ll*inv[i+1]*(i+1)%mod;
  f[0][0]=1;
	fp(i,1,n)
		fp(j,0,i)
	{
		(f[i][j]+=f[i-1][j])%=mod;
		if(j) (f[i][j]+=C(n*k-(j-1)*(k-1)-i-1,k-2)*f[i][j-1]%mod*(n-j+1)%mod)%=mod;
	}
  printf("%d\n",f[n][n]);
  return 0;
}


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

int main(void){
    int x,y;
    while(true){
       cin >> x;
       cin >> y;     
        if(x==0 && y==0){
            break;
        }
        if(x<y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
}


Measured memory_bytes: 3016
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> ais;
    for (ll i = 0; i < N; i++) {
        ll ai;
        cin >> ai;
        ais.push_back(ai);
    }
    ais.insert(ais.begin(), W);
    vector<ll> dp_x(ais.size(), numeric_limits<ll>::min());
    vector<ll> dp_y(ais.size(), numeric_limits<ll>::max());
    for (ll i = ais.size() - 1; i >= 1; i--) {
        for (ll j = i; j < ais.size(); j++) {
            if (j == ais.size() - 1) {
                dp_x[i] = max(dp_x[i], abs(ais[i-1] - ais[j]));
                dp_y[i] = min(dp_y[i], abs(ais[i-1] - ais[j]));
            } else {
                dp_x[i] = max(dp_x[i], dp_y[j+1]);
                dp_y[i] = min(dp_y[i], dp_x[j+1]);
            }
        }
    }
    cout << dp_x[1] << endl;
}



Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H, A = getlist()
	if H % A == 0:
		print(int(H // A))
	else:
		print(int(H // A) + 1)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

const int INF = 20000000;

void dfs(int v, int p, vector<int> &dist, vector<int> G[]) {
  if (dist[v] != INF) return;
  if (p != -1) dist[v] = dist[p] + 1;
  else dist[v] = 0;
  for (auto&u: G[v]) {
    if (u == p) continue;
    dfs(u, v, dist, G);
  }
}

int main() {
  int n;in(n);
  vector<int> G[n];
  loop(i,0,n-1) {
    int a, b; in(a),in(b);
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int s = 0, t = n-1;
  vector<int> fromS(n, INF), fromT(n, INF);
  dfs(s, -1, fromS, G);
  dfs(t, -1, fromT, G);
  
  int cnt = 0;
  loop(i,0,n) {
    // TよりもSに近いところはFが取れる.
    cnt += fromS[i] <= fromT[i];
  }
  if (cnt >= (n + 2) / 2) print("Fennec");
  else print("Snuke");
  return 0;
  return 0;
}


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

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    vector<int> x1(2);
    vector<int> x2(2);
    cin >> x1[0] >> x1[1] >> x2[0] >> x2[1];
    int x_sa = x1[0] - x2[0];
    int y_sa = x2[1] - x1[1];

    vector<int> x3(2);
    x3[0] = x2[0] - y_sa;
    x3[1] = x2[1] - x_sa;

    vector<int> x4(2);
    x4[0] = x3[0] + x_sa;
    x4[1] = x3[1] - y_sa;

    cout << x3[0] << " " << x3[1] << " " << x4[0] << " " << x4[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, K;
    string s;
    cin >> N >> K;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        if (s[i] == 'L' && i > 0)
        {
            if (s[i] == s[i - 1]) ++ans;
        }
        else if (s[i] == 'R' && i < N - 1)
        {
            if (s[i] == s[i + 1]) ++ans;
        }
    }

    cout << MIN(N - 1, ans + 2 * K) << "\n";
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>


using namespace std;
typedef long long ll;

int A,B,C = 0;

int main(){

    vector<int > ABC;

    for(int i = 0; i < 3; i++){
        int t = 0;
        cin >> t;
        ABC.push_back(t);
    }

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

    int total =( ABC[2] * 10 + ABC[1] ) + ABC[0];

    cout << total << endl;
    
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, k, x=1;
	scanf("%d %d", &n, &k);
	while(n--)  x += x<k? x:k;
	printf("%d\n", x);
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int day,works,i,time;
  int sum=0;
  
  scanf("%d",&day);
  scanf("%d",&works);
  
  for(i=1;i<=works;i++)
  {
    scanf("%d",&time);
    //printf("%d\n",time);
    sum+=time;
  }
  //printf("%d\n",sum);
  if(day-sum>=0)
    printf("%d",day-sum);
  else
    printf("-1");
  
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1, 0);
  for(int i = 1; i<n+1; i++){ cin >> a.at(i);}
  ll money = abs(a.at(n));
  for(int i = 1; i< n+1; i++){
    money += abs(a.at(i)-a.at(i-1));
  }
  vector<ll> b(n+1, 0);
  for(int i = 1; i<n+1; i++){
    if(i!=n){
    b.at(i) = abs(a.at(i+1)-a.at(i)) + abs(a.at(i)-a.at(i-1)) - abs(a.at(i+1)-a.at(i-1));
  }
  b.at(n)=abs(a.at(0)-a.at(n))+abs(a.at(n)-a.at(n-1))-abs(a.at(n-1));
  }
  for(int i = 1; i<n+1; i++){
    cout << money- b.at(i) << endl;
  }
  }


Measured memory_bytes: 4584
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[250][250];
int main(){
    int n,m,r;
    cin>>n>>m>>r;
    vector<int> root(r);
    for(int i=0;i<r;i++){
        cin>>root[i];
        root[i]--;
    }
    sort(all(root));
       for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(i!=j)dp[i][j]=inf;
    for(int i=0;i<m;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        dp[a][b]=c;
        dp[b][a]=c;
    }
     int V=n;
     for(int k=0;k<V;k++)
                for(int i=0;i<V;i++)
                   for(int j=0;j<V;j++)
                   dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    ll ans=inf;
    do{
        ll res=0;
        for(int i=0;i<r-1;i++){
       res+=dp[root[i]][root[i+1]];
      }
          ans=min(res,ans);
    }while(next_permutation(all(root)));
   
   cout<<ans<<endl;
}  

Measured memory_bytes: 768
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

ll n;
ll a[MAXN];

ll solve(deque<int> & d, int l, int r, int dir) {
	if (l > r) {
		vector<int> v;
		while (!d.empty()) {
			v.push_back(d.front());
			d.pop_front();
		}
		ll ret = 0;
		for (int i = 0; (int)i < v.size() - 1; i++) {
			ret += llabs(v[i] - v[i + 1]);
		}
		return ret;
	}
	if (dir == 1) {
		d.push_front(a[l]);
		if (l < r) {
			d.push_back(a[l + 1]);
			return solve(d, l + 2, r, -dir);
		} else {
			return solve(d, l + 1, r, -dir);
		}
	} else {
		d.push_front(a[r]);
		if (l < r) {
			d.push_back(a[r - 1]);
			return solve(d, l, r - 2, -dir);
		} else {
			return solve(d, l, r - 1, -dir);
		}
	}
}

int main() {
	cout << fixed << setprecision(12);	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	deque<int> d1, d2;
	d1.push_front(a[n - 1]);
	ll s1 = solve(d1, 0, n - 2, 1);
	d2.push_front(a[0]);
	ll s2 = solve(d2, 1, n - 1, -1);
	cout << max(s1, s2) << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,M,C,score,ans;
  vi B;
  cin >> N>>M>>C;
  vector<vector<int>> A(N);
  REP(k,M){
    int x;
    cin >>x;
    B.push_back(x);
	}
  REP(i,N){
    REP(j,M){
      int x;
      cin >>x;
      A[i].push_back(x);
    }
	}
  ans = 0;
  REP(i,N){
    score=0;
    REP(j,M){
      score = score+A[i][j]*B[j];
    }
    if(score+C>0){
      ans=ans+1;
    }
  }
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
# define MOD 1000000000+7
# define INF 1000000000
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int main() {

	int n = 0, m = 0,a,b;
	int ans = 0,r = 0;
	vector<int> v;
	bool list[100][100] = {false};
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		list[a - 1][b - 1] = true;
		list[b - 1][a - 1] = true;
	}
	rep(i, n) {
		v.push_back(i);
	}


	do {

		for(int i = 0; i < n - 1; i++){

			if (list[v[i]][v[i + 1]] == true || list[v[i + 1]][v[i]] == true) {
				r++;
			}
		}

		if (r == n - 1 && v[0] == 0) ans++;

		r = 0;

	} while (next_permutation(v.begin(), v.end()));
	
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
x, y = input().split()
x = int(x)
y = int(y)

def check(x, y):
    # 動物の可能性を考える
    for i in range(0, x+1):
        # 2本足,4本足の動物の数
        leg2_animal = i
        leg4_animal = x - leg2_animal
        
        # 全体の足の数を数えてみる
        sum_legs = leg2_animal * 2 + leg4_animal * 4

        if sum_legs == y:
            print("Yes")
            return

    print("No")

check(x,y)

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

int main(){
    string n;
    cin >> n;

    for(int i = 0; i < 3; ++i) {
        if(n.at(i) == '1') {
            n.at(i) = '9';
        } else {
            n.at(i) = '1';
        }
    }

    cout << n << endl;
}

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    K, X = map(int, readline().split())
    if 500 * K >= X:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>

using namespace std;

#define ALL(x) begin(x), end(x)


int main() {
  int W, H, N;
  cin >> W >> H >> N;

  int xmin{0},xmax{W},ymin{0},ymax{H};
  int x,y,a;
  for (int i = 0; i < N; i++) {
    cin >> x >> y >> a;
    switch(a) {
      case 1:
        xmin = max(xmin,x);
        break;
      case 2:
        xmax = min(xmax,x);
        break;
      case 3:
        ymin = max(ymin,y);
        break;
      case 4:
        ymax = min(ymax,y);
        break;
    }
  }

  cout << max(0,ymax-ymin)*max(0,xmax-xmin) << endl;

  return 0;
}


Measured memory_bytes: 256
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=;

int32_t main()
{
    
	fast
	ll n;
	cin>>n;
	ll a[n+1];
	map<ll,ll> m1,m2;
	// set<ll> m2;
	for(ll i=1;i<=n;i++){
	cin>>a[i];
	m1[a[i]-i]++;
	m2[a[i]+i]++;
	// m2.insert(a[i]+i);
	}
	
	ll ans=0;
	for(auto i:m1){
		ll x=i.y;
		// ans+=x*x;
		
		ans+=x*m2[-i.x];
		
	}
	cout<<ans;
	

	



    

	return 0;
    
}

Measured memory_bytes: 39488
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

using Graf_char=vector<vector<char>>;
using Graf_int=vector<vector<int>>;
#define MAX 10000000

int main()
{
    int n,m;
    cin >> n >> m;
    priority_queue<ll> q;
    ll a;
    rep(i,n){
        cin >> a;
        q.push(a);
    }
    rep(i,m){
        ll b=q.top();
        q.pop();
        b/=2;
        q.push(b);
    }
    ll ans=0;
    rep(i,n){
        ans+=q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include<stdio.h>
#include<math.h>
#define MAX 500000
#define s 1000000000
void merge(int*,int, int, int);
void mergeSort(int*,int ,int); 
int count;

int main(){
  int i,j;
  int n,S[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);

  for(j=0;j<n;j++){
     printf("%d",S[j]);
     if(j!=n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
  
}  

void merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k;
  int L[MAX],R[MAX];
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }

  for(i=0;i<=n2-1;i++){
    R[i]=A[mid+i];
  }
  
  L[n1]=s;
  R[n2]=s;
  i=0;
  j=0;

  for(k=left;k<=right-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    count++;  
    }else{
      A[k]=R[j];
      j=j+1;
      count++;
    }
  }
}

void mergeSort(int *A,int left,int right){
  int mid;  
  if(left+1<right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

  



Measured memory_bytes: 5696
#include<stdio.h>
#define N 250
typedef struct{
  int key;
}node;
int main(){
  int n,i;
  node H[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&H[i].key);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,H[i].key);
    if(i!=1) printf("parent key = %d, ",H[i/2].key);
    if(n>=(2*i)) printf("left key = %d, ",H[2*i].key);
    if(n>=(2*i+1)) printf("right key = %d, ",H[2*i+1].key);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
from itertools import groupby

def fast_prime_factorization_many(lst):
    # 素因数分解（ロー法、複数）
    from subprocess import Popen, PIPE
    res = Popen(["factor"] + list(map(str, lst)), stdout=PIPE).communicate()[0].split(b"\n")[:-1]
    return [list(map(int, r.split()[1:])) for r in res]

def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9+7
    max_factor = [0] * (1010101)
    lcm = 1
    Factors = fast_prime_factorization_many(A)
    for factors in Factors:
        for prime, group in groupby(factors):
            n = len(list(group))
            n_old = max_factor[prime]
            if n_old < n:
                for i in range(n - n_old):
                    lcm = lcm * prime % mod
                max_factor[prime] = n
    ans = 0
    for a in A:
        ans += pow(a, mod-2, mod)
    ans = ans * lcm % mod
    print(ans)

main()


Measured memory_bytes: 20688
a, b, k = map(int, input().split())
if a + k > b:
  a_k = b
else:
  a_k = a + k

if b - k < a:
  b_k = a
else:
  b_k = b - k
  
if a == b:
  a_k = a + 1
  b_k = b + 1

result = list(set([i for i in range(a, a_k)] + [i for i in range(b_k + 1, b + 1)]))
result.sort()
for n in result:
  print(n)

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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    int N,A[110]={},r[10]={};
    cin>>N;

    for(int i=1;i<=N;i++){
        cin>>A[i];

        if(A[i]>=3200){
            r[8]++;
        }else{
            r[(A[i]/400)]++;
        }
    }

    int ans=0;
    for(int i=0;i<8;i++){
        if(r[i]>0)ans++;
    }

    //min
    cout<<max(1,ans)<<" ";
    //max
    cout<<ans+r[8]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
string s, t; cin >> s >> t;
int ans = 0;
 if(s[0] == t[0]) ans++;
if(s[1] == t[1]) ans++;
 if(s[2] == t[2]) ans++;
 cout << ans << endl;
return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main() {
    ll n, i, j, a, b, c, d, ans=0;
    cin >> n;
    
    vector<p> red ,blu;
    
    for(i=0; i<n; i++) {
        cin >> a >> b;
        red.push_back(make_pair(b, a));
    }
    for(i=0; i<n; i++) {
        cin >> c >> d;
        blu.push_back(make_pair(c, d));
    }
    
    sort(red.begin(), red.end());
    sort(blu.begin(), blu.end());
    
    for(j=0; j<n; j++) {
        for(i=n-1; i>=0; i--) {
            if(red[i].first!=INF && blu[j].first!=INF && red[i].second<blu[j].first && red[i].first<blu[j].second) {
                ans++;
                red[i].first=INF;
                blu[j].first=INF;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256