akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(;;){
        int n,m;
        cin>>n>>m;
        if(!n) return 0;
        vector<int> a(n);
        rep(i,0,n) cin>>a[i];
        int res=-1;
        rep(i,0,n){
            rep(j,i+1,n){
                if(a[i]+a[j]<=m) res=max(res, a[i]+a[j]);
            }
        }
        if(res==-1) cout <<"NONE"<<"\n";
        else cout <<res<<"\n";
    }
}


Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    i64 n,k;
    cin >> n >> k;
    vector<i64> a(n);
    rep(i,n) cin >> a[i];

    int one_cnt[45] = {0};
    i64 bit = 1;
    int max_i = 0;
    rep(i,45)
    {
        rep(j,n)
        {
            if(i64(a[j]&bit) != 0)
            {
                one_cnt[i]++;
                max_i = i;
            }                
        }

        bit = bit << 1;
    }

    bit = 1;
    i64 dp[45][2];
    dp[0][0] = dp[0][1] = 0;
    rep(i,45)
    {        
        if(one_cnt[i] >= n - one_cnt[i])
            dp[i+1][0] = dp[i][0] + one_cnt[i] * bit;
        else
            dp[i+1][0] = dp[i][0] + (n - one_cnt[i]) * bit;

        if(i64(k&bit) != 0)
            dp[i+1][1] = max(dp[i][0] + one_cnt[i] * bit, dp[i][1] + (n-one_cnt[i]) * bit);
        else
            dp[i+1][1] = dp[i][1] + one_cnt[i] * bit;

        // cout << one_cnt[i] << " " << dp[i+1][0] << " " << dp[i+1][1] << endl;

        if(i >= max_i && i64(bit << 1) > k)
        {
            cout << dp[i+1][1] << endl;
            break;
        }

        bit = bit << 1;
    }

    return 0;
}

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

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

  string r="";

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      r += '0';
    } else if (s.at(i) == '1'){
      r += '1';
    } else {
      if (r.size() == 0){
        continue;
      } else {
        r.pop_back();
      }
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]){
    Iterator.continually(readLine)   
    .map(s => {
      val xs = s.split(" ").map(_.toInt) 
      (xs(0), xs(1))
    })
    .takeWhile{
      case (0, 0) => false
      case _ => true
    }
    .foreach{
      xs =>
      val n = xs._1
      val x = xs._2
      var count = 0 
      for (a <- 1 to n; b <- a + 1 to n; c <- b + 1 to n){
        if (a + b + c == x) count += 1
      }
      println(count)
    }
  }
}

Measured memory_bytes: 46432
package main

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

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, []int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n := scanInt(sc)
	ds := make([]int, 0, n)
	for i := 0; i < n; i++ {
		ds = append(ds, scanInt(sc))
	}
	return n, ds
}

func resolve(n int, ds []int) int {
	sum := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sum += ds[i] * ds[j]
		}
	}
	return sum
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int num=0;
  for(int i=1;i<=n;i++){
    int cnt = 0;
    for(int j=1;j<=n;j++){
      if(i%j == 0 && j%2 == 1){
        cnt++;
      }
    }
    if(cnt == 8){
      num++;
    }
  }
  
  cout << num << endl;
    
  return 0;
  
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #pragma GCC optimization ("unroll-loops")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 2e5 + 4;
  ll n,k;
  vll v(maxn);	
  bool check(ll mid){
  	ll count =0;
  	  for(int i=0;i<n;i++){
		  count += (v[i]/mid - (v[i]%mid==0));
  	  }
  	  return count <= k;
  }
  void solve(){
	 	cin >> n >> k;
	 	for(int i=0;i<n;i++){
	 		cin >> v[i];
	 	}		
	 	// deb(v);
	 	ll low = 1;
	 	ll high = 1e9;
	 	while(low!=high){
	 		ll mid = (low+high)/2;
	 		if(check(mid)){
	 			high=mid;
	 		}
	 		else{
	 			low = mid+1;
	 		}
	 	}
	 	cout << low;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

Measured memory_bytes: 4704
import copy
n,w = map(int,input().split())
V = n*10**3+2
b = [float("inf")]*V
b[0] = 0
a = [float("inf")]*V
a[0] = 0
for _ in range(n):
  wi,vi = map(int,input().split())
  for i in range(vi):
    a[i] = min(b[i],wi)
  for i in range(vi,V):
    a[i] = min(b[i],b[i-vi]+wi)
  b = copy.copy(a)
i = 0
while b[i] <= w:
  i += 1
print(i-1)  
    
    
              
    
    
    

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  int paint[H][W];
  memset(paint, 0, sizeof(paint));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < W; j++) {
      paint[i][j] = 1;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < w; j++) {
      paint[i][j] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans += (int) (paint[i][j] == 0);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;

	scanf("%d %d", &a, &b);
	a = (a + 11) % 13;
	b = (b + 11) % 13;

	puts(a > b ? "Alice" : a < b ? "Bob" : "Draw");

	return 0;
}


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

int main()
{
    int n,capacity;
    cin>>n>>capacity;
    int A[n][2];
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            cin>>A[i][j];
        }
    }
    long long int dp[n][capacity+1];
    for(int i=0;i<n;i++){
        for(int j=0;j<=capacity;j++){
            if(i==0){
                if(A[i][0]<=j){
                    dp[i][j] = A[i][1];
                }
                else
                    dp[i][j] = 0;
            }
            else
            dp[i][j] = 0;
        }
    }
    
    for(int i=1;i<n;i++){
        for(int j = 0;j<=capacity;j++){
            if(A[i][0]<=j){
                dp[i][j] = max(A[i][1]+dp[i-1][j-A[i][0]],dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n-1][capacity]<<endl;
	return 0;
}

Measured memory_bytes: 78336
#include <stdio.h>

int gcd(int x, int y){
	/* euclid algorithm */
    int r;
	while((r=x%y)!=0) x=y, y=r;
	return y;
}

int lcm(int x, int y){
    if(x == 0 || y == 0) return 0;
    return x/gcd(x, y)*y; /* ツ静ヲツづ謁ツ掛ツつッツづゥツづ暗ャツづェツづゥ */
}

int main(void){
	int a,b;
	while(~scanf("%d %d",&a,&b))
		printf("%d %d\n",gcd(a,b),lcm(a,b));
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
using namespace std;
typedef long long ll;
ll pw(ll b,ll e){
	ll i,r=1;
	for(i=0;i<e;i++)r*=b;
	return r;
}
int main(){
	ll n,k;
	while(cin>>n>>k,n){
		ll m,s,r;
		for(m=1;n>9*m*pw(10,m-1);m++)n-=9*m*pw(10,m-1);
		for(r=0;n>m;r++)n-=m;
		s=pw(10,m-1)+r;
		stringstream ans;
		while(ans.str().size()<=k+n)ans<<s++;
		cout<<ans.str().substr(n-1,k)<<endl;
	}
	return 0;
}

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

int main() {
  int N;
  int sum = 0;
  int num = 0;
  int j;
  cin >> N;
  j = N;
  while (j > 0){
    num = j % 10 ;
    sum += num ;
    j = j/10 ;
  }
  if (N % sum == 0 ){
  	cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    static final int MOD = 1_000_000_007;
    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N];
        for (int n = 0; n < N; n++)
            A[n] = in.nextInt();
        long sum = 0;
        for (int n = 0; n < N; n++)
            sum += A[n];
        long ans = 0;
        for (int n = 0; n < N; n++) {
            sum -= A[n];
            sum += MOD;
            sum %= MOD;
            ans += sum * A[n];
            ans %= MOD;
        }
        out.println(ans);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 62440
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    rep(i,0,n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int sum = 0;
    for(vector <int>::iterator i = a.begin(); i != a.end(); i++) {
       if (next(i) != a.end())  {
           sum += *i;
       } else {
           sum += *i /2;
       }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3144
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

int main(){fastio
    
    ll a[3];rep(i,0,2)cin>>a[i];
    sort(a,a+3);
    ll ans=a[2]*2-a[1]-a[0];
    if(ans%2==1)ans+=3;
    cout<<ans/2<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 2e5 + 5, MOD = 1e9 + 7;

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rw", stdin);
#endif
	ll a;
	cin >> a;
	cout << a + (a * a) + (a * a * a);
	return 0;
}


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

int main(){
int n;
cin >> n;
vector<double> v(n);
for(int i = 0; i< n;i++)cin >> v[i];
sort(v.begin(), v.end());
double a;
for(int i = 0; i< n-1 ;i++){
    a = (double)((v[i] + v[i+1])*0.5);
     v[i+1]  = a;
}
printf("%.10f\n", a);
return 0;
}

Measured memory_bytes: 3780
list = map(int,raw_input().split())
W = list[0] 
H = list[1] 
x = list[2]
y = list[3]
r = list[4]

if x-r < 0:
    print "No"
elif x + r > W:
    print "No"
elif y-r < 0:
    print "No"
elif y+r > H:
    print "No"
else:
    print "Yes"


Measured memory_bytes: 4636
s = gets.chop.split.map(&:to_i)
s=s[0]

d=[]
d[0]=s/1000
d[1]=(s-d[0]*1000)/100
d[2]=(s-d[0]*1000-d[1]*100)/10
d[3]=(s-d[0]*1000-d[1]*100-d[2]*10)

if ((d[0]==d[1])||(d[1]==d[2])||(d[2]==d[3]))
  puts "Bad"
else
  puts "Good"
end


Measured memory_bytes: 3836
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
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; }

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        G[x - 1].push_back(y - 1);
    }
    vector<int> dp(N, -1);
    function<int(int)> rec = [&](int v) {
        if (dp[v] != -1) return dp[v];
        int res = 0;
        for (auto nv : G[v]) chmax(res, rec(nv) + 1);
        return dp[v] = res;
    };
    int res = 0;
    for (int v = 0; v < N; v++) chmax(res, rec(v));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<cstdio>
#include<math.h>
#define NGS 100000

using namespace std;

bool isPrime(int);

int main(){
  int N,Arrange[2][NGS],i,j,k,l,count=0;
 
  /* 
  for(i=0;i<NGS;i++){
    Arrange[0][i]=0;
    Arrange[1][i]=0;
  }
  */
  
  while( scanf("%d",&N)!=EOF){
    count=0;
    k=1;
    l=N;
    
    for(i=0;i<N;i++){
      Arrange[0][i]=k;
      k++;
      Arrange[1][i]=l;
      l--;
    }
      
    /*  for(i=0;i<N;i++){
      cout << Arrange[0][i];
    }
    cout << endl;
    
    for(i=0;i<N;i++){
      cout << Arrange[1][i];
    }    
    cout << endl;
    */

    for(i=0;i<N;i++){     
      if(isPrime(Arrange[0][i]) == true)
	{
	  if(isPrime(Arrange[1][i]) == true)count++;
	}
    }
    
    cout << count << endl;
    
    
    
  }
}


bool isPrime(int x){
  int i;

  // cout << x << endl;
  if(x<2)return false;
  else if(x == 2)return true;
  if(x%2 == 0)return false;
  int limit = (int)sqrt((double)x) +1;
  for(i=3;i<=limit;i+=2){
    if(x%i==0)return false;
  }
  return true;
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

int a[200][200], b[200][200];
signed main(){
	while(1){
		int n, m;
		scanf("%lld%lld", &m, &n);
		if(n == 0 and m == 0)break;
		rep(i,200)rep(j,200)a[i][j] = b[i][j] = inf;
		rep(i,200)a[i][i] = b[i][i] = 0;
		rep(i,m){
			int x, y, c, t;
			scanf("%lld%lld%lld%lld", &x, &y, &c, &t);x--;y--;
			a[x][y] = a[y][x] = min(a[x][y], c);
			b[x][y] = b[y][x] = min(b[x][y], t);
		}
		rep(i,n)rep(j,n)rep(k,n){
			a[j][k] = a[k][j]= min(a[j][k], a[j][i]+a[i][k]);
			b[j][k] = b[k][j]= min(b[j][k], b[j][i]+b[i][k]);
		}
		int k;
		scanf("%lld", &k);
		rep(i,k){
			int x, y, f;
			scanf("%lld%lld%lld", &x, &y, &f);x--;y--;
			//printf("*%lld %lld %lld*\n", x, y, a[x][y]);
			if(f == 0)printf("%lld\n", a[x][y]);
			else printf("%lld\n", b[x][y]);
		}
		/*rep(i,n){
			rep(j,n)printf("%lld ", a[i][j]);
			printf("\n");
		}*/
	}
	return 0;
}






Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<stdio.h>
#include<iomanip>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long
int main(){
    int n;
    double ans=0.0,A;
    cin>>n;
    rep(i,n){
        cin>>A;
        ans+=1.0/A;
    }
    ans=1.0/ans;
    cout<<setprecision(16)<<ans<<endl;
    return 0;
}

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

int main(){
  int n;
  while(cin >> n && n){
    int A=0,B=0;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      if(a > b) A += a + b;
      else if(a < b) B += a + b;
      else {
	A += a;
	B += b;
      }
    }
    cout << A << ' '<< B << endl;
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int d[6];

enum {
    NORTH,
    EAST,
    SOUTH,
    WEST
};

void run(int c) {
    switch (c) {
    case NORTH:
        swap(d[1], d[0]);
        swap(d[0], d[4]);
        swap(d[4], d[5]);
        break;
    case EAST:
        swap(d[3], d[0]);
        swap(d[0], d[2]);
        swap(d[2], d[5]);
        break;
    case SOUTH:
        swap(d[5], d[4]);
        swap(d[4], d[0]);
        swap(d[0], d[1]);
        break;
    case WEST:
        swap(d[2], d[0]);
        swap(d[0], d[3]);
        swap(d[3], d[5]);
        break;
    }
}

int main() {
    map<string, int> cmds;
    cmds["north"] = NORTH;
    cmds["east"]  = EAST;
    cmds["south"] = SOUTH;
    cmds["west"]  = WEST;
    int n;
    while (cin >> n, n) {
        for (int i = 0; i < 6; i++) {
            d[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
            string cmd;
            cin >> cmd;
            run(cmds[cmd]);
        }
        cout << d[0] << endl;
    }
}

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

int main() {
  int k;
  int x;
  cin >> k >> x;
  int min_bound = max(-1000000,x-k+1);
  int max_bound = min(1000000, x+k-1);
  for(int i=min_bound; i<max_bound; i++){
    cout << i << " ";
  }
  cout << max_bound;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i+=2){
		//cout<<i;
		if(s[i]!='h'||s[i+1]!='i')
		{
			cout<<"No";
			return 0;
		}
	} 
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 256
# AGC 017: A – Biscuits
N, P = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]

isAllEven = True

for k in A:
    if k % 2 == 1:
        isAllEven = False
        break

if isAllEven:
    if P == 0:
        print(2 ** N)
    else:
        print(0)
else:
    print(2 ** (N -1))

Measured memory_bytes: 3064
function Main(input) {
  // 入力値（文字列）をスペースで区切り、配列として格納し各要素の値を数値に変換
  const result = input
  .split(/\s/);

  if(result[0] <= 8 && result[1] <= 8){
    console.log('Yay!');
  }else {
    console.log(':(');

  }
};
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>

int A[100005];
int cnt[100005];

int main(){

	int N;

	scanf("%d",&N);

	int i;
	for(i=0;i<N;i++){
	scanf(" %d",&A[i]);
	cnt[A[i]]++;
	}
	int one=0;
	int two=0;
	for(i=1;i<=100000;i++){
		if(cnt[i]%2==0 && cnt[i]>0){
			cnt[i]=2;
			two++;
		}
		else if(cnt[i]%2==1&&cnt[i]>0){
			cnt[i]=1;
			one++;
		}
	}
	if(two%2==1){
	two--;
	}
	printf("%d\n",one+two);

	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define mod		1000000007
#define inf     1000000000000000000
#define MX1		100005
#define MX2		10000004
#define pi		acos(-1)
#define pb      push_back
#define vlli    vector<lli>
#define plli    vector<pair<lli,lli> >
#define mp      make_pair
#define all(v)  v.begin(),v.end()
#define test    int t;cin>>t;
lli gcd(lli a, lli b){return b?gcd(b,a%b):a;}
lli power(lli a,lli b){lli ans=1;while(b){if(b&1){ans=(ans*a)%mod;}a=(a*a)%mod;b>>=1;}return ans;}
int arr[MX1];
int main()
{
	opt;
	lli n;
	cin>>n;
	vector<lli>v;
	lli i,j,k,l=0;
	v.pb(0);
	for(i=0;i<n;i++)
	{
		cin>>j;
		v.pb(j);
	}
		i=1;
	while(1)
	{
	
		if(arr[i]==1)
		{
			cout<<"-1\n";
			break;
		}
		else if(v[i]!=2)
		{
			arr[i]=1;
			l++;
			i=v[i];
		}
		else
		{
			cout<<l+1<<"\n";
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 1524
// Problem : D - Wizard in Maze
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 int H,W;
 vi grd[MX];
int dx[]={0,0,-1,1,1,1,-1,-1},dy[]={1,-1,0,0,1,-1,1,-1};
 inline bool isValid(int x,int y)
 {
 	if(x>=0 && x<H && y>=0 && y<W && !grd[x][y])
 		return true;
 	return false;
 }
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>H>>W;
	pi st,en;
	cin>>st.f>>st.s>>en.f>>en.s;
	st.f--,st.s--,en.f--,en.s--;
	F0R(x,H)
	{
		string str;
		cin>>str;
		F0R(y,W)
		{
			grd[x].pb(str[y]=='#'?1:0);
			// cout<<grd[x][y];
		}
		// cout<<nl;
	}
	int mvs[H][W];
	// int vis[H][W]={0};
	fill(mvs[0],mvs[0]+H*W,INT_MAX);
	// 0/1 BFS
	deque<pi> q;
	q.pb(st);
	// vis[st.f][st.s]=1;
	mvs[st.f][st.s]=0;
	while(sz(q)!=0)
	{
		pi S=q.front();
		q.pop_front();
		F0R(x,4)
		{
			pi v={S.f+dx[x],S.s+dy[x]};
			if(isValid(v.f,v.s) && mvs[v.f][v.s]>mvs[S.f][S.s])
			{
				q.push_front(v);
				mvs[v.f][v.s]=mvs[S.f][S.s];
			}
		}
		FOR(x,-2,3)
		{
			FOR(y,-2,3)
			{
				int a=S.f+x,b=S.s+y;
				if(isValid(a,b) && mvs[a][b]>mvs[S.f][S.s]+1)
				{
					q.pb({a,b});
					mvs[a][b]=1+mvs[S.f][S.s];
				}
			}
		}
	}
	mvs[en.f][en.s]=mvs[en.f][en.s]==INT_MAX?-1:mvs[en.f][en.s];
	cout<<mvs[en.f][en.s];
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 16376
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    int X; cin >> X;
    cout << ((X==7||X==5||X==3)?"YES":"NO") << endl;
    
    return 0;
}


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

using namespace std;

typedef unsigned long long lint;
lint get_paty(int n, lint x, vector<lint> a, vector<lint> p)
{
  if(n == 0){
    if(x < 1)
      return 0;
    else
      return 1;
  }
  if(x == 1){
    return 0;
  }
  if(x <= 1 + a[n-1]){
    return get_paty(n-1, x-1, a, p);
  }
  else if(x == 2 + a[n-1]){
    return 1 + p[n-1];
  }
  else if(x <= 2 + 2 * a[n-1]){
    return 1 + p[n-1] + get_paty(n-1, x-2-a[n-1], a, p);
  }
  else if(x == 3 + 2 * a[n-1]){
    return 1 + 2 * p[n-1];
  }
}

int main(void)
{
  lint N, X;
  cin >> N >> X;
  vector<lint> a(N);
  vector<lint> p(N);
  a[0] = 1;
  p[0] = 1;
  for(int i = 1; i < N; i++){
    a[i] = 3 + 2 * a[i-1];
    p[i] = 1 + 2 * p[i-1];
  }
  cout << get_paty(N, X, a, p) << endl;;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define debug(x) if(MODE==x)
#define MODE 0
using namespace std;

int main()
{
    int i,j;
    int a,b;

    scanf("%d %d",&a,&b);
    int cnt = 0;
    int total = 1;
    while(total < b)
    {
        total += a;
        total -= 1;
        cnt++;
    }
    printf("%d\n",cnt);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6

int32_t main()
{



    string s,t;
    cin >> s >> t;
    int a, b;
    cin >> a>> b;

    string u;

    cin >> u;

    if(u == s)
    {
      cout << a - 1 << " " << b;
    }
    else if(u == t)
    {
      cout << a << " " << b-1;
    }
    else
    {
      cout << a << " " << b;
    }
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
A = [int(v)-1 for v in input().split()]

memo = {}
p = 0
for i in range(k):
  if p in memo:
    itvl = i - memo[p]
    rest = (k-i-1)%itvl
    for j in range(rest+1):
      p=A[p]
    print(p+1)
    exit()
  else:
    memo[p]=i
  p=A[p]
print(p+1)


Measured memory_bytes: 32328
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, Q;
	string S;

	cin >> N >> Q;
	cin >> S;
	vector<int> s(N, 0);
	vector<int> cum(N + 1, 0);

	for (int i = 0; i + 1 < N; i++)
	{
		if (S[i] == 'A' && S[i + 1] == 'C')
			s[i] = 1;
	}

	for (int i = 0; i < N; i++)
	{
		cum[i + 1] = cum[i] + s[i];
	}

	for (int i = 0; i < Q; i++)
	{
		int left, right;
		cin >> left >> right;
		cout << cum[right - 1] - cum[left - 1] << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1872
#桁数をNとし、各桁の数字の和をSとすると
#(N - 1) + (S - 1) // 9 が答え

M = int(input())
S = 0 #mod 9
N = 0
for i in range(M):
  d, c = map(int, input().split())
  N += c
  S += d * c
  
ans = (N - 1) + (S - 1) // 9
print(ans)

Measured memory_bytes: 44248
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
	int k;string s;
  cin >> k >> s;
  	if(s.size()<=k){
     cout<<s<<endl; 
    }
  else{
	string ans;
    for(int i=0;i<k;i++){
      ans+=s.at(i);
    }
    ans+="...";
    cout<<ans<<endl;
  }
  

}
    



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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int V = 1e5+5;
int dp[105][V];
int cost[105], val[105];

void solve(){
    int n, w;
    cin >> n >> w;
    for(int i = 0; i < n; ++i) cin >> cost[i] >> val[i];

    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= 1e5; ++j)
            dp[i][j] = dp[i-1][j];
        for(int j = val[i-1]; j <= 1e5; ++j){
            dp[i][j] = min(dp[i-1][j-val[i-1]] + cost[i-1], dp[i][j]);
        }
    }

    for(int v = 1e5; v >= 0; --v){
        if(dp[n][v] <= w){
            cout << v << "\n";
            return;
        }
    }
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 44580
a,b,K = map(int,input().split())

def func(m,n):
	x = max(m,n)
	y = min(m,n)
	tmp =[]
	for it in range(y):
		it = it + 1
		if x%it == 0 and y%it==0:
			tmp.append(it)
	return tmp

tmp =func(a,b)
print(tmp[len(tmp)-K])


Measured memory_bytes: 3060
from collections import Counter
n = int(input())
s = input()
ans_list = [0]*n
e_num = Counter(s[1:])['E']
ans = e_num
for i in range(1, n):
    if s[i] == 'E':
        e_num -= 1
    if s[i-1] == 'W':
        e_num += 1
    ans = min(e_num, ans)
print(ans)

Measured memory_bytes: 46040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); //n个
		int[] arr1 = new int[n];
		for(int i=0;i<arr1.length;i++)
		{
			arr1[i]=sc.nextInt();
		}
		int q = sc.nextInt(); //q
		int[] arr2 = new int[q]; //不重复的
		for(int i=0;i<arr2.length;i++)
		{
			arr2[i]=sc.nextInt();
		}
		int sum=0;
		
		for(int i=0;i<arr2.length;i++)
		{
			if(lineSearch(arr1, arr2[i]))
			{
				sum++;
			}
		}
		
		System.out.println(sum);
		
	}
	
	
	public static boolean lineSearch(int arr[],int key)
	{
		boolean flag=false;
		for(int i=0;i<arr.length;i++)
		{
			if(arr[i]==key)
			{
				flag = true;
				break;
			}
		}
		
		return flag;
	}
}



Measured memory_bytes: 40124
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>


char s[100 + 5];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; ++ i) {
    for (int j = i; j <= n; ++ j) {
      std::string w = std::string(s + 0, s + i) + std::string(s + j, s + n);
      if (w == "keyence") {
        return puts("YES"), 0;
      }
    }
  }
  puts("NO");
}

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


int main(){
    int N;
    int64_t res=1,tmp;
    cin>>N;
    vector<int64_t> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        if(A.at(i)==0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<N;i++){
        tmp=res;
        res*=A.at(i);
        if(res<tmp||res>1000000000000000000){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<res<<endl;
}

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



Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI ans;
    if (n == 3)ans = { 2,5,63 };
    else {
        VI m2, m3, m6 = { 6 };
        for (int i = 6; i <= 30000; i += 2)if (i % 6 != 0)m2.push_back(i);
        for (int i = 12; i <= 30000; i += 3) {
            if (i % 6 == 0)m6.push_back(i);
            else m3.push_back(i);
        }

        ans = { 2,4,3,9 };
        while (ans.size() < n) {
            if (2 <= n - ans.size()) {
                VI *a = &m6;
                if (!m2.empty())a = &m2;
                else if (!m3.empty())a = &m3;
                FOR(i, 0, 2) {
                    ans.push_back(a->back());
                    a->pop_back();
                }
            }
            else ans.push_back(m6.back());
        }
    }

    FOR(i, 0, n)cout << ans[i] << ENDL(i, n);
}

Measured memory_bytes: 520
s = str(input())
b = 2**(len(s)-1)-1
suma = 0

for i in range(0,(2**(len(s)-1)-1)+1):
    ans = list(str(s))
    binlist = list(str(format(b,'0' + str(len(s)-1) + 'b')))
    a = 0
    for i in range(0,len(binlist)):
        if binlist[i] == '1':
            ans.insert((i+1)+a,"+")
            a+=1

    b-=1
    suma += eval(''.join(ans))

print(suma)

Measured memory_bytes: 3064
#include <algorithm>
#include <deque>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, Q, M;
    cin >> N >> Q;
    M = int(sqrt(N)) + 1;
    vector<deque<int>> a;
    vector<int> b((N + M - 1) / M, 1 << 30);
    for (int i = 0; i < b.size(); ++i) {
        a.emplace_back(min(M, N - i * M));
        for (int& j : a.back()) {
            cin >> j;
            b[i] = min(b[i], j);
        }
    }
    for (int h = 0; h < Q; ++h) {
        int z, l, r;
        cin >> z >> l >> r;
        if (z == 0) {
            int p;
            int x = 0;
            for (int i = 0; i < a.size(); ++i) {
                if (r < x + a[i].size()) {
                    p = a[i][r - x];
                    a[i].erase(a[i].begin() + r - x);
                    b[i] = 1 << 30;
                    for (int j : a[i])
                        b[i] = min(b[i], j);
                    break;
                }
                x += a[i].size();
            }
            x = 0;
            for (int i = 0; i < a.size(); ++i) {
                if (l < x + a[i].size()) {
                    a[i].insert(a[i].begin() + l - x, p);
                    b[i] = 1 << 30;
                    for (int j : a[i])
                        b[i] = min(b[i], j);
                    break;
                }
                x += a[i].size();
            }
        } else if (z == 1) {
            ++r;
            int mn = 1 << 30;
            int x = 0;
            for (int i = 0; i < a.size(); ++i) {
                int p = l < x ? 0 : l < x + a[i].size() ? 1 : 2;
                int q = r < x + a[i].size() ? 1 : 2;
                if (p == 1 || q == 1) {
                    int sz = min<int>(a[i].size(), r - x);
                    for (int j = max(0, l - x); j < sz; ++j)
                        mn = min(mn, a[i][j]);
                } else if (p == 0 && q == 2) {
                    mn = min(mn, b[i]);
                }
                if (q == 1) break;
                x += a[i].size();
            }
            cout << mn << endl;
        } else {
            int x = 0;
            for (int i = 0; i < a.size(); ++i) {
                if (l < x + a[i].size()) {
                    a[i][l - x] = r;
                    b[i] = 1 << 30;
                    for (int j : a[i])
                        b[i] = min(b[i], j);
                    break;
                }
                x += a[i].size();
            }
        }
        int i = int(Q / sqrt(N));
        if (h % (i + 1) == i) {
            vector<deque<int>> c(1);
            for (auto& p : a) {
                for (int i : p) {
                    if (c.back().size() == M)
                        c.emplace_back(deque<int>());
                    c.back().emplace_back(i);
                }
            }
            a = move(c);
            for (int i = 0; i < a.size(); ++i) {
                b[i] = 1 << 30;
                for (int j : a[i])
                    b[i] = min(b[i], j);
            }
        }
    }
    return 0;
}

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

int main(void) {
    int n, x;
    while(~scanf("%d", &n)) {
        int abs_mx = 0, idx = -1;
        for(int i = 1; i <= n; ++i) {
            scanf("%d", &x);
            if(abs(abs_mx) < abs(x)) {
                abs_mx = x;
                idx = i;
            }
        }
        if(idx == -1) {
            puts("0");
            continue;
        }
        printf("%d\n", (n << 1) - 1);
        for(int i = 1; i <= n; ++i)
            printf("%d %d\n", idx, i);
        if(abs_mx > 0) {
            for(int i = 1; i < n; ++i)
                printf("%d %d\n", i, i + 1);
            } else {
                for(int i = n; i > 1; --i)
                    printf("%d %d\n", i, i - 1);
            }
    }
}


Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))

M = 1000005

cnt = [0 for i in range(M)]

for x in a:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x, M, x):
        cnt[i] += 1

ans = 0

for x in a:
    if cnt[x] == 1:
        ans += 1
    
print(ans)



Measured memory_bytes: 32244
#include <iostream>
using namespace std;
int x[50] , y[50] , a[50] , b[50] ;
int n , m ;
const int MAX = 400000001 ;
     
int main(void){
     
     
     cin >> n >> m ;
     
     for(int i = 0 ; i < n ; i++){
          cin >> x[i] >> y[i] ;
     }
     
     for(int i = 0 ; i < m ; i++){
          cin >> a[i] >> b[i] ;
     }
     
     for(int i = 0 ; i < n ; i++){
          int d = MAX ;
          int num ;
          for(int j = 0 ; j < m ; j++){
               
               int md = max(x[i]-a[j] , a[j]-x[i]) + max(y[i]-b[j] , b[j]-y[i]) ; 
               if(md < d){
                    d = md ;
                    num = j ; 
               } 
          }
          cout << num + 1 << endl ;
     }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int n;
string s;
map<int, set<int> > pos;

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

  cin >> n;
  cin >> s;

  for(int i=0;i<sz(s);i++){
    int a = s[i] - '0';
    pos[a].insert(i);
  }

  int ans = 0;
  for(int i=0;i<=9;i++){
    for(int j=0;j<=9;j++){
      for(int k=0;k<=9;k++){
        if(sz(pos[i]) == 0
        or sz(pos[j]) == 0
        or sz(pos[k]) == 0) continue;
        int pos1 = *pos[i].begin();
        int pos2 = *pos[j].upper_bound(pos1);
        if(pos[j].find(pos2) != pos[j].end()){
          int pos3 = *pos[k].upper_bound(pos2);
          if(pos[k].find(pos3) != pos[k].end()){
            if(pos2 > pos1 and pos3 > pos2){
              // cout << i << " - " << j << " - " << k << endl;
              ans++;
            }
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1664
n=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    if b>a:
        return gcd(b,a)
    if b==0:
        return(a)
    else:
        return gcd(b,a%b)
g=A[0]
seki=A[0]
for i in range(1,n):
    g=gcd(g,A[i])
    seki*=A[i]
lcm=seki//(g**(n-1))
cnt=0
for j in range(n):
    cnt += (lcm-1) % A[j]
print(cnt)

Measured memory_bytes: 3316