akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            for(int i = input[0]; i < input[1]+1; i++)
            {
                if (input[2] % i == 0) count++;
            }

            Console.WriteLine(count);
                
         }
    }
}



Measured memory_bytes: 18456
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 200000
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

vector< int > graph[MAX_N];
map< int, int > counter;

void dfs(int v, int p, int a, map< int, int >& c){
  c[v] = a + counter[v];
  for(int w: graph[v]){
    if(w != p) dfs(w, v, c[v], c);
  }
}

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

  int n, q;
  cin >> n >> q;
  int a[n - 1], b[n - 1];
  for(int i = 0; i < n - 1; i++){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }
  int p[q], x[q];
  for(int i = 0; i < q; i++){
    cin >> p[i] >> x[i];
    --p[i];
  }

  for(int i = 0; i < n - 1; i++){
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }

  for(int i = 0; i < q; i++){
    counter[p[i]] += x[i];
  }

  map< int, int > ans;
  dfs(0, -1, 0, ans);

  string buf;
  for(int i = 0; i < n; i++){
    buf += to_string(ans[i]) + " ";
  }

  cout << buf << endl;

  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
vector<vector<ll>>e(100100);
pair<ll,ll> dfs(int now,int par){
  ll white=1;
  ll black=1;
  for(int i=0;i<e[now].size();i++){
    if(par==e[now][i])continue;
    pair<ll,ll> hoge=dfs(e[now][i],now);
    white*=(hoge.F+hoge.S);
    white%=MOD;
    black*=(hoge.F);
    black%=MOD;
  }
  return mp(white,black);
}
int main(){
  int n;cin>>n;
  for(int i=0;i<n-1;i++){
    int x,y;cin>>x>>y;
    e[--x].pb(--y);
    e[y].pb(x);
  }
  pair<ll,ll> ans=dfs(0,0);
  cout<<(ans.F+ans.S)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
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()
{
    ll N, K;
    cin >> N >> K;

    COMinit();

    ll ans = COM(N + N - 1, N - 1);
    repd(i, K + 1, N) {
        ans -= COM(N, i) * COM(N - i - 1 + i, N - i - 1);
        ans %= MOD;
        if (ans < 0) ans += MOD;
    }

    // if (K % 2) ans--;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}

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

int main(){
    ll H, W, cnt = 0;
    cin >> H >> W;
    char board[H][W];
    memset(board, '.',sizeof(board));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> board[i][j];
            if(board[i][j] == '#') cnt++;
        }
    }
    bool flag = true;
    if(cnt != H + W - 1){
        flag = false;
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(board[i][j] == '.') continue;
            if(i + 1 != H && board[i + 1][j] == '#'){

            }else if(j + 1 != W && board[i][j + 1] == '#'){

            }else if(i + 1 == H && j + 1 == W){
            }else{
                flag = false;
            }
        }
    }

    if(flag){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);}
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans+= d.at(i)*d.at(j);
    }
  }
   cout<<ans<<endl;
  
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  double A, B;
  cin >> A >> B;

  if(A > B){
    cout << "GREATER" << endl;
  }else if(A < B){
    cout << "LESS" << endl;
  }else{
    cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin >> H >> N;
  vector<int> v(N);
  int d = 0;
  for(int i = 0;i<N;i++){
    cin >> v.at(i);
    d += v.at(i);
  }
  if(d >= H){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
    
  }

Measured memory_bytes: 640
x1,y1,x2,y2 = map(int,input().split())

dx = x2 - x1
dy = y2 - y1

nx1 = -dy
ny1 = dx
nx2 = -ny1
ny2 = nx1

print(x2+nx1,y2+ny1,x2+nx1+nx2,y2+ny1+ny2)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main () {
    // input
    int num_cards = 0;
    cin >> num_cards;
    
    string str_taro, str_hanako;
    int points_taro = 0;
    int points_hanako = 0;
    for (int i=0; i<num_cards; i++) {
        cin >> str_taro >> str_hanako;

        // think
        if (str_taro > str_hanako) {
            points_taro += 3;
        } else if (str_taro < str_hanako) {
            points_hanako += 3;
        } else {
            points_taro += 1;
            points_hanako += 1;
        }
    }

    // output
    cout
        << points_taro
        << " "
        << points_hanako << endl;
}


Measured memory_bytes: 3216
n,h=gets.chomp.split.map(&:to_i)
ab=[]
n.times do
  a,b=gets.chomp.split.map(&:to_i)
  ab << [a,'a']
  ab << [b,'b']
end
ab.sort!.reverse!

ans=0
ab.each do |v, c|
  if c=='b'
    h-=v
    ans += 1
    if h <= 0
      break
    end
  else
    ans += (h.to_f/v).ceil
    break
  end
end
puts ans


Measured memory_bytes: 29028
#include <stdio.h>
#include <algorithm>
using namespace std;

inline int pow2(int x){
	return ( 1 << x );
}

int main(){
	int n,dp[1<<17],t[20][20];
	for( ; scanf("%d",&n),n ; printf("%d\n",dp[pow2(n)-1]) ){
		for(int i=0 ; i < pow2(n) ; i++ ){
			dp[i] = 1<<30;
		}
		
		for(int j=0 ; j < n ; j++ ){
			for(int i=0 ; i < n+1 ; i++ ){
				scanf("%d",t[j]+i);
			}
		}
		
		//Xe[Wð0ÂNA·éÌÉ©©éÔÍ0
		dp[0] = 0;
		for(int T=0 ; T < pow2(n) ; T++ ){
			for(int j=0 ; j < n ; j++ ){
				for(int i=0 ; i < n ; i++ ){
					//TÉÂ¢ÄXe[Wj+1ðNAµÄ¢È©Á½ç
					if( !( T & pow2(j) ) ){
						//TÉÂ¢Ä·ÅÉXe[Wi+1ÌíðÁÄ¢½ç
						if( T & pow2(i) ){
							dp[T+pow2(j)] = min( dp[T+pow2(j)] , dp[T]+t[j][i+1] );
						}else{
							dp[T+pow2(j)] = min( dp[T+pow2(j)] , dp[T]+t[j][0] );
						}
					}
				}
			}
		}
		;
	}
}

Measured memory_bytes: 1016
# coding: utf-8 
n = int(input())
ans = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

for x in make_divisors(n):
    if x > 2 and n//(x-1) == n%(x-1):
        ans += x-1
print(ans)

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

int main()
{
  int n, k, i = 0, ans=1, count=0;
  cin >> n >> k;
  while(count < n)
  { 
    if(ans * 2 < ans + k) ans *= 2; 
    else ans += k;
    count++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
struct
{
    ll x,y;
}a[100];
int n,K;

int main()
{
    cin >> n >> K;
    for (int i = 1; i <= n; ++i)
        cin >> a[i].x >> a[i].y;
    ll ans = (1LL<<62);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            for (int k = 1; k <= n; ++k)
                for (int l = 1; l <= n; ++l)
                {
                    ll ix = min(min(a[i].x, a[j].x),min(a[k].x,a[l].x));
                    ll ax = max(max(a[i].x, a[j].x),max(a[k].x,a[l].x));
                    ll iy = min(min(a[i].y, a[j].y),min(a[k].y,a[l].y));
                    ll ay = max(max(a[i].y, a[j].y),max(a[k].y,a[l].y));

                    int now = 0;
                    for (int e = 1; e <= n; ++e)
                        now += (a[e].x>=ix && a[e].x<=ax && a[e].y>=iy && a[e].y<=ay);
                  //  cout<<ix<<' '<<ax<<' '<<iy<<' '<<ay<<' '<<now<<endl;
                    if (now>=K)
                    {
                        //cout<<now<<' '<<(ax-ix)*(ay-iy)<<endl;
                        ans=min(ans,(ax-ix)*(ay-iy));
                    }
                }
    cout<<ans<<endl;

    

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
    ll n;cin>>n;
    vl lim(n+1),a(n+1);
    rep(i,n+1)cin>>a[i];
    lim[0]=1;
    for(int i=1;i<=n;i++){
        ll m=(lim[i-1]-a[i-1])*2ll;
        if(m<0){
            cout<<-1<<endl;
            return 0;
        }
        lim[i]=min(LINF,m);
    }
    if(lim[n]<a[n]){
        cout<<-1<<endl;
        return 0;
    }
    ll ret=a[n],now=a[n];
    for(int i=n-1;i>=0;i--){
        now+=a[i];
        now=min(now,lim[i]);
        ret+=now;
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  string S;
  cin>>S;
  int N = S.size();
  string s = S;
  reverse(ALL(s));

  string t2 = S.substr(0,(N-1)/2);
  string t3 = t2; reverse(ALL(t3));

  string t4 = s.substr(0,(N-1)/2);
  string t5 = t4; reverse(ALL(t5));


  if(S==s && t2==t3 && t4==t5) cout << "Yes" <<endl;
  else cout << "No"<<endl;

  return 0;
}


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

int main()
{
    
    int h,a;
    cin>>h>>a;
    int x,sum=0;
    for(int i=0;i<a;++i){
        cin>>x;
        sum+=x;
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Set<Integer> set = new HashSet<Integer>();
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(scan.next());
            map.put(a, 1);
            if (set.contains(a)) {
                map.put(a, 0);
            } else {
                set.add(a);
            }
        }
        scan.close();

        int ans = 0;
        for (int a : set) {
            if (map.get(a) == 0) {
                continue;
            }
            if (a == 1) {
                ans++;
                continue;
            }
            if (set.contains(1)) {
                continue;
            }

            boolean isOK = true;
            for (int j = 2; j <= Math.sqrt(a); j++) {
                if (a % j == 0) {
                    if (set.contains(j) || set.contains(a / j)) {
                        isOK = false;
                        break;
                    }
                }
            }
            if (isOK) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

int main(){
	int N,M;
	cin >> N >> M;
	int H[N],ma[N];
	for(int i=0;i<N;i++){
		cin>>H[i];
		ma[i]=0;
	}
	for(int i=0;i<M;i++){
		int A,B;
		cin >> A >> B;
		if(ma[A-1]<H[B-1]){
			ma[A-1]=H[B-1];
		}
		if(ma[B-1]<H[A-1]){
			ma[B-1]=H[A-1];
		}
	}
	int count=0;
	for(int i=0;i<N;i++){
		if(H[i]>ma[i]){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define PI acos(-1)
#define EPS 1e-15
#define f first
#define s second


int main(){
	int x, a, b;
	cin >> x >> a >> b;
	if(abs(x-a) > abs(x-b)){
		cout << "B" << endl;
	}else{
		cout << "A" << endl;
	}
	
	return 0;
}






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

class Test {
	static void Main(string[] args) {
      var inputs = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      int N = inputs[0];
      int X = inputs[1];
      int T = inputs[2];
      if(N%X == 0){
        Console.WriteLine(N/X*T);
      }else{
        Console.WriteLine((N/X+1)*T);
      }
	}
}

Measured memory_bytes: 18992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
string S; cin >> S;
rep(i,S.size()){
  cout << "x";
}
  cout << endl;
  }


Measured memory_bytes: 256
N = int(input())
li = list(map(int,input().split()))
HPmin = 0
sum = 0
while sum != N-1 :
    li.sort()
    for i in range(sum + 1,N) :
        li[i] %= li[sum]
    HPmin = li[0]
    sum = 0
    for i in range(N) :
        if li[i] == 0 :
            sum+=1
li.sort()
print(li[N-1])

Measured memory_bytes: 62704
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	     Scanner SC=new Scanner(System.in);
	     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	     PrintWriter pw=new PrintWriter(System.out);
	     int t=0;
	     
	     /*if(SC.hasNext())
	     t=SC.nextInt();
	     
	     for(int i=0;i<t;i++)
	     {
	          
	     }*/
	     
	     int n;
	     String s;
	     
	     n=Integer.parseInt(br.readLine());
	     s=br.readLine();
	     
	     int x=0;
	     int max=0;
	     
	     for(int i=0;i<n;i++)
	     {
	         if(s.charAt(i)=='I')
	         x++;
	         else
	         x--;
	         
	         
	         max=(int)Math.max(max,x);
	     }
	     
	     //x=(int)Math.max(0,x);
	     if(max>0)
	     pw.println(max);
	     else
	     pw.println("0");
	     //code for reading n long from bfreader in one line
	    /* String inp2=br.readLine();
	         for(int j=0;j<n-1;j++)
     	    {
     	         arr[j]=Long.parseLong(inp2.substring(0,inp2.indexOf(" ")));
     	         inp2=inp2.substring(inp2.indexOf(" ")+1);
     	    }
     	    arr[(int)n-1]=Long.parseLong(inp2);*/
	     
	     pw.close();     
		
}
}


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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ld long double
const int MxN = 200001 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)
const int MOD = 1e9 + 7 ; 

/* VARIABLES */
int n,k  ;
VI logs(MxN) ; 
/* END OF VARIABLES */

ll fun(int v) {
	ll cnt = 0 ; 
	FOR(i,0,n) {
		if(logs[i] <= v)
			continue ; 
		int rem = (logs[i] + v -1 ) / v;
		//cout << rem << " " ; 
		cnt += rem-1 ; 
	}
	return cnt ; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;  

	cin >> n >> k ; 
	FOR(i,0,n) 
		cin >> logs[i] ; 
	ll l = 1 ; 
	ll r = 1e9 ; 
	ll ans = 1e9 ; 
	while(l <= r ) {
		ll m = l + (r-l)/2 ; 
		//cout << m << " " << fun(m) << endl ; 
		if(fun(m) > k)
			l = m +1  ; 
		else {
			ans = min(ans,m) ; 
			r = m - 1;
		}
	}
	cout << ans ; cout << endl ; 
	//cout << fun(5) ; 

		
	return 0 ; 
}



Measured memory_bytes: 3896
//Bismillah hirrahmanir Rahim
        #include<bits/stdc++.h>
        #define ll long long
        #define pb push_back
        #define dbug printf("I am here\n");
        #define Fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        using namespace std;
    long long int gcd(long long int a, long long int b){
        if(a%b==0)return b;
        return gcd(b, a%b);
        }
        int main(){
       int a;
       cin>>a;
       ll int sum=0;
       for(int i=1;i<=a;i++){
         for(int j=1;j<=a;j++){
            for(int k=1;k<=a;k++){
                sum+=gcd(gcd(i,j),k);
            }
         }
       }
       cout<<sum<<endl;

        return 0;
        }


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

import sys

data = []
count = 0
for i in sys.stdin:
    data.append(int(i))
    count = count+1
    if count == 10:
        break

N = len(data)
m = 100

for i in range(m):
    for n in range(N-1):
        a = data[n]
        b = data[n+1]
        if a <= b:
            data[n] = b
            data[n+1] = a
        else:
            pass
for i in range(3):
    print(data[i])

Measured memory_bytes: 7648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100010
typedef long long ll;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
ll a[N],b[N],sum,pre[N];
pair<ll,ll> ans;
bool operator < (const pair<ll,ll> a,const pair<ll,ll> b){
	return (__int128)a.first*b.second<(__int128)a.second*b.first;
}
struct Bar{
	ll a,b;
	bool operator < (const Bar y)const{
		return a>y.a; 
	}
}t[N];
inline ll calc(int x,int k){
	ll val=max(a[x],b[x]);
	return t[k].a<=val?pre[k]-val:pre[k];
}
int Find(int x){
	int l=1,r=n+1,ans=-1;
	while(l<r){
		int mid=(l+r)>>1;
		if(calc(x,mid)>=sum-b[x]){
			ans=r=mid;
		}
		else{
			l=mid+1;
		}
	}
	return ans;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read(),b[i]=read();
		sum+=a[i];
		t[i].a=max(a[i],b[i]);
		t[i].b=i;
	}
	sort(t+1,t+n+1);
	for(int i=1;i<=n;++i){
		pre[i]=pre[i-1]+t[i].a;
	}
	ans=make_pair(n,1);
	for(int i=1;i<=n;++i){
		int k=Find(i);
		if(!~k)continue;
		ll val=sum-calc(i,k);
		if(val<0)continue;
		if(t[k].a<=max(a[i],b[i]))--k;
		pair<ll,ll> nw=make_pair(val+1LL*b[i]*k,b[i]);
		ans=(nw<ans?nw:ans);
	}
	ans.second*=n;
	ans.first=ans.second-ans.first;
	ll g=__gcd(ans.first,ans.second);
	ans.first/=g,ans.second/=g;
	printf("%lld %lld\n",ans.first,ans.second);
	return 0;
}



Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
vector<int>adj[100005];
int vis[5];
vector<int>v;
map<int,int>mp;
int main()
{
   int a1,b1,a2,b2,a3,b3;
   cin>>a1>>b1;
   cin>>a2>>b2;
   cin>>a3>>b3;
   mp[a1]++;
   mp[a2]++;
   mp[b1]++;
   mp[b2]++;
   mp[a3]++;
   mp[b3]++;

   v.pb(mp[1]);
   v.pb(mp[2]);
   v.pb(mp[3]);
   v.pb(mp[4]);
   sort(v.begin(),v.end());
   if(v[0]==1 && v[1]==1 && v[2]==2 && v[3]==2)
   {
       cout<<"YES"<<endl;
   }
   else cout<<"NO"<<endl;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
	fastio
	//t_case
	{
		ll n,m,ans=0,f=1,k=0,x,y,sum=0,h,l  ;cin>>n ;
		if (n>=30) cout<<"Yes";
		else cout<<"No";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
namespace ZDY{
    #define res register
    #define ri res ll
    #define ll long long
    #define db double
    #define sht short
    #define il inline
    #define MB template <class T>
    #define Fur(i,x,y) for(ri i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(ri i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fl(i,x) for(ri i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define inf 21474836473
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdin)
    #define l2(n) (ceil(log2(n)))
    MB il T ABS(T x){return x>0?x:-x;}
    MB il T MAX(T x,T y){return x>y?x:y;}
    MB il T MIN(T x,T y){return x<y?x:y;}
    MB il T GCD(T x,T y){return y?GCD(y,x%y):x;}
    //#define gc() getchar()
    il char gc(){static char buf[1000000],*s,*t;return s==t?(((t=(s=buf)+fread(buf,1,1000000,stdin))==s)?-1:*s++) : *s++;}
    il int gi(){int x=0,f=0;char c=gc();while(c<'0'||'9'<c){if(c=='-')f=!f;c=gc();}while('0'<=c&&c<='9'){x=x*10+c-48;c=gc();}return f?(-x):x;}
}using namespace ZDY;using namespace std;
#define N 20001
int main(){
    int n=gi(),s=0,ma=0;
    Fur(i,1,n){
        int x=gi();
        s+=x;ma=MAX(ma,x);
    }
    s-=ma/2;
    printf("%d\n",s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m;
    cin >> m;
    cout << 48 - m << endl;
}


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int a,b,c;cin>>a>>b>>c;
    int x,y;cin>>x>>y;

    int ans = INF;
    rep(p, 0, 200001){
        if (p%2==1) continue;
        int res = p * c;
        int rx = max(0LL, x - p/2);
        int ry = max(0LL, y - p/2);
        res += rx * a;
        res += ry * b;
        chmin(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 1
    var prev = aa[0]
    var isFirst = true
    var isUp = true

    for (i in 1 until aa.size) {
        if (isFirst && prev == aa[i]) {
            continue
        }
        if (isFirst && prev != aa[i]) {
            isUp = (aa[i] - prev > 0)
            prev = aa[i]
            isFirst = false
            continue
        }
        if (aa[i] == prev) continue

        if (aa[i] > prev && isUp) {
            prev = aa[i]
            continue
        }
        if (aa[i] < prev && !isUp) {
            prev = aa[i]
            continue
        }

        cnt++
        isFirst = true
        prev = aa[i]
    }

    println(cnt)
}



Measured memory_bytes: 54240
// ABC72-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

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

    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        int s;
        cin>>s;
        a[i]=s;
    }
    int ans=0;
    rep(i,n-1){
        if(a[i]==(i+1)){
            int bef,af;
            bef=a[i];
            af=a[i+1];
            a[i]=af;
            a[i+1]=bef;
            ans++;
        }
    }
    if(a[n-1]==(n))ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
char s[N];int n,ans,f[N][3];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		f[i][2] = f[i-1][1];
		if(s[i] == s[i-1])
			f[i][0] = f[i-1][2]+1 , f[i][1] = f[i-1][0]+1;
		else f[i][0] = max(f[i-1][0],f[i-1][2])+1,f[i][1] = f[i-1][0]+1;
	}
	printf("%d\n",f[n][0]);
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int n,a[100000],c=0,k;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		if(a[i] != i && c == 0){
			k = a[i];
			swap(a[i],a[k]);
			c = 1;
		}
		else if(a[i] != i && c == 1){
			printf("NO");
			return 0;
		}
	}
	printf("YES");
}

Measured memory_bytes: 256
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL poww(LL a,LL n)
{
    if(n==0) return 1;
    LL val=poww(a,n/2);
    if(n%2==0) return (val*val)%mod;
    else return (((val*val)%mod)*a)%mod;
}

LL fact[5000005],inv[5000005];

inline LL perm(LL n,LL k)
{
	if(n-k<0) return 0;
	if(n==0||k==0) return 1;
    return (((fact[n])%mod)*inv[n-k])%mod;
}

inline LL comb(LL n,LL k)
{
	if(n-k<0) return 0;
    if(n==0||k==0) return 1;
    return (((fact[n]*inv[k])%mod)*inv[n-k])%mod;
}

LL n,m;

int main() {
	FIO;
	cin >> n >> m;
	fact[0]=1;
	inv[0]=1;
	rep(i,1,m+3){
	    fact[i]=(fact[i-1]*i)%mod;
	    inv[i]=poww(fact[i],mod-2);
	}
	LL ans = (perm(m,n)*perm(m,n))%mod;
	rep(i,1,n) {
		LL val = (perm(m,i)*comb(n,i)) % mod;
		val = (val*(perm(m-i, n-i))) % mod;
		val = (val*(perm(m-i, n-i))) % mod;
		if(i % 2) val = (mod-val) % mod;
		ans = (ans+val) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11400
#include<iostream>
using namespace std;
int main(){
  int n,m,most1,most2,d[11000]={0};
  while(1){
    cin >> n;
    if(n==0){
      break;
    }

    most1=0;most2=0;
    for(int i=0;i<10100;i++){
      d[i]=0;
    }

    for(int i=2;i*i<=n;i++){
      if(d[i]==0){
	for(int j=i+i;j<=n;j+=i){
	  d[j]=1;
	}
      }
    }
    
    for(int i=n;i>=0;i--){
      if(d[i]==0 && d[i-2]==0){
	most1=i-2;
	most2=i;
	break;
      }
    }

    cout << most1 << " " << most2 << endl;
  }
}

Measured memory_bytes: 1208
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

a,v = map(int,readline().split())
b,w = map(int,readline().split())
t = int(readline())

if a < b:
    a += v*t
    b += w*t
    if a < b:
        print("NO")
    else:
        print("YES")
else:
    a -= v*t
    b -= w*t
    if a > b:
        print("NO")
    else:
        print("YES")


Measured memory_bytes: 61876
#include <iostream>

using namespace std;

int const nmax = 1000000;
char v[1 + nmax];

int legendre(int n, int k){
  int result = 0;
  for(int i = k; i <= n; i *= k)
    result += n / i;
  return result;
}

int comb(int n, int k){
  return legendre(n, 2) - legendre(k, 2) - legendre(n - k, 2);
}

int solve(int n){
  int result = 0;
  for(int i = 1;i <= n; i++)
    if(0 == comb(n - 1, i - 1))
      result ^= v[i];
  return result;
}

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

  int n;
  cin >> n;
  for(int i = 1;i <= n; i++) {
    cin >> v[i];
    v[i] -= '1';
  }

  bool mode = 0;
  for(int i = 1;i <= n; i++)
    mode |= (v[i] == 1);
  if(mode == 1){
    for(int i = 1;i <= n; i++)
      if(v[i] == 2)
        v[i] = 0;
    cout << solve(n);
  } else {
    for(int i = 1;i <= n; i++)
      if(v[i] == 2)
        v[i] = 1;
    cout << solve(n) * 2;
  }
  return 0;
}


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

using namespace std;

int a[3];
int b[3];

bool solve()
{
    int cnt[4];
    for(int i=0; i<4; i++) cnt[i] = 0;
    for(int i=0; i<3; i++){
        cnt[a[i]-1]++;
        cnt[b[i]-1]++;
    }
    sort(cnt, cnt+4);
    // for(int i=0; i<4; i++) cout << cnt[i] << " ";
    if(cnt[0]==1 && cnt[1]==1 && cnt[2]==2 && cnt[3]==2) return true;
    else return false;
}

int main()
{
    for(int i=0; i<3; i++) {
        cin >> a[i] >> b[i];
    }
    if(solve()) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
PI = 3.14159265358979323846

a,b,x = gets.split.map(&:to_f)

s = x / a
ans = 0
a2  = 0

if s == a * b
  ans = 0
else
  if s > b * a / 2
    bu = 2 * s / a - b
    s -= a * bu
    b -= bu
    a2 = 2 * s / b
  else
    a2 = 2 * s / b
  end
  r = Math.atan(b/a2)
  ans = r * (180.0/PI)
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pa pair
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;




int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    rep(i,10) rep(j,10){
        
        rep(k,N){
            if(int(S[k]-'0') == i){
                for (int l = k+1; l < N; l++) {
                    
                    if(int(S[l]-'0') == j){
                       
                        map<int,int> M;
                        for (int m = l+1; m < N; m++) {
                            //cout << i << j << S[m]-'0' << endl;
                            M[S[m]-'0'] = 1;
                        }
                        ans += int(M.size());
                        break;
                    }
                }
                break;
            }
        }
        
        
    }
    
    out(ans);
    
    
    
    return 0;
}



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

int main() {
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << char(s1.at(0)-32) << char(s2.at(0)-32) << char(s3.at(0)-32) << endl;
}

Measured memory_bytes: 3572
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= b[i]) {
                ans += b[i];
            } else {
                ans += a[i];
                b[i] -= a[i];
                if (b[i] >= a[i+1]) {
                    ans += a[i+1];
                    a[i+1] = 0;
                } else {
                    a[i+1] -= b[i];
                    ans += b[i];
                }
            }
        }
        System.out.println(ans);
    }

}


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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int K, S;
    cin >> K >> S;
    K = min(K, S);
    int ans = 0;
    for (int _X = S - K; _X <= S; _X++)
    {
        if (_X > 2*K)
            break;
        if (_X < 0)
            continue;
        ans += (_X <= K ? _X : 2 * K - _X) + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 300
map<int, pair<int, int>> m;
vector<int> inds[N * N];
vector<ll> dist[N * N];
vector<ll> psum[N * N];
int mdist(pair<int, int> i, pair<int, int> j) {
    return abs(i.first - j.first) + abs(i.second - j.second);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w, d;
    cin >> h >> w >> d;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int aij;
            cin >> aij;
            aij--;
            m[aij] = {i, j};
            inds[aij % d].push_back(aij);
        }
    }
    for(int i = 0; i < d; i++) {
        sort(inds[i].begin(), inds[i].end());
        dist[i].push_back(0);
        for(int j = 1; j < inds[i].size(); j++) {
            dist[i].push_back(mdist(m[inds[i][j-1]], m[inds[i][j]]));
        }
        psum[i].resize(dist[i].size());
        partial_sum(dist[i].begin(), dist[i].end(), psum[i].begin());
    }
    int q;
    cin >> q;
    while(q--) {
        int L, R;
        cin >> L >> R;
        L--, R--;
        cout << psum[R % d][R / d] - psum[L % d][L / d] << endl;
    }
    return 0;
}


Measured memory_bytes: 20864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n+1);
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }

    // A_i + i
    map<ll, ll> Api;
    for(int i=1; i<=n; i++){
        Api[a[i]+i]++;
    }

    // j - A_j を見ていく
    ll ans = 0;
    for(int j=1; j<=n; j++){
        ans += Api[j - a[j]];
    }

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

Measured memory_bytes: 27360
#include <bits/stdc++.h>
//#include "cpp/Solution.h"

using namespace std;

int main() {
    int i;
    cin >> i;
    if(i % 1000 == 0){
        cout << 0 <<endl;
    }else{
        cout << 1000 - (i % 1000);
    }
    return 0;
}





Measured memory_bytes: 3632
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys

sys.setrecursionlimit(10 ** 5 + 10)


# input = sys.stdin.readline


def resolve():
    # 入力
    N, M = map(int, input().split())
    # 隣接関係は隣接リストで管理する
    lst_edge = [[] for _ in range(N)]
    for _ in range(M):
        x, y = map(int, input().split())
        # 最初のindexをゼロにする
        lst_edge[x - 1].append(y - 1)
    # dp[v] := ノードvを始点とした時の有向パスの長さの最大値
    # -1 未訪問で初期化。
    dp = [-1] * N

    # メモ化再帰。rec(v)でvから行ける有向パスの長さを更新してゆく
    def rec(v):
        # 既に更新済み
        if dp[v] != -1:
            return dp[v]
        ans = 0
        lst_nv = lst_edge[v]
        # ノードvから直接行くことのできる各ノードnv
        for nv in lst_nv:
            ans = max(ans, rec(nv) + 1)
        # メモりつつリターン
        dp[v] = ans
        return dp[v]

    # 全ての点に対して更新する
    ans = 0
    for v in range(N):
        ans = max(ans, rec(v))

    print(ans)


resolve()

Measured memory_bytes: 144588
#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int

using namespace std ;

int main()
{
    int n,a,b;
    cin >>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<int>> dp(h,vector<int>(w,0));
  vector<vector<char>> maze(h,vector<char>(w));
  dp[0][0] = 1;
  rep(i,h)rep(j,w) cin >> maze.at(i).at(j);
  rep(i,h)rep(j,w){
    if(i==0 && j==0) continue;
    if(maze.at(i).at(j) == '#')continue;
    if(i != 0) dp.at(i).at(j) += dp.at(i-1).at(j);
    if(j != 0) dp.at(i).at(j) += dp.at(i).at(j-1);
    dp.at(i).at(j) %= MOD;
  }
  cout << dp.at(h-1).at(w-1) << endl;
  return 0;
}



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


typedef long long LLI;

int main(){
  LLI N; cin >> N;
  LLI ans = 0;
  cerr << "N: " << N << endl;

  if( N % 2 != 0){

  } else { 
    N = N / 2 ;
    while(N > 1){
      ans += N / 5;
      N = N / 5;
      cerr << "N: " << N << endl;
    }
  }

  cout << ans << endl;
    


}




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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int N,M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    vector<ll> B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    vector<ll> sum_a(N + 1);
    vector<ll> sum_b(M + 1);

    sum_a[0] = 0;
    sum_b[0] = 0;

    rep(i, N) sum_a[i + 1] = sum_a[i] + A[i];
    rep(i, M) sum_b[i + 1] = sum_b[i] + B[i];

    ll ans = 0;

    rep(i,N+1){
        if (sum_a[i] > K) break;
        auto idx = upper_bound(sum_b.begin(), sum_b.end(), (ll)(K - sum_a[i]));
        idx--;
        chmax(ans, i + (idx - sum_b.begin()));
    }

    cout << ans << endl;
}


Measured memory_bytes: 9524
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# s,t = S_MAP()
s = input()
t = input()
cnt = 0
for i in range(len(s)):
    if s[i] != t[i]:
        cnt += 1
print(cnt)

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

int main() {
  int n, max;
  cin >> n >> max;
  vector<int> num(n);
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  long long ans = 0;
  if (num[0] > max) {
    ans += (num[0] - max);
    num[0] = max;
  }
  for (int i = 1; i < n - 2; i++) {
    if (num[i] + num[i - 1] > max) {
      ans += (num[i] + num[i - 1] - max);
      num[i] = max - num[i - 1];
    }
  }
  if (num[n - 1] + num[n - 2] > max) {
    ans += (num[n - 1] + num[n - 2] - max);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            var count = S.Length - T.Length;
            int retMatch = -1;
            for (int i = 0; i <= count; i++)
            {
                int cntMatch = 0;
                for (int j = 0; j < T.Length; j++)
                {
                    if (S[i + j] == T[j])
                    {
                        cntMatch++;
                    }
                }
                retMatch = Math.Max(retMatch, cntMatch);
            }

            Console.WriteLine(T.Length -retMatch);
        }
    }
}

Measured memory_bytes: 25796
A = int(input()) # 500円玉の枚数
B = int(input()) # 100円玉の枚数
C = int(input()) #  50円玉の枚数
X = int(input()) # 合計金額

ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1

print(ans)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
answer = 0
tmp = abs(a[0])
check = 0

for b in a:
    if b == 0:
        check += 1
        tmp = 0
    else:
        if b < 0:
            check += 1
        b = abs(b)
        if b < tmp:
            tmp = b
            answer += tmp
        else:
            answer += b
if check % 2 == 1:
    answer -= 2*tmp
print(answer)


Measured memory_bytes: 14412
#include<iostream>
#define ll long long
using namespace std;

int n,a=0,b=0,c=0;
ll tmp;

int main(){
  cin >> n;
  for(int i = 0; i<n; i++){
    cin >> tmp;
    if(tmp % 4 == 0) b++;
    else if(tmp % 2 == 0) c++;
    else a++;
  }

  /*/
  if(c == 0 and b+1 >= a){
    cout << "Yes" << endl;
    return 0;
  }
  if( c != 0 and b >= a){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  /*/
  if(c != 0) a++;
  if( b+1 >= a) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 256