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

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

using namespace std;
typedef long long int ll;
typedef vector<ll> VL;

template <class I, class BiOp> class SegmentTree {
  int n;
  std::vector<I> dat;
  BiOp op;
  I e;

public:
  typedef int size_type;
  typedef I value_type;
  SegmentTree(int n_, BiOp op, I e) : op(op), e(e) {
    n = 1;
    while (n < n_)
      n *= 2; // n is a power of 2
    dat.resize(2 * n);
    for (int i = 0; i < 2 * n - 1; i++) {
      dat[i] = e;
    }
  }
  /* ary[k] <- v */
  void update(int k, I v) {
    k += n - 1;
    dat[k] = v;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }
  /* http://proc-cpuinfo.fixstars.com/2017/07/optimize-segment-tree/
   * [a, b)
   */
  I query(int a, int b) const {
    I left = e;
    I right = e;
    a += n - 1;
    b += n - 1;
    while (a < b) {
      if ((a & 1) == 0) {
        left = op(left, dat[a]);
      }
      if ((b & 1) == 0) {
        right = op(dat[b - 1], right);
      }
      a = a / 2;
      b = (b - 1) / 2;
    }
    return op(left, right);
  }
  I operator[](int idx) const {
    return dat[idx + n - 1];
  }
};


const int N = 200100;
const ll inf = 1e16;

struct min_fun {
  ll operator()(ll x, ll y) const {
    return min(x, y);
  }
};

int main(void){
  int n;
  ll e, t;
  cin >> n >> e >> t;
  VL x(n);
  SegmentTree<ll, min_fun> raw(n + 1, min_fun(), inf); // dp[i]
  SegmentTree<ll, min_fun> boiled(n + 1, min_fun(), inf); // dp[i] - 2 * x[i]
  REP(i, 0, n) {
    cin >> x[i];
  }
  raw.update(0, 0);
  boiled.update(0, -2 * x[0]);
  REP(i, 0, n) {
    // Compute the range of j s.t. t <= 2 * (x[i] - x[j]) (0 <= j <= i)
    int j_boundary =
      upper_bound(x.begin(), x.begin() + i + 1, x[i] - (t+1)/2) - x.begin();
    ll ret = inf;
    ret = min(ret, boiled.query(0, j_boundary) + 2 * x[i]);
    ret = min(ret, raw.query(j_boundary, i + 1) + t);
    raw.update(i + 1, ret);
    if (i < n - 1) {
      boiled.update(i + 1, ret - 2 * x[i + 1]);
    }
  }
  cout << raw[n] + e << endl; 
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>

using namespace std;

int main(void) {
    int H,W;
    int h,w;
    cin >> H;
    cin >> W;
    cin >> h;
    cin >> w;

    int sum = H * W;
    int diff = (H * w) + (W * h - w * h);
    int ans = sum - diff;
    cout << ans << endl;  
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N; cin >> N;
	vector<pair<int, int>>vec(N);
	for (int i = 0;i < N;i++) {
		int A; cin >> A;
		vec[i] = make_pair(A, i);
	}
	sort(vec.begin(), vec.end());

	for (int i = 0;i < N;i++) {
		if (i != vec[N-1].second) {
			cout << vec[N - 1].first << endl;
		} else cout << vec[N - 2].first << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <ctype.h>
using namespace std;


int main ()
{

 int n,k;
 string s;
 
  cin >> n >> k >> s;
  
  s[k-1]= tolower(s[k-1]);

  cout << s << endl;

	return 0;
}











Measured memory_bytes: 3064
N,X=map(int,input().split())
m=[int(input()) for _ in range(N)]
m.sort()
cnt=0
flg=1
flg2=1
X-=sum(m)
cnt+=len(m)
while flg2==1:
    if X>=min(m):
        X-=min(m)
        cnt+=1
    else:
        flg2=0
    
print(cnt)
        

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {

int H, W;
cin >> H >> W;
int C[10][10];
REP(i, 10)REP(j, 10) cin >> C[i][j];

REP(k, 10)REP(i, 10)REP(j, 10){
    C[i][j] = min(C[i][j] , C[i][k] + C[k][j]);
}

int A;
int res = 0;
REP(i, H)REP(j, W)
{
    cin >> A;
    if(A >= 0) res += C[A][1]; 
}
cout << res << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
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 ans = 0;
		
		if((A>=6)&(A<=12)){
			ans = B / 2;
		}else if(A>=13){
			ans = B;
		}

		System.out.println(ans);

   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;

int main(){
	int a, z, i;
	string s;
	cin>>s;
	for(i=0; i<s.length(); i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	for(i=s.length()-1; i>0; i--){
		if(s[i]=='Z'){
			z=i;
			break;
		}
	}
	cout<<z-a+1<<endl;
	return 0;
}

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

using namespace std;

int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  }
  else if (R < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
N, K, Q = map(int,input().split())
A = [0 for i in range(N)]
for i in range(Q):
    a = int(input())
    A[a-1] += 1
for i in range(N):
    if(K - Q + A[i] > 0):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4684
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long int ll;
const ll cs=1000000000;
//15
bool z[1000]={};

int main()
{
 int N,Z,W,a[2002];
 int x[2002]={},y[2002]={}; //x,yにr枚取られた状態で回ってきた時のスコア
 scanf("%d %d %d",&N,&Z,&W);
 a[0]=W;
 for(int i=1;i<=N;i++)
 {
	scanf("%d",&a[i]);
 }
 x[N-1]=y[N-1]=abs(a[N-1]-a[N]);
 for(int i=N-1;i>=0;i--)
 {
	//i枚とられた状態でxに回る→yはa[i]を持っている
	//ここでxが取りうるスコアは全部取るa[i]-a[N]と「j枚とられた状態でyに回る」=y[j](j>i) これの中で一番大きいものがx[i]
	int bs=abs(a[i]-a[N]);
	for(int j=i+1;j<N;j++)
	{
		bs=max(bs,y[j]);
	}
	x[i]=bs;
	
	//i枚とられた状態でyに回る→xはa[i]を持っている
	//ここでyが取りうるスコアは全部取るa[i]-a[N]と「j枚とられた状態でyに回る」=x[j](j>i) これの中で一番小さいものがy[i]
	bs=abs(a[i]-a[N]);
	for(int j=i+1;j<N;j++)
	{
		bs=min(bs,x[j]);
	}
	y[i]=bs;
 }
 printf("%d\n",x[0]);
}

Measured memory_bytes: 3804
#include<stdio.h>
int main(){
    int n,p,ans=0,max=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&p);
        ans+=p;
        if(max<p) max=p;
    }
    ans-=(max/2);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if(map.containsKey(a)) {
        map.put(a, map.get(a) + 1);
      } else {
        map.put(a, 1);
      }
    }
    int ans = 0;
    int p = 0;
    for(int key : map.keySet()) {
      ans++;
      int t = map.get(key);
      if((t % 2) == 0) p++;
    }
    if((p % 2) == 1) ans--;
    System.out.println(ans);
  }
}

Measured memory_bytes: 63340
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
signed main() {
    int N;
    cin>>N;
    int ans=0;
    
    for(int i=1;i<N;i++){
        ans+=(N-1)/i;
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    ll n,k;
    cin>>n>>k;
    ll as=0;
    rep(i,k,n+2){
        ll le=(ll)i*(i-1)/2;
        le=mod(le,MOD);
        ll ri=n*(n+1)/2-(n-i)*(n-i+1)/2;
        ri=mod(ri,MOD);
        as=mod(as,MOD);
        as=(as+ri-le+1+MOD)%MOD;
    }
    cout<<as<<nl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>

#define N 22

using namespace std;

int main(void)
{

	int n;
	int x1,y1;
	int m;
	char c;
	int l;

	int i,j;

	int f[N][N];

	int x,y;

	int count;


	while(1){

		for (i=0;i<N;i++) {
			for( j=0;j<N;j++){
				f[i][j] = 0;

	//			cout << f[i][j] << " ";
			}
	//		cout << endl;
		}

		cin >> n;
		if(n==0) break;


		for(i=0;i<n;i++){

			cin >> x1;
			cin >> y1;
			
			f[y1][x1] = 1;

		}


		cin >> m;


		x = 10;
		y = 10;
		count = 0;

		if (f[y][x] == 1) {
			f[y][x] = 0;
			count++;
		}

		for(i=0;i<m;i++){
			cin >> c;
			cin >> l;

			for(j=0;j<l;j++){

				if(c == 'N') y++;
				else if(c == 'S') y--;
				else if(c == 'E') x++;
				else if(c == 'W') x--;

				if(f[y][x] == 1){
					f[y][x] = 0;
					count++;
				}
			}
		}

		if(count == n) cout << "Yes" << endl;
		else cout << "No" << endl;



	}

	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

void insertionSort(int *A) {
    int i, j, v;
    for (i=1;i<10;i++) {
        v=A[i];
        j=i-1;
        while (j>=0 && A[j]>v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
    }
}

int main(void) {
    int i, A[10];

    for (i=0;i<10;i++) scanf("%d", &A[i]);
    insertionSort(A);
    for (i=9;i>=7;i--) printf("%d\n", A[i]);
    return 0;
}



Measured memory_bytes: 2056
// Gracias, Rodolfo
// Gracias, MarcosK
// Gracias, Graphter
// Obrigado, Dilson
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for (Long i = a; i < b; i++)
#define roF(i,a,b) for (Long i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long Long;
typedef long double Double;
typedef unsigned long long ULong;
typedef pair<Long, Long> Pair;
typedef vector<Long> Vector;
typedef vector<Pair> PairVector;

const int N = 1e6;
const Long INF = 1e18;
const Double EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
Long random(Long a, Long b) { return uniform_int_distribution<Long> (a, b) (rng); }

void solve() {
	Long n;
	cin >> n;
	Long pos[n + 1];
	For(i,0,n) {
		Long who;
		cin >> who;
		pos[who] = i + 1;
	}
	For(i,1,n+1) cout << pos[i] << " ";
	cout << endl;
}

int main() {
	fastio;
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 4360
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,a[7],p[7],f[305][35];double ans;
int calc(){
	memset(f,0,sizeof(f));
	f[a[0]*n][0]=1;
	for(int i=0;i<n*m;++i)
		if(i%n)
			for(int j=i;j<=n*m;++j)
				for(int k=0;k<1<<n-1;++k)
					if(~k>>(p[i%n]-1)&1)
						f[max(j,min(n*m,i+a[p[i%n]]*n))][k|1<<p[i%n]-1]+=f[j][k];
	return f[n*m][(1<<n-1)-1];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i)scanf("%d",&a[i]),p[i]=i;
	sort(a,a+n);reverse(a,a+n);
	do ans+=calc();while(next_permutation(p+1,p+n));
	for(int i=1;i<n;++i)ans/=i*m;
	printf("%.16lf\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    char ch;
    cin >> ch;
    if (ch >= 'a' && ch <= 'z')
        cout << "a" << endl;
    else
        cout << "A" << endl;
    return 0;
}


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

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

    int amax = 0;
    int amin = 1000000001;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        amax = max(amax, a);
        amin = min(amin, a);
    }
    cout << amax - amin << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }
long long modinv(long long a, long long mod) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

vector<pair<long long, long long>> primeFactorize(long long n) {
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; p++) {
        if ( n % p != 0) continue;
        long long num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res.push_back({p, num});
    }

    if (n != 1) res.push_back({n, 1});
    return res;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    map<ll,ll> mp;
    rep(i,n){
        vector<pair<ll,ll>> p = primeFactorize(a[i]);
        for(pair<ll,ll> q : p){
            chmax(mp[q.first], q.second);
        }
    }
    ll res=0;
    const ll mod = 1e9+7;
    ll LCM = 1;
    for(auto itr = mp.begin(); itr!=mp.end(); itr++){
        LCM *= modpow(itr->first, itr->second, mod);
        LCM %= mod;
    }
    rep(i,n){
        ll tmp = LCM * modinv(a[i], mod);
        tmp%=mod;
        res+=tmp;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;

}

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

int main(){
string s,t,u;
int a,b;
cin>>s>>t>>a>>b>>u;
if (u==s)
{
    /* code */
    a--;
}
else
{
    b--;
}
cout<<a<<" "<<b<<endl;




}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Where's Snuke?
https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_a

"""
import sys


from string import ascii_uppercase

def solve(grid):
    for y, row in enumerate(grid, start=1):
        for x, word in enumerate(row):
            if word == 'snuke':
                return ascii_uppercase[x] + str(y)


def main(args):
    H, W = map(int, input().split())
    grid = [input().split() for _ in range(H)]
    ans = solve(grid)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Map<String,Integer> minMap = new HashMap<>();
        final String MIN = "min";
        int[] numList = new int[220000];
        for(int i=0;i<N;i++){
            numList[i] = Integer.parseInt(sc.next());
        }
        minMap.put(MIN,numList[0]);
        int count = 0;
        for(int i=0;i<N;i++){
            if(numList[i] <= minMap.get(MIN)){
                minMap.put(MIN,numList[i]);
                count++;
            } 
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 50600
N,Y=map(int, input().split())
cnt=0
for i,j,k in ((i,j,N-i-j) for i in range(N+1) for j in range(N+1)):
  if k>=0:
    if 10000*i+5000*j+1000*k==Y:
      print("{} {} {}".format(i,j,k))
      cnt+=1
      break
if cnt==0:
    print("-1 -1 -1")

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int H, W, D;
int sum[100000];

int main() {
   cin >> H >> W >> D;
   vec<pair<int, int>> p(H*W+10);
   rep (i, H) {
      rep (j, W) {
         int A;
         cin >> A;
         p[A] = {i, j};
      }
   }

   for (int i = D+1; i <= H*W; i++) {
      sum[i] = sum[i-D] + abs(p[i].first - p[i-D].first) + abs(p[i].second - p[i-D].second);
   }

   int Q;
   cin >> Q;
   while (Q--) {
      int l, r;
      cin >> l >> r;
      cout << sum[r] - sum[l] << endl;
   }

   return 0;
}

Measured memory_bytes: 2304
use whiteread::parse_line;

fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut v: Vec<(bool, u32)> = vec![(false, 0); n];
    let (ac, wa);

    for _ in 0..m {
        let (p, s): (usize, String) = parse_line().unwrap();
        match s.as_str() {
            "AC" => {
                if !v[p - 1].0 {
                    v[p - 1].0 = true;
                }
            }
            "WA" => {
                if !v[p - 1].0 {
                    v[p - 1].1 += 1;
                }
            }
            _ => unreachable!(),
        }
    }
    ac = v.iter().filter(|x| x.0).count();
    wa = v.iter().filter(|x| x.0).fold(0, |x, y| x + y.1);
    println!("{} {}", ac, wa);
}


Measured memory_bytes: 2804
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();

        // 
        String result = "";
        if( a < b && b < c ){
            result = "Yes";  
        }else{
            result = "No";
        }
        // 
        System.out.printf("%s\n",result);
        sc.close();
    }
}


Measured memory_bytes: 26112
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int a, b, c, d, e, f, water[3005], sugar[3005], answ, anss;
double con = 0;

int main() {
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;
    for (int i = 0; i <= f; i++) {
        for (int j = 0; j <= f; j++) {
            int x = i*a + j*b;
            if (x <= f) water[x] = 1;
        }
    }
    for (int i = 0; i <= f; i++) {
        for (int j = 0; j <= f; j++) {
            int y = i*c + j*d;
            if (y <= f) sugar[y] = 1;
        }
    }    for (int i = 0; i <= f; i++) {
        for (int j = 0; j <= f; j++) {
            if (water[i] == 1 && sugar[j] == 1 && i != 0  && i + j <= f) {
                double ti = (double)i, tj = (double)j;
                if (ti * e / 100 >= tj) {
                    if (100 * tj / (ti + tj)>=con) {
                        con = 100 * tj / (ti + tj);
                        answ = i;
                        anss = j;
                    }
                }
                else {
                    int t;
                    for (int k = ti * e / 100; k >= 0; k--) {
                        if (sugar[k] == 1) {
                            t = k;
                            break;
                        }
                    }
                    if (100 * t / (ti + t) >= con) {
                        con = 100 * t / (ti + t);
                        answ = i;
                    }
                }
            }
        }
    }
    cout << answ + anss << ' ' << anss << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ",trim(fgets(STDIN)));
  $list = [];
  for($i=0; $i<$n; $i++){
    $list[$a[$i]-1] = $i;
  }
  for($i=0; $i<$n; $i++){
    echo $list[$i]+1;
    if($i != $n-1){
      echo " ";
    }
  }
  echo "\n";

Measured memory_bytes: 19188
# C - Bugged
# https://atcoder.jp/contests/abc063/tasks/arc075_a

n = int(input())
S = [int(input()) for _ in range(n)]

S.sort()

score = sum(S)

if score % 10 != 0:
  print(score)
else:
  for s in S:
    if s % 10 != 0:
      print(score - s)
      exit()
  print(0) 

Measured memory_bytes: 3060
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        mut av: [u64; n]
    };

    av.sort_by_key(|&x| -(x as i64));
    let mut res = av[0];
    let mut rest = n - 2;
    let mut i = 1;
    while rest > 0 {
        rest -= 1;
        res += av[i];
        if rest > 0 {
            rest -= 1;
            res += av[i];
        }
        i += 1;
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 5220
import scala.io.StdIn._

object Main extends App {

  val A = Array.fill(3)(readLine().split(" ").map(_.toInt))
  val n = readInt()
  val B = Array.fill(n)(readInt())



  def solve(): String = {
    val flatA = A.flatten
    val r = (0 to 8).map { i =>
      B.contains(flatA(i))
    }
    val pattern = Array(
      Array(r(0),r(1),r(2)),
      Array(r(3),r(4),r(5)),
      Array(r(6),r(7),r(8)),
      Array(r(0),r(3),r(6)),
      Array(r(1),r(4),r(7)),
      Array(r(2),r(5),r(8)),
      Array(r(0),r(4),r(8)),
      Array(r(2),r(4),r(6))
    )
    pattern.foreach { list =>
      if(list.forall(identity)) return "Yes"
    }
    "No"
  }

  println(solve())

}



Measured memory_bytes: 54864
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n, k = MI()
    xy = []
    xx = []
    yy = []
    for _ in range(n):
        x, y = MI()
        xy.append([x, y])
        xx.append(x)
        yy.append(y)
    xx.sort()
    yy.sort()
    #print(xx)
    #print(yy)
    xtoi = {x: i for i, x in enumerate(xx)}
    ytoj = {y: j for j, y in enumerate(yy)}
    cs2d = [[0] * (n + 1) for _ in range(n + 1)]
    for x, y in xy:
        i, j = xtoi[x], ytoj[y]
        cs2d[i + 1][j + 1] = 1
    #p2D(cs2d)
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            cs2d[i][j] += cs2d[i][j - 1]
    for j in range(1, n + 1):
        for i in range(1, n + 1):
            cs2d[i][j] += cs2d[i-1][j]
    #p2D(cs2d)
    ans = 10 ** 20
    for ri in range(n):
        r = xx[ri]
        for li in range(ri):
            l = xx[li]
            for ti in range(n):
                t = yy[ti]
                for bi in range(ti):
                    b = yy[bi]
                    cnt = cs2d[ri+1][ti+1]-cs2d[ri+1][bi]-cs2d[li][ti+1]+cs2d[li][bi]
                    if cnt >= k:
                        s = (r - l) * (t - b)
                        if s < ans: ans = s
    print(ans)

main()


Measured memory_bytes: 3192
// D - Knight
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

#define MOD 1000000007
#define MAX 1000001
ll fac[MAX]; // 累乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の累乗 (n^-1)! = (1/n)!

void init(int n, int p){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rp(i, 2, n+1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p/i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}

ll comb(int n, int r, int m){
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

int main(){
	int X,Y; cin>>X>>Y;
	init(max(X,Y)+1, MOD);
	int k = (Y - X/2 - X%2*2)/3;
	int y = X/2 + X%2*2 + 3*k;
	if(y != Y || k<0 || X/2<k){//NG
		puts("0");
		return 0;
	}
	int n = X/2 + X%2 + k;
	int r = X-n;
	cout<< comb(n, r, MOD) % MOD << endl;
}

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

int N;
int A[200];

int main(){
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> A[i];
	
	int res = 0;
	
	while (true){
		bool exist_odd = false;
		for(int i = 0; i < N ; ++i){
			if (A[i] % 2 != 0) exist_odd = true;
		}
		if (exist_odd) break;
		
		for (int i = 0; i < N ; ++i){
			A[i] /= 2;
		}
		++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b;

    scanf("%d %d", &a, &b);

    if(a==b)
    {
        int ar[10];

        for(int i=0; i<a; i++)
        {
            ar[i]=a;
        }

        for(int i=0; i<b; i++)
        {
            printf("%d", ar[i]);
        }

        printf("\n");
    }

    else
    {
        if(a>b)
        {
            for(int i=0; i<a; i++)
            {
                printf("%d", b);
            }
        }

        else if(b>a)
        {
            for(int i=0; i<b; i++)
            {
                printf("%d", a);
            }
        }

        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
  
    cin>>a>>b>>c;
    
    if(a==b && b==c)
    {
       cout <<"1";
    }
    else if( (a==b && b!=c) || (b==c && c!=a) ||(c==a && b!=c))
    {
       cout <<"2";
    }
    else
      cout <<"3";
    
  
}

Measured memory_bytes: 256
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
x = [int(input()) for i in range(Q)]

for xi in x:
    b, d = bisect.bisect_right(s, xi), bisect.bisect_right(t, xi)
    min_d = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1 = abs(S - xi) + abs(T - S)
            d2 = abs(T - xi) + abs(S - T)
            min_d = min(min_d, d1, d2)
    print(min_d)


Measured memory_bytes: 16144
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()

#define naman                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

const ll INF=1e18;
const double PI=4*atan(1);


void solve(){
   int n;
   cin >> n;
   string s;
   cin >> s;
   ll ans=0;
   loope(i,0,n-3){
      if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
   }

   cout << ans << endl;

}


int32_t main(){
    naman
    ll i = 0,j = 0;

// #ifndef ONLINE_JUDGE
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

    //cout << fixed << setprecision(10);

    int t;
    t=1;
    //cin >> t;
    //ll cno=0;
    while (t--){
        solve();

    }

}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "queue"

using namespace std;
typedef long long ll;

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  cout << min({a, b}) << " " << max({0, a + b - n}) << "\n";
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int n;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        a[i] = x-i-1;
    }
    sort(all(a));
    int mid;
    if(n % 2 == 0) mid = (a[n/2] + a[n/2-1]) / 2;
    else mid = a[n/2];
    ll sum = 0;
    for(int i = 0; i < n; i++) sum += abs(mid - a[i]) * 1ll;
    cout << sum;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 1024
import copy


def dfs(A):
    global ans
    if len(A) == n + 1:
        now = 0
        for j in range(q):
            if A[b[j]] - A[a[j]] == c[j]:
                now += d[j]
        ans = max(ans, now)
        return

    B = copy.copy(A)
    B.append(A[-1])
    while B[-1] <= m:
        dfs(B)
        B[-1] += 1


n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
ans = 0

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

dfs([1])

print(ans)


Measured memory_bytes: 9348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int W = sc.NextInt();
        int H = sc.NextInt();
        int x = sc.NextInt();
        int y = sc.NextInt();
        int r = sc.NextInt();
        if (x >= r && x + r <= W && y >= r && y + r <= H)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 5312
fn main() {
    let lr = read_vec::<u64>();
    let l = lr[0];
    let r = lr[1];

    let mut mi = 2019;
    let mut i_cnt = 0;
    for i in l..r {
        let mut j_cnt = 0;
        for j in i+1..r+1 {
            if (i * j) % 2019 < mi {
                mi = (i * j) % 2019;
            }

            j_cnt += 1;
            if j_cnt > 2019 {
                break;
            }
        }
        i_cnt += 1;
        if i_cnt > 2019 {
            break;
        }
    }

    println!("{}", mi);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(){
	int a,b,t;
	scanf("%d %d",&a,&b);
	t = a + b;
	if(t>=24){
		t = t-24;
		printf("%d\n",t);
		}
		else{
			printf("%d\n",t);
			}
	return 0;
	}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s;

void solve()
{
    cin >> s;
    string k[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for (int i=0;i <7; i++) {
        if (s==k[i]) nout(7-i);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int main() {
    ll S = 3;
    vvi A(S, vi(S));
    for (int i = 0; i < S; i++) {
        for (int j = 0; j < S; j++) {
            cin >> A[i][j];
        }
    }

    ll N;
    cin >> N;
    for (int k = 0; k < N; k++) {
        ll b;
        cin >> b;
        for (int i = 0; i < S; i++) {
            for (int j = 0; j < S; j++) {
                if (A[i][j] == b) A[i][j] = 0;
            }
        }
    }

    ll ans = 0;
    // 縦横
    for (int i = 0; i < S; i++) {
        ll s = 0, t = 0;
        for (int j = 0; j < S; j++) {
            s += A[i][j];
            t += A[j][i];
        }
        if (s == 0) ans++;
        if (t == 0) ans++;
    }
    // ななめ
    ll s = 0, t = 0;
    for (int i = 0; i < S; i++) {
        s += A[i][i];
        t += A[i][S - i - 1];
    }
    if (s == 0) ans++;
    if (t == 0) ans++;

    if (ans > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N,a[100000];
  cin >> N;
  for(int i=1;i<=N;i++){
    cin >> a[i];
  }

  int min=0,cnum=1,bnum;

  while(cnum!=2 && a[cnum]!=-1){
    bnum=cnum;
    cnum=a[cnum];
    a[bnum]=-1;
    min++;
  }

  if(a[cnum]==-1) min=-1;

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 640
def dfs_grid(h,w,sy, sx, maze,visited):
    cur = defaultdict(int)
    def bfs(cur):
        queue = []
        queue.insert(0, (sy, sx))
        visited[sy][sx] = True
        cur[maze[sy][sx]] += 1
        while len(queue):
            y, x = queue.pop()
            now = maze[y][x]
            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0<= nx <w and 0<= ny <h and maze[ny][nx] != now and (not visited[ny][nx])):
                    queue.insert(0, (ny, nx))
                    visited[ny][nx] = True
                    cur[maze[ny][nx]] +=1
        return cur
    return bfs(cur)
def examC():
    H, W = LI()
    S = [SI() for _ in range(H)]
    ans = 0
    visited = [[False]*(W) for _ in range(H)]
    for i in range(H):
        for j in range(W):
            d = dfs_grid(H,W,i,j,S,visited)
            ans += d["."]*d["#"]
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 50140
#include<bits/stdc++.h>
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 Would
#define you
#define please

vector<int> mp[200001];
vector<int> mp2[200001];
int already[200001] = {};

void tree(int oya, int oooya) {

	while (mp2[oya].empty() != true) {
		if (already[mp2[oya].back()] == 0) {
			already[mp2[oya].back()] = 1;
			//cout << oooya << " " << mp2[oya].back() << "\n";
			mp[oooya].push_back(mp2[oya].back());
			tree(mp2[oya].back(), oooya);
		}
		mp2[oya].pop_back();
	}

}



int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	int p[200001], x, y;

	cin >> N >> M;
	rep(i, N) cin >> p[i];
	rep(i, M) {
		cin >> x >> y;
		mp2[x - 1].push_back(y - 1);
		mp2[y - 1].push_back(x - 1);
	}

	rep(i, N) {
		if (already[i] == 0) {
			already[i] = 1;
			mp[i].push_back(i);
			tree(i, i);
		}
	}
	int kotae = 0;

	rep (ii, N) {
		if (mp[ii].size()) {
			vector<int> retu, retup;
			rep(i, mp[ii].size()) {
				retu.push_back(mp[ii][i]);
				retup.push_back(p[mp[ii][i]]);
			}
			sort(retu.begin(), retu.end());
			sort(retup.begin(), retup.end());

			int k1 = 0;
			int k2 = 0;
			while (k1 + 1 < retu.size() || k2 + 1 < retup.size()) {
				if (retu[k1] + 1 == retup[k2]) kotae++;
				if (k1 + 1 >= retu.size()) k2++;
				else if (k2 + 1 >= retup.size()) k1++;
				else if (retu[k1] + 1 < retup[k2]) k1++;
				else k2++;
			}
			if (retu[k1] + 1 == retup[k2]) kotae++;
		}
	}


	cout << kotae << "\n";

	Would you please return 0;
}

Measured memory_bytes: 17272
use std::io;
use std::collections::HashMap;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n: usize = sc.next();
    let k: usize = sc.next();
    let l: usize = sc.next();
    let mut road = UnionFind::new(n);
    let mut rail = UnionFind::new(n);

    for _ in 0..k {
        let p: usize = sc.next();
        let q: usize = sc.next();
        road.merge(p-1, q-1);
    }

    for _ in 0..l {
        let r: usize = sc.next();
        let s: usize = sc.next();
        rail.merge(r-1, s-1);
    }

    let mut map = HashMap::new();

    for i in 0..n {
        let p = (road.root(i), rail.root(i));
        let val = map.entry(p).or_insert(0);
        *val += 1;
    }

    for i in 0..n {
        let p = (road.root(i), rail.root(i));
        print!("{} ", map.get(&p).unwrap());
    }
    println!("");
}

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind {
            par: (0..n).collect(),
            rank: vec![0; n],
        }
    }

    fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let parx = self.par[x];
            self.par[x] = self.root(parx);
            self.par[x]
        }
    }

    fn merge(&mut self, x: usize, y: usize) -> bool {
        let x = self.root(x);
        let y = self.root(y);
        if x != y {
            if self.rank[x] < self.rank[y] {
                self.par[x] = y;
            } else {
                self.par[y] = x;
                if self.rank[x] == self.rank[y] {
                    self.rank[x] += 1;
                }
            }
        }
        x != y
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
}

struct Scanner<B> {
    reader: B,
    buffer: Vec<String>,
}

impl<B: io::BufRead> Scanner<B> {
    pub fn new(reader: B) -> Scanner<B> {
        Scanner {
            reader: reader,
            buffer: Vec::new(),
        }
    }

    pub fn next<T: ::std::str::FromStr>(&mut self) -> T
    where
        T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }
}



Measured memory_bytes: 26920
#include<bits/stdc++.h>
#include<iostream>
#define mod 1000000007
using namespace std;

int main()
{
    long long a1,p,b,a;
    while(cin>>a>>b)
    {
        a1 = a%mod;
        p = 1;
        while (b > 0)
        {
            if (b%2==1)
            {
                p *= a1;
                p = p%mod;
            }
            b /= 2;
            a1 = (a1 * a1)%mod;
        }
        cout<<p<<endl;
    }
    return 0;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

vector<pair<long long,int>> factorize(long long n){
	vector<pair<long long,int>> res;
	for( long long i = 2; i*i <= n; ++i){
		if(n%i) continue ; 
		res.emplace_back(i,0);
		while(n%i == 0){
			n /= i ;
			res.back().second++;
		}
	}
	if ( n != 1) res.emplace_back(n,1);
	return res;
}
int main()
{
	ll n;
	cin >> n;
	auto a = factorize(n);

	ll ans = 0;
	for(auto x:a) {
		// xはpair型
		ll now = 0 ;
		for(int i = 1; i <= 50; i++){
			if (x.second >= now + i){
				ans ++;
				now += i;
			} else {
				break;
			}
		}
	}
	cout << ans << endl;
}


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

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

  int v[21];
  int c[21];

  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] - c[i] > 0) {
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
 int W,H,x,y;
 cin >> W>> H >> x >> y;
 cout << double(W)*double(H)/2.0 <<" " <<(W/2.0 == x&&H/2.0 == y);
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i;
    int a[5];
    int count[4]={0};
    double cos_a[3];
    for(;;){
        scanf("%d %d %d", &a[0], &a[1], &a[2]);
        if(a[0]+a[1]<=a[2] || a[1]+a[2]<=a[0] || a[2]+a[0]<=a[1])break;
        a[3]=a[0];a[4]=a[1];
        for(i=0;i<3;i++)cos_a[i]=(double)(a[i+1]*a[i+1]+a[i+2]*a[i+2]-a[i]*a[i])/(2*a[i+1]*a[i+2]);
        if(cos_a[0]==0 || cos_a[1]==0 || cos_a[2]==0)count[1]++;
        else if(cos_a[0]*cos_a[1]*cos_a[2]>0)count[2]++;
        else count[3]++;
        count[0]++;
    }
    printf("%d %d %d %d\n", count[0], count[1], count[2], count[3]);
    return 0;
}


Measured memory_bytes: 2044