akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    int k,a,b;
    cin >> k >> a >> b;

    rep(i,a,b+1){
	if(i%k == 0){
	    P("OK");
	    ret 0;
	}
    }
    P("NG");
    return  0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];
  vector<int64_t> B(N);
  rep(i, N) cin >> B[i];

  vector<int64_t> C;
  int64_t answer = 0;
  int64_t debt = 0;
  rep(i, N) {
    if (A[i] < B[i]) {
      ++answer;
      debt += B[i] - A[i];
    } else {
      C.emplace_back(A[i] - B[i]);
    }
  }
  if (debt == 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(C.begin(), C.end(), greater<int64_t>());

  for (auto gain : C) {
    ++answer;
    debt -= gain;
    if (debt <= 0) {
      cout << answer << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
  int a,b,c,t;
  
  scanf("%d %d %d",&a,&b,&c);

  if(a>=1 && a<=10000 && b>=1 && b<=10000 && c>=1 && c<=10000)
  {

    if(a>b)
    {
      t = a;
      a = b;
      b = t;
    }
    if(a>c)
    {
      t = a;
      a = c;
      c = t;
    }
    if(b>c)
    {
      t = b;
      b = c;
      c = t;
    }

    printf("%d %d %d\n",a,b,c);
    }
  return 0;
}



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

 int main()
 {
   int i,j,k,ans=0,sum,num,count=0,c,e=0;
   
   int n,d,x[10][10];
   cin>>n>>d;
   for(i=0;i<n;i++)
   {
     for(j=0;j<d;j++)
     {
     cin>>x[i][j];
     }
   }
   for(i=0;i<n-1;i++)
   {
     
     for(j=i+1;j<n;j++)
     { 
       //cout<<"I,J="<<i<<" "<<j<<endl;
       e=0;
       for(k=0;k<d;k++)
       {
         c=x[j][k]-x[i][k];
         c*=c;
         e+=c;
       }
      // cout<<"e="<<e<<endl;
   
       k=1;
       
       while(1)
       {
         if(k*k==e)
         {
           count++;
          // cout<<"ans"<<endl;
           break;
         }
         if(k*k>e)break;
         k++;
       } 
       
     }
   }
   cout<<count<<endl;
 }

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

#define ll long long int
#define pb push_back


int main(){
	int n;
	cin >> n;
	if( n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9 ){
		cout << "hon\n";
	}else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
		cout << "pon\n";
	}else{
		cout << "bon\n";
	}
}


Measured memory_bytes: 3584
#include<iostream>
#include <map> 
#include <string>
using namespace std;
 
int main() {
    int n;
    string com;
    map<string, int> dic;
    cin >> n;
    string str;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> com >> str;
        if (com[0] == 'i') {
            dic[str]= cnt;
            cnt++;
        }
        else {
            int ret = dic.count(str);
            if (ret == 1)
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 36856
fun main(args: Array<String>) {
    val s = readLine()!!.toLong()

    val x1 = 1e9.toLong()
    val y1 = 1

    val y2 = (s + x1 - 1) / x1
    val x2 = x1 * y2 - s

    println("0 0 $x1 $y1 $x2 $y2")
}


Measured memory_bytes: 31564
#include <iostream>
using namespace std;
int main() {
  int s;
  cin >> s;
  int sum = 0;
  int b = s;
  while (0 < b) {
    sum += b % 10;
    b /= 10;
  }
  if (s % sum == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

using namespace std;

int main(){

	int n;
	cin>>n;
	int a[10000];
	for(int i=0;i<n;i++) cin>>a[i];
	int mn = a[0], mx=a[0];
	long long sum =0;
	for(int i=0;i<n;i++){
		mn=min(mn,a[i]);
		mx=max(mx,a[i]);
		sum +=a[i];}

	cout<<mn<<" "<<mx<<" "<<sum<<endl;

	return 0;
}


Measured memory_bytes: 3120
import math

N = int(input())
divided = N
prime_factor = []

for i in range(2, int(math.sqrt(N)//1)+1):
  while divided%i == 0:
      prime_factor.append(i)
      divided //= i
if divided != 1:
  prime_factor.append(divided)

print("{}: ".format(N, *prime_factor), end="")
print(*prime_factor)


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

    ll ans;
    cin>>ans;
    ll val = 1000000000;
    ll x = (val-ans%val)%val;
    ll y = (ans+x)/val;
    cout<<0<<" "<<0<<" "<<1000000000<<" "<<1<<" "<<x<<" "<<y;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char n[3];
	for(int i=0;i<3;i++){
		cin >>n[i];
	}	
	if(n[0]=='R'&&n[1]=='R'&&n[2]=='R'){
		cout << "3";
	}
		else if(n[0]=='R'&&n[1]=='R'||n[1]=='R'&&n[2]=='R'){
		cout << "2";
	}
	else if(n[1]=='S'&&(n[0]=='R'||n[2]=='R')){
		cout << "1";
	}
	else if(n[1]=='R'&&(n[0]=='S'||n[2]=='S')){
		cout << "1";
	}
		
	else
		cout << "0";
	return 0;
}

Measured memory_bytes: 3568
use strict;
use warnings;
use utf8;

use feature qw(say);
use Data::Dumper;

my $k = <STDIN>;
chomp $k;

my $num_list = [split //, $k];
my $sum = 0;
for my $num (@$num_list) {
    $sum = $sum + $num;
}

if ($sum % 9 == 0) {
    say 'Yes';
} else {
    say 'No';
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if(c <= 0) break;
        a -= d;
        if(a <= 0) break;
    }
    cout << ((c <= 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int a[200010], b[200010];
int zalgo[600010], val[600010];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> a[i];
	for(int i=0; i<N; ++i) cin >> b[i];
	for(int i=0; i+1<N; ++i) zalgo[i]=(b[i])^(b[i+1]);
	for(int i=0; i+1<N; ++i) zalgo[N-1+i]=(a[i])^(a[i+1]);
	zalgo[N*2-2]=(a[N-1])^(a[0]);
	for(int i=0; i+1<N; ++i) zalgo[N*2-1+i]=(a[i])^(a[i+1]);
	zalgo[N*3-2]=-1;
	val[0]=N*3-2;
	int p=1, q=0;
	while(p<N*3-2){
		while(zalgo[q]==zalgo[p+q]) ++q;
		val[p]=q;
		if(q==0){
			++p;
			continue;
		}
		int k=1;
		while(p+k<N*3-2 && k+val[k]<q){
			val[p+k]=val[k];
			++k;
		}
		p += k;
		q -= k;
	}
	for(int i=0; i<N; ++i){
		if(val[N-1+i]>=N-1){
			int ans=(a[i])^(b[0]);
			cout << i << ' ' << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define fi first
#define se second
typedef long long ll;
using namespace std;

pair<int,int> dp[2][200001];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while(cin>>n,n){
    int a[201];
    fill(a,a+201,0);
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    for(int i=0;i<=200000;i++)dp[0][i]=make_pair(-1,0);
    dp[0][0]=make_pair(0,0);
    for(int i=0;i<n;i++){
      for(int j=0;j<=200000;j++)dp[(i+1)&1][j]=make_pair(-1,0);
      for(int j=0;j<=200000;j++){
        if(dp[i&1][j].fi==-1)continue;
        int tmp=a[i]%1000;
        if(tmp<=500 && tmp>=1)
          dp[(i+1)&1][j+500-tmp]=max(make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i]),dp[(i+1)&1][j+500-tmp]);
        else{
          int pay=(tmp+500)%1000;
          dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
          if(pay<=j)
            dp[(i+1)&1][j-pay]=max(make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i]),dp[(i+1)&1][j-pay]);
          int pay2=(1000-tmp)%1000;
          dp[(i+1)&1][j+pay2]=max(make_pair(dp[i&1][j].fi,dp[i&1][j].se-a[i]),dp[(i+1)&1][j+pay2]);
        }
      }
    }
    pair<int,int> ans=make_pair(0,0);
    for(int i=0;i<=200000;i++){
      if(dp[n&1][i]>ans){
        ans=make_pair(dp[n&1][i].fi,dp[n&1][i].se);
      }
    }
    cout<<ans.fi<<" "<<-ans.se<<endl;
  }
  return 0;
}


Measured memory_bytes: 6256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		// 文字列の入力
		if((a<c&&c<b)||(a>c&&c>b))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n;
    cin >> n;
    int t = 1, ans = 0;
    while(1) {
        ans += t;
        if(n <= 1) {
            break;
        }
        n /= 2;
        t *= 2;
    }

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

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

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

    ll sum = accumulate(A.begin(), A.end(), 0LL);

    ll ans = N - sum;

    if (ans < 0) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3668
import sys
sys.setrecursionlimit(10**9)
def SCC(G):
  D=[]
  C=[len(G)-1]
  U=[1]*len(G)
  def DFS(x):
    if U[x]:
      U[x]=0
      for i in range(len(G[x])):
        DFS(G[x][i])
      D.append(x)
  
  for i in range(len(G)):
    if U[i]:
      DFS(i)
  GR=[[] for i in range(len(G))]
  for i in range(N):
    for j in range(len(G[i])):
      GR[G[i][j]].append(i)
  R=[]
  U=[1]*len(G)
  def DFSR(x):
    if U[x]:
      R[-1].append(x)
      U[x]=0
      for i in range(len(GR[x])):
        DFSR(GR[x][i])
  
  for i in range(len(G)-1,-1,-1):
    if U[D[i]]:
      R.append([])
      DFSR(D[i])
  return R

S=sys.stdin.readlines()
N,M=map(int,S[0].split())
G=[[] for i in range(N)]
a,b=0,0
for i in range(M):
  a,b=map(int,S[i+1].split())
  G[a].append(b)
P=SCC(G)
print(len(P))
for i in range(len(P)):
  print(*([len(P[i])]+P[i]))


Measured memory_bytes: 652960
import std.stdio,std.string,std.conv;

int main()
{
	string s = readln.chomp;
	char[] ans;
	ans.length = s.length;
	foreach(i;0..s.length)
	{
		if(s[i] == 'a' && s[i+1] == 'p' &&s[i+2] == 'p' && s[i+3] ==  'l' && s[i+4] == 'e')
		{
			ans[i] = 'p';
			ans[i+1] = 'e';
			ans[i+2] = 'a';
			ans[i+3] = 'c';
			ans[i+4] = 'h';
			i += 4;
		}
		else if(s[i] == 'p' && s[i+1] == 'e' &&s[i+2] == 'a' && s[i+3] ==  'c' && s[i+4] == 'h')
		{
			ans[i] = 'a';
			ans[i+1] = 'p';
			ans[i+2] = 'p';
			ans[i+3] = 'l';
			ans[i+4] = 'e';
			i += 4;
		}
		else ans[i] = s[i];
	}
	ans.writeln;
	return 0;
}

Measured memory_bytes: 1032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    int n = 0;
    int[] nums = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      n = Integer.parseInt(br.readLine());
      nums = new int[n];

      for (int i = 0; i < nums.length; i++) {
        nums[i] = Integer.parseInt(br.readLine());
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    boolean b = false;
    int idx = 0;
    int sum = 0;
    for (int i = 0; i <= nums.length - 1; i++) {
      sum++;
      if (nums[idx] == 2) {
        b = true;
        break;
      }
      else {
        idx = nums[idx]-1;
      }
    }

    System.out.print(b == true ? sum : -1);
  }
}


Measured memory_bytes: 31960
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
 
int main()
{
    int x;
    cin >> x;
    for (int i = 0; i < 8; i++)
    {
        if (x >= (i+2)*200 && x <= (i+3)*200-1)
        {
            cout << 8-i << endl;
            return 0;
        }
        
    }
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;	cin >> n;
  int a[n],b[n];
  int ans = 0;
  
  for(auto &X :a)	cin >> X;
  for(auto &X :b)	cin >> X;
  
  for(int i=0; i<n; i++)
    ans+= max(0, a[i]-b[i]);
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n;
 	string s;
 	cin >> n >> s;
 	for(int i=0;i<sz(s);i++)
 	{
 		int x = s[i] - 'A';
 		x = (x+n)%26;
 		s[i] = x + 'A';
 		//debug(s[i]);
 	}
 	cout << s;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val cnt = IntArray(n + 1)
    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        cnt[a]++
        cnt[b]++
    }
    println(if (cnt.all { it % 2 == 0 }) "YES" else "NO")
}


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

using namespace std;

const int N = 1e5 + 7;
int n, m;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = 1 ; i <= 1000 ; ++i) {
        if(i *d >= l and i *d <= r) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3648
n = gets.to_i
res = Array.new(n, 0)

1.step(100) do |x|
  x.step(100) do |y|
    y.step(100) do |z|
      t = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      if t < 1 || t > n
        next
      end

      if x != y && y != z
        res[t - 1] += 6
      elsif x == y && y == z
        res[t - 1] += 1
      else
        res[t - 1] += 3
      end
    end
  end
end
puts res


Measured memory_bytes: 14296
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

s = b[a[0]-1]

for i in range(1,n):
    s += b[a[i]-1]
    if(a[i] == a[i-1]+1):s+=c[a[i-1]-1]
print(s)

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

int main() {
  
  int N;
  int num = 0;
  int num2;
  int num3;

  int answer = -1e9;
  int ans2 = -1e9;
  
  cin >> N;
  
  vector<int> V(N);
  vector<int> C(N);
  
  for(int i = 0;i < N;++i){
    cin >> V[i];
  }
  
  for(int i = 0;i < N;++i){
    cin >> C[i];
  }
  
  for(int i = 0;i < N;++i){
    num2 = V[i] - C[i];
    if(num2 > 0){
      num = num2 + num;
    }
  }
  
  cout << num << endl;
}


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

int main() {
  int a=0, b=0;
  string S;
  cin >> S;
  
  for (int i = 0; i < 3; i++) {
    if (S.at(i)=='A'){
      a++;
    }
    else {
      b++;
    }
  }
  
  if (a==3 || b==3){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;  
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N, M;
vector<P> edges;

class unionFind {
public:
    vector<ll> data;
    
    unionFind(ll size) {
        data.assign(size, -1);
    }
    
    bool same(ll x, ll y) {
        return find(x)==find(y);
    }
    
    void unite(ll x, ll y) {
        x=find(x);
        y=find(y);
        if(x==y) return;    //すでに同じ連結成分の場合
        if(data[x]>data[y]) swap(x, y);
        data[x]+=data[y];
        data[y]=x;
    }
    
    ll find(ll k) {
        if(data[k]<0) return k;
        return data[k]=find(data[k]);
    }
    
    ll size(ll k) {
        return -data[find(k)];
    }
    
};

int main(void) {
    cin >> N >> M;
    ll i;
    ll ans[MAX]={};
    
    for(i=0; i<M; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges.pb(P(a, b));
    }
    
    unionFind uf=unionFind(N);
    ll cnt=N*(N-1)/2;
    
    for(i=M-1; i>=0; i--) {
        ans[i]=cnt;
        
        ll a=edges[i].ft;
        ll b=edges[i].sc;
        if(!uf.same(a, b)) {
            cnt-=uf.size(a)*uf.size(b);
            uf.unite(a, b);
        }
        
    }
    
    for(i=0; i<M; i++) pt(ans[i]);
    
}





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

bool primes[1000000];
void Prime(){
  primes[0] = false; primes[1] = false;
  for (int i = 2; i < 1000000; i++) primes[i] = true;
  for (int i = 2; i < 1000; i++) {
    if (primes[i]) {
      for (int j = i * 2; j < 1000000; j += i) primes[j] = false;
    }
  }
}

int main() {
  Prime();
  int n;
  while(cin >> n) {
    int cnt = 0;
    for (int i = 2; i <= n; i++) if (primes[i]) cnt++;
    cout << cnt << endl;
  }
  return 0;
} 


Measured memory_bytes: 3960
class FUnionFind
  attr_reader :nodes, :parents, :ranks

  def initialize(n)
    @parents = (0...n).to_a
    @nodes = @parents.map{ |x| [x] }
  end

  def find(i)
    @parents[i]
  end

  def union(i,j)
    i = @parents[i]; j = @parents[j]
    return if i == j
    j,i = i,j if @nodes[i].size < @nodes[j].size
    #p [i,j,@nodes[i],@nodes[j]]
    #p [i,j,@nodes[i].size,@nodes[j].size]
    @nodes[j].each{ |k| @parents[k] = i }
    @nodes[i].concat(@nodes[j])
    @nodes[j].clear
  end

  def setsize(i)
    @nodes[find(i)].size
  end
end

N,M = gets.split.map(&:to_i)
uf = FUnionFind.new(N)
v = N*(N-1)/2
puts (0...M).map{
  a,b = gets.split.map(&:to_i)
}.reverse.map{ |a,b|
  next v.tap{
    if uf.find(a-1) != uf.find(b-1)
      v -= uf.setsize(a-1) * uf.setsize(b-1)
      uf.union(a-1, b-1)
    end
  }
}.reverse

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

int main()
{
  int n,Y;
  cin >> n >> Y;
  
  for (int x = 0; x <= n; x++) {
    for (int y = 0; y <=n; y++) {
      if (9000 * x + 4000 * y == Y - 1000 * n && n - x - y >= 0) {
        cout << x << " " << y << " " << n - x - y << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

class Program
{
    const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = cin.NextInt();
        }
        int max = a.Max();
        int min = a.Min();

        int maxIndex = Array.IndexOf(a, max);
        int minIndex = Array.LastIndexOf(a, min); // if max num is the same as min num, min index is also the same max index.

        var others = a.Where((num, i) => i != maxIndex && i != minIndex).ToArray();
        int result = max - min + others.Sum(Math.Abs);

        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        Console.WriteLine(result);

        int tmpMin = min;
        foreach (var num in others.Where(e => e >= 0))
        {
            Console.WriteLine("{0} {1}", tmpMin, num); // Remarks: order as x - y
            tmpMin -= num;
        }

        int tmpMax = max;
        foreach (var num in others.Where(e => e < 0))
        {
            Console.WriteLine("{0} {1}", tmpMax, num); // Remarks: order as x - y
            tmpMax -= num;
        }

        Console.WriteLine("{0} {1}", tmpMax, tmpMin);// Remarks: x - y == result -> true.

        Console.Out.Flush();
        
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 32584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long int llint;
int main(){
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		if (i <= k){
			ans += x;
		}
		else{
			ans += y;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    vector<int> dp(N);
    for (int k = 0; k < N; ++k) {
        dp[k] = INF;
    }

    dp[0] = 0;

    for (int j = 0; j < N-1; ++j) {
        dp[j+2] = min(dp[j+2], dp[j] + abs(h[j+2] - h[j]));
        dp[j+1] = min(dp[j+1], dp[j] + abs(h[j+1] - h[j]));
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    count = Counter(a)
    ans = 0
    o2 = []
    for k, v in count.items():
        if v >= 2:o2.append(k)
        if v >= 4:ans = max(ans,k*k)
    o2.sort()
    if len(o2) >= 2:ans = max(ans,o2[-1] * o2[-2])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18592
#!/usr/bin/env python3


def main():
    H,W,K = map(int,input().split())
    S = [input() for _ in range(H)]
    answer = [[0]*W for _ in range(H)]
    count = 0

    strobery_count = [0]*H
    for i in range(H):
        strobery_count[i] = S[i].count("#")
    flag = False
    for i in range(H):
        tmp = 1
        if strobery_count[i] == 0:
            if i >= 1:
                answer[i] = answer[i-1]
            else:
                flag = True
            continue
        
        count += 1
        for j in range(W):
            answer[i][j] = count
            if S[i][j] == "#" and tmp < strobery_count[i]:
                count += 1
                tmp += 1
    
    if flag:
        a = 0
        for i in range(H):
            if strobery_count[i] == 0:
                a = i
            else:
                a = i
                break
        
        for h in range(a):
            answer[h] = answer[a]

    for i in range(H):
        print(*answer[i])          

if __name__ == '__main__':
    main()


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

int main(){
int n,x,t;cin>>n>>x>>t;



if(n%x==0)cout<<n*t/x<<endl;
if(n%x!=0)cout<<t+t*(n-n%x)/(x)<<endl;

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//79502884197169399375105820974944
  int r;
   cin>>r;
   long double pi=3.141592653;
   long double s= 2*r;
   
long  double ans = s*pi;
std::cout<<std::fixed;
std::cout<<std::setprecision(10);
cout<<ans;

  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector< ii > vii;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef	vector<pair<int,pair<int,int > > > viii;
typedef long long int lli;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(a) (int)(a.size())

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define slli(n) scanf("%llid",&n)
#define lldout(n) printf("%llid\n",n)
const int N = (int)1e5 + 10;
map<string,int> ph;
int main(){
 	int n;
 	cin>>n;
 	cin.ignore();
 	string s;
 	int flg=0;
 	char g;
 	rep(i,0,n){cin>>s;ph[s]+=1;if(ph[s]>1)flg=1;if(i>0 and g!=s[0])flg=1;g=s[sz(s)-1];} 
  	if(flg)cout<<"No"<<endl;
  	else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (((a * 100 + b * 10 + c) % 4 == 0) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()

    else:
        dfs(i+1, f + "-" + s[i+1], sum - int(s[i+1]))
        dfs(i+1, f + "+" + s[i+1], sum + int(s[i+1]))


s = input()

print(dfs(0, s[0], int(s[0])))

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main() {
  int N,x; cin >> N >> x;
  if(x==1||x==2*N-1){
    cout << "No" << endl;
  }else if(N==2){
    cout << "Yes" << endl;
    rep(i,3) cout << i+1 << endl;
  }else{
    cout << "Yes" << endl;
    vi a(2*N-1,-1);
    a[N-1] = x-1;
    a[N-2] = x-2;
    a[N] = x;
    int now = 0;
    if(x-3>=0){
      a[N+1] = x-3;
      rep(i,2*N-1){
        if(i>=N-2&&i<=N+1) continue;
        if(now==x-3) now += 4;
        a[i] = now;
        now++;
      }
    }else{
      a[N-3] = x+1;
      rep(i,2*N-1){
        if(i>=N-3&&i<=N) continue;
        if(now==x-2) now += 4;
        a[i] = now;
        now++;
      }
    }
    rep(i,2*N-1) cout << a[i]+1<< endl;
  }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

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

int main(void){
  ll a,b; cin >> a >> b;
  ll G = gcd(a,b);
  if(G== 1){
    cout << 1 << endl;
    return 0;
  }
  int count = 1;
  int i = 2;
  while(i <= pow(G,0.5)){
    if(G%i == 0) count++;
    while(G%i == 0){
      G = G/i;
    }
    i++;
  }
  if(G != 1) count++;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int W[100], Tg, Tl, min=1000;
  for(int i=0; i<N; i++){
    cin >> W[i];
  }
  for(int i=0; i<N; i++){
    Tg = 0;
    Tl = 0;
    for(int j=0; j<N; j++){
      if(j <= i) Tl += W[j];
      else Tg += W[j];
    }
    if(abs(Tg-Tl) < min) min = abs(Tg-Tl);
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int N; cin>>N;
    if (N==1) {
        cout << "Hello World" <<endl;
        return 0;
    }
    int A,B; cin>>A>>B;
    cout<<A+B<<endl;
}


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

int main(){

    string s;
    cin >> s;
    vector<string> ss(10);
    int count = 0;
    int out = 0;
    int i = 0;
    bool a = true;

    while(a){
        bool f = true;
        while(f){
            if(s[0] == 'A'||s[0] == 'G'||s[0] == 'C'||s[0] == 'T'){
                ss[i] += s[0];
                s.erase(s.begin());
                if(s.empty() == true){
                    f = false;
                    ++count;
                    a = false;
                }
            }else{
                s.erase(s.begin());
                f = false;
                if(ss[i].empty() == false)++count;else --i;
                if(s.empty() == true)a = false;
            }
        }
        ++i;
    }
    for(int i = 0; i < count; ++i){

        if(ss[i].size() > out)out = ss[i].size();

    }

    cout << out << endl;

    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b && b == c){
    cout << 1 << endl;
  }
  else if(a==b || b==c || c==a){
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
   
  }
}

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

using namespace std;

struct CumulativeSum2D
{
  vector< vector< int > > data;

  CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0))
  {
  };

  inline void add(int x, int y, int z)
  {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  inline int query(int sx, int sy, int gx, int gy)
  {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

int main()
{
  int N, M, X[5000], Y[5000];

  scanf("%d %d", &N, &M);
  vector< int > xs(N), ys(N);
  for(int i = 0; i < N; i++) {
    scanf("%d %d", &X[i], &Y[i]);
    xs[i] = X[i];
    ys[i] = Y[i];
  }
  sort(begin(xs), end(xs));
  xs.erase(unique(begin(xs), end(xs)), end(xs));
  sort(begin(ys), end(ys));
  ys.erase(unique(begin(ys), end(ys)), end(ys));
  CumulativeSum2D sum(xs.size(), ys.size());
  for(int i = 0; i < N; i++) {
    sum.add(lower_bound(begin(xs), end(xs), X[i]) - begin(xs),
            lower_bound(begin(ys), end(ys), Y[i]) - begin(ys), 1);
  }
  sum.build();
  for(int i = 0; i < M; i++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x1 = lower_bound(begin(xs), end(xs), x1) - begin(xs);
    y1 = lower_bound(begin(ys), end(ys), y1) - begin(ys);
    x2 = upper_bound(begin(xs), end(xs), x2) - begin(xs);
    y2 = upper_bound(begin(ys), end(ys), y2) - begin(ys);
    printf("%d\n", sum.query(x1, y1, x2, y2));
  }
}

Measured memory_bytes: 100784
import copy, sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
A = [int(i) for i in input().split()]
edge = [[] for i in range(n)]

grundy = [-1] * n

for i in range(n-1):
    a, b = [int(i) for i in input().split()]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v):
    if grundy[v] != -1: return grundy[v]
    mex = [0] * (len(edge[v]) + 1)
    for vv in edge[v]:
        if A[vv] < A[v]: 
            gg = dfs(vv)
            if gg <= len(edge[v]): mex[gg] = 1
    for i in range(len(edge[v])+1):
        if mex[i] == 0:
            grundy[v] = i
            return i

for i in range(n):
    dfs(i)

ans = []
for i in range(n):
    if grundy[i] != 0: ans.append(i+1)

print(*ans)


Measured memory_bytes: 10136
n = int(input())
p = list(map(int, input().split()))
p_sort = sorted(p)
non_0 = 0

for i in range(n):
    diff = p[i] - p_sort[i]
    if diff != 0:
        non_0 += 1
        if non_0 >2:
            print('NO')
            exit()

print('YES')

Measured memory_bytes: 3060
// C++ program to find LCM of n elements
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
ll findlcm(ll arr[], ll n)
{
    // Initialize result
    ll ans = arr[0],i;
 
    // ans contains LCM of arr[0],..arr[i]
    // after i'th iteration,
    for (i=1; i<n; i++)
    {
        ll GCD=__gcd(arr[i],ans);
        ans=ans*(arr[i]/GCD);
    }
 
    return ans;
}
 
// Driver Code
int main()
{
    ll N,i;
    cin>>N;
    
    ll arr[N];
    for(i=0;i<N;i++)
    {
        cin>>arr[i];
    }
    cout<<findlcm(arr, N);
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int N;

signed main()
{
    cin >> N;
    ll ans = 1;
    for(int i = 1; i <= N; ++i) {
        ans *= i;
        ans %= MOD;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n=101;

int main(){
  int i,j,k,u,v;
  int N[n][n];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      N[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      N[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j>0){
        printf(" ");
      }
      printf("%d",N[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2112
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100];

int main(void){
	int n,i,j,r=0;
	ll s=0ll,ans=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		s ^= a[i];
	}
	for(i=0; i<n; ++i){
		a[i] &= ~s;
	}
	for(j=59; j>=0; --j){
		for(i=r; i<n; ++i){
			if(a[i]&(1ll<<j)){
				break;
			}
		}
		if(i==n){
			continue;
		}
		if(i>r){
			a[r] ^= a[i];
		}
		for(i=r+1; i<n; ++i){
			if(a[i]&(1ll<<j)){
				a[i] ^= a[r];
			}
		}
		++r;
	}
	for(i=0; i<n; ++i){
		ans = max(ans,ans^a[i]);
	}
	ans <<= 1;
	ans += s;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }


int main(void) {
	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && A != C) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A == C && A != B) {
		cout << "Yes" << endl;
		return 0;
	}

	if (B == C && A != B) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
int n;
LL ans;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		if(i % 3 && i % 5) ans += (LL)i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <iostream>

using namespace std;

struct bar
{
    int max;
    int min;
};

bool operator<(const bar &left, const bar &right)
{
    return left.max < right.max;
}

int main()
{
    int n;
    scanf("%d", &n);
    int x[n], l[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d%d", &x[i], &l[i]);
    }

    vector<bar> bars;
    struct bar a;
    for (int i = 0; i < n; i++)
    {
        a.min = x[i] - l[i];
        a.max = x[i] + l[i];
        bars.push_back(a);
    }

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

    int s = 1;
    int d = 0;

    while(d < n){
        for(int i = d; i < n; i++){
            if(bars[d].max <= bars[i].min) {
                s++;
                d = i;
                break;
            }
          if(i == n-1) d=n;
        }
    }

    printf("%d", s);
    return 0;

}

Measured memory_bytes: 2168
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val a1 = readLine()!!.split(" ").map{ it.toInt() }
	val a2 = readLine()!!.split(" ").map{ it.toInt() }
	
	(0..n-1).map{ a1.take(it+1).sum() + a2.drop(it).sum() }
			.max().let {println(it)}
	
}

Measured memory_bytes: 37864
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

ans = 0
num_str = [str(i).zfill(3) for i in range(1000)]

for i in num_str:
    j = 0
    k = 0
    while k < 3:
        while j < len(S):
            if S[j] == i[k]:
                k += 1
                j += 1
                break
            j += 1
        if j == len(S):
            break
    if k == 3:
        ans += 1

print(ans)


Measured memory_bytes: 41308
#include<iostream>
int main()
{
	int n,m,s;
	std::cin>>n;
	if(n%1000==0){
		std::cout<<0<<std::endl;
	}
	else
	{
		m=n/1000;
		s=(m+1)*1000;
		std::cout<<s-n<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<list>
#include<array>
#include<cassert>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<< #X <<": "<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) (X).begin(),(X).end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};

const int INF=100000000;
const int MOD7=1000000007;
int mode=1;

int main(){
	int n,x,y,a[3000];
	cin>>n>>x>>y;
	ARREP(i,n,a);
	int some1=abs(a[n-2]-a[n-1]);
	int some2=abs(a[n-1]-y);
	cout<<max(some1,some2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=7368800;
bool a[M];
int m,n;

int main(){
	while(1){
		cin>>m>>n;
		if(!m&&!n) break;
		fill(a,a+M,0);
		while(1){
			if(!a[m]){
				if(!n) break;
				for(int i=m;i<M;i+=m) a[i]=1;
				n--;
			}
			m++;
		}
		cout<<m<<endl;
	}
}


Measured memory_bytes: 10272