akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=120000;
ll ans1=0,ans2=0;
int n,L[N],R[N];
typedef pair<int,int> pii;
#define mk make_pair

set<pii> st1,st2;
int _abs(int x){return x<0 ? -x : x;}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) 
    {
        scanf("%d%d",&L[i],&R[i]);
        st1.insert(mk(R[i],i));
        st2.insert(mk(L[i],i));
    }
    int to=st1.begin()->second,now=0;
    if(R[to]<now||L[to]>now){
        if(_abs(now-R[to])<_abs(now-L[to])) ans1+=_abs(now-R[to]),now=R[to];
        else ans1+=_abs(now-L[to]),now=L[to];
    }
    st1.erase(mk(R[to],to)); st2.erase(mk(L[to],to));
    while(!st1.empty()){//1
        int pos1=st1.begin()->second, pos2=st2.rbegin()->second;
        int tmp=R[pos1],dis=now-R[pos1]; to=pos1; 
        if(dis<L[pos2]-now) dis=L[pos2]-now,to=pos2,tmp=L[pos2];
        if(R[to]<now||L[to]>now){
            if(_abs(now-R[to])<_abs(now-L[to])) ans1+=_abs(now-R[to]),now=R[to];
            else ans1+=_abs(now-L[to]),now=L[to];
        }
        st1.erase(mk(R[to],to)); st2.erase(mk(L[to],to));
    }
    ans1+=_abs(now);

    for(int i=1;i<=n;i++) 
    {
        st1.insert(mk(R[i],i));
        st2.insert(mk(L[i],i));
    }
    to=st2.rbegin()->second,now=0;
    if(R[to]<now||L[to]>now){
        if(_abs(now-R[to])<_abs(now-L[to])) ans2+=_abs(now-R[to]),now=R[to];
        else ans2+=_abs(now-L[to]),now=L[to];
    }
    st1.erase(mk(R[to],to)); st2.erase(mk(L[to],to));
    while(!st1.empty()){//1
        int pos1=st1.begin()->second, pos2=st2.rbegin()->second;
        int tmp=R[pos1],dis=now-R[pos1]; int to=pos1;
        if(dis<L[pos2]-now) to=pos2,tmp=L[pos2];
        //cout<<now<<" "<<to<<" "<<ans2<<endl;
        if(R[to]<now||L[to]>now){
            if(_abs(now-R[to])<_abs(now-L[to])) ans2+=_abs(now-R[to]),now=R[to];
            else ans2+=_abs(now-L[to]),now=L[to];
        }
        st1.erase(mk(R[to],to)); st2.erase(mk(L[to],to));
    }
    ans2+=_abs(now);
    //cout<<ans1<<" "<<ans2<<endl;
    cout<<max(ans1,ans2)<<endl;
    return 0;
}

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

const int N = 1e6 + 10;
int n, ans;
string s, t;
queue<int> q;

int main() {
    cin >> n >> s >> t;
    if (s == t) return puts("0"), 0;
    int up = n - 1, down = n - 1;
    while (down >= 0) {
        while (down && t[down - 1] == t[down]) --down;
        while (up >= 0 && (up > down || s[up] != t[down])) --up;
        if (up < 0) return puts("-1"), 0;
        while (q.size() && q.front() - q.size() >= down) q.pop();
        if (up != down) q.push(up);  // 折线真的是折的，而不是直接竖下来
        ans = max(ans, (int)q.size() + 1);
        --down;
    } printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 6280
N = int(input())
S_list = [input() for i in range(N)]
AC = S_list.count('AC')
WA = S_list.count('WA')
TLE = S_list.count('TLE')
RE = S_list.count("RE")
print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))

Measured memory_bytes: 82668
#include <iostream>

using namespace std;

void swap(int *a, int *b)
{
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(void)
{
  int a = 0, b = 0, c = 0;
  cin >> a >> b >> c;

  if (a > b) {
    swap(&a, &b);
  }

  if (b > c) {
    swap(&b, &c);
  }

  if (a > b) {
    swap(&a, &b);
  }

  cout << a << " " << b << " " << c << endl;

  return 0;
}

Measured memory_bytes: 1164
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        s: chars
    }
    let mut table = vec![];
    let mut prev = 'P';
    let mut tmp = 1;
    for c in s {
        if prev == 'P' {
            // no-op
        } else if prev == c {
            tmp += 1;
        } else {
            table.push(tmp);
            tmp = 1;
        }
        prev = c;
    }
    table.push(tmp);


    let mut sum = 0;
    for t in &table {
        sum += *t - 1;
    }
    if table.len() > k * 2 {
        println!("{}", sum + k * 2);
    } else {
        println!("{}", sum + table.len() - 1);
    }
}


Measured memory_bytes: 4476
#include<iostream>
#include<vector>
//#include<math.h>
#include <unordered_map>
using namespace std;

int main()
{
    int n;
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i>=1&&i<=9)
        {
            ans++;
        }
        if(i>=100&&i<=999)
        {
            ans++;
        }
        if(i>=10000&&i<=99999)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, x; std::cin >> N >> x;
  std::vector<int> a(N);
  int64_t ans = 0;
  for(int i = 0; i < N; ++i) {
    std::cin >> a[i];
    ans += a[i];
  }
  for(int64_t k = 1; k < N; ++k) {
    int64_t cur = k*x;
    if(cur >= ans) continue;
    int save = a[N-1];
    for(int i = N-1; i > 0; --i) a[i] = std::min(a[i], a[i-1]);
    a[0] = std::min(a[0], save);
    for(int i: a) cur += i;
    ans = std::min(ans, cur);
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <numeric>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;



int main(void)
{
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    int a[n];
    a[0] = 0;
    for(int i = 1;i < n;i++)
    {
        if(s[i]=='C' && s[i-1] == 'A')
        {
            a[i] = a[i-1] + 1;
        }
        else
        {
            a[i] = a[i-1];
        }       
    }
    REP(i,q)
    {
        int l,r;
        cin >> l >> r;
        l--;r--;
        cout << a[r] - a[l] << endl;
    }
}




Measured memory_bytes: 1408
import heapq
import sys
input=sys.stdin.readline

class Dijkstra:
    INF = 10**18
    threshold = 10**9

    def __init__(self, N):
        self.MAX_V = N + 1
        self.dist = [self.INF] * self.MAX_V
        self.G = [[] for _ in range(self.MAX_V)]

    def insert(self, X, Y, cost): self.G[X].append(cost * self.threshold + Y)

    def dijkstra(self, st):
        q = []
        heapq.heappush(q, st)
        self.dist[st] = 0

        while len(q):
            p = heapq.heappop(q)
            cost = p // self.threshold
            node = p - cost * self.threshold
            if cost > self.dist[node]: continue
            for to in self.G[node]:
                to_cost = to // self.threshold
                to_node = to - to_cost * self.threshold
                to_cost += self.dist[node]
                if self.dist[to_node] > to_cost:
                    self.dist[to_node] = to_cost
                    heapq.heappush(q, to_cost * self.threshold + to_node)

h, w = map(int, input().split())
sh, sw = map(int, input().split())
eh, ew = map(int, input().split())

sh -= 1
sw -= 1
eh -= 1
ew -= 1

S = [input() for _ in range(h)]

di = Dijkstra(h*w)
for x in range(h):
    for y in range(w):
        if S[x][y] == '#': continue
        for i in range(-2, 3):
            for j in range(-2, 3):
                X = x + i
                Y = y + j
                if X < 0 or Y < 0 or X >= h or Y >= w or S[X][Y] == '#': continue
                D = abs(i) + abs(j)

                if D == 1: di.insert(x * w + y, X * w + Y, 0)
                if D >= 2: di.insert(x * w + y, X * w + Y, 1)

di.dijkstra(sh * w + sw)
ans = di.dist[eh * w + ew]
if ans == 10**18: print(-1)
else: print(ans)


Measured memory_bytes: 213440
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int x;
    cin>>x;
    if(x==3 or x==5 or x==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int main() {
    const int MAX_N = 20;
    int N, V[MAX_N], C[MAX_N];    
    cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> V[i];
    }   
    for (int i = 0; i < N; ++i){
        cin >> C[i];
    }  

    int ans = 0;
    for (int i = 0; i < N; ++i){
        ans += max(0, V[i] - C[i]);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import fractions as fra
import math
a,b = map(int,input().split())
n = fra.gcd(a,b)
tmp = int(math.sqrt(n)) + 1
l = [1]
ans = 0
for i in range(2,tmp):
  while n % i == 0:
    n //= i
    if i not in l:
      l.append(i)
      ans += 1
if n not in l:
  ans += 1
  
print(ans+1)

Measured memory_bytes: 5044
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {

    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        if (i % 2 == 1 && a % 2 == 1) ans++;
    }

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

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

int main() {
    int n;
    cin >> n;
    int h[n], dp[n];
    rep(i, n) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
typedef long long ll;

int main(void){
  ll a, b;
  ll t;
  scanf("%lld %lld", &a, &b);

  // aを大きくする
  if(a<b){
    t=a;
    a=b;
    b=t;
  }

  // printf("%lld\n", a-b);
  if((a-b)%2==1){
    printf("IMPOSSIBLE\n");
  }else{
    printf("%lld\n", (a+b)/2);
  }

  return 0;
}


Measured memory_bytes: 128
function Main(input){
  //パラメータの受け取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  inputStr = input[1].split(" ");
  const A  = inputStr.map(inputStr => Number.parseInt(inputStr));
  inputStr = input[2].split(" ");
  const B  = inputStr.map(inputStr => Number.parseInt(inputStr));
  inputStr = input[3].split(" ");
  const C  = inputStr.map(inputStr => Number.parseInt(inputStr));
  //計算処理
  var ans = B[A[0]-1];
  for(var i=1 ; i<N ; i++){
    ans += B[A[i]-1];
    if( A[i] === A[i-1]+1){
      ans += C[(A[i]-1)-1];
    }
  }
  //結果出力
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,d; cin >> n >> d;
    int ans; cin >> ans;
    REP(i,n){
        int a; cin >> a;
        for(int i=1; i<=d; i+=a) ans++;
    }
    out(ans);

    return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    char[] array = in.readLine().toCharArray();
    System.out.println((char)(array[0]+1));
  }
}

Measured memory_bytes: 20948
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<algorithm>
#include<unordered_map>
#include<cstdlib>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<long long ,long long >
#define i64ii pair< long long, pair<int,int> > 
#define i64i pair<long long , int > 
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>

#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;

 
typedef long long ll;
typedef vector< int> vi;
typedef long double ld;

const int MAX = 3e2 + 10;
const int maxn = 2e5+100;

int n, m, L, d[MAX][MAX], d2[MAX][MAX];

void fill(){
	for(int i = 1;i <= n;i++){
		for(int j= 1; j<= n;j++){
			d[i][j] = d2[i][j] = inf;
		}
	}
			
	for(int i = 1 ;i <= n;i++) {
		d[i][i] = d2[i][i] = 0;
	}
}

void f(){
	for(int k = 1; k <= n;k++){
		for(int i = 1 ;i <= n;i++){
			for(int j = 1 ;j <= n;j++){
				if (d[i][k] + d[k][j] < d[i][j] ){
					d[i][j] = d[i][k]+d[k][j];
				}
			}
		}
	}
}

void f2(){
	
	for(int i = 1;i<= n;i++){
		for(int j =1 ;j <= n;j++){
			if ( d[i][j] <= L ){
				d2[i][j] = d[j][i] = 1;
			}
		}
	}
	
	for(int k = 1; k <= n;k++){
		for(int i = 1 ;i <= n;i++){
			for(int j = 1 ;j <= n;j++){
				if (d2[i][k] + d2[k][j] < d2[i][j] ){
					d2[i][j] = d2[i][k]+d2[k][j];
				}
			}
		}
	}
	
}
 
 
int main (){
	//~ in
	scanf(" %d %d %d ", &n , &m , &L );
	
	fill();
			
	for(int i = 0 ;i < m;i++){
		int a, b, c;
		scanf(" %d %d %d", &a, &b ,&c);
		d[a][b] = min( d[a][b], c );
		d[b][a] = d[a][b];
	}
	
	f();
	f2();
	int q;
	
	scanf(" %d", &q);
	while ( q--){
		int a, b;
		scanf("%d %d" , &a, &b );
		
		if ( d2[a][b] == inf )
			printf("-1\n");
		else
			printf("%d\n", d2[a][b]-1  );
	}
	
	
	return 0;
}


 


Measured memory_bytes: 1280
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[100001];
        long ans = 0L;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            ans += x;
            a[x]++;
        }
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            ans += a[b] * (c - b);
            sb.append(ans + "\n");
            a[c] += a[b];
            a[b] = 0;
        }
        System.out.println(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 64304
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int a, b, k;
    cin >> k >> a >> b;
    
    int res = (b / k) - ((a - 1) / k);
    if (res > 0) cout << "OK" << '\n';
    else cout << "NG" << '\n';
    
    return 0;
}

Measured memory_bytes: 3600
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_left

n,m = map(int,readline().split())
a = list(map(int,readline().split()))

b = [0]*(n+1)
a.sort()
for i in range(n):
  b[i+1] = b[i]+a[i]

def is_ok(arg):
    c = 0
    f = False
    for i in a:
      if c >= m:
        break
      c += (n-bisect_left(a,arg-i))
    if c >= m:
      f = True
    return f

def bisect_ok(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

x = bisect_ok(2*a[-1]+1,1)
ans = 0
cnt = 0
for i in a:
  ind = n-bisect_left(a,x-i)
  cnt += ind
  ans += i*ind+(b[-1]-b[n-ind])
if cnt > m:
  ans -= x*(cnt-m)
print(ans)

Measured memory_bytes: 12488
import math
from functools import reduce
import itertools

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


K =int(input())
lisK =[i for i in range(1,K+1)]
ans=0
for v in itertools.combinations(lisK,3):
    ans += 6*gcd_list(v)
for w in itertools.combinations(lisK,2):
    ans += 6*gcd_list(w)
for x in range(1,K+1):
    ans += x
print(ans)

Measured memory_bytes: 9640
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i,n)    cin >> l[i];

    int ans=1;
    int sum=0;
    rep(i,n) {
        sum+=l[i];
        if(sum<=x) {
            ans++;
        }
    }

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

int n, ans, d;

int f(int n, int d) {
    while (n % d == 0) {
        n /= d;
    }
    return n % d == 1;
}

main() {
    cin >> n;
    ans = 0;
    d = 1;
    while (d * d <= (n - 1)) {
        if ((n - 1) % d == 0) {
            ans++;
            if (d * d < (n - 1)) {
                ans++;
            }
        }
        ++d;
    }
    d = 2;
    while (d * d <= n) {
        if (n % d == 0) {
            ans += f(n, d);
            if (d * d < n) {
                ans += f(n, n / d);
            }
        }
        ++d;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s=="ABC") cout << "ARC" <<endl;
    else cout << "ABC" <<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 402;
const int M = 100010;
int ed[M][2];
bool used[N][N];
bool bad[N];
int n, m;

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

    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &ed[i][0], &ed[i][1]);
        ed[i][0]--;
        ed[i][1]--;
    }
    for (int i = 0; i < n; i++)
        used[i][i] = 1;
    for (int id = m - 1; id >= 0; id--) {
        for (int v = 0; v < n; v++) {
            bad[v] |= used[v][ed[id][0]] && used[v][ed[id][1]];
            used[v][ed[id][0]] |= used[v][ed[id][1]];
            used[v][ed[id][1]] |= used[v][ed[id][0]];
        }
    }
    int ans = 0;
    for (int v = 0; v < n; v++)
        for (int u = v + 1; u < n; u++) {
            bool ok = !bad[v] && !bad[u];
            for (int i = 0; i < n; i++)
                ok &= !(used[v][i] && used[u][i]);
            ans += (int)ok;
        }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<stack>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define sd(n) scanf("%d",&n)
#define sf(n) scanf("%lf",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sld(n)  scanf("%lld",&n)
#define ss(str) scanf("%s",str)
#define pd(n) printf("%d",n)
#define pld(n) printf("%lld",n)
#define plf(n) printf("%lf",n)
#define mm(a,n) memset(a,n,sizeof(a))
#define tmp(x) std::cout<<"& "<<x<<" &\n"
using namespace std;
const int maxn=1e5;
int ans[1010][1010];
int main(){
    //freopen("in.txt","r",stdin);
    int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    for(int i=1;i<=b;++i){
        for(int j=1;j<=a;++j){
            ans[i][j]=1;
        }
    }
    for(int i=b+1;i<=h;++i){
        for(int j=a+1;j<=w;++j){
            ans[i][j]=1;
        }
    }
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j  ){
            pd(ans[i][j]);
        }printf("\n");
    }
    return 0;
}
	

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n, d;
  cin >> n >> d;
  int max_val = 2 * d + 1;
  cout << (n + max_val - 1) / max_val << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
long long n,k;
long long gg(long long x)
{
	return x*x*x;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	long long ans=gg((n/k));
	if(k%2)
	{
		printf("%lld",ans);
		return 0;
	}
	ans+=gg(n/(k/2)-n/k);
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(auto i=(a); i<(b); i++)
#define dec(i,n,a) for(auto i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 2e-9
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 202020
#define LOGN 20
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

char s[303];
int pd[303][303][303];

int solve(int l, int r, int k){
	if(r<l) return 0;
	if(r==l) return 1;
	int & ret = pd[l][r][k];
	if(ret != -1) return ret;
	ret = max(solve(l+1,r,k),solve(l,r-1,k));
	if(s[l]==s[r]) ret = max(ret, solve(l+1,r-1,k)+2);
	else if(k) ret = max(ret, solve(l+1,r-1,k-1)+2);
	return ret;
}

int main(){
	clr(pd,-1);
	int n, k;
	scanf("%s%d", s, &k);
	n = strlen(s);
	printf("%d\n", solve(0,n-1,k));
}


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

int main() {
  
  int N,X;
  cin >> N >> X;
  
  vector<int> L(N),B(N+1);
  
  for( int i = 0; i<N; i++){
    cin >> L.at(i);
  }
  
  B.at(0) = 0;
  
  for( int i = 0; i<N; i++){
    B.at(i+1) = B.at(i) + L.at(i);
  }
  
  int count = 0;
  
  for( int i = 0; i<N+1; i++){
    if( B.at(i) <= X){
      count++;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll inf=0x3f3f3f3f;
const ld pi=acos(-1.0);
ll n,k;
ll vis[maxn];
string s;
void run(){
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>vis[i];
    sort(vis,vis+n);
    ll ans=0;
    for(int i=0;i<k;i++)ans+=vis[i];
    cout<<ans<<'\n';
}

int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)

int n;
i64 a[101010];

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

  i64 base = 0;
  for (int i = 1; i <= n + 1; i++) {
    base += abs(a[i] - a[i - 1]);
  }
  for (int i = 1; i <= n; i++) {
    cout << base - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i - 1] - a[i + 1]) << endl;
  }
}

Measured memory_bytes: 2048
import java.util.*;

class Main {

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);
        int res = 0;

        while(sc.hasNext()) {
            char[] line = sc.nextLine().toCharArray();
            boolean palind = true;
            for(int i = 0; i < line.length; i++) {
                if (line[i] != line[line.length - i - 1]) {
                    palind = false;
                    break;
                }
            }

           if(palind)   res += 1; 
        }

        System.out.println(res);

    }
}

Measured memory_bytes: 12000
let distance = (x1, y1, x2, y2) => {
  return Math.abs(x1 - x2) + Math.abs(y1 - y2)
}

function can(before, current) {
  let [time1, x1, y1] = before
  let [time2, x2, y2] = current
  let time = time2 - time1
  let dist = distance(x1, y1, x2, y2)
  let rest = time - dist
  //console.log(time2, time, dist, rest)
  if (rest < 0) {
    return false
  }
  return rest % 2 == 0
}

function solve(input) {
  const [_, ...b] = input.split("\n")

  let p = b.map((bb) => bb.split(" ").map((m) => Number(m)))
  let r = p.every((current, i) => {
    const before = p[i - 1] || [0, 0, 0]

    return can(before, current)
  })
  return r ? "Yes" : "No"
}
const input = require("fs").readFileSync("/dev/stdin", "utf8")
console.log(solve(input.trim()))


Measured memory_bytes: 51412
// #include <bits/stdc++.h>
// #include<cmath>
// #define _GLIBCXX_DEBUG
// #define rep(i, n) for (int i = 0; i < (int)(n); i++)
// #define Graph vector<vector<int>>
// typedef long long ll;
// 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; }
// const ll INF = (1LL << 60LL);

// int main(){
//     int N,R;
//     cin>>N>>R;
//     int naibu;
//     if(N<10){
//         naibu=R+100*(10-N);
//     }
//     else{
//         naibu=R;
//     }
//     cout<<naibu;
// }
#include <bits/stdc++.h>
#include<cmath>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Graph vector<vector<int>>
typedef long long ll;
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; }
const ll INF = (1LL << 60LL);

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll>h(0);
    int ans=1;
    while(N!=0){
        ans=N%K;
        h.push_back(ans);
        N/=K;
    }

    cout<<h.size();
}

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

int main ()
{
    int n, maxi = -1e+9;
    cin >> n;
    int a[n];
    for (int i = 0;i < n;i++) cin >> a[i];
    
    for (int i = 0;i < n-1;i++)
    {
        for (int j = i+1;j < n;j++)
        {
            if (a[j] < a[i] && maxi > 0) break;
            if (a[j] - a[i] > maxi)
            {
                maxi = a[j] - a[i];
            }
        }
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // spocitame pocet vsetkych postupnosti (0-9) a odcitame pocet tych, ktore
    // maju len cisla 1-9 alebo cisla 0-8. Pripocitame pocet tych, ktore maju len cisla
    // 1-7
    const ll mod = 1000 * 1000 * 1000 + 7;
    ll n;
    cin >> n;
    if (n < 2)
    {
        cout << "0\n";
        return 0;
    }
    ll all = 1, bad = 1, twice = 1;
    for (ll i = 0; i < n; i++)
    {
        all *= 10;
        all %= mod;
        bad *= 9;
        bad %= mod;
        twice *= 8;
        twice %= mod;
    }
    ll ans = (mod * 2 + all - bad * 2 + twice) % mod;
    cout << ans << "\n";
    return 0;
}

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

int main(){

	int input[10], temp, i, j;
	
	for(i=0; i < 10; i++){
	
	cin >> input[i];
	
	}

	for(i = 0; i < 10; i++){
		for(j= 0; j < 9; j++){
			if(input[j] < input[j+1]){
				temp = input[j];
				input[j] = input[j+1];
				input[j+1] = temp;
				}
			}
		}
		
	for(i = 0; i < 3; i++){
	
	cout << input[i] << endl;
	
	}

	return 0;
	
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(1e5 + 5);
int n, k, dp[N], v[N];
int main() {
    DAU
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> v[i];
    for (int i = 2; i <= n; ++i){
        dp[i] = 2e9;
        for (int j = max(1, i - k); j < i; ++j)
            dp[i] = min(dp[i], dp[j] + abs(v[i] - v[j]));
    }
    cout << dp[n];
    PLEC
}


Measured memory_bytes: 1024
H, W = map(int, input().split())
S = [[0 if a == '.' else '#' for a in list(input()) ]for _ in range(H)]

for h in range(H):
    S[h].extend([0])
S.append([0 for _ in range(W+1)])

for h in range(H):
    for w in range(W):
        if S[h][w] == 0:
            near = [(h-1, w-1), (h, w-1), (h+1, w-1), (h-1, w), (h+1, w), (h-1, w+1), (h, w+1), (h+1, w+1)]
            for nh, nw in near:
                if S[nh][nw] == '#':
                    S[h][w] += 1
for h in range(H):
    print(''.join([str(a) for a in S[h][:-1]]))

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

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


int main(){

  int n;
  cin >> n;
  priority_queue<long double,vector<long double>,greater<long double>> que;
  REP(i,n){
    int x;cin >> x;
    que.push(x);
  }
  REP(i,n-1){
    long double x = que.top();que.pop();
    long double y = que.top();que.pop();
    que.push((x+y)/2);
  }
  cout << fixed << setprecision(15);
  cout << que.top();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
B = [int(i) for i in input().split()]

A = []

A.append(B[0])
A.append(B[0])

for i in range(1, N - 1):
  if B[i] >= A[i]:
    A.append(B[i])

  else:
    A.pop(i)
    A.append(B[i])
    A.append(B[i])

print(sum(A))

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
int main(void){
	
	int i,n;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int c=0;
	
	for(i=0;i<n;i++){
		
		int y=sqrt(a[i]);
		//	printf("y=%d\n",y);
		int j;
		
		if(y==1){
			c++;
		} else{
			for(j=2;j<=y;j++){
				//if(a[i]%j==0) {printf("i=%d\nj=%d\n",i,j);}
				if(a[i]%j==0) break;
			}
			//printf("%d\n",j);
			if(j==y+1){
				c++;
			}
		}
		
	}
	printf("%d\n",c);
	
	return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;


int main(){
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll C;
    cin >> C;
    swap(A,B);swap(A,C);
    cout<<A<<" "<<B<<" "<<C<<endl;



return 0;
}  



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

int main(){

  string s;
  int k = 0,u = 0,p = 0,c = 0;

  cin >> s;

  for(int i=0;i<s.size();i++){
    if('K' == s[i]) k++;
    if('U' == s[i]) u++;
    if('P' == s[i]) p++;
    if('C' == s[i]) c++;
  }

  k = min(k,u);
  p = min(p,c);
  k = min(k,p);

  cout << k << endl;
}

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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }


// ***************************************

vector<int> ans;


int main(void){

    int N;
    cin >> N;

    vector<vector<int>> graph(N);

    vector<int> deg(N);

    int a, b;
    REP(i, N) {
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
        deg[a-1]++; deg[b-1]++;
    }

    queue<int> que;
    vector<bool> is_pushed(N, false);
    REP(i, N) {
        if (deg[i] == 1) {
            que.push(i);
            is_pushed[i] = true;
        }
    }

    while (!que.empty()) {
        int p = que.front(); que.pop();

        is_pushed[p] = true;
        for (int c : graph[p]) {
            deg[c]--;
            if (deg[c] == 1) {
                que.push(c);
                is_pushed[c] = true;
            }
        }
    }

    int Q;
    cin >> Q;

    REP(i, Q) {
        cin >> a >> b;
        if (!is_pushed[a - 1] && !is_pushed[b - 1]) {
            cout << 2 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 8700
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final String s = scanner.nextLine();
    final String[] s1 = s.split(" ");

    final int i = 500 * Integer.parseInt(s1[0]);

    if (i >= (Integer.parseInt(s1[1]))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,d,ans;
int x[11][11];
int main() {
	scanf("%d%d",&n,&d);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=d; j++) {
			scanf("%d",&x[i][j]);
		}
	}
	for(int i=1; i<=n; i++) {
		for(int j=i+1; j<=n; j++) {
			int t=0,m;
			for(int k=1; k<=d; k++) {
				t+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			m=sqrt(t);
			if(m*m==t)ans++;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
    int a,b;
    int k;
    cin>>a>>b>>k;
    if(b-a+1<=2*k)
    {
        for(int i=a;i<=b;i++)
            cout<<i<<endl;
    }
    else
    {
        for(int j=a;j<a+k;j++)
            cout<<j<<endl;
        for(int z=b-k+1;z<=b;z++)
            cout<<z<<endl;
    }
    return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int A[N], B[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		A[i] += i * n + 1, B[i] = (n - i - 1) * n + 1;
		int p; cin >> p; p--;
		A[p] += i;
	}
	for (int i = 0; i < n; i++) cout << A[i] << ends;
	cout << endl;
	for (int i = 0; i < n; i++) cout << B[i] << ends;
	cout << endl;


	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll mod = 998244353;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	vector<int> v;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		v.pb(x);
	}
	sort(all(v));
	ll res = 1;
	for(int i=0;i<sz(v);i++)
	{
		ll g = __gcd(v[i],i);
		res = (res*g)%mod;
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    string a1, a2, b1, b2;
    a1 = to_string(a);
    a2 = to_string(a);
    for (int i = 1; i < b; i++) {
        a1 += a2;
    }
    b1 = to_string(b);
    b2 = to_string(b);
    for (int i = 1; i < a; i++) {
        b1 += b2;
    }
    a = stoi(a1);
    b = stoi(b1);
    if (a > b){
        cout << a1 << endl;
    }
    else{
        cout << b1 << endl;
    }
}

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

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

    int64_t A,B,C,X,Y;
    std::cin >> A >> B >> C >> X >> Y;
    constexpr int64_t INF = 1LL << 60;
    int64_t min_sum = INF;

    //Case1. A = X, B = Y, C = 0
    min_sum = std::min(min_sum, A * X + B * Y);
    //Case2. X >= Y, C = 2Y, A = X - Y
    //Case3. X >= Y, C = 2X
    if(X >= Y){
        min_sum = std::min(min_sum, C * 2 * Y + A * (X - Y));
        min_sum = std::min(min_sum, C * 2 * X);
    }
    //Case4. X <= Y, C = 2X, B = Y - X
    //Case5. X <= Y, C = 2Y
    else{
        min_sum = std::min(min_sum, C * 2 * X + B * (Y - X));
        min_sum = std::min(min_sum, C * 2 * Y);
    }

    std::cout << min_sum << std::endl;
    return 0;

}


Measured memory_bytes: 256
use std::io::*;
// use std::collections::HashMap;

fn read(s: &mut StdinLock) -> usize {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as usize + a * 10)
}
// fn read_tuple(s: &mut StdinLock) -> (usize, usize) {
//     (read(s), read(s))
// }
// fn read_line_split(s: &mut StdinLock, n: usize) -> Vec<usize> {
//     (0..n).map(|_| read(s)).collect()
// }
// fn read_line(s: &mut StdinLock) -> Vec<usize> {
//     s.by_ref().bytes().map(|c| c.unwrap() as char)
//         .take_while(|c| !c.is_whitespace())
//         .skip_while(|c| c.is_whitespace())
//         .map(|c| (c as u8 - b'0') as usize)
//         .collect()
// }
fn read_line_char(s: &mut StdinLock) -> Vec<char> {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .collect()
}
// fn read_line_split_char(s: &mut StdinLock, n: usize) -> Vec<char> {
//     (0..n).map(|_| read_char(s)).collect()
// }
fn read_char(s: &mut StdinLock) -> char {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .collect::<Vec<char>>()[0]
}
// fn read_mat_split(s: &mut StdinLock, n: usize, m: usize) -> Vec<Vec<usize>> {
//     (0..n).map(|_| read_line_split(s, m)).collect()
// }
// fn read_mat(s: &mut StdinLock, n: usize) -> Vec<Vec<usize>> {
//     (0..n).map(|_| read_line(s)).collect()
// }
// fn read_mat_char(s: &mut StdinLock, n: usize) -> Vec<Vec<char>> {
//     (0..n).map(|_| read_line_char(s)).collect()
// }
// fn read_mat_tuple(s: &mut StdinLock, n: usize) -> Vec<(usize, usize)> {
//     (0..n).map(|_| read_tuple(s)).collect()
// }

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let mut answer = read_line_char(&mut s);
    let mut left: Vec<char> = Vec::new();
    let q = read(&mut s);
    let mut sw = false;
    for _ in 0..q {
        if read_char(&mut s) == '1' {
            sw = !sw;
        } else {
            let key = read_char(&mut s);
            if (key == '1' && !sw) || (key =='2' && sw) {
                left.push(read_char(&mut s));
            } else {
                answer.push(read_char(&mut s));
            }
        }
    }
    if sw {
        answer = answer.iter().rev().map(|x| *x).collect::<Vec<char>>();
        answer.append(&mut left);
        println!("{}", answer.iter().map(|x| *x).collect::<String>());
    } else {
        left = left.iter().rev().map(|x| *x).collect::<Vec<char>>();
        left.append(&mut answer);
        println!("{}", left.iter().map(|x| *x).collect::<String>());
    }
}

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

int main() {
    //ll n;
    string n;
    cin >> n;
    //vector<int> num(n);
    ll count=0;
    
    for(int i=0;i<n.size();i++) count+=n[i]-'0';
    
    if(count%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3716
'''
Problem Link - https://atcoder.jp/contests/abc176/tasks/abc176_b
'''
from sys import stdin,stdout
from math import *
from collections import *

mod = 1000000007

def gcd(a,b):
	while b:
		a,b = b,a%b
	return a

def lcm(a,b): return (a*b) // gcd(a,b)

def set_bits(X):
	c = 0
	while X:
		X &= (X-1);c += 1
	return c

def compute_MOD(N,M): return (N%M + M) % M

def get_array(): return list(map(int, stdin.readline().split()))
 
def get_ints(): return map(int, stdin.readline().split())

def get_int(): return int(stdin.readline())

def get_input(): return stdin.readline().strip()

def main():
	N = get_input()
	Sum = 0
	for i in N:Sum+=int(i)
	if Sum%9==0:stdout.write('Yes\n')
	else:stdout.write('No\n')
	

if __name__ == "__main__":
    main()

Measured memory_bytes: 9676
n = int(input())
v = list(map(int, input().split()))
odd_dic = {}
even_dic = {}
for a in range(n):
    b = v[a]
    if a % 2 == 0:
        dic = odd_dic
    else:
        dic = even_dic
    if b in dic:
        dic[b] += 1
    else:
        dic[b] = 1
answer = n
odd_dic = sorted(odd_dic.items(), key=lambda x:x[1])
even_dic = sorted(even_dic.items(), key=lambda x:x[1])
if odd_dic[-1][0] == even_dic[-1][0]:
    answer -= odd_dic[-1][1]
    tmp = 0
    if len(even_dic) > 1:
        tmp = even_dic[-2][1]
    if len(odd_dic) > 1:
        tmp = max(odd_dic[-2][1], tmp)
    answer -= tmp
else:
    answer -= odd_dic[-1][1]
    answer -= even_dic[-1][1]
print(answer)

Measured memory_bytes: 17652
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut n: usize = itr.next().unwrap().parse().unwrap();
    let mut m: usize = itr.next().unwrap().parse().unwrap();
    if n > m {
        std::mem::swap(&mut n, &mut m);
    }
    if m == 1 {
        println!("1");
    } else if n == 1 {
        println!("{}", m - 2);
    } else {
        println!("{}", (n - 2) * (m - 2));
    }
}


Measured memory_bytes: 2088
package main

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

func nextInt(sc *bufio.Scanner) (n int, err error) {
	sc.Scan()
	s := sc.Text()
	n, err = strconv.Atoi(s)
	return
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
loop:
	for {
		arr := make([]int, 3)
		for i, _ := range arr {
			if a, err := nextInt(sc); err == nil {
				arr[i] = a
			} else {
				break loop
			}
		}
		sort.Sort(sort.IntSlice(arr))
		fmt.Println(arr[0], arr[1], arr[2])
	}
}


Measured memory_bytes: 1100