akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<time.h> 
#define loop(i,c,n) for(long long i=c;i<n;i++) 
#define iter(v) for(auto x : v)  // to iterate over entire vector/sets/map
using namespace std; 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii; 
typedef set<int> si; 
int max(int a,int b){if(a>b)return a;
return b;} 
//optimised school method
bool isPrime(ll a){ 
if(a<=1)return false ;
if(a<=3)return true ;
if(a%2==0 || a%3==0)return false;
for(ll i=5;i*i<=a;i=i+6){//Instead of checking till n, we can check till √n because a larger factor of n 
//must be a multiple of smaller factor that has been already checked.
if(a%i==0 || a%(i+2)==0)return false;}return true;}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);  
    cout.tie(0);
    //  to read input from local files  
     #ifndef ONLINE_JUDGE 
    clock_t clocktime; 
    clocktime= clock(); 
     freopen("input.txt", "r",stdin);
     freopen("output.txt", "w",stdout);
    #endif
    // to read entire line with spaces 
    // string s;
    // getline(cin,s);
    
    // when amount of data is unknown
    // while(cin>>x){}    
    
 int n; 
 cin>>n ; vi v(5,0);n++;
 while(n--){ string s;
     getline(cin,s);  
     if(s=="AC")v[1]++;
     else if( s=="WA")v[2]++;
     else if(s=="TLE")v[3]++;else if(s=="RE")v[4]++; 
     else continue;} 
     cout<<"AC x "<<v[1]<<"\n"; 
      cout<<"WA x "<<v[2]<<"\n";
       cout<<"TLE x "<<v[3]<<"\n";
        cout<<"RE x "<<v[4];

    
    #ifndef ONLINE_JUDGE
    clocktime = clock()-clocktime; 
    double runtime  = (((double)clocktime)/CLOCKS_PER_SEC); 
    cout<<"\n--------\nTimeUsed -- "<<runtime<<"s"; 
    #endif
    return 0;
}

Measured memory_bytes: 3660
//
//  main.cpp
//  matrix_chain_multiplication
//
//  Created by ???????????? on 2017/10/17.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#define INFTY (1 << 21)


using namespace std;

int p[110];

void matrixChainMultiplication(int n){
    int m[n+1][n+1];
    for (int i = 1; i <= n; i++) m[i][i] = 0;
    
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= (n-l+1); i++){
            int j = i + l - 1;
            m[i][j] = INFTY;
            for(int k = i; k <= (j-1); k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
}


int main(int argc, const char * argv[]) {
    int n, i, pi, pi_1;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d", &pi, &pi_1);
        if(i) p[i+1] = pi_1;
        else {
            p[0] = pi;
            p[1] = pi_1;
        }
    }
    matrixChainMultiplication(n);
//    std::cout << "Hello, World!\n";r
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    queue<ll> a;
    for (int i = 1; i < 10; i++)
    {
        a.push(i);
    }
    
    ll num = 0;
    while(k!=0){
        num = a.front(); a.pop();
        int num1 = num%10;
        if (num1!=0) a.push(num*10 + num1-1);
        a.push(num*10 + num1);
        if (num1!=9) a.push(num*10 + num1+1);
        k--;
    }

    cout << num << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;

int n;
int d, x;
int a[100];

int main() {
	int i;
	
	cin >> n >> d >> x;
	rep(i, n) cin >> a[i];
	d--;
	
	int ans = 0;
	rep(i, n) {
		ans += d / a[i] + 1;
	}
	ans += x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	private static int h, w, cnt;
	private int[] ColumnCheck(char c[]){
		int a[] = new int[w];
		for(int i = 0;i < w;i++){
			if(c[i] == 'c') cnt = 0;
			else if(cnt >= 0) cnt++;
			a[i] = cnt;
		}
		return a;
	}
	private void print(int a[][]){
		for(int i = 0;i < h;i++){
			for(int k = 0;k < w;k++){
				if(k != w - 1) System.out.print(a[i][k] + " ");
				else System.out.println(a[i][k]);
			}
		}
	}
	private void doIt(){
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		int a[][] = new int[h][w];
		char c[][] = new char[h][w];
		for(int i = 0;i < h;i++){
			cnt = -1;
			c[i] = sc.next().toCharArray();
			a[i] = ColumnCheck(c[i]);
		}
		print(a);
	}
	public static void main(String args[]){
		new Main().doIt();
	}
}

Measured memory_bytes: 36852
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main(){
    int N,M;
    cin>>N>>M;
    vector<vector<int>> array(M);
    vector<int> light(M);
    for(int i=0;i<M;i++){
        int k;
        cin>>k;
        array[i].resize(k);
         for(int j=0;j<k;j++){
            cin>>array[i][j];
            array[i][j]--;
        }
    }
    for(int i= 0;i<M;i++)cin>>light[i];
    int ans = 0;
    for(int i=0;i<(1<<N);i++){
        bool ok = 1;
        for(int j=0;j<M;j++){
            int c=0;
            for(int id:array[j]){
                if((i>>id)&1){
                    c++;
                }
            }
            c%=2;
            if(c != light[j])ok =0;
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long n, sum = 0;
    cin >> n;
    while (n)
    {
        sum += n % 10;
        n /= 10;
    }
    if (sum > 1)cout << sum;
    else cout << sum * 10;
    return 0;
}


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

using namespace std;

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

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

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

  vector<double> p(n + 1);

  for (auto i = 1; i <= n; ++i) {
    cin >> p[i];
  }

  double dp[n + 1][n + 1];
  memset(dp, 0, sizeof(dp));

  dp[0][0] = 1;

  for (auto i = 1; i <= n; ++i) {
    dp[i][0] = dp[i - 1][0] * (1 - p[i]);
  }

  for (auto i = 1; i <= n; ++i) {

    for (auto j = 1; j <= n; ++j) {
      dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
    }
  }

  double ans = 0;

  for (auto i = (n / 2) + 1; i <= n; ++i) {
    ans += dp[n][i];
  }

  cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 70528
#include <iostream>
using namespace std;
#define MOD 1000000007

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int *A=new int[N];
    long long s=0,s2=0;
    for(int i=0;i<N;++i){
        cin>>A[i];
        s+=A[i];
        s%=MOD;
        s2+=(long long)A[i]*A[i];
        s2%=MOD;
    }
    s*=s;
    s%=MOD;
    s-=s2;
    s%=MOD;
    if(s<0){
        s+=MOD;
    }
    if(s%2==0){
        cout<<(s/2)<<endl;
    }else{
        cout<<((s+MOD)/2)<<endl;
    }
    
    delete[] A;
    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar_unlocked()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar_unlocked())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	int n; rd(n);
	printf("%d\n", n == 0);
}

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

const int MAX_N = 10000;

struct UnionFind
{
  int par[MAX_N];
  int rank[MAX_N];

  void init(int n){
    for(int i = 0; i < n; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y) return;

    if(rank[x] < rank[y]) par[x] = y;
    else{
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
};

int main()
{
  int n, q;
  cin >> n >> q;
  UnionFind uf;
  uf.init(n);

  for(int i = 0; i < q; i++){
    int c, x, y;
    cin >> c >> x >> y;

    if(c == 0) uf.unite(x, y);
    if(c == 1){
      if(uf.same(x, y))
        cout << 1 << endl;
      else
        cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 1236
import sys
  
for s in sys.stdin:
    x1,y1,x2,y2,x3,y3,xp,yp = [ float(x) for x in s.split() ]

    v12 = (x2-x1, y2-y1)
    v23 = (x3-x2, y3-y2)
    v31 = (x1-x3, y1-y3)
    v1p = (xp-x1, yp-y1)
    v2p = (xp-x2, yp-y2)
    v3p = (xp-x3, yp-y3)
    cp1 = v12[0]*v1p[1] - v1p[0]*v12[1]
    cp2 = v23[0]*v2p[1] - v2p[0]*v23[1]
    cp3 = v31[0]*v3p[1] - v3p[0]*v31[1]

    if cp1 > 0 and cp2 > 0 and cp3 > 0:
        print('YES')
    elif cp1 < 0 and cp2 < 0 and cp3 < 0:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5596
#include <cstdio>
#include <algorithm>
using namespace std;
long long A, B, C, D, ans, x; int t1, t2;
int main() {
  scanf("%ld %ld %ld %ld", &A, &B, &C, &D);
  t1 = min(C, D), t2 = max(C, D);
  for(int r = 1; r > 0;) {r = t2%t1; t2 = t1; t1 = r;}
  x = C*D/t2;
  ans = B-A+1;
  ans -= B/C-(A-1)/C+B/D-(A-1)/D;
  ans += B/x-(A-1)/x;
  printf("%ld", ans);
}

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

int main() {
	vector <int> array(3);
	for (int i = 0; i < 3; i++) {
		cin >> array.at(i);
	}
	sort(array.begin(), array.end());
	reverse(array.begin(), array.end());
	cout << stoi(to_string(array.at(0)) + to_string(array.at(1))) + array.at(2) << endl;
}


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

using namespace std;
using ll = long long;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d) cout<<"Yes"<<endl;
    else if(abs(a-b)<=d&&abs(b-c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
// RAM RAM
    #include <bits/stdc++.h>
    #define int long long
    #define pb push_back
    #define ppb pop_back
    #define vi vector<int>
    #define mp make_pair
    #define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
    #define N 55
    const int MOD=1000000007;
    using namespace std;
     
    int32_t main()
    {
    	ios_base::sync_with_stdio(false);cin.tie(0);
        int n;cin>>n;
        cout<<(15*800-200)*(n/15) + (n%15)*800<<endl;
    	return 0;
    }

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

	typedef long long ll;
	using namespace std;

	int main(){
		int a ,b, k;
		cin >> a >>b >> k;
		int c=0;
		for(int i=b; i >= 1; i--){
			if( (a%i == 0) && (b%i == 0) ){
				c++;
				if(c == k){
					cout << i <<endl;
					return 0;
				}
			}
		}

		return 0;
	}

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

const int MAX_H=21;

int H,ans,ok,rev;
vector<vector<int>> stones(MAX_H,vector<int>(5));
vector<int> seq(5);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	while(cin >> H,H){
		for (int i=0;i<H;++i)
			for (int j=0;j<5;++j)
				cin >> stones[H-1-i][j];
		ans=0;
		while(1){
			ok=0;
			for (int i=0;i<H;++i){
				for (int j=0;j<5;++j) seq[j]=0;
				seq[2]=(stones[i][2]>0); rev=0;
				for (int j=1;j<=2;++j){
					if (seq[1+j]&&stones[i][2+j]==stones[i][2]) seq[2+j]=1;
					if (seq[3-j]&&stones[i][2-j]==stones[i][2]) seq[2-j]=1;
				}
				for (int j=0;j<5;++j) rev+=seq[j];
				if (rev>=3){
					ok=1; ans+=rev*stones[i][2];
					for (int j=0;j<5;++j){
						if (seq[j]) stones[i][j]=0;
					}
				}
			}
			for (int i=0;i<H;++i){
				for (int j=0;j<5;++j){
					if (!stones[i][j]){
						for (int k=i+1;k<H;++k){
							if (stones[k][j]){
								stones[i][j]=stones[k][j];
								stones[k][j]=0;
								break;
							}
						}
					}
				}
			}
			if (!ok) break;
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 3220
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<cstring>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	int n;cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	
	REP(i,n)cin >> a[i] >> b[i];
	
	ll ans = 0;
	
	REP(i,n)
	{
		ll now = n - i - 1;
		ll tmp = (a[now] + ans) - (((a[now] + ans)/b[now]) * b[now]);
		//cout << (a[now] + ans) << ' ' << (((a[now] + ans)/b[now]) * b[now]) << ' ' << b[now] << ' ' << tmp << endl;
		if(tmp != 0)tmp = b[now] - tmp;
		ans += tmp;
		//cout << tmp << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  int l = 0, r = 1001001001;
  while (r - l > 1) {
    int c = (l + r) / 2;
    long long cnt = 0;
    for (int i = 0; i < n; i++) cnt += (a[i] - 1) / c;
    (cnt <= k ? r : l) = c;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll n;
  cin >> n;
  ll tmp = n / 1000;
  cout << ((tmp+1) * 1000 - n) % 1000 << endl;
}

Measured memory_bytes: 3688
def add(x,y):
    return x + y
def sub(x,y):
    return x - y
def mul(x,y):
    return x * y
def mod(x,y):
    return x / y



x = []
a = []
while True:
    x = raw_input().split()
    if x[1]=='?':
        break
    if x[1]=='+':
        y = add(int(x[0]),int(x[2]))
    if x[1]=='-':
        y = sub(int(x[0]),int(x[2]))
    if x[1]=='*':
        y = mul(int(x[0]),int(x[2]))
    if x[1]=='/':
        y = mod(int(x[0]),int(x[2]))
    a.append(y)

    
for j in range(len(a)):
    print a[j]
    

Measured memory_bytes: 6340
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;
double condition = 0.0;

void func()
{
	int N, M;
	cin >> N >> M;
	int ans = 0;

	if (N >= 2)
		ans = N * (N - 1) / 2;
	if (M >= 2)
		ans += M * (M - 1) / 2;
	cout << ans << endl;

}

int main() {
//	while(1)
	func();
	return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{
    int n;
    cin >> n;
    ll ans=0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += a-1;
    }
    cout<< ans << endl;



    return 0;
}

Measured memory_bytes: 3528
#include<stdio.h>
#include<string.h>
#define MAX_N 3005
#define MOD 100000
int N,M,S,n,m,s,i,j;

int dp[50][MAX_N];

int main()
{
	for(;scanf("%d%d%d",&N,&M,&S),N;)
	{
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		N*=N;
		for(m=1;m<=M;m++)
			for(n=N;n>0;n--)
				for(s=m;s<=S;s++)
					dp[n][s]=(dp[n][s]+dp[n-1][s-m])%MOD;
		printf("%d\n",dp[N][S]);
	}
	return 0;
}

Measured memory_bytes: 1192
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    a = list(map(lambda x: int(x) // 400, input().split()))
    colors = [0] * 9

    # See:
    # https://beta.atcoder.jp/contests/abc064/submissions/2416018
    for i in a:
        if i < 8:
            colors[i] = 1
        else:
            colors[8] += 1

    kind = sum(colors[:8])
    print(max(kind, 1), kind + colors[8])


Measured memory_bytes: 3060
/*----------------------|
/ Author : Ashraf Tasin |
/ Date   :   08.08.19   |
/----------------------*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define all v.begin(),v.end()
#define flash ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define db double
#define endl "\n"
#define mnm pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>
#define show for(int i=0;i<v.size();i++) cout << v[i] << " ";
#define eps 1e-6
#define mx 100008
using namespace std;

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

/*Knight Moves

int dx[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int dy[] = { 1, 2, 2, 1, -1, -2, -2, -1 }; */

/*Normal Moves

int x[] = {0, 1, 0, -1};
int y[] = {-1, 0, 1, 0}; */


int main()
{
   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);

    flash

    int n;
    cin >> n;

    map<string,int> m;
    map<string,int> :: iterator it;

    for(int i=1;i<=n;++i)
    {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        ++m[s];
    }

    ll cnt=0;

    for(it=m.begin();it!=m.end();++it)
    {
        ll x=it->second;
        cnt+=(x*(x-1))/2;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 11264
n = int(input())
dp = [[0] * 3 for _ in range(n + 1)]
abc = [list(map(int, input().split())) for _ in range(n)]
for i in range(1, n + 1):
    for j in range(3):
        dp[i][j] = max(dp[i- 1][(j + 1) % 3] + abc[i - 1][j], dp[i- 1][(j + 2) % 3] + abc[i - 1][j] )
print(max(dp[:][n]))

Measured memory_bytes: 51116
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	int N=S.size();
	int ans=0;
	for(int i=0;i<N/2;i++){
		if(S[i]!=S[N-i-1]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main() {

    string s,t;
    bool check = true;

    cin>>s>>t;

    if(s.length() + 1 == t.length()) {
        for(int i = 0; i < s.length(); i++ ) {
            if(s.at(i) != t.at(i)) {
                check = false;
                break;
            }
        }
    }

    if(check == false) {
        cout<< "No";
    }
    else {
        cout<< "Yes";
    }

}



Measured memory_bytes: 3640
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
        ll n;
        cin>>n;
        if(n==0 || n==1)
        cout<<"0"<<endl;
        else if(n%2==0)
        {
            ll p1 = n/2;
            ll ans =0;
            while(p1)
            {
                ans+=p1/5;
                p1/=5;
            }
            
        cout<<ans;
        }
        else
        {
            cout<<"0";
        }
         

      }
      






}












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

namespace ABC
{
    class ProgramD
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();
            var result = 0L;

            list.Sort((a, b) => b - a);

            // long right, left;
            // right = list[0];
            // left = list[0];

            // for (var i = 1; i < n; i++)
            // {
            //     if (right > left)
            //     {
            //         result += left;
            //         right = list[i];
            //     }
            //     else
            //     {
            //         result += right;
            //         left = list[i];
            //     }
            // }
            var t = n - 1;

            for (var i = 0; i < n; i++)
            {
                var count = i == 0 ? 1 : 2;
                for (var j = 0; j < count; j++)
                {
                    if (t > 0)
                    {
                        result += list[i];
                        t--;
                    }
                }
            }

            Console.WriteLine(result);
        }

    }
}


Measured memory_bytes: 47128
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if ((a*b) % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 1e9 + 7;

ll my_pow(ll n, ll m) {
    if (m == 0) return 1;
    ll now = my_pow(n, m / 2);
    if (m % 2 == 0) return (now * now) % mod;
    return (((now * now) % mod) * n) % mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> cnt(k + 1);
    for (int i = 1; i <= k; i++) cnt[i] = my_pow(k / i, n);
    for (int i = k; i > 1; i--) {
        for (int j = 1; j * j <= i; j++) {
            if (i % j != 0) continue;
            cnt[j] -= cnt[i];
            if (cnt[j] < 0) cnt[j] += mod;
            if (j * j != i && j != 1) cnt[i / j] -= cnt[i];
            if (cnt[i / j] < 0) cnt[i / j] += mod;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= k; i++) {
        ans += cnt[i] * i;
        ans %= mod;
    }
    cout << ans;
    return 0;
}



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

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

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

  cout << (s[0]==s[1] && s[1]!=s[2] && s[2]==s[3] ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N;
	scanf("%d",&N);
	
	int a[N];
	int i;
	for (i = 0; i < N; i++) {
		scanf("%d",&a[i]);
	}
	
	int b = a[0];
	for(i = 1; i <= N; i++) {
		if(b == 2) {
			printf("%d",i);
			break;
		}
		b = a[b-1];
		if(i == N && b != 2) {
			printf("-1");
		}
	}
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <regex>
using namespace std;
int main()
{
    int n, m, tmp, count;
    cin >> n >> m;
    // 文字列の入力
    string a[n], b[m], yes, no;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    // 出力
    yes = "Yes";
    no = "No";
    tmp = -1;
    count = 0;
    int i=0;
    for(int i=0; i<=n-m; i++){
        if(a[i].find(b[0])!=-1){
            tmp = a[i].find(b[0]);
            for(int j=0; j<=n-m; j++){
                if(a[i].substr(j, n).find(b[0])!=-1){
                    for(int k=0; k<m; k++){
                        if(a[i+k].substr(j, m).find(b[k])!=-1){
                            count++;
                            if(count>=m){
                                cout << yes << endl;
                                return 0;
                            }
                        }
                    }
                    count = 0;   
                }
            }
        }
    }
    cout << no << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d.sort()
t.sort()
index = 0
for i in range(m):
    if index >= n:
        print("NO")
        exit()
    while index < n and t[i] != d[index]:
        index += 1
    if index >= n:
        print("NO")
        exit()
    if t[i] != d[index]:
        print("NO")
    else:
        index += 1
print("YES")

Measured memory_bytes: 127828
import sys
sys.setrecursionlimit(10000000)
N, M = map(int, input().split())
ki = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)
tf = [False for _ in range(N)]

# DFS
def dfs(v):
    global eda
    tf[v] = True
    eda += 1
    for nv in set(ki[v]):
        if not tf[nv]:
            dfs(nv)

ans = 0
for i in range(N):
    if not tf[i]:
        eda = 0
        dfs(i)
        ans = max(ans, eda)
print(ans)

Measured memory_bytes: 258324
# -*- coding: utf-8 -*-
import math

X = int(input())
sq = int(math.sqrt(1000))

ans = 1
for i in range(2, sq+1):
    for j in range(2, sq+1):
        if i ** j <= X and ans < i ** j:
            ans = i ** j
            continue
print(ans)

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        int cnt = 0;

        for(int i = a; i <= b; i++){
            String s = String.valueOf(i);
            char[] c = s.toCharArray();
            if(c[0] == c[4] && c[1] == c[3]){
                cnt ++;
            }
        }

        System.out.println(cnt);
        
    }
}

Measured memory_bytes: 31956
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll ans, c;
int n;
ll x[100005], v[100005], m1[100005], m2[100005];

int main(void) {
    cin >> n >> c;
    rep(i, 1, n+1) scanf("%lld %lld", &x[i], &v[i]);

    ll Sv = 0;
    for (int i=n; i>=1; i--) {
        Sv += v[i];
        m2[i] = max(m2[i+1], Sv-(c-x[i]));
    }
    Sv = 0;
    for (int i=1; i<=n; i++) {
        Sv += v[i];
        m1[i] = max(m1[i-1], Sv-x[i]);
    }

    Sv = 0;
    for (int i=1; i<=n; i++) {
        Sv += v[i];
        ll t = max(Sv-x[i], Sv-x[i]*2+m2[i+1]);
        ans = max(ans, t);
    }

    Sv = 0;
    for (int i=n; i>=0; i--) {
        Sv += v[i];
        ll t = max(Sv-(c-x[i]), Sv-(c-x[i])*2+m1[i-1]);
        ans = max(ans, t);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
  int a;
  int b;
  cin >> a;
  cin >> b;
  int c = a*b;
  if (c%2==0){
    cout << "Even" << endl;
  }else{
      cout << "Odd" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////

int main() {
	int d, t, s; cin >> d >> t >> s;
	if (s*t < d) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
  ll N, M, K;
  cin >> N >> M >> K;

  vector<ll> A(N), B(M);

  for(ll i = 0; i < N; i++) {
    cin >> A[i];
  }

  for(ll i = 0; i < M; i++) {
    cin >> B[i];
  }

  vector<ll> sa(N + 1), sb(M + 1);

  for(ll i = 0; i < N; i++) {
    sa[i + 1] = A[i] + sa[i];
  }

  for(ll i = 0; i < M; i++) {
    sb[i + 1] = B[i] + sb[i];
  }
    
    ll ans = 0;
    ll j = M;
    ll max = M;
  for(ll i = 0; i < N + 1; i++) {
      
      while(sa[i] + sb[j] > K) {
        j--;
        if(j < 0) { j = max; break; }
      }
      if(sa[i] + sb[j] <= K) {
         max = j; 
        if(ans < i + j) ans = i + j;
         }
      
      
  }


  cout << ans;
  

  return 0;
}

Measured memory_bytes: 9568
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N, M int
	con.Scan(&N, &M)
	A := 0
	if N > M/2 {
		A = M / 2
	} else {
		M -= N * 2
		A = N + M/4
	}
	con.Println(A)
	return nil
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long int arr[1000009],arr1[1000009],dp[109][100009];
long long int f(int n,int w)
{
    if(n==0)
        return 0;
        if(dp[n][w]!=-1)
            return dp[n][w];
    if(w-arr[n]>=0)
        dp[n][w]=max((arr1[n]+f(n-1,w-arr[n])),f(n-1,w));


   else
    dp[n][w]=f(n-1,w);

    return dp[n][w];

}
int main()
{
    for(int i=0;i<109;i++)
    {

        for(int j=0;j<100009;j++)
                dp[i][j]=-1;
    }
    int n,w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
    {

        cin>>arr[i]>>arr1[i];
    }
     cout<<f(n,w);
}


Measured memory_bytes: 88320
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		double r = sc.nextDouble();
		
		System.out.printf("%.6f %.6f\n",r * r * Math.PI,(r*2) * Math.PI);
		sc.close();
	}
}


Measured memory_bytes: 28308
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

char a, b;

int main() {
    scanf("%c %c", &a, &b);

    if (a > b) cout << '>' << endl;
    else if (a < b) cout << '<' << endl;
    else cout << '=' << endl;
}


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

using namespace std;

#define foru(i, l, r) for(register int i = l; i <= r; i++)
#define ford(i, r, l) for(register int i = r; i >= l; i--)

int N, A[100005];

int main() {
  //  freopen("a.in", "r", stdin);
  //  freopen("a.out", "w", stdout);
  scanf("%d", &N);
  foru(i, 1, N) scanf("%d", &A[i]);
  int now_len = 0, Ans = 0, type = -1;
  now_len++;
  foru(i, 2, N) {
    if(now_len == 1) {
      now_len++;
      if (A[i] == A[i - 1])
        type = -1;
      else
        type = A[i] > A[i - 1];
      continue;
    }
    if(A[i] == A[i - 1]) {
      now_len++;
      continue;
    }
    if(type < 0) {
      now_len++;
      type = A[i] > A[i - 1];
      continue;
    }
    if(A[i] > A[i - 1] && type) {
      now_len++;
      continue;
    }
    if (A[i] < A[i - 1] && !type) {
      now_len++;
      continue;
    }
    Ans++, now_len = 1;
  }
  printf("%d\n", Ans + 1);
  return 0;
}


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

typedef long long lli;
const lli mod = 1000000007;

int vec2int(const vector<int> &x) {
    int ret = 0;
    for (auto v : x) ret = 10 * ret + (v+1);
    return ret;
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<int> init_op(w);
    for (int i = 0; i < w; i++) init_op[i] = i;

    lli op[8][8] = {};
    for (int i = 0; i < 1<<(w-1); i++) {
        bool ok = true;

        auto ret = init_op;
        for (int j = 0; j < (w-1); j++) {
            if (!(i >> j & 1)) continue;
            if (j && ((i >> (j-1)) & 1)) {
                ok = false;
                break;
            }
            swap(ret[j], ret[j+1]);
        }
        if (!ok) continue;

        for (int j = 0; j < ret.size(); j++) {
            op[j][ret[j]]++;
        }
    }

    vector<lli> pattern(w, 0);
    pattern[0] = 1;
    for (int step = 0; step < h; step++) {
        vector<lli> next_pattern(w, 0);
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < w; j++) {
                next_pattern[j] += ((pattern[i] % mod) * (op[i][j] % mod) % mod);
                next_pattern[j] %= mod;
            }
        }
        pattern = next_pattern;
    }
    cout << pattern[k-1] << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

p = 0
prev = -1
for i in A:
    p += B[i-1]
    if i - prev == 1:
        p += C[prev-1]
    prev = i
print(p)


Measured memory_bytes: 3060
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
//a,m=MOD MOD逆元
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,d;
    cin >> h >> w >> d;
    VV vec(h, V(w));
    rep(i, h) rep(j, w) cin >> vec[i][j];
    VP rec(h * w);
    rep(i,h)rep(j,w){
        rec[vec[i][j]-1] = {i,j};
    }
    VV temp(d);
    rep(i,d){
        for (int j = i; j <( h * w);j+=d){
            if(j==i){
                temp[i].push_back(0);
            }else{
                ll f = j - d;
                ll k = abs(rec[f].F - rec[j].F) + abs(rec[f].S - rec[j].S);
                temp[i].push_back(k);
            }
        }
        rep3(j,1,temp[i].size()){
            temp[i][j]+=temp[i][j-1];
        }
    }
  /*  rep(i,d){
        rep(j,temp[i].size()){
            cout<<temp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    ll q;
    cin >> q;
    rep(i,q){
        ll L, R;
        cin >> L >> R;
        L--;R--;
        ll k=L%d;
        cout << temp[k][R / d] - temp[k][L / d] << endl;
    }
}


Measured memory_bytes: 7552
#include<stdio.h>

int main(){
  double a, b, c, d, e, f;
  double list[100][2];
  int j=0;
  double x, y;
  while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f)!=EOF){
    x = (c*e - b*f) / (a*e - b*d);
    y = (a*f - c*d) / (a*e - b*d);
    if(x==-0)x=0;
    if(y==-0)y=0;
    list[j][0] = x;
    list[j][1] = y;
    j+=1;
  }
  int i;
  for(i=0; i<j; i++){
    printf("%.3lf %.3lf\n", list[i][0], list[i][1]);
  }
  return 0;
}

Measured memory_bytes: 652
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[q];
		for (int i = 0; i < q; i++) {
			a[i] = sc.nextInt();
		}
		int[] plus = new int[n];
		for (int i = 0; i < q; i++) {
			plus[a[i] - 1]++;
		}
		for (int i = 0; i < n; i++) {
			if (k + plus[i] - q <= 0) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 56892
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    i64 ret = 0;
    for(int r=0;r*R<=N;r++){
        for(int g=0;R*r+G*g<=N;g++){
            int k = N - (R*r + G*g);
            if(k % B == 0){
                // cout << r << " " << g << " " << k / B << endl;
                ret++;
            }
        }
    }
    cout << ret << endl;
    return 0;
}


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

int main()
{
   int n;
   cin >>n;
   int a;
   if (n % 1000 == 0)
   {
       cout <<"0";
   }
   else
   {
    a = n/1000;
    a += 1;
    int b = a * 1000;
    int c = b - n;
    cout << c;
   }
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

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

    int n, m;
    int l[100001], r[100001];
    int lm = -1;
    int rm = 1000000;
    int ans = 0;


    cin >> n >> m;
    for(int i = 0; i < m; i ++){
        cin >> l[i] >> r[i];
    }

    for(int i = 0; i < m; i ++){
        lm = max(lm,l[i]);
        rm = min(rm,r[i]);

    }

    if(lm > rm) cout << 0;
    else {
        for(int i = lm; i <= rm; i ++){
            ans++;
        }
        cout << ans;
    }


    return 0;
}









Measured memory_bytes: 4368
unittest
{
	assert( [ "1222" ].parse.expand.solve == 3 );
	assert( [ "3456" ].parse.expand.solve == 0 );
	assert( [ "9592" ].parse.expand.solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ns = input.front.strip.to!( dchar[] );
	return tuple( ns );
}

auto solve( dchar[] ns )
{
	return ns.count!( ( a ) => a == '2' );
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int cards[128][14] = {{0}};
    int i, N;
    scanf("%d", &N);
    for(i = 0; i < N; i++) {
        char c; 
        int cn;
        scanf("%c", &c);
        scanf("%c %d", &c, &cn);
        cards[c][cn] = 1;}

    for(i = 1; i <= 13; i++) {
        if(cards['S'][i] == 0) {
        printf("S %d\n", i);}}
    for(i = 1; i <= 13; i++) {
        if(cards['H'][i] == 0) {
        printf("H %d\n", i);}}
    for(i = 1; i <= 13; i++) {
        if(cards['C'][i] == 0) {
        printf("C %d\n", i);}}
    for(i = 1; i <= 13; i++) {
        if(cards['D'][i] == 0) {
        printf("D %d\n", i);}}

    return 0;
}



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

int main() {
    double v, t, y;
    while(cin >> v){
        t = v/9.8;
        y = 4.9*t*t;
        int ans = 1;
        while(double(ans-1)*5<y)ans++;
        cout << ans << endl;
    }
    return 0;
}   



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    x-=z;
    cout << x/(y+z) << endl;
}


Measured memory_bytes: 256