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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int sum[3][32];
int D[1000][1000];
int c[1000][1000];

int main() {
  int N, C; cin>>N>>C;
  for(int i = 1; i <= C; i++)
    for(int j = 1; j <= C; j++)
      cin>>D[i][j];
  for(int i = 1; i <= N; i++)
    for(int j = 1; j <= N; j++)
      cin>>c[i][j];
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= N; j++) {
      for(int color = 1; color <= C; color++) {
        int m =	(i+j)%3;
	int X =	c[i][j];
	sum[m][color] +=	D[X][color];
      }
    }
  }
  ll ans = 1LL<<60;
  for(int c1 = 1; c1 <= C; c1++) {
    for(int c2 = 1; c2 <= C; c2++) {
      if(c1==c2) continue;
      for(int c3 = 1; c3 <= C; c3++) {
        if(c1==c3) continue;
        if(c2==c3) continue;
	ll tmp = (ll)(sum[0][c1]+sum[1][c2]+sum[2][c3]);
	ans = min(ans, tmp);
      } 
    }
  }

  cout << ans << endl;
  return 0;
}


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

int main(){

    int N;
    cin >> N;
    vector<int> a(N+1);
    for(int i=1; i<=N; i++) cin >> a.at(i);

    vector<bool> used(N+1, false);

    int cnt = 0;
    int pos = 1;
    used.at(pos) = true;
    bool flg = false;
    while(true){
        pos = a.at(pos);
        cnt++;
        if(used.at(pos) == true) break;
//        cout << pos << endl;
        used.at(pos) = true;

        if(pos == 2){
            flg = true;
            break;
        }
    }

    if(flg) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main()
{
  long long L,R;
  long long res=INF;
  cin >> L >> R;

  long long divL, divR;

  divL = L/2019;
  divR = R/2019;

  if(divL==divR){
    for(int i=0; i<R-L; i++)//L
      for(int j=1; j<=R-L; j++){//R
        long long prod = (L+i)*(L+j);
        res = min(res, prod % 2019);
      }
  }
  else res = 0;
  
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] array = new String[999];
		int i = 0;
		
		while(sc.hasNext()){
			String num = sc.next();
				if(num.equals("0")){
					i--;
					System.out.println(array[i]);
					array[i] = "";
				} else {
					array[i] = num;
					i++;
				}
		}
	}
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	ll n, a, b, sum=0;
	cin >> n >> a >> b;
	range(i, 1, n + 1) {
		ll ans = (i / 10000) + (i / 1000 % 10) + ((i / 100) % 10) + ((i / 10) % 10) + (i % 10);
		if (a <= ans&&ans <= b) {
			sum += i;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
while True:
   n,x=map(int,input().split())
   if n==0 and x==0:
     break
   else:
     count=0
     for i in range(1,n-1):
       for j in range(i+1,n):
         for k in range(j+1,n+1):
           if i+j+k==x:
              count=count+1
     print(count)


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

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    string st;
    cin >> st;
    for(int i = 0; i < st.length()-1; i++){
        if(st[i] == 'A' && st[i+1] == 'C'){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 764
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;

int main(){
	IOS;
	ll n, k;
	cin >> n >> k;
	cout << n - k + 1;
	
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, x;
	do
		scanf("%d%d%d",&x,&a,&b);
	while (x < a + b || a < 1 || b < 1 || a>1000 || b>1000 || x>10000);
	x -= a;
	while (x - b >= 0)
		x -= b;
	printf("%d", x);
	return 0;
}

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

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

using namespace std;
int main() {
	char a, b;
	cin >> a >> b;
	if (a == b)
		cout << "=" << endl;
	else if (a < b)
		cout << "<" << endl;
	else
		cout << ">" << endl;

	return 0;
}

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

int main(){
	string s;
	cin>>s;
	ll cnt=0;
	for(int i=0;i<s.size();i++)cnt+=(s[i]-'0');
	if(cnt%9)cout<<"No";
	else cout<<"Yes";
	return 0;
}


Measured memory_bytes: 3756
n, a, b = map(int,input().split())
s_list = list(input())
judge=[]
count_tot = 0
count_inter = 0

for s in s_list:
    if s == 'a':
        if count_tot < a+b:
            judge.append('Yes')
            count_tot += 1
            continue
    elif s == 'b':
        if count_tot < a+b and count_inter < b:
            judge.append('Yes')
            count_tot += 1
            count_inter += 1
            continue
    judge.append('No')

for result in judge:
    print(result)

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

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

	int k = 1;
	string before, current;
	before = s[0];
	current = "";
	for (int i = 1; i < s.size(); i++) {
		current += s[i];
		if (before != current) {
			before = current;
			current = "";
			k++;
		}
	}
	cout << k << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << (a + b) / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(x+r<=W){
        	if(x-r>=0){
        		if(y+r<=H){
        			if(y-r>=0){
        				System.out.println("Yes");
        			}
        			else System.out.println("No");
        		}
        		else System.out.println("No");
        	}
        	else System.out.println("No");
        }
        else System.out.println("No");
	}

}


Measured memory_bytes: 26308
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
const int maxn=500001;
typedef long long ll;
map<ll,ll> cnt;
int p = 53;
const ll MOD = 1e9+7;
string s[301];

ll row_hash[301][301];
ll col_hash[301][301];
ll prep[301];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; ++i)
        cin>>s[i];
    for(int i=0; i<n; ++i){

        for(int j=0; j<n; ++j){
            row_hash[i][j+1]=(row_hash[i][j]*p+s[i][j]-'a'+1)%MOD;
            col_hash[i][j+1]=(col_hash[i][j]*p+s[j][i]-'a'+1)%MOD;
        }
    }
    prep[0]=1;
    for(int i=1; i<=n; ++i)
        prep[i]=prep[i-1]*p%MOD;
    int ans=0;
    for(int A=0; A<n; ++A){
        for(int B=0; B<n; ++B){
            bool good=true;
            for(int i=0; i<n; ++i){
                int row_ind=(i+A)%n;
                int col_ind=(i+B)%n;
                ll row_st=B;
                ll col_st=A;
                ll r_hash=(row_hash[row_ind][row_st]+(row_hash[row_ind][n]-row_hash[row_ind][row_st]*prep[n-B]%MOD)*prep[B]%MOD)%MOD;
                if (r_hash<0)
                    r_hash+=MOD;
                ll c_hash=(col_hash[col_ind][col_st]+(col_hash[col_ind][n]-col_hash[col_ind][col_st]*prep[n-A]%MOD)*prep[A]%MOD)%MOD;
                if (c_hash<0)
                    c_hash+=MOD;
                if (c_hash!=r_hash)
                    good=0;
            }
            ans+=good;
        }
    }
    cout<<ans;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	if (a > b || (n == 1 && a != b)) cout << 0 << endl;
	else if (n == 1) cout << 1 << endl;
	else cout << 1LL * (b - a) * (n - 2) + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }



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

    ll a, b;
    cin >> a >> b;

    if (abs(b - a) % 2ll == 1) {
        cout << "IMPOSSIBLE" << "\n";
        return 0;
    }

    if ((a - b) > 0)
    {
        swap(a, b);
    }

    ll ans = (b - a) / 2ll + a;
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int INF=-1000000;
int main(){
	int n,m;
	cin>>n>>m;
	int maxx=INF;
	int a=n+m;
	maxx=max(a,maxx);
	int b=n*m;
	maxx=max(b,maxx);
	int c=n-m;
	maxx=max(c,maxx);
	cout<<maxx<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<queue>
#include<algorithm>
using namespace std;
long s[1000000];
bool flag[10000][2];
int main(){
    long n;
    cin >> n;
    long cnt=0;
    for(long i=1; (i*i)<n; i++){
        if( n%i==0 ) {s[cnt]=i; cnt++; }
    }
    long res=0;
    for(long i=0; i<cnt; i++){
        long tmp = n-s[i];
        if( tmp%s[i] == 0 ) 
            if( tmp/s[i] > s[i])
                {res+=(n-s[i])/s[i];}
    }
    cout << res << endl;;
    return 0;
}


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

int main() {
    int n, flag, check;
    cin >> n;
    int p[n];
    flag = 1;
    check = -1;
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        if((check == -1) && (p[i] != i + 1)) {
            check = p[i];
        } else if((check != -1) && (p[i] != i + 1)) {
            if(i + 1 != check) {
                flag = 0;
            }
        }
    }
    if(flag) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define North 0
#define East 1
#define West 2
#define South 3
#define No 4

int src[5][2]={{-1,0},{0,1},{0,-1},{1,0},{0,0}};

class Pair{
public:
	Pair(){x=y=0;}
	void move(int t){
		x+=src[t][0];
		y+=src[t][1];
	}
	int x,y;
};

int main(){
	while(1){
		int h,w;
		bool stop=false;
		Pair pos;
		char c[101][101];
		scanf("%d%d",&h,&w);
		if(!h&&!w) break;
		for(int i=0;i<h;i++) scanf("%s",c[i]);
		while(!stop){
			Pair tmp=pos;
			switch(c[pos.x][pos.y]){
			case '^':
				pos.move(North);
				break;
			case '>':
				pos.move(East);
				break;
			case '<':
				pos.move(West);
				break;
			case 'v':
				pos.move(South);
				break;
			case '.':
				stop=true;
				printf("%d %d\n",pos.y,pos.x);
				break;
			case 0:
				stop=true;
				printf("LOOP\n");
			}
			c[tmp.x][tmp.y]=0;
		}
	}
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

bool piya(P p, P q) {
	if (p.first != q.first)return p.first < q.first;
	else return p.second > q.second;
}

int n, l[100010], r[100010];
vector<P> vec;
int mal, mir = 1000000000, ma;
int rmi[100010];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i] >> r[i];
		r[i]++;
		ma = max(ma, r[i] - l[i]);
		mal = max(mal, l[i]);
		mir = min(mir, r[i]);
	}
	ans = ma + max((int)0, mir - mal);
	for (int i = 0; i < n; i++)vec.push_back(make_pair(r[i] - mal, mir - l[i]));
	sort(all(vec), piya);
	rmi[n - 1] = vec[n - 1].first;
	for (int i = n - 2; i >= 0; i--)rmi[i] = min(rmi[i + 1], vec[i].first);
	int mi = 1000000000;
	for (int i = 0; i < n - 1; i++) {
		mi = min(mi, vec[i].second);
		ans = max(ans, mi + rmi[i + 1]);
	}
	cout << ans << endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (true) {
		if (C-B<=0) {
			cey;
			break;
		}
		C -= B;
		if (A-D<=0) {
			cen;
			break;
		}
		A -= D;
	}

    return 0;
}



Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int d;

bool ok(int n, int m) {
    if (abs(n - m) <= d) {
        return true;
    }
    else {
        return false;
    }
}

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

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

using namespace std;

typedef long long ll;
const ll INF = 1e15;

class max_flow {
	struct edge {
		ll to, cap, rev;
		edge(ll to_, ll cap_, ll rev_) : to(to_), cap(cap_), rev(rev_) {};
	};

	ll V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	ll DFS(int v, int t, ll f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				ll d = DFS(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	max_flow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, ll cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	ll dinic(int s, int t) {
		ll flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			ll f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};

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

    int n;cin>>n;
    vector<ll> a(n+1);
	ll sum=0;
	max_flow mf(n+2);
    for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<=0){
			mf.add(0,i,-a[i]);
		}
		else{
			sum += a[i];
			mf.add(i,n+1,a[i]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=2;i*j<=n;j++){
			mf.add(i,i*j,INF);
		}
	}
	cout<<sum-mf.dinic(0,n+1)<<endl;

}


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

using namespace std;

const int mod = 1e9 + 7;
const int N = 5001;

int sum(int a, int b) {
	if ((a += b) >= mod) {
		a -= mod;
	}
	return a;
}

int n, m;
int dp[N][N];
int pw2[N];
int suf_dp[N][N + 1];

int main() {
	pw2[0] = 1;
	for (int i = 1; i < N; i++) {
		pw2[i] = sum(pw2[i - 1], pw2[i - 1]);
	}
	cin >> n >> m;
	dp[0][m] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = m; j >= 1; j--) {
			dp[i][j] = sum(1LL * (j + 1) * dp[i - 1][j] % mod, 1LL * j * suf_dp[i - 1][j + 1] % mod);
			suf_dp[i - 1][j] = sum(sum(suf_dp[i - 1][j + 1], suf_dp[i - 1][j + 1]), dp[i - 1][j]);
			/*for(int p = m; p >= j + 1; p--) {
				dp[i][j] = sum(dp[i][j], 1LL * dp[i - 1][p] * pw2[p - j - 1] % mod * j % mod);
			}*/
		}
	}
	int ans = 0;
	for (int rem = 1; rem <= m; rem++) {
		ans = sum(ans, dp[n][rem]);
	}
	cout << ans;
}


Measured memory_bytes: 199032
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np

# A = input()
A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()


print(A/3 * A/3 * (A-(A/3)*2))

Measured memory_bytes: 12388
#include "bits/stdc++.h"
#define inf 0x3f3f3f3f
#define pb push_back
#define vi vector<int>
#define fi first
#define se second 
#define mp make_pair
typedef unsigned long long ull;
//typedef pair<int,int> P;
#define LL long long 
#define pi acos(-1)
#define MOD 998244353
typedef long long ll;
using namespace std;
const int maxn = 100005; 
const char p[]="AGC";
int main(){
	int n,k;
	cin>>n>>k;
	puts(n<2*k-1?"NO":"YES");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<algorithm>
#include<math.h>

using namespace std;
int max(int a, int b, int c)
{
	int d;
	d = (a < b) ? b : a;
	d = (d < c) ? c : d;
	return d;
}
int a, b, c, k;
int main()
{
	while (std::cin >> a >> b >> c >> k)
	{
		int sum = a + b + c;
		//		int m = std::max(a, b, c);
		int m = max(a, b, c);
		std::cout << sum - m + m*pow(2, k) << std::endl;
	}
	return 0;
}

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

#define int long long

void fastio() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

const int MOD = (int)1e9 + 7;
#define MAX 100010
int dpa[MAX];
int dpb[MAX];

int B(vector<vector<int> > &G, int node, int parent);

int A(vector<vector<int> > &G, int node, int parent) {
	if (dpa[node] != -1) return dpa[node];
	int ans = 1;
	for (const auto &child : G[node]) {
		if (child == parent) continue;
		ans = ans * B(G, child, node);
		ans %= MOD;
	}
	dpa[node] = ans;
	return ans;
}

int B(vector<vector<int> > &G, int node, int parent) {
	if (dpb[node] != -1) return dpb[node];
	int ans = 1;
	for (const auto &child : G[node]) {
		if (child == parent) continue;
		ans = ans * (A(G, child, node) + B(G, child, node)) % MOD;
		ans %= MOD;
	}
	dpb[node] = ans;
	return ans;
}

void setup() {
	for (int i = 0; i < MAX; ++i) {
		dpa[i] = -1;
		dpb[i] = -1;
	}
}

#undef int
int main(int argc, char const *argv[])
{
	#define int long long
	setup();
	int n;
	cin >> n;
	vector<vector<int> > G(n + 1);
	vector<int> parent(n + 1, -1);

	for (int i = 0; i < n - 1; ++i)  {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int root = 1;
	cout << (A(G, root, 1) + B(G, root, 1))%MOD << endl;
	return 0;
}

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

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


Measured memory_bytes: 3080
#include<iostream>
#include<string>
 
using namespace std;
int main(){
    int N;cin>>N;
    int a[N];for(int i=0;i<N;i++)cin>>a[i];
 
    int max=-1;
    int min=1000000000;
 
    for(int i=0;i<N;i++){
        if(max<a[i])max=a[i];
        if(min>a[i])min=a[i];
    }
    cout<<abs(max-min)<<endl;
 
}

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

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int X;
  cin >> X;
  if (X < 1200) printf("ABC");
  else printf("ARC");

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<LL> VL;

int main() {
	string s; cin >> s;
	int cnt = 0, mae = -1;
	for (int i = 0; i < sz(s); i++) {
		//cout << i << "->";
		if (mae != -1) {
			i = mae;
			mae = -1;
		}
		//cout << i << endl;

		if (i != sz(s)-1 && s[i] != s[i + 1]) {
			s.erase(i, 2);
			cnt += 2;
			//cout << "erase -> i:" << i << " str:" << s << endl;
			mae = max(i - 1, 0);
			i = max(i - 1, 0);
			//cout << "erase_i" << i << endl;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define R real()
#define I imag()
using namespace std;
typedef complex <double> point;
struct S{
  double x,y,z,r;
  S(){x=y=z=r=0;}
  S(double x,double y,double z,double r):x(x),y(y),z(z),r(r){};
};

S s[2001],b[20],E;
vector <int> B[20];

double get_dis(S a,S b){
  a.x-=b.x,a.y-=b.y,a.z-=b.z;
  return sqrt(a.x*a.x+a.y*a.y+a.z*a.z);
}

bool check(S s,S p){
  S res;
  point A=point(s.x,s.y),B=point(p.x,p.y);
  if(abs(A))B*=(conj(A)/abs(A));
  res.y=B.I;

  A=point(abs(A),s.z),B=point(B.R,p.z);
  if(abs(A))B*=(conj(A)/abs(A));
  res.x=B.R,res.z=B.I;
  
  double X=get_dis(s,S(0,0,0,0)),r=0;
  if(res.x<0) r=get_dis(res,S(0,0,0,0));
  else if(X<res.x) r=get_dis(res,S(X,0,0,0));
  else r=sqrt(res.z*res.z+res.y*res.y);
  if(max(get_dis(res,S(0,0,0,0)),get_dis(res,S(X,0,0,0)))<=p.r)return 0;
  return p.r>=r;
  
}

double cal(S a){return a.r/((a.x*a.x)+(a.y*a.y)+(a.z*a.z));}

int main(){
  int n,m,r;
  while(1){
    cin>>n>>m>>r;
    if(!n&&!m&&!r)break;

    for(int i=0;i<n;i++)cin>>s[i].x>>s[i].y>>s[i].z>>s[i].r;
    for(int i=0;i<m;i++)cin>>b[i].x>>b[i].y>>b[i].z>>b[i].r;
    cin>>E.x>>E.y>>E.z;
    for(int i=0;i<n;i++)s[i].x-=E.x,s[i].y-=E.y,s[i].z-=E.z;
    for(int i=0;i<m;i++)b[i].x-=E.x,b[i].y-=E.y,b[i].z-=E.z;

    for(int i=0;i<m;i++){
      B[i].clear();
      for(int j=0;j<n;j++)
	if(check(b[i],s[j]))B[i].push_back(j);
    }


    double ans=0;
    for(int i=0;i<(1<<m);i++){
      int used[2001]={},cnt=0;
      double sum=0;
      for(int j=0;j<m;j++){
	if(!((i>>j)&1))continue;
	for(int k=0;k<B[j].size();k++)cnt+=!used[B[j][k]],used[B[j][k]]=1;
	if(cnt>r)break;
	sum+=cal(b[j]);
      }
      ans=max(ans,sum);
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1484
s = list(input())
N = len(s) - 1

ans = 0
for i in range(2 ** N):
    e = 0
    for j in range(N+1):
        ans += int(s[-(j+1)]) * (10 ** e)
        e += 1
        if ((i >> j) & 1):
            e = 0

print(ans)


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

#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);


#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
using namespace std;

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


int main(){
    ll a,b,res=0;
    cin >>a>>b;
    if(a == 1 ){
        res+=300000;
    }
    if(a == 2 ){
        res+=200000;
    }
    if(a == 3 ){
        res+=100000;
    }
    if(b == 1 ){
        res+=300000;
    }
    if(b == 2 ){
        res+=200000;
    }
    if(b == 3 ){
        res+=100000;
    }
    if(a==1 && b==1)res+=400000;
    cout<<res;
    return 0;
}




















/*
int main(){
    double a ,b;
    cin>>a>>b;
    ll res =0;
    while(1){
        if(a > b){
            cout<<"t1\n";

            ll k = a /b;
            a -= (b*k);
            res+=k;
        }
        if(a < b){
            cout<<b;
            ll k = b/a;
            b -= (a*k);
            res+=k;
        }
        if(a ==b){
            res++;
            break;
        }
    }



    cout<<res;
    return 0;
}
*/

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

using namespace std;

int main() {
    int S, h, m ,s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1164
#include <iostream>
   
using namespace std;
   
int main(){
int x;
int y;
cin >> x >> y;
while(x || y)
{
if( x > y){
int tmp = x;
x = y;
y = tmp;
}
cout << x << " " << y << endl;
cin >> x >> y;
}
return 0;
}


Measured memory_bytes: 2960
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int a[400], b[400];
int n, c;
//1~jのi乗
ll sum[401][401];
bool chked[400][401];
ll memo[400][401];
ll calc(int id, int s) {
	if (s < 0)return 0;
	if (chked[id][s])return memo[id][s];
	if (id == n - 1) {
		return (sum[s][b[id]] - sum[s][a[id] - 1]+mod)%mod;
	}
	ll res = 0;
	rep(i, s + 1) {
		res = (res + (sum[i][b[id]] - sum[i][a[id] - 1] + mod)%mod*calc(id+1,s-i)%mod) % mod;
	}
	chked[id][s] = true; memo[id][s] = res; return res;
}
void init() {
	rep(i,401){
		ll csum = 0;
		rep1(j, 400) {
			ll c = 1;
			rep(k, i)c = c * j%mod;
			csum = (csum + c) % mod;
			sum[i][j] = csum;
		}
	}
}
int main() {
	init();
	cin >> n >> c;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	cout << calc(0, c) << endl;
	return 0;
}

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

int main() {
    int H, W;
    bool isSharp = true;
    cin >> H >> W;
    while (true) {
        for (int i = 0; i < H; i++) {
            if (i % 2 == 0) {
                isSharp = true;
            } else {
                isSharp = false;
            }
            for (int j = 0; j < W; j++) {
                if (isSharp) {
                    cout << "#";
                } else {
                    cout << ".";
                }
                isSharp = !isSharp;
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
    }
}


Measured memory_bytes: 3092
#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 < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if (k == 1) cout << 0 << endl;
    else cout << n - k << endl;
    
    return 0;
}



Measured memory_bytes: 256
# cook your code here
from collections import defaultdict
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
d={}
a=[0]+a
d = defaultdict(list) 
for i in range(m):
    u,v=map(int,raw_input().split())
    


    d[u].append(a[v]) 
    d[v].append(a[u]) 
      
    


c=0
#print d
for i in range(1,n+1):
	if i in d:
		if a[i]>max(d[i]):
			c+=1
	
	else:
		c+=1

print c
	

Measured memory_bytes: 100340
#include<stdio.h>
#include<stdlib.h>

int main(int argc, const char * argv[]){
    int i,ex1,ex2,ex3,ex4,a;
    int dice_1[7],dice_2[7];
    int w;
    
    for(i = 1;i <= 6;i++){
        scanf("%d",&dice_1[i]);
    }
    
    for(i = 1;i <= 6;i++){
        scanf("%d",&dice_2[i]);
    }
    
    for(i = 0;i < 10000;i++){
        w = rand() % 4;
        if(w == 0){
            ex1 = dice_1[1];
            ex2 = dice_1[2];
            ex3 = dice_1[5];
            ex4 = dice_1[6];
            dice_1[1] = ex3;
            dice_1[2] = ex1;
            dice_1[5] = ex4;
            dice_1[6] = ex2;
        }else if(w == 1){
            ex1 = dice_1[1];
            ex2 = dice_1[2];
            ex3 = dice_1[5];
            ex4 = dice_1[6];
            dice_1[1] = ex2;
            dice_1[2] = ex4;
            dice_1[5] = ex1;
            dice_1[6] = ex3;
        }else if(w == 2){
            ex1 = dice_1[1];
            ex2 = dice_1[3];
            ex3 = dice_1[4];
            ex4 = dice_1[6];
            dice_1[1] = ex3;
            dice_1[3] = ex1;
            dice_1[4] = ex4;
            dice_1[6] = ex2;
        }else if(w == 3){
            ex1 = dice_1[1];
            ex2 = dice_1[3];
            ex3 = dice_1[4];
            ex4 = dice_1[6];
            dice_1[1] = ex2;
            dice_1[3] = ex4;
            dice_1[4] = ex1;
            dice_1[6] = ex3;
        }
        for(a = 1;a <= 6;a++)
            if(dice_1[a] != dice_2[a])
                break;
        if(a == 7){
            printf("Yes\n");return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2104
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C
 */
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

bool
isprime(const int n, set<int> &known)
{
    int checked;
    for (auto& it : known) {
        if (n == it) {
            return true;
        } else if (n % it == 0) {
            return false;
        }
        checked = it;
    }
    for (int i = checked + 2; i * i <= n; i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

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

    set<int> knownprimes{2, 3, 5, 7};

    set<int> given;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a; cin.ignore();
        given.insert(a);
    }
    int count = 0;
    for (auto& it : given) {
        if (isprime(it, knownprimes)) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3472
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        for(int i = 0; i < str.length(); i++){
            switch(str){
                case "A":
                    p("T") ;
                    break;
                case "T":
                    p("A");
                    break;
                case "G":
                    p("C");
                    break;
                case "C":
                    p("G");
                    break;
                default:
            }


        }
    }

    public static void p(String s){
        System.out.print(s);
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int a[2010][2010], b[2010][2010];

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

    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
        {
            if (s[j] == '#')
                a[i][j] = b[i][j] = -INF;
            else
                a[i][j] = b[i][j] = 1;
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w - 1; j++)
        {
            if (a[i][j + 1] == -INF)
                continue;
            a[i][j + 1] += max(0LL, a[i][j]);
        }
    }
    for (int i = 0; i < h; i++)
    {
        int num = -INF;
        for (int j = w - 1; j >= 0; j--)
        {
            if (a[i][j] == -INF)
            {
                a[i][j] = 0;
                num = -INF;
                continue;
            }
            a[i][j] = max(a[i][j], num);
            num = max(num, a[i][j]);
        }
    }
    for (int i = 0; i < w; i++)
    {
        for (int j = 0; j < h - 1; j++)
        {
            if (b[j][i] == -INF)
                continue;
            b[j + 1][i] += max(0LL, b[j][i]);
        }
    }
    for (int i = 0; i < w; i++)
    {
        int num = -INF;
        for (int j = h - 1; j >= 0; j--)
        {
            if (b[j][i] == -INF)
            {
                b[j][i] = 0;
                num = -INF;
                continue;
            }
            b[j][i] = max(b[j][i], num);
            num = max(num, b[j][i]);
        }
    }
    int ans = 1;
    rep(i, h)
    {
        rep(j, w)
        {
            ans = max(ans, a[i][j] + b[i][j] - 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 63232
#!/usr/bin/perl
#A - Pair

use strict;
use warnings;

my ($ret) = 0;

# データ取得
my ($end);
{
    my ($data) = <STDIN>;
    chomp($data);
    ($end) = split(/ / , $data);
}

my ($i,$j);
my ($odd);

for ($i = 1 ; $i < ($end) ; $i++) {

    $odd = ($i & 0x01);   # 奇数

    for ($j = ($i+1) ; $j <= $end ; $j++) {

        # 奇数 と偶数である
        if ($odd != ($j & 0x01)) {
            $ret++;
        }

    }
}

print("$ret\n");

exit(0);


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int n;
  ll sum = 0;
  cin >> n;
  vector<int> v(n);
  map<int,ll> mp;
  vector<ll> s(n+1,-1);
  REP(i,n){
    cin >> v[i];
    mp[v[i]]++;
  }
  for(auto au : v){
    if(s[au] != -1)continue;
    if(mp[au] == 0 || mp[au] == 1){
      s[au] = 0;
    }else{
      s[au] = mp[au] - 1;
      sum += mp[au]*(mp[au]-1)/2;
    }
  }
  REP(i,n){
    cout << sum - s[v[i]] << endl;
  }



  return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

vector<ll> divisor;
void find_divisor(ll N) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}
int main() {
  ll N;
  cin >> N;
  find_divisor(N);
  ll ans = longinf;
  for(ll d: divisor) ans = min(ans, d + N / d - 2);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<long long>q;
	vector<long long>p;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		q.push_back(x + y);
		p.push_back(y - x);
	}
	long long a = *max_element(q.begin(), q.end()) - *min_element(q.begin(), q.end());
	long long b = *max_element(p.begin(), p.end()) - *min_element(p.begin(), p.end());
	cout << max(a,b);
	return 0;
}

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

#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    string s; cin >> s;
    cout << s.front() << s.length()-2 << s.back() << endl;
}


Measured memory_bytes: 256
ABCD=str(input())
A=int(ABCD[0])
B=int(ABCD[1])
C=int(ABCD[2])
D=int(ABCD[3])
listA=[A,B,C,D]
for i in range(2**3):
    listn=[0]*3
    for j in range(3):
        if ((i>>j)&1):
            listn[j]=1
    num=A
    for k in range(3):
        if listn[k]==0:
            num+=listA[k+1]
            listn[k]="+"
        elif listn[k]==1:
            num-=listA[k+1]
            listn[k]="-"
    if num==7:
        print(str(A)+listn[0]+str(B)+listn[1]+str(C)+listn[2]+str(D)+"=7")
        break

Measured memory_bytes: 3064
A,B,C,X,Y = map(int,input().split())
a = A*X+B*Y
Z = max(X,Y)
z = min(X,Y)
b = 2*Z*C
if X >= Y:
    c = A*(X-Y)+2*C*Y
else:
    c = B*(Y-X)+2*C*X
print(min(a,b,c))

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
n=int(input())
AB=[list(map(int,input().split())) for _ in range(n)]
AB.sort(key=lambda x: (x[1],-x[0]))
time=0
for a,b in AB:
    time+=a
    if time>b:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 86236
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

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

typedef long long lint;
typedef pair<int,int> P;

int main()
{

    int N,Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    int l[100010];
    int r[100010];

    REP(i,Q){
    	cin >> l[i] >> r[i];
    }

    int left[100010]={0};
    int num_ac = 0;
    FOR(i,2,N+1){
    	if(S[i-2]=='A' && S[i-1]=='C'){
    		num_ac ++;
    	}
    	left[i] = num_ac;
    }

    FOR(i,0,Q){
    	lint ans;

    	ans = left[r[i]]-left[l[i]];

    	cout << ans << endl;
    }




}


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

int N,M;


int main(void){
  cin >> N >> M;
  vector<int> X(M);
  vector<int> L(M-1);
  int i,sum=0;
  for(i=0; i<M;i++) cin >> X[i];

  if(N >= M) cout << 0 << endl;
  else{
    sort(X.begin(),X.end());
    for(i=0;i<M-1;i++) L[i] = X[i+1] - X[i];
    sort(L.begin(),L.end());
    for(i=0;i<M-N;i++) sum+=L[i];
    cout << sum << endl;
  }

  return 0;
}

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

int main() {
  string a;
  int n;
  cin >> a;
  if(a=="RRR")
    n=3;
  if(a=="RRS" || a=="SRR")
    n=2;
  if(a=="RSR" || a=="SSR" || a=="RSS" || a=="SRS")
    n=1;
  if(a=="SSS")
    n=0;
  cout << n << endl;
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  ll cnt=0;
  while(n>0){
    n/=k;
    cnt++;
  }
  cout<<cnt<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	double degree1,degree2;
	scanf("%lf %lf",&degree1,&degree2);

	if(degree1 > degree2)swap(degree1,degree2);

	if(degree2-degree1 < 180.0){
		printf("%.10lf\n",(degree1+degree2)/2);
	}else{
		degree2 = degree2 - 360.0;

		double ans = (degree1+degree2)/2;
		if(ans < 0){
			ans += 360.0;
		}

		printf("%.10lf\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
string s;
string ans;
int use[MAXN];
int check(){
    REP(i,0,10)use[i]=0;
    REP(i,0,n-1)use[s[i]-'a']++;
    int sum;
    REP(i,0,10)if(use[i])sum++;
    return sum;
}
void change(){
    int tmp=check();
    PER(i,n-1,0){
        if(s[i]-'a'<=tmp&&use[s[i]-'a']>1){
            s[i]++;
            REP(j,i+1,n-1)s[j]='a';
            break;
        }
    }
}
int main(){
    cin>>n;
    REP(i,0,n-1){
        ans.push_back('a'+i);
        s.push_back('a');
    }
    cout<<s<<endl;
    while(ans!=s){
        change();
        cout<<s<<endl;
    }
}

Measured memory_bytes: 3584