akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		ll N=in();
		if(N<0) break;

		ll V=N;
		string S;
		while(V/4){
			char M = V%4;
			S.push_back(M+'0');
			V/=4;
		}
		S.push_back((char)V+'0');
		reverse(ALL(S));
		out(S);
	}
	
	return 0;
}



Measured memory_bytes: 3088
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    String[] vowelArray = {"a", "i", "u", "e", "o"};
    String ans = "consonant";
    
    for(int i = 0; i < vowelArray.length; i++){
      if(str.equals(vowelArray[i])){
        ans = "vowel";
      }
    }
    System.out.println(ans);
  }
}
      

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;
    vector<int> C(N-1);
    vector<int> S(N-1);
    vector<int> F(N-1);

    for(int i = 0; i < N-1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    int now = 0;
    int start_time = 0;
    vector<int> ans(N);
    
    for(int i = 0; i < N-1; i++){
        now = S[i];//で、乗る
        now = now + C[i]; 
        for(int j = i+1; j < N-1; j++){
            // 次に発射できるのは、nowより大きくて最初
            if(now < S[j]){
                start_time = S[j];
            }else{
                start_time = S[j] + F[j] * (((now-S[j]) + F[j]-1) / F[j]);
            }
            now = start_time + C[j];
        }
        ans[i] = now;
    }


    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, m, x;
        cin >> n >> m >> x;
        vector<vector<int>> v(n, vector<int> (m + 1));
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= m; j++){
                cin >> v[i][j];
            }
        }
        int ans = INF;
        for(int i = 0; i < (1 << n); i++){
            int sum = 0;
            vector<int> res(m);
            for(int j = 0; j < n; j++){
                if(i & (1 << j)){
                    sum += v[j][0];
                    for(int k = 1; k <= m; k++){
                        res[k - 1] += v[j][k];
                    }
                }
            }
            int flag = 0;
            for(auto &it : res){
                if(it < x){
                    flag = 1;
                }
            }
            if(!flag){
                ans = min(ans, sum);
            }
        }
        if(ans == INF){
            ans = -1;
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 34616
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    // dp[i][0] : i桁目で，丁度L,　dp[i][1]:L以下
    ll dp[l.size() + 1][2] = {};
    dp[0][0] = 1;

    rep(i, l.size()){
        if(l[i] == '0'){
            dp[i+1][0] = dp[i][0];// 丁度Lで０ならそのまま
            dp[i+1][1] = 3*dp[i][1];// 0:0, 0:1, 1:0の３通り
        }
        else {
            dp[i+1][0] = 2*dp[i][0];// 1:0, 0:1の２とうり
            dp[i+1][1] = 3*dp[i][1] + dp[i][0];// 0:0, 1:0, 0:1の３通りと丁度できて1->0にしたもの
        }

        dp[i+1][0] %= MOD;
        dp[i+1][1] %= MOD;
    }

    cout << (dp[l.size()][0] + dp[l.size()][1]) % MOD << endl;
}

Measured memory_bytes: 5280
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define aint(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revrep(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define ii pair<int,int>
#define pb push_back
#define f first
#define s second
#define ll long long int
#define vi vector<int>
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   ll a,b;
   cin>>a>>b;
   if(a+b>=10)
    cout<<"error";
   else
    cout<<a+b;
   return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
int a, b;

int main () {
	cin >> n >> a >> b;
	if ((b - a) & 1) cout << "Borys" << endl; else cout << "Alice" << endl;
	return 0;
}

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

int main(){
    std::array<int, 8> point;
    for(int i = 0; i < 4; i++){
        std::cin >> point[i];
    }
    
    int dx = point[2] - point[0];
    int dy = point[3] - point[1];
    point[4] = point[2] - dy;
    point[5] = point[3] + dx;
    point[6] = point[4] - dx;
    point[7] = point[5] - dy;
    
    std::cout << point[4] << " " << point[5] << " " << point[6] << " " << point[7] << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	pp := make([]int, n)

	for i := 0; i < n; i++ {
		pp[i] = getNextInt(scanner)
	}

	ans := 0
	for i := 1; i < n-1; i++ {
		if pp[i-1] < pp[i] && pp[i] > pp[i+1] {
			continue
		}
		if pp[i-1] > pp[i] && pp[i] < pp[i+1] {
			continue
		}
		ans++
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    if(n<1000){
        cout << "ABC"; 
    }
    else{
        cout << "ABD";
    }

    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 8e3 + 5;

int n,m,k;
ii st;
bool vis[N][N];
char c[N][N];
int wx[4] = {0,0,-1,1};
int wy[4] = {1,-1,0,0};
vector <ii> vec;
queue <pair<int,ii> > Q;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> m >> k;
  for (int i = 1 ; i <= n ; i++)
    for (int j = 1 ; j <= m ; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'S')
        st = {i,j};
    }
  Q.push({0,st});
  while(Q.empty() == false) {
    auto temp = Q.front();
    Q.pop();
    int cost = temp.first,x = temp.second.first, y = temp.second.second;
    if (vis[x][y] == true || c[x][y] == '#' || cost > k || x < 1 || y < 1 || x > n || y > m)
      continue;
    vec.push_back({x,y});
    vis[x][y] = true;
    for (int i = 0 ; i < 4 ; i++)
      Q.push({cost + 1,{x + wx[i],y + wy[i]}});    
  }
  while(Q.empty() == false)
    Q.pop();
  int ans = 1e9;
  for (auto i : vec)
    Q.push({0,i});
  memset(vis,0,sizeof vis);
  while(Q.empty() == false) {
    auto temp = Q.front();
    Q.pop();
    int cost = temp.first,x = temp.second.first, y = temp.second.second;
    if (vis[x][y] == true || x < 1 || y < 1 || x > n || y > m)
      continue;
    vis[x][y] = true;
    if (x == 1 || x == n || y == 1 || y == m)
      ans = min(ans,cost / k + (cost % k != 0) + 1);
    for (int i = 0 ; i < 4 ; i++)
      Q.push({cost + 1,{x + wx[i],y + wy[i]}}); 
  }
  cout << ans << endl;
}


Measured memory_bytes: 107752
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const int sqrtN = 512;
const ll LINF=1e18;
const ld PI=abs(acos(-1));

struct Node{
	int data;
	
	Node(int data) : data(data) {};
	
	Node operator*(const Node r) const{
		return data < r.data ? *this : r;
	}
} e((1LL << 31) - 1);

struct SqrtDecomposition{
	vector<Node> data;
	vector<Node> bucket;
	int N, K;
	
	SqrtDecomposition(int n) : N(n){
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K * sqrtN, e);
		bucket.assign(K, e);
	}
	
	void update(int k, int x){
		data[k] = x;
		k = k / sqrtN;
		
		Node ret = e;
		for(int i = k * sqrtN; i < (k + 1) * sqrtN; i++){
			ret = ret * data[i];
		}
		
		bucket[k] = ret;
	}
	
	int get(int a, int b){
		Node ret = e;
		for(int k = 0; k < K; k++){
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			
			if(b<=l||r<=a) continue;
			if(a<=l&&r<=b) ret = ret * bucket[k];
			else{
				for(int i = max(a, l); i < min(b, r); i++){
					ret = ret * data[i];
				}
			}
		}
		
		return ret.data;
	}
};

int main(){
	int n,q; cin >> n >> q;
	SqrtDecomposition data(n);
	REP(i,0,q){
		int a,b,c; cin >> a >> b >> c;
		
		if(a == 0) data.update(b, c);
		else if(a == 1) cout << data.get(b, c + 1) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3120
#include<stdio.h>

int main(void){
	float a,b,c,d,e,f;
	float x,y;
	
	while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)==6){
		x=(e*c-b*f)/(e*a-b*d);
		if(x==-0.0) x=0.0;
		y=(d*c-a*f)/(d*b-a*e);
		if(y==-0.0) y=0.0;
		
		printf("%.3f %.3f\n",x,y);
			
	}
	
	return 0;
}

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


int main(){
	int n = 0;
	rep(i,3){
        int tmp;
        cin >> tmp;
        n *= 10;
        n += tmp;
	}
	cout << (n%4 ? "NO\n" : "YES\n");
}


Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    ans = [8, 7, 6, 5, 4, 3, 2, 1]
    x = ni()
    print(ans[(x - 400) // 200])


if __name__ == '__main__':
    main()


Measured memory_bytes: 11256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll n,x;
	cin>>n>>x;
	ll a = n-x;
	ll ans = 0;
	while(a){
		// cout<<a<<" "<<x<<endl;
		if(!x) break;
		ans += a/x * x * 3;
		ll aa = a,xx = x;
		x = aa % xx;
		a = xx;
	}

	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> //accumulate
#include <queue>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r-l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }

};

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> a(n, 0);
    LazySegmentTree seg(vector<ll> (n, 0));
    for(int i = 0; i < q; i++){
        int c, s, t, x;
        cin >> c;
        if(c) {
            cin >> s >> t;
            cout << seg.getsum(s-1, t) << endl;
        }
        else {
            cin >> s >> t >> x;
            seg.add(s-1, t, x);
        }
    }

    return 0;
}


Measured memory_bytes: 8392
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  int n, r;
  cin >> n >> r;
  
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + 100*(10 - n) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = ReadLine().Split(' ');
            if (x[1] == "+") WriteLine(int.Parse(x[0]) + int.Parse(x[2]));
            if (x[1] == "-") WriteLine(int.Parse(x[0]) - int.Parse(x[2]));
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int n;
char str[200000+10];
vector<int> vec;
char Xor(char a,char b)
{
    return a==b?'0':'1';
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)    cin>>str[i];
    for(int i=n/2;i>=1;i--)
    {
        char cur=str[i];
        for(int j=2*i;j<=n;j+=i)    cur=Xor(cur,str[j]);
        str[i]=cur;
    }
    for(int i=1;i<=n;i++)
    {
        if(str[i]=='1') vec.push_back(i);
    }
    int size=vec.size();
    cout<<size<<endl;
    for(int i=0;i<size;i++)    cout<<vec[i]<<" ";
    return 0;
}

Measured memory_bytes: 1912
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){
	
	int a[7],b[7];
	
	for(int i=0;i<7;i++)
		cin>>a[i]>>b[i];
	
	for(int i=0;i<7;i++)
		cout<<a[i]-b[i]<<endl;


}

Measured memory_bytes: 1160
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var list = new Array(3);
  list[0] = myconv(next(),4);
  list[1] = myconv(next(),4);
  list[2] = myconv(next(),4);
  var N = myconv(next(),1);
  for(var i = 0; i < N; i++){
    var tmp = myconv(next(),1);
    for(var j = 0; j < 3; j++){
      for(var k = 0; k < 3; k++){
        if(list[j][k] == tmp){
           list[j][k] = 0;
        }
      }
    }
  }
  if(list[0][0] == 0 && list[0][1] == 0 && list[0][2] == 0){
     myout("Yes");
    return;
  }
  if(list[1][0] == 0 && list[1][1] == 0 && list[1][2] == 0){
     myout("Yes");
    return;
  }
  if(list[2][0] == 0 && list[2][1] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][0] == 0 && list[1][0] == 0 && list[2][0] == 0){
     myout("Yes");
    return;
  }
  if(list[0][1] == 0 && list[1][1] == 0 && list[2][1] == 0){
     myout("Yes");
    return;
  }
  if(list[0][2] == 0 && list[1][2] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][0] == 0 && list[1][1] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][2] == 0 && list[1][1] == 0 && list[2][0] == 0){
     myout("Yes");
    return;
  }
  myout("No");
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') f = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> Tp chkmax(Tp &x, Tp y) {return x > y ? x : x=y;}
template <typename Tp> Tp chkmin(Tp &x, Tp y) {return x < y ? x : x=y;}
template <typename Tp> Tp Max(Tp x, Tp y) {return x > y ? x : y;}
template <typename Tp> Tp Min(Tp x, Tp y) {return x < y ? x : y;}

int p[5], N;

int main()
{
	FOR(i, 1, 4) in(p[i]); in(N);

	p[1] *= 4; p[2] *= 2;

	std::sort(p + 1, p + 4);

	if (p[1] * 2 <= p[4]) {
		printf("%lld\n", 1ll * p[1] * N);
	}

	else {
		printf("%lld\n", 1ll * (N / 2) * p[4] + 1ll * (N % 2) * p[1]); 
	}
	
	return 0;
}


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

using namespace std;

int main()
{
    int N,buf;
    vector<int> L;

    cin >> N;
    for(int i=0;i<N;i++){
        scanf("%d",&buf);
        L.push_back(buf);
    }
    sort(L.begin(),L.end());
    
    int sum=0;

    for(int i=0;i<N-1;i++)
        sum+=L[i];

    if(sum>L[N-1])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
                
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    while(true) {
        int N, M, K;
        cin >> N >> M >> K;
        if(!N && !M && !K) break;

        int patnum = 1;
        for(int i = 0; i < N; ++i) patnum *= M;

        int sum = 0;
        for(int i = 0; i < patnum; ++i) {
            int pat = i;
            int dice = 0;
            for(int j = 0; j < N; ++j) {
                int n = (pat % M) + 1;
                dice += n;
                pat /= M;
            }
            if(dice > K) sum += dice - K;
            else sum += 1;
        }

        printf("%.8f\n", (double)sum / patnum);
    }
    return 0;
}

Measured memory_bytes: 904
x = int(input())
if x <= 599:
  print(8)
elif x <= 799:
  print(7)
elif x <= 999:
  print(6)
elif x <= 999:
  print(6)
elif x <= 1199:
  print(5)
elif x <= 1399:
  print(4)
elif x <= 1599:
  print(3)
elif x <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9184
#include<stdio.h>
int main()
{
	int n, H[100000], num = 0, p;
	p = num;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &H[i]);
		if (i > 0)
		{
			if (H[i] <= H[i - 1])
			{
				num++;
				if (num > p)
					p = num;
			}
			else
				num = 0;
		}
	}
	printf("%d", p );
	return 0;
}

Measured memory_bytes: 512
/**
 * Created by hiramekun at 20:51 on 2019-10-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll ans = 0;
    rep(i, n) {
        while (i < n - 1 && s[i] == s[i + 1]) i++;
        ans++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    string s;
    cin >> s;
    string a = s;
    reverse(a.begin(),a.end());
    bool ans = false;
    if(s == a){
        ans = true;
    }
    
    string x = s.substr(0,s.length()/2);
    string y = s.substr(s.length()/2+1,s.length());
    reverse(x.begin(),x.end());
    reverse(y.begin(),y.end());
    if(ans && s.substr(0,s.length()/2) == x && s.substr(s.length()/2+1,s.length()) == y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	n := func() int { stdin.Scan(); i, _ := strconv.Atoi(stdin.Text()); return i }()
	fmt.Println(factorial(n))
}
func permutation(n int, k int) int {
	v := 1
	w := int(math.Pow(10, 9)) + 7
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v = v * (n - i) % w
		}
	} else if k > n {
		v = 0
	}
	return v
}
func factorial(n int) int {
	return permutation(n, n-1)
}
func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int n, m, p[300000], q[300000], c[300000], ans[300000], nodeans[300000], expanded[300000];
vector< vector<int> > graph(300000);
map< pair<int, int>, int> m1;
vector< vector< pair<int, int> > > c_edge(1100000);
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> p[i] >> q[i] >> c[i];
		graph[p[i]].push_back(i);
		graph[q[i]].push_back(i);
		c_edge[c[i]].push_back(make_pair(p[i], q[i]));
		c_edge[c[i]].push_back(make_pair(q[i], p[i]));
		ans[i] = 1e9;
		m1[mp(p[i], c[i])] = 1e9;
		m1[mp(q[i], c[i])] = 1e9;
	}

	for (int i = 1; i <= 1e6; i++)
		sort(c_edge[i].begin(), c_edge[i].end());

	for (int i = 1; i <= n; i++)
	{
		nodeans[i] = 1e6;
		m1[mp(i, 0)] = 1e9;
	}
	
	priority_queue< pair<int, pair<int, int> > > pq;
	pq.push(mp(-1, mp(1, 0))); 
	m1[mp(1, 0)] = 1;
	while (!pq.empty())
	{
		pair<int, pair<int, int> > temp = pq.top(); pq.pop();
		int node = temp.second.first, mode = temp.second.second;
		//cout << temp.first << " " << temp.second.first << " " << temp.second.second << endl;
		if (-temp.first != m1[mp(node, mode)])
		{
			continue;
		}
		nodeans[node] = min(nodeans[node], -temp.first);
		if (node == n)
			break;
		if (mode == 0)
		{
			for (int i = 0; i < graph[node].size(); i++)
			{
				int edgenum = graph[node][i];
				if (m1[mp(node, c[edgenum])] < -temp.first)
					continue;
				int node2 = p[edgenum];
				if (node2 == node)
					node2 = q[edgenum];
				if (m1[mp(node2, c[edgenum])] > -temp.first)
				{
					m1[mp(node2, c[edgenum])] = -temp.first;
					pq.push(mp(temp.first, mp(node2, c[edgenum])));
				}
				if (m1[mp(node2, 0)] > -temp.first+1)
				{
					m1[mp(node2, 0)] = -temp.first+1;
					pq.push(mp(temp.first-1, mp(node2, 0)));
				}
			}
		}
		else
		{
			int index = lower_bound(c_edge[mode].begin(), c_edge[mode].end(), mp(node, -1)) - c_edge[mode].begin();
			while (index < c_edge[mode].size())
			{
				pair<int, int> temp2 = c_edge[mode][index++];
				if (temp2.first != node)
					break;
				if (m1[mp(temp2.second, mode)] > -temp.first)
				{
					m1[mp(temp2.second, mode)] = -temp.first;
					pq.push(mp(temp.first, mp(temp2.second, mode)));
				}
				if (m1[mp(temp2.second, 0)] > -temp.first+1)
				{
					m1[mp(temp2.second, 0)] = -temp.first + 1;
					pq.push(mp(temp.first - 1, mp(temp2.second, 0)));
				}
			}
		}
	}
	if (nodeans[n] == 1e6)
		nodeans[n] = -1;
	cout << nodeans[n] << endl;
}

Measured memory_bytes: 83312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;


ll n, a[100], C = 0, B = 0;

int main(){
	cin >> n;
	REP(i, n){
		C = 0, B = 0;
		REP(j, 10)cin >> a[j];
		REP(j, 10){
			if (a[j] > B){
				B = a[j];
			}
			else if (a[j] > C){
				C = a[j];
			}
			else{
				cout << "NO\n";
				break;
			}
			if (j == 9){
				cout << "YES\n";
			}
		}
	}
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;
  int c = 0;//+の数
  for(int i = 0;i<4;i++){
    if(S[i] == '+') c++;
  }
  int d = 4- c;
  cout << c- d << endl;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> T( N );
	for( auto& v: T ) { cin >> v; }

	int M;
	cin >> M;

	for( int i = 0; i < M; ++i ) {
		int P, X;
		cin >> P >> X;

		int s = 0;
		for( int j = 0; j < N; ++j ) {
			s += P-1 == j ? X : T.at( j );
		}

		cout << s << endl;
	}
}


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

void printArray(int A[], int n, int count) {
	for (int i{ 0 }; i != n; i++) {
		if (i != 0)cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << count << endl;
}

void swap(int& a, int& b) {
	int temp = a;
	a = b;
	b = temp;
}

int selectionSort(int A[], int n) {
	int count = 0;

	for (int i{ 0 }; i < n; i++) {
		int mini = i;
		for (int j = i; j < n; j++) {
			if (A[mini] > A[j]) {
				swap(mini,j);
			}
		}

		if (mini != i) count++;
		swap(A[i], A[mini]);
	}
	return count;
}

int main()
{
	int n;
	int a[100];
	cin >> n;
	for (int i{ 0 }; i < n; i++) {
		cin >> a[i];
	}
	int count = selectionSort(a, n);
	printArray(a, n, count);
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <string.h>
long long Atol(char *str)
{
	int strLen=strlen(str);
	long long sumV=0;
	long long dec = 1;
	for (int i=strLen-1;i>=0;i--){
		sumV += dec*(str[i]-'0');
		dec *= 10;
	}
	return sumV;
}
long long Add(long long s0,char *str,int plus)
{
	char s1[11],s2[11];
	long long sumV=0;
	if (plus==0){
		sumV += s0 + Atol(str);
	}else if (plus == 1){
		int strLen=strlen(str);
		//一つの+
		for (int i=1;i<strLen;i++){
			strncpy(s1,str,i);
			s1[i]='\0';
			strncpy(s2,str+i,strLen-i);
			s2[strLen-i]='\0';
			sumV += s0+Atol(s1)+Atol(s2);
		}
	}else{
		int strLen=strlen(str);
		for (int i=1;i<=strLen-plus;i++){
			strncpy(s1,str,i);
			s1[i]='\0';
			strncpy(s2,str+i,strLen-i);
			s2[strLen-i]='\0';
			sumV += Add(s0+Atol(s1),s2,plus-1);
		}
	}
	return sumV;
}
using namespace std;
int main(int argc, char* argv[])
{
	string  S;
	cin>>S;

	int plus;
	long long sumV=0;
	long long sumv;
	for (plus=0;plus<S.length();plus++){
		sumv=Add(0,(char*)S.c_str(),plus);
		sumV+=sumv;
	}
	cout<<sumV<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main(void){
	int n;
	int cnt1=0,cnt2=0,cnt4=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int aa;
		scanf("%d",&aa);
		if (aa%4==0){
			cnt4++;
			continue;
		}
		if (aa%2==0){
			cnt2++;
			continue;
		}
		cnt1++;
	}
	if (cnt2){
		if (cnt4>=cnt1){
			printf("Yes");
		}
		else{
			printf("No");
		}
	}
	else{
		if (cnt4>=cnt1-1){
			printf("Yes");
		}
		else{
			printf("No");
		}
	}
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;

  int cnt = 0;

  for (int i = 0; i < N-2; i++) {
    if (S.substr(i, 3) == "ABC") cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define vii vector<pair<int,int> >
#define vi vector<ll>
#define ll long long
#define rep(i,a,b) for(i=a;i<=b;i++)
#define inf 100000000000000000

using namespace std;

int n,m;
vector<int> v[100001];
int dp[100001];
bool vis[100001];

int f(int x)
{
    vis[x]=true;
    for(auto i:v[x])
    {
        if(!vis[i])
        {
            dp[x]=max(dp[x],1+f(i));
        }
        else{
            dp[x]=max(dp[x],1+dp[i]);
        }
    }
    return dp[x];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
    }
    fill(dp+1,dp+n+1,0);
    fill(vis+1,vis+n+1,false);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            f(i);
        }
    }
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        mx=max(mx,dp[i]);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int X, Y, A, B, C;
ll sum;
vector<ll> ps, qs, rs;
int main(){
    cin >> X >> Y >> A >> B >> C;
    for(int i = 0; i < A; i++){
        ll p;
        cin >> p;
        ps.push_back(p);
    }for(int i = 0; i < B; i++){
        ll q;
        cin >> q;
        qs.push_back(q);
    }
    for(int i = 0; i < C; i++){
        ll r;
        cin >> r;
        rs.push_back(r);
    }
    sort(ps.rbegin(), ps.rend());
    sort(qs.rbegin(), qs.rend());
    sort(rs.begin(), rs.end());
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for(int i = 0; i < X; i++) pq.push(ps[i]), sum += ps[i];
    for(int i = 0; i < Y; i++) pq.push(qs[i]), sum += qs[i];
    for(int i = 0; i < C; i++){
        if(rs[i] > pq.top()){
            sum -= pq.top();
            pq.pop();
            sum += rs[i];
            pq.push(rs[i]);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
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;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 28;
void solve(int a) { cout << (a ? "Yes" : "No") << endl; }
int main()
{
    int n, k;
    ll ans = INFLL;
    cin >> n >> k;
    V a(n, INFLL);
    ll up = 0LL;
    ll current = 0LL;
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(bit, (1 << n))
    {
        if (__builtin_popcount(bit) == k and (bit & (1 << 0)))
        {
            current = 0LL;
            rep(i, n){
                if (i == 0){
                    up = a[0];
                }
                if(bit&(1<<i) and i!=0){
                    if(up==a[i]){
                        current++;
                        up++;
                    }else if(up >a[i]){
                        up++;
                        current+=(up-a[i]);
                    
                    }else{
                        up=a[i];
                    }
                }
                chmax(up,a[i]);
            }
            chmin(ans, current);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import heapq
from collections import defaultdict

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

cnt = defaultdict(list)
for _ in range(n):
    a, b = map(int, input().split())
    cnt[a].append(b)

t = []
heapq.heapify(t)
ans = 0
for i in range(1, m+1):
    for j in cnt[i]:
        heapq.heappush(t, -j)
    if t: ans -= heapq.heappop(t)

print(ans)


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

int gcd(int A,int B){
    if(B == 0){
        return A;
    }
    return gcd(B,A%B);
}

int main(){
    
    int A,B;
    scanf("%d%d",&A,&B);
    if(A >= B){
        printf("%d\n",gcd(A,B));
    }else{
        printf("%d\n",gcd(B,A));
    }

    return 0;
}



Measured memory_bytes: 2716
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HWD = Sarray();
            var H = HWD[0];
            var W = HWD[1];
            var D = HWD[2];
            var dct = new Dictionary<long, Tuple<int, int>>();
            for (var i = 0; i < H; ++i)
            {
                var a = Sarray();
                for (var j = 0; j < W; ++j)
                    dct[a[j] - 1] = Tuple.Create(i, j);
            }
            var rui = new long[H * W];
            for (var i = D; i < H * W; ++i)
            {
                var dst = Abs(dct[i - D].Item1 - dct[i].Item1) + Abs(dct[i - D].Item2 - dct[i].Item2);
                rui[(int)i] = rui[(int)i - D] + dst;
            }
            var Q = Sarray()[0];
            for (var i = 0; i < Q; ++i)
            {
                var lr = Sarray();
                var l = lr[0] - 1;
                var r = lr[1] - 1;
                var ans = rui[r] - rui[l];
                WriteLine(ans);
            }
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 31152
Scanf.scanf " %d %d %d" @@ fun a b c ->
  let rems = Array.make b false in
  let rec f n =
    let r = n mod b in
    if r = c then (print_endline "YES"; exit 0)
    else if rems.(r) then (print_endline "NO"; exit 0)
    else
      (rems.(r) <- true;
      f (n + a)) in
  f a

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 b, w; scanf("%lld%lld", &b, &w);
	
	const int MOD = 1e9 + 7;
	
	auto powMod = [MOD](i64 x, i64 n) {
		i64 ret = 1;
		while(n) {
			if(n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	};
	
	const i64 n = b + w;
	std::vector<i64> fact(n + 1, 1), inv(n + 1, 1);
	for(i64 i = 0; i < n; i++) fact[i + 1] = fact[i] * (i + 1) % MOD;
	for(int i = 0; i < n; i++) inv[i] = powMod(fact[i], MOD - 2);
	
	auto comb = [fact, inv, MOD](int n, int r) {
		if(n < r) return 0LL;
		return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
	};
	
	i64 p = 0, q = 0, latte = 1;
	for(int i = 0; i < n; i++) {
		printf("%lld\n", (1 - q + p + MOD) * inv[2] % MOD);
	
		(latte *= inv[2]) %= MOD;
		(p += comb(i, w - 1) * latte % MOD) %= MOD;
		(q += comb(i, b - 1) * latte % MOD) %= MOD;
	}
	return 0;
}


Measured memory_bytes: 8448
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        int N = NextInt();
        NX K = NextLong();
        NX[] A = LineLong().OrderBy(x => x).ToArray(), F = LineLong().OrderByDescending(x => x).ToArray();

        //時間に間に合うかどうか
        NX ok = NX.MaxValue - 10, ng = -1;
        while (ok - ng > 1)
        {
            NX time = (ok + ng) / 2;
            NX cost = 0;
            for (int i = 0; i < N; i++)
            {
                NX eat_time = A[i] * F[i];
                cost += Math.Max(0, (eat_time - time + F[i] - 1) / F[i]);
            }
            if (cost <= K) ok = time;
            else ng = time;
        }
        Console.WriteLine(ok);
    }
}


public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 49032
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    for (i in 0..n / 4) {
        var a = 4 * i
        for (j in 0..n / 7) {
            a += 7 * j
            if (n < a) break
            if (n == a) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[1252];

const ll INF = 1e18;

ll dp[1252];
int bef[1252];
// bef[i] = -1 -> begin from i

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  // goes negative
  if(*max_element(a,a+n) <= 0){
    printf("%d\n",*max_element(a,a+n));
    printf("%d\n",n-1);
    int id = max_element(a,a+n) - a;
    while(n-1 > id){
      printf("%d\n",n);
      n--;
    }
    while(n>=2){
      puts("1");
      n--;
    }
    return 0;
  }
  // dp
  REP(i,n)dp[i] = a[i];
  REP(i,n)bef[i] = -1;
  REP(i,n){
    // skip odd
    for(int skip=1;i+skip+1<n;skip+=2){
      if(dp[i] + a[i+skip+1] > dp[i+skip+1]){
        dp[i+skip+1] = dp[i] + a[i+skip+1];
        bef[i+skip+1] = i;
      }
    }
  }
  int cur = 0;
  REP(i,n)if(dp[i] > dp[cur]){
    cur = i;
  }
  printf("%lld\n",dp[cur]);
  vi hands;
  int tail = n-1;
  while(tail > cur){
    hands.push_back(tail);
    tail--;
  }
  while(bef[cur] != -1){
    int bf = bef[cur];
    int width = cur - bf - 1;
    while(width >= 1){
      hands.push_back(bf + (width+1)/2);
      width -= 2;
    }
    cur = bf;
  }
  while(cur > 0){
    hands.push_back(0);
    cur--;
  }
  printf("%d\n",(int)hands.size());
  REP(i,hands.size()){
    printf("%d\n", hands[i]+1);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int sum = 0, m = 0;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		sum += n;
		m = max(m, n);
	}

	cout << sum - (m / 2) << endl;
}

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

using namespace std;

int main() {
  string w;
  cin >> w;
  unordered_map<char, int> counts;
  for (char c : w) counts[c]++;

  for (char c = 'a'; c <= 'z'; c++) {
    if (counts[c] % 2 == 1) {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  char R = 'R';
  char U = 'U';
  char D = 'D';
  char L = 'L';
  int M;
  int S = 0;
  M = N.size();
  for(int i=0;i<M;i++){
    if(i%2 == 0){if(N.at(i)== R ||N.at(i)== U ||N.at(i)== D ){S = S+1;}}
    if(i%2 == 1){if(N.at(i)== L ||N.at(i)== U ||N.at(i)== D ){S = S+1;}}
  }
  string c;
  if(S == M){c = "Yes";} else{c = "No";}
  cout << c << endl;
}
  

Measured memory_bytes: 256