akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n, t, a;
    cin >> n >> t >> a;
    int tmp_height, answer;
    double tmp_min_dif = 99999999;
    REP(i,n){
        cin >> tmp_height;
        
        if(abs(1.0*a-(1.0*t-(0.006*tmp_height)))<tmp_min_dif){
            answer = i + 1;
            tmp_min_dif = abs(1.0 * a - (1.0 * t - (0.006 * tmp_height)));

        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s.size()>=4 && s.substr(0,4)=="YAKI"){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
# 75
while True:
    X,Y = (int(x) for x in input().split())
    if X == 0 and Y == 0:
        break
    elif X < Y:
        X,Y = Y,X

    i = 0
    while Y != 0:
        X = X % Y
        X,Y = Y,X
        i += 1

    print(X, i)


Measured memory_bytes: 5608
/*
 *  Author  : StelaYuri
 * Language : GNU G++ 14
 */

//#pragma comment(linker,"/STACK:1024000000,1024000000")
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
//#include<unordered_map>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define perr(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define eb emplace_back
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-12;
const double PI=acos(-1.0);
const double angcst=PI/180.0;
const ll mod=998244353;
ll max_3(ll a,ll b,ll c){if(a>b&&a>c)return a;if(b>c)return b;return c;}
ll min_3(ll a,ll b,ll c){if(a<b&&a<c)return a;if(b<c)return b;return c;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qmul(ll a,ll b){ll r=0;while(b){if(b&1)r=(r+a)%mod;b>>=1;a=(a+a)%mod;}return r;}
ll qpow(ll a,ll n){ll r=1;while(n){if(n&1)r=(r*a)%mod;n>>=1;a=(a*a)%mod;}return r;}
ll qpow(ll a,ll n,ll p){ll r=1;while(n){if(n&1)r=(r*a)%p;n>>=1;a=(a*a)%p;}return r;}



void solve()
{
    int n;
    cin>>n;
    cout<<(n>=30?"Yes\n":"No\n");
}
int main()
{
    closeSync;
    //multiCase
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int cnt = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0) cnt++;
  }
  cout<<cnt<<endl;
}

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define SIZE(arr) ((int)arr.size())
#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

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

const int MOD = 1e9 + 7;


set<ll> s;

ll check(ll x, ll y) {
	while(x % y == 0) {
		x /= y;
	}
	return x % y;
}

void doMath(ll x) {
	if(x > 1)
		s.insert(x);
	for (ll i = 2; i * i <= x; ++i) {
		if(x % i == 0) {
			s.insert(i);
			s.insert(x/i);
		} 
	}
}

int main()
{
//	#ifndef ONLINE_JUDGE
//		(void)freopen("input.txt", "r", stdin);
//		(void)freopen("output.txt", "w", stdout);
//	#endif
	FAST_IO;
	ll n;
	cin >> n;
	ll cnt = 0;
	doMath(n);
	doMath(n-1);
	for(auto& t : s) {
		if(check(n, t) == 1)
			++cnt;
	}	
	
	cout << cnt;
	return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1e9+7;


int main(){
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> s = nextCharArray();
		ArrayList<String> conv = myconv("CODEFESTIVAL2016", 0);
		int output = 0;
		for(int i = 0; i < s.size(); i++){
			output += (!s.get(i).equals(conv.get(i))) ? 1 : 0;
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33108
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;
using ull = size_t;

ll N;
vector<ll> L;

void input() {
    cin >> N;
    L.resize(N);
    for (auto& l : L) cin >> l;
}

void solve() {
    sort(L.begin(), L.end());
    ll sum = 0;
    for (ull i = 0; i < N - 1; i++)
        sum += L[i];
    bool exist = sum > L.back();
    cout << (exist ? "Yes" : "No") << endl;
}

int main() {
    input();
    
    solve();
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  ll d,a;
  cin>>n>>d>>a;
  vector<pair<ll,ll>> v(n);
  vector<ll> pos(n),bomb(n+1,0);
  for(int i=0;i<n;++i)
  {
    ll x,h;
    cin>>x>>h;
    v[i]={x,h};
    pos[i]=x;
  }
  sort(v.begin(),v.end());
  sort(pos.begin(),pos.end());
  ll b=(v[0].second%a)==0?(v[0].second/a):(v[0].second/a)+1;
  int idx=upper_bound(pos.begin(),pos.end(),pos[0]+2*d)-pos.begin();
  bomb[0]=b;
  bomb[idx]=-b;
  ll curbomb=a*b;
  for(int i=1;i<n;++i)
  {
    ll inx=pos[i],health=v[i].second;
    if(health>curbomb && bomb[i]==0)
    {
      idx=upper_bound(pos.begin(),pos.end(),inx+2*d)-pos.begin();
      b=((health-curbomb)%a)==0?((health-curbomb)/a):((health-curbomb)/a)+1;
      curbomb+=(a*b);
      bomb[i]+=b;
      bomb[idx]-=b;
    }
    else if(bomb[i]<0)
    {
      ll heal=a*llabs(bomb[i]);
      curbomb-=heal;
      bomb[i]=0;
      if(health>curbomb)
      {
        idx=upper_bound(pos.begin(),pos.end(),inx+2*d)-pos.begin();
        b=((health-curbomb)%a)==0?((health-curbomb)/a):((health-curbomb)/a)+1;
        curbomb+=(a*b);
        bomb[i]+=b;
        bomb[idx]-=b;
      }
    }
  }
  for(int i=1;i<n;++i)
    bomb[i]+=bomb[i-1];
  //for(auto i:bomb)
    //cout<<i<<" ";
    //cout<<endl;
  cout<<*max_element(bomb.begin(),bomb.end())<<endl;
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll MOD = 1E9 + 7;

int main() {
    ios::sync_with_stdio(false);
    ll res = 1;
    ll ct = 0;
    ll pos = -1;
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) {
    	int x;
    	cin >> x;
    	if (x < pos + 2) {
    		res *= (ct + 1);
    		res %= MOD;
    	}
        else {
        	ct++;
            pos += 2;
        }
    }
    for (int i = 1;i <= ct;i++) {
    	res *= i;
    	res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
# N = gets.chomp.to_i
A, B, M = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

# Try M pattern
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

ans = a.min + b.min
0.upto(M-1).each do |i| 
  # Try ticket-i
  x, y, c = gets.chomp.split.map(&:to_i)
  x -= 1; # 0-indexed
  y -= 1; # 0-indexed
  price = a[x] + b[y] - c
  if (price < ans)
    ans = price
  end
end

p ans

Measured memory_bytes: 22044
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N, Q, M, D, cnt[101];

int main(void) {
  while(cin >> N >> Q, N && Q) {
    REP(i, 1, 101) cnt[i] = 0;
    REP(i, 0, N) {
      cin >> M;
      REP(j, 0, M) {
        cin >> D;
        cnt[D]++;
      }
    }
    int ans = 0, d = 0;
    REP(i, 1, 101) {
      if(d < cnt[i] && Q <= cnt[i]) {
        ans = i;
        d = cnt[i];
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2988
var
  n,i:longint;
  a:array[0..1000]of boolean;
begin
  read(n);
  a[0]:=true;
  for i:=0 to n do
    begin
      if a[i]=true then
        begin
          a[i+4]:=true;
          a[i+7]:=true;
          if i=n then
            begin
              write('Yes');
              exit;
            end;
          end;
    end;
  write('No');
end.

Measured memory_bytes: 128
package main
import "fmt"
const mod int64 = 998244353
func main() {
  var k,n int64
  fmt.Scan(&k,&n)
  initlz(k+n)
  a := make([]int64,2*k+1)
  for i:=int64(2);i<k+2;i+=2 {
    for j:=int64(0);j<i/2+1;j++ {
      if k+n-i-1 < 0 || n-j < 0 { continue }
      a[i] = (a[i]+(comb(i/2,j)*((p[j]*comb(k+n-i-1,n-j))%mod))%mod)%mod
    }
    if i < 2*k { a[i+1] = a[i] }
  }
  for i:=k+2;i<2*k+1;i++ { a[i] = a[2*k-i+2] }
  for i:=int64(2);i<2*k+1;i++ { fmt.Println(a[i]) }
}
func min(n,m int64) int64 {
  if n < m { return n }
  return m
}

const size int = 50
var f []int64
var invf []int64
var p []int64
func initlz(n int64) {
  f = make([]int64,n+1)
  invf = make([]int64,n+1)
  p = make([]int64,n+1)
  f[0] = 1
  invf[0] = 1
  p[0] = 1
  for i:=int64(1);i<n+1;i++ {
    f[i] = (f[i-1]*(i%mod))%mod
    invf[i] = inv(f[i])
    p[i] = (p[i-1]*2)%mod
  }
}
func comb(n,k int64) int64 {
  if k < 0 || k > n { return 0 }
  if n == 0 && k == 0 { return 1 }
  if n == 0 { return 0 }
  return (f[n]*((invf[k]*invf[n-k])%mod))%mod
}
func inv(n int64) int64 {
  if n == 1 { return 1 }
  k := make([]int64,size)
  a,b,u := mod,n,size
  for i:=0;i<size;i++ {
    k[i],a,b = a/b,b,a%b
    if b == 0 { u = i;break }
  }
  var y0,y1 int64 = 1,-k[0]
  for i:=1;i<u;i++ { y0,y1 = y1,y0-k[i]*y1 }
  for y1 < 0 { y1 += mod }
  return y1%mod
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	
	ll max = 0;
	if(K <= A){
		cout << K << endl;
	}
	else if(K > A && K <= A+B){
		cout << A << endl;
	}
	else{
		cout << A-(K-A-B) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
	int n, i;
	int xmax = 600;
	int S;
	while(scanf("%d\n", &n) == 1) {
		S = 0;
		for(i=0;i<xmax;i=i+n) {
			S = S + i*i*n;
		}
		printf("%d\n", S);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main()
{
    while (1)
    {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0)
        {
            break;
        }
        int ans = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                for (int k = j + 1; k <= n; k++)
                {
                    if (i + j + k == x)
                    {
                        ++ans;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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


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

#define pb(a) push_back(a)
#define INF 1145141919810
#define mod 1000000007

typedef long long ll;

const int dsize = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[dsize],fac[dsize];

template <class T = ll> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<dsize;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<dsize;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int p = min(a+b+1,c);
	cout<<p+b<<endl;
}
    

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

using namespace std;
const int MAX = 1000000;
vector <int> primeCountList(MAX, 0);//indx:number value:primeCount

void setPrimeCount()
{
    int primeCount = 1;
    for(int i=3;i<=MAX;i+=2)
    {
        bool isPrime = true;
        for(int j=3;j*j<=i;j+=2)
        {
            if(i%j == 0)
            {
                isPrime = false;
                break;
            }
        }
        primeCountList[i-1] = primeCount;
        if(isPrime)
        {
            primeCount++;
            primeCountList[i] = primeCount;

        }
        else
        {
            primeCountList[i] = primeCount;
        }

    }
    primeCountList[2] = 1;

}
/*
 * getPrimeNumber:0009
 */
int main()
{
    setPrimeCount();
    int n;
    while(cin >> n)
    {
        cout << primeCountList[n] << endl;
    }
    return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, d[50], sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> d[i];
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,i,r=0;
	scanf("%d%d%d",&a,&b,&c);
	for(i=a;i<=b;i++)
	{
		if(c%i==0)
			r++;
		}
	printf("%d\n",r);
	return 0;
}



Measured memory_bytes: 2000
N = int(input())
x = []
y = []
# offsets
x.append([])
y.append([])
for i in range(N):
    A = int(input())
    xtmp = []
    ytmp = []
    for _ in range(A):
        xx, yy = [int(x) for x in input().split()]
        xtmp.append(xx)
        ytmp.append(yy)
    x.append(xtmp)
    y.append(ytmp)

num_honest = 0

for i in range(2**N):
    is_honest_inv = '{:015b}'.format(i) + '0' # add dummy
    is_honest = [int(is_honest_inv[15-i]) for i in range(N+1)]
    # print(is_honest_inv, is_honest)
    is_ok = True
    for j in range(1, N+1):
        for xx, yy in zip(x[j], y[j]):
            # print(xx, yy, is_honest[xx])
            if is_honest[j] == 1:
                if is_honest[xx] != yy:
                    is_ok = False
                    break
        if not is_ok:
            break
    if is_ok:
        num_honest = max(num_honest, sum(is_honest))
        # print(f'OK: {num_honest}')
print(num_honest)



Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

string s;

void print(int a, int b) {
	for (int i = a; i <= b; i++) {
		cout << s[i];
	}

	cout << endl;

	return;
}

void reverse(int a, int b) {
	string tmp = s;

	for (int i = b; i >= a; i--) {
		tmp[i] = s[a + b-i];
	}

	s = tmp;
}

void replace(int a, int b, string p) {
	for (int i = a; i <= b; i++) {
		s[i] = p[i-a];
	}
	return;
}

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

	for (int i = 0; i < n; i++) {
		string order; cin >> order;
		int a, b; cin >> a >> b;
		if (order == "replace") {
			string buf; cin >> buf;
			replace(a, b, buf);
		}

		if (order == "reverse") {
			reverse(a, b);
		}

		if (order == "print") {
			print(a, b);
		}

	}
	
	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 1000000000
typedef long long ll;

ll gcd(ll C,ll D){
    ll tmp;
    if(C>D){tmp=C;C=D;D=tmp;}
    if(D%C==0)return C; 
    return gcd(C,D%C);
}

int main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll X,Y,ans;

    if(gcd(C,D)>1){
        if(D%C==0||C%D==0){ //CD 2,8とか
            ll cn = min(C,D);
            X=(A/cn);
            Y=(B/cn);
            if(A%cn==0) ans=(B-A+1)-(Y-X+1);
            else ans=(B-A+1)-(Y-X);    
        }else{              //CD 6 8とか
            ll cd = C*D/gcd(C,D);
            X=(A/C)+(A/D)-(A/cd);
            Y=(B/C)+(B/D)-(B/cd);
            if(A%cd==0) ans=(B-A+1)-(Y-X+1);
            else ans=(B-A+1)-(Y-X); 
        }
    }else{                  //CD 3 5とか
        //互いに素
        X=(A/C)+(A/D)-(A/C/D);
        Y=(B/C)+(B/D)-(B/C/D);
        if(A%C==0||A%D==0) ans=(B-A+1)-(Y-X+1);
        else ans=(B-A+1)-(Y-X);
    }
    cout<<ans<<endl;
    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();
        String S = sc.next();
        long E = 0;
        long W = 0;
        long El = 0;
        long Wl = 0;
        char[] car = S.toCharArray();
        for (char c : car) {
            if (c == 'E') E++;
            else W++;
        }
        long ans = Long.MAX_VALUE;
        for (char c : car) {
            long count = 0;
            if (c == 'E') {
                E--;
                count += (Wl+E);                
                El++;
            } else {
                W--;
                count += (Wl+E);
                Wl++;
            }
            ans = Math.min(ans, count);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 42644
#include <iostream>
#include <stdio.h>

#include <string>

#include <vector>
#include <list>
#include <map>

#include <algorithm>
#include <utility>

using namespace std;

int main(const int argc, const char **argv){
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);

  if(y > 2019){
    printf("TBD");
  }else if(y == 2019){
    if(m > 4){
      printf("TBD");
    }else if(m == 4){
      if(d > 30){
        printf("TBD");
      }else{
        printf("Heisei");
      }
    }else{
      printf("Heisei");
    }
  }else{
    printf("Heisei");
  }

  return 0;
}


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

using namespace std ;
#define rep(i,n) for(int i =0 ; i < int (n); i++)
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n ;
	int c1 = 0, c2= 0 , c3= 0 , c4 = 0;
	cin >> n;
	string a[n];
	rep(i,n){
		cin >> a[i];
	}
	rep(i,n){
		if(a[i] == "AC"){
			c1++;
		}
		if(a[i] == "WA"){
			c2++;
		}
		if(a[i] == "TLE"){
			c3++;
		}
		if(a[i] == "RE"){
			c4++;
		}
	}


	cout << "AC " <<"x " <<c1<<endl ;
	cout << "WA " <<"x " <<c2<<endl ;
	cout << "TLE " <<"x " <<c3<<endl ;
	cout << "RE " <<"x " <<c4<<endl ;
	
	



	return 0 ;
}

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

def f(a,b):
    ret = 0
    a,b = min(a,b),max(a,b)
    l = len(str(N))
    if a==b:
        if l==1:
            if a<=N: return 1
            else: return 0
        ret = 1
        for d in range(l-1):
            for i in range(10**d):
                A = a*(10**(d+1)+1) + i*10
                if A<=N: ret += 1
                else: break
            else:
                continue
            break
        ret **= 2
    else:
        Acnt = 0
        Bcnt = 0
        for d in range(l-1):
            for i in range(10**d):
                A = a*(10**(d+1)) + b + i*10
                B = b*(10**(d+1)) + a + i*10
                if B<=N: Bcnt += 1
                if A<=N: Acnt += 1
                else: break
            else:
                continue
            break
        ret = Acnt * Bcnt    
    return ret

ans = 0
for a in range(1,10):
    for b in range(1,10):
        ans += f(a,b)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{

ios_base::sync_with_stdio(false), cin.tie(NULL);
string s;
cin>>s;
long long int sum=0;
for(int i=0;i<s.length();i++)
{
int j=s[i]-'0';
sum+=j;
}
if(sum%9==0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3700
from collections import defaultdict
N=int(input())

ans_dic=defaultdict(int)
for _ in range(N):
  s=input()
  ans_dic[s]+=1

print("AC x " + str(ans_dic["AC"]))
print("WA x " + str(ans_dic["WA"]))
print("TLE x " + str(ans_dic["TLE"]))
print("RE x " + str(ans_dic["RE"]))

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    a*=100;b*=100;
    double M = -1;
    int M1;
    int M2;
    for(int na=0; na<=f/a; na++){
        int r1=f-na*a;
        for(int nb=0; nb<=r1/b; nb++){
            int r2 = r1-nb*b;
            for(int nc=0; nc<=r2/c; nc++){
                int r3 = r2-nc*c;
                for(int nd=0; nd<=r3/d; nd++){
                    if((c*nc+d*nd)*100>e*(a*na+b*nb))break;
                    double nodo = (double)(c*nc+d*nd)/(a*na+b*nb+c*nc+d*nd);
                    if(nodo>M){
                        M=nodo;
                        M1=a*na+b*nb+c*nc+d*nd;
                        M2=c*nc+d*nd;
                    }
                }
            }
        }
    }
    cout<<M1<<" "<<M2<<endl;

    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    string s;
    cin >> s;
    int ans=0;
    rep(i,s.size()){
        for(ll j=1;j<=s.size()-i;j++){
            string t=s.substr(i,j);
            bool acgt=true;
            rep(k,t.size()){
                if(t[k] != 'A' && t[k] != 'C' && t[k] != 'G' && t[k] != 'T') acgt=false;
            }
            if(acgt && ans < t.size()) ans = t.size();
        }
    }
    cout << ans << endl;
}

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


void solve(char C){
    cout << (char)(C + 1) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    char C;
    std::cin >> C;
    solve(C);
    return 0;
}


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

void printArray(int* A , int N) {
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i < N-1) cout << " ";
    }
    cout << endl;
}

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

int main() {
    int N, A[100];

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

    printArray(A, N);
    insertionSort(A, N);
    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
int main(void)
{
    int N, A[10000], che=1, count = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }
    while (che)
    {
        che = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 == 0)
            {
                A[i] = A[i] / 2;
                che = 1;
                break;
            }
        }
        if (che)
            count++;
    }
    printf("%d", count);
    return 0;
}

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

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);

    rep(i, N)
    {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());
    cout << abs((A.at(0) - A.at(N - 1))) << endl;
}

Measured memory_bytes: 256
x=int(input())
if 400<=x<=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
elif 1800<=x<=1999:
    print(1)


Measured memory_bytes: 9200
N = int(input())
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
c = list(map(int,input().split(" ")))
#アルゴリズムわからないけどN log N?
a.sort()
b.sort()
c.sort()
 
#O(N)?
i,j,k = 0,0,0
ans = 0
while j < N:
  while i < N and a[i]<b[j] :
    i += 1
  while k < N and c[k]<=b[j]:
    k += 1
  ans += i * (N - k)
  j += 1
 

print(ans)

Measured memory_bytes: 23328
#include<cstdio>
int main() {
	int n, sum=0, a, b;
	scanf("%d", &n);
	for(int i=1; i<=n; i++) {
		scanf("%d%d", &a, &b);
		sum+=b-a+1;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int A[200010];
long long ans;
int MAX;

int main(){
	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	for (int i = 0; i < N; i++){
		MAX = max(MAX, A[i]);
		int B = MAX;
		ans += B - A[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4404
n = gets.to_i
s = gets.chomp
r_cnt = 0
g_cnt = 0
b_cnt = 0

n.times do |i|
	if s[i] == "R"
		r_cnt += 1
	elsif	s[i] == "G"
		g_cnt += 1
	else
		b_cnt += 1
	end
end

ans = r_cnt * g_cnt * b_cnt

(n-1).times do |i|
	(i+1).upto(n-1) do |j|
		k = 2*j - i
		break if k >= n
		if s[i] != s[j] && s[j] != s[k] && s[k] != s[i]
			ans -= 1
		end
	end
end

puts ans

Measured memory_bytes: 14320
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      for (int l = 0; ; l++) {
        if ((i ^ j) & 1 << l) {
          if (j) cout << ' ';
          cout << l+1;
          break;
        }
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 512
void main() {
	auto arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
	writeln(arr[ri-1]);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double degree = ((h+m/60)*30-m*6)/360*2*Math.PI;
		double height = Math.sin(degree)*a;
		double width = b-Math.cos(degree)*a;

		double ans = Math.pow(Math.pow(height, 2)+Math.pow(width, 2),0.5);

		System.out.println(ans);

	}


	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n>>k;
        cout<<(n+2*k)/(2*k+1);

    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (int i = 0; i < n; i++)
int main() {
	ll N;
	cin>>N;
	string buf;
	ll max = 0;
	map<string,ll> dict;
	REP(i,N){
		cin>>buf;
		if(dict[buf] == 0){
			dict[buf] =1;
			// max = 1;
		}else{
			dict[buf] = dict[buf]+1;
			if(max < dict[buf]){
				// max = dict[buf];
			}
		}
		// cout<<dict[buf]<<endl;
	}
	for(auto i = dict.begin();i != dict.end();i++){
		if(max < i->second){
			max = i->second;
		}
	}
	// cout<<max<<endl;
	for(auto i = dict.begin();i != dict.end();i++){
		if(i->second == max){
			cout<<i->first<<endl;
		}
	}
return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    int a, b;
    cin >> a >> b;

    if (a == b)
    {
        cout << "Draw" << endl;
        return;
    }

    if (a == 1)
    {
        cout << "Alice" << endl;
        return;
    }

    if (b == 1)
    {
        cout << "Bob" << endl;
        return;
    }

    if (a > b)
    {
        cout << "Alice" << endl;
        return;
    }
    else
    {
        cout << "Bob" << endl;
        return;
    }

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
H,W,D = list(map(int, input().split()))
A = []
for i in range(H):
    A.append(list(map(int, input().split())))

Q = int(input())
L = [0 for _ in range(Q)]
R = [0 for _ in range(Q)]
for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

masu = [[0,0] for _ in range(H*W)]
for i in range(H):
    for j in range(W):
        masu[A[i][j]-1] = [i, j]

MP = [0 for _ in range(H*W)]
for i in range(H*W):
    if i < D:
        MP[i] = 0
    else:
        MP[i] = MP[i-D] + abs(masu[i][0]-masu[i-D][0]) + abs(masu[i][1]-masu[i-D][1])

for i in range(Q):
    print(MP[R[i]-1] - MP[L[i]-1])


Measured memory_bytes: 28656
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		boolean j = true;
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		String[] strArray = s.split("");
		if(strArray.length != a+b+1) j = false;
		if(strArray[a].equals("-")) {
			for(int i = 0;i < strArray.length;i++) {
				if(i != a) {
					if(!(strArray[i].equals("-"))) {
						int x = Integer.parseInt(strArray[i]);
						if(x >= 10 && x < 0) j = false;
					}
					else j = false;
				}
			}
		}
		else j = false;
		if(j) System.out.println("Yes");
		else if(!j) System.out.println("No");
		sc.close();	
	}
}


Measured memory_bytes: 22996
using System;

public class ABC113B {
  static public void Main(){
    string[] buf;
    buf = Console.ReadLine().Split(' ');
    int N = int.Parse(buf[0]);
    buf = Console.ReadLine().Split(' ');
    int T = int.Parse(buf[0]);
    int A = int.Parse(buf[1]);
    buf = Console.ReadLine().Split(' ');
    int[] H = new int[buf.Length];
    for (int i = 0; i < buf.Length; i++) {
      H[i] = int.Parse(buf[i]);
    }
    double closestDiff = double.PositiveInfinity;
    int closestIdx = -1;
    for (int i = 0; i < H.Length; i++) {
      double diff = Math.Abs(A - (T - H[i] * 0.006));
      if (diff < closestDiff) {
        closestIdx = i;
        closestDiff = diff;
      }
    }
    Console.WriteLine(closestIdx + 1);
  }
}


Measured memory_bytes: 13204
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
	ll X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}
ll dat[100005];
pair<ll,ll> p[100005];
ll sz[100005];
ll from[100005];
ll to[100005];
ll n;
int main()
{
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>dat[i];
		p[i]=make_pair(dat[i],i);
	}
	sort(p,p+n);
	ll id=0;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		sz[i]=1;
	}
	for(ll i=n-1;i>=1;i--)
	{
		ll curid=p[i].second;
		ll tmp=p[i].first;
		ll nx=n-2*sz[curid];
		if(nx<=0)
		{
			cout<<-1<<endl;
			return 0;
		}
		ll pos=lower_bound(p,p+n,make_pair(tmp-nx,0LL))-p;
		if(p[pos].first!=tmp-nx)
		{
			cout<<-1<<endl;
			return 0;
		}
		from[id]=p[i].second;
		to[id++]=p[pos].second;
		sum+=sz[curid]*(n-sz[curid])*2;
		sz[p[pos].second]+=sz[curid];
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ans+=dat[i];
	}
	if(sum!=ans)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(ll i=0;i<id;i++)
	{
		cout<<from[i]+1<<" "<<to[i]+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

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

       Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();

        int[] a = new int[n];

       int ans = 0;
       a[0] = stdIn.nextInt();

        for(int i = 1;i < n;i++){
            a[i] = stdIn.nextInt();

            if(a[i - 1] == a[i]){
                   a[i] = -1;
                   ans++;

            }

        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    if (k % 2 == 0) {
        ll x = n / k;
        ll y = (n + k/2) / k;
        cout << x*x*x + y*y*y << endl;
    } else {
        ll x = n / k;
        cout << x*x*x << endl;
    }
}

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

using namespace std;
typedef long long ll;
const int MAXN = 505;
int n,m,a[MAXN][MAXN];
vector<int> gr[MAXN][MAXN];
inline void addEdge(int u, int v, int c)
	{ gr[u][v].push_back(c), gr[v][u].push_back(c); }
int match[MAXN<<2];
bool vis[MAXN<<2];
inline bool dfs(int u)
{
	for(int i = n+1; i<=2*n; i++)
		if(!vis[i]&&!gr[u][i].empty())
		{
			vis[i] = true;
			if(match[i]<0||dfs(match[i]))
			{
				match[i] = u;
				return true;
			}
		}
	return false;
}
inline int calc(int x)
	{ return (x-1)/m+1; }
int ansb[MAXN][MAXN],tmp[MAXN],ansc[MAXN][MAXN];

int main()
{
	cin >> n >> m;
	for(int i = 1; i<=n; i++)
		for(int j = 1; j<=m; j++)
			cin >> a[i][j];
	for(int i = 1; i<=n; i++)
		for(int j = 1; j<=m; j++)
			addEdge(i,n+calc(a[i][j]),a[i][j]);
	for(int i = 1; i<=m; i++)
	{
		memset(match,-1,sizeof(match));
		for(int j = 1; j<=n; j++)
		{
			memset(vis,0,sizeof(vis));
			dfs(j);
		}
		for(int j = n+1; j<=2*n; j++)
		{	
			ansb[match[j]][i] = gr[j][match[j]][gr[j][match[j]].size()-1];
			gr[j][match[j]].pop_back(), gr[match[j]][j].pop_back();
		}
	}	
	for(int i = 1; i<=m; i++)
	{
		for(int j = 1; j<=n; j++)
			tmp[j] = ansb[j][i];
		sort(tmp+1,tmp+n+1);
		for(int j = 1; j<=n; j++)
			ansc[j][i] = tmp[j]; 
	}
	for(int i = 1; i<=n; i++)
	{
		for(int j = 1; j<=m; j++)
			cout << ansb[i][j] << " ";
		cout << endl;
	}
	for(int i = 1; i<=n; i++)
	{
		for(int j = 1; j<=m; j++)
			cout << ansc[i][j] << " ";
		cout << endl;	
	}
	return 0;
}


Measured memory_bytes: 7552
n=int(input())
s=list([input() for i in range(n)])
m=int(input())
t=list([input() for i in range(m)])
a=[]
for i in range(len(s)):
    a.append(s.count(s[i])-t.count(s[i]))
a.sort()
print(max(0,a[-1]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long unsigned int ll;




int main(){
    int n;
    ll x;
    cin>>n>>x;
    ll a[105];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    /*for(int i=0;i<n;i++){
        cout<<a[i]<<endl;
    }*/
    while(x>=a[ans]){
            x-=a[ans];
            ans++;
        //cout<<ans<<endl;
        if(ans==n){
            if(x>0){
                ans--;
            }
            break;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
a = Array.new(gets.to_i) {|i| i+1}
list = []
gets.to_i.times{ list << gets.split(",").map(&:to_i).map{|i| i-1} }
list.each { |item|
	temp = a[item[0]]
	a[item[0]] = a[item[1]]
	a[item[1]] = temp
}
a.each{|n| p n}

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

int main(){
  int N;
  cin >> N;
  string ans="APPROVED";
  for(int i=0; i<N; i++){
    int A;
    cin >> A;
    if(A%2==0){
      if(A%3!=0 && A%5!=0) ans="DENIED";
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256