akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>
#define mkp make_pair

ll N,A[202020];

stack<pll> As;

ll i,j,a,ans;

bool ck(ll ans){
    while(!As.empty()){
        As.pop();
    }
    fornum(i,1,N){
        if(A[i-1]>=A[i]){
            a = A[i];
            while(!As.empty()&&As.top().first>a){
                As.pop();
            }
            if(!As.empty()&&As.top().first==a){
                As.top().second++;
                while(As.top().second==ans){
                    As.pop();
                    a--;
                    if(a==0){
                        return false;
                    }
                    if(!As.empty()&&As.top().first==a){
                        As.top().second++;
                    }else{
                        As.push(mkp(a, 1));
                    }
                }
            }else{
                As.push(mkp(a, 1));
            }
        }
    }
    return true;
}


int main(){
    scanf("%lld",&N);
    fornum (i,0,N){
        scanf("%lld", &A[i]);
    }

    fornum(i,1,N){
        if(A[i-1]>=A[i])
            break;
    }
    if(i==N){
        printf("1");
        return 0;
    }
    ans = 1;
    fornum(i,1,N){
        if(A[i]==1)
            ans++;
    }
    ans = ans>2?ans:2;
    while(true){
        if(ck(ans)){
            printf("%lld", ans);
            return 0;
        }
        ans++;
    }
    
    
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    rep(i, a + 1)rep(j, b + 1)rep(k, c + 1) {
        int tmp = i * 500 + j * 100 + k * 50;
        if (x == tmp) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
    int n,l,i,j;
    char a[105][105];
    scanf("%d %d",&n,&l);
    for(i = 0; i<n; i++)
        scanf("%s",&a[i]);
    for(i =0; i<n-1; i++)
    {
        for(j = i+1;j<n;j++)
        {
            if(strcmp(a[i],a[j])>0)
            {
                char t[105];
                strcpy(t,a[i]);
                strcpy(a[i],a[j]);
                strcpy(a[j],t);
            }
        }
    }
    for(i = 0;i<n;i++)
    {
        printf("%s",a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
char a,b;
cin>>a>>b;
int a1= a - '0';
int b1= b - '0';
string s="";
if(a1>b1){
     for (int i=0; i<a1;i++)
        s += b;

}
else if(a1<b1){
    for (int i=0; i<b1;i++)
        s += a;
}
else{
         for (int i=0; i<a1;i++)
        s += b;
}
cout<<s<<endl;
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if(a > 8 || b > 8)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,ans=0LL; cin >> n >> k;
    for(long long int i=k;i<=n+1;i++){
        ans += ((i*(n-i))+i+1);
        ans %= 1000000007;
    }
    cout << ans;
}


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

using namespace std;
typedef long long ll;
const int N = 1e5+10;

int main() {
	string a,b;
	cin>>a>>b;
	bool done=1;
	if(b.length()>a.length()){
		puts("UNRESTORABLE");
		return 0;
	}
	for(int x=0;x<a.length();x++){
		if(a[x]=='?'){
			done=0;
		}	
	}
	if(done){
		cout << a << endl;
		return 0;
	}
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	bool o=0;
	for(int x=0;x<=a.length()-b.length();x++){
		bool c=0;
		for(int i=0;i<b.length();i++){
			bool v=0;
			
			if(a[x+i]!=b[i]){
				if(a[x+i]!='?'){
					v=1;
				}
			}
			if(v){
				break;
			}
			if(i==b.length()-1){
				c=1;
			}
		}
		if(c){
			o=1;
			for(int i=0;i<b.length();i++){
				a[x+i]=b[i];
			}
		}
		if(o){
			break;
		}
	}
	reverse(a.begin(),a.end());
	if(o){
		for(int x=0;x<a.length();x++){
			if(a[x]=='?'){
				cout << 'a';
			}else{
				cout << a[x];
			}
		}
	}else{
		cout << "UNRESTORABLE";
	}
	cout << endl;
}


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

using namespace std;

int main() {
  	int n, l;
  	cin >> n >> l;
  	vector<string> s(n);
  	for (string& x : s)
      	cin >> x;
  	sort(s.begin(), s.end());
  	for (string x : s)
         cout << x;
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		long num, length;
		long ans;
		int i = 0, a = 0;
		String b;
		char c;
		Scanner sc = new Scanner(System.in);
		while (true) {
			ans = 0;
			b = sc.nextLine();
			// System.out.println(b);
			length = b.length();
			if (b.equals("0")) {
				break;
			}
			for (i = 0; i < length; ++i) {
				c = b.charAt(i);
				a = c - '0';
				ans += a;
			}
			System.out.println(ans);
		}
		sc.close();
	}

}



Measured memory_bytes: 26720
def main():
    n, k = map(int, input().split())
    d_lst = [0 for _ in range(k)]
    a_lst = [0 for _ in range(k)]

    for i in range(k):
        d_lst[i] = int(input())
        a_lst[i] = list(map(int, input().split()))

    snuke_lst = [0 for _ in range(n)]

    for i in range(k):
        for a in a_lst[i]:
            snuke_lst[a - 1] = 1

    ans = n - sum(snuke_lst)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 67936
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

const int N= 20001;
int dp[N];

void solve() {
        int n; cin >> n;
        dp[0]= 1;
        dp[1]= 0;
        dp[2]= 0;

        for (int i= 1; i<= n; i++) {
                for (int j= 3; j<= n; j++) {
                        if (i- j>= 0) {
                                dp[i]= (dp[i]% mod+ dp[i- j]% mod);
                        }
                }
        }

        cout << dp[n];
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

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

template<typename T>
T gcd(T a, T b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll res = 0;
    int k;
    cin >> k;
    vector<vector<int> > tmp(k + 1, vector<int>(k + 1));
    FOR (i, 1, k + 1) {
        FOR (j, 1, k + 1) {
            tmp[i - 1][j - 1] = gcd(i, j);
        }
    }
    FOR (i, 1, k + 1) {
        FOR (j, 1, k + 1) {
            FOR (l, 1, k + 1) {
                res += gcd(tmp[i - 1][j - 1], l);
            }
        }
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

int main() {
  Graph GCD(209,vector<int>(209,-1));
  rep(i,200) rep(j,200){
    if(i<j) continue;
    if(GCD[i+1][j+1]!=-1) continue;
    if(i==j){
      int temp=i+1;
      while(temp<=200){
        GCD[temp][i+1]=i+1;
        GCD[i+1][temp]=i+1;
        temp+=i+1;
      }
    }
    else{
      GCD[i+1][j+1]=GCD[j+1][(i+1)%(j+1)];
      GCD[j+1][i+1]=GCD[i+1][j+1];
    }
  }
  
  long long n;
  cin>>n;
  long long ans=0;
  rep(i,n) rep(j,n) rep(k,n){
    ans+=GCD[GCD[i+1][j+1]][GCD[j+1][k+1]];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3812
from collections import Counter

class UnionFind:
    def __init__(self,num:int):
        self.r = [-1 for i in range(num)]
    def root(self,x:int):
        if(self.r[x] < 0):
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]
    def unite(self,x:int,y:int):
        rx = self.root(x)
        ry = self.root(y)
        if(rx == ry):
            return False
        if(self.r[rx] > self.r[ry]):
            rx,ry = ry,rx
        self.r[rx] += self.r[ry]
        self.r[ry] = rx
        return True
    def size(self,x:int):
        return -self.r[self.root(x)]

N,M = map(int,input().split())
group = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    group.unite(A-1,B-1)
ans = 0
for i in range(N):
    ans = max(ans,group.size(i))
print(ans)


Measured memory_bytes: 15124
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

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

    int n;
    while (cin >> n, n) {
        int pre = 0;    // floor
        vector<int> a(2, 0);
        int ans = 0;
        rep(i, n) {
            string s;
            cin >> s;
            a[s[0] == 'r'] = s[1] == 'u';
            if (a[0] != pre && a[1] != pre) {
                ans++;
                pre ^= 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;

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

    cout << ((x >= 30) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
pair<char, int> A[4040];
int b[4040][2020];//b[i][j]:=i番目より後ろにj以上の黒玉は何個あるか
int w[4040][2020];//白
int dp[4040][2020];//dp[i][j]:=i番目までで白がjまで,黒がi-jまで並んでいるとき必要な操作回数の最小
int bidx[2020];
int widx[2020];

template<typename... Args>
void debug(Args... args) {
    for (auto message:{args...})cerr << message << " ";
    cerr << endl;
}

signed main() {
    cin >> N;
    rep(i, 2 * N) {
        cin >> A[i].first >> A[i].second;
        --A[i].second;
        if (A[i].first == 'W') {
            widx[A[i].second] = i;
        } else {
            bidx[A[i].second] = i;
        }
    }
    for (int i = 2 * N - 1; i >= 0; --i) {
        rep(j, N + 1) {
            b[i][j] = b[i + 1][j];
            w[i][j] = w[i + 1][j];
        }
        if (A[i].first == 'W') {
            for (int j = A[i].second + 1; j <= N; ++j) {
                ++w[i][j];
            }
        } else {
            for (int j = A[i].second + 1; j <= N; ++j) {
                ++b[i][j];
            }
        }
    }
    rep(i, 4040)rep(j, 2020)dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, 2 * N) {
        rep(wc, min(N, i + 1) + 1) {
            int bc = i + 1 - wc;
            if (bc != 0) {
                //dp[i][wc]から遷移
                int idx = bidx[bc - 1];
                int cost = idx + b[idx][bc] + w[idx][wc] - 1 - i;
                dp[i + 1][wc] = min(dp[i + 1][wc], dp[i][wc] + cost);
            }
            if (wc != 0) {
                //dp[i][wc-1]から遷移
                int idx = widx[wc - 1];
                int cost = idx + b[idx][bc] + w[idx][wc] - 1 - i;
                dp[i + 1][wc] = min(dp[i + 1][wc], dp[i][wc - 1] + cost);
            }
        }
    }
    cout << dp[2 * N][N] << endl;
    return 0;
}


Measured memory_bytes: 190976
import static java.lang.Math.*;

import java.util.Scanner;

public class Main {
	  public static void main(String[] args) {
		  int n,i,b,count,kekka=0,j,c;
		  double d;
		 
	    Scanner sc=new Scanner(System.in);
	    n=Integer.parseInt(sc.next());
	    
	    int a[]=new int[n+1];
	    for(i=0;i<n;i++){
	    	a[i]=Integer.parseInt(sc.next());
	    	
	    }
	    
	    for(i=0;i<n;i++){
	    	count=0;
	    	
	    	
    	d=sqrt(a[i]);
    	
    	if((int)d<d){
    		 c=(int)d+1;
    	}
    	else{
    		 c=(int)d;
    	}
    	
	    	for(j=2;j<=c;j++){
	    		if(a[i]==2){
	    			kekka++;
	    			
	    			break;
	    		}
	    		
	    		if(a[i]%j==0){
	    			count++;
	    			
	    		}
	    		
	    		if(count==1){
	    			
	    			break;
	    		}
	    		if(j==c){
		    		kekka++;
		    		
		    	}
	    	}
	    	
	    	
	    }
	    System.out.println(kekka);
	  }
	  }

Measured memory_bytes: 34164
#include <bits/stdc++.h>
using namespace std;
int t;
long long n,m;
long long a[200005],f[200005];
bool cmp(int a,int b)
{
    return a>b;
}
bool check(long long mid)
{
    long long res=m;
        for(int i=1;i<=n;i++)
        {
            if(mid/f[i]<a[i])
            {
                long long x=a[i]-mid/f[i];
                if(x>res)
                    return 0;
                res-=x;
            }
        }
        return 1;
}

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>f[i];
    sort(a+1,a+1+n);
    sort(f+1,f+1+n,cmp);
    long long right=-1;
    for(int i=1;i<=n;i++)
        right= max(right,a[i]*f[i]);
    long long left=0;
    long long ans=0;
    while(left<=right)
    {
        long long mid=(left+right)/2;
        if(check(mid)) right=mid-1,ans=mid;
        else left=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
"use strict"
function Main(input) {
  input = input.trim().split('');
  const len = input.length;
  
  let ret = 0;
  if(len%2 === 0){
    let pre = input.slice(0, len/2);
    let bak = input.slice(len/2, len).reverse();
    let max = pre.length;
    
    for(let i=0; i<max; i++){
      if(pre[i] !== bak[i]) ret += 1;
    }
  } else {
    let pre = input.slice(0, len/2);
    let bak = input.slice(len/2+1, len).reverse();
    let max = pre.length;

    for(let i=0; i<max; i++){
      if(pre[i] !== bak[i]) ret += 1;
    }
  }

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

Measured memory_bytes: 22204
#include<iostream>
#include<array>
#include<algorithm>

int main() {
	int n = 0;
	std::array<int,3> ar;
	std::cin >> ar[0] >> ar[1] >> ar[2];

	std::sort(ar.begin(), ar.end());

	for (int i = 1; i < 3; i++) {
		n += ar[i] - ar[i - 1];
	}
	std::cout<<n<<std::endl;
	return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int A = 26;
Int D = 365;
Int c[26];
Int s[365][26];

int main() {
    Int d;
    cin >> d;
    for (Int i = 0; i < (Int)A; i++) {
        cin >> c[i];
    }
    for (Int i = 0; i < (Int)D; i++) {
        for (Int j = 0; j < (Int)A; j++) {
            cin >> s[i][j];
        }
    }
    for (Int i = 0; i < (Int)D; i++) {
        print(1);   
    }
    return 0;
}

Measured memory_bytes: 3696
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

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! {
        s: chars,
        k: usize,
    }
    let n = s.len();
    let mut ans = 0;
    let mut cnt = 1;
    if s.iter().all(|&c| c == s[0]){
        ans = n * k / 2;
    }else{
        for i in 1..n{
            if s[i - 1] == s[i]{
                cnt += 1;
            }else{
                ans += cnt / 2;
                cnt = 1;
            }
        }
        if s[0] == s[n - 1]{
            let mut cntf = 1;
            for j in 1..n{
                if s[j - 1] == s[j]{
                    cntf += 1;
                }else{
                    break;
                }
            }
            ans -= cntf / 2;
            ans *= k;
            ans += (cnt + cntf) / 2 * (k - 1) + cntf / 2 + cnt / 2;
        }else{
            ans += cnt / 2;
            ans *= k;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  int ans = 0;
  if(A == B && B == C) {
    if(A % 2 == 0)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  } else {
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
      int a = A, b = B, c = C;
      A = (b + c) / 2;
      B = (a + c) / 2;
      C = (a + b) / 2;
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,t2;
    cin>>s>>t;
    int s1,t1;
    s1=s.length();
    t1=t.length();
    t2=t.substr(0,s1);
    if(t1==(s1+1))
    {
        if((s.compare(t2))==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <climits>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define rev(i, n) for (int i=(n);i>0;--i)
#define INF (1e9+1e9)

// euclid
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
// gcd * lcm = ab
int lcm(int a, int b) {
    return a*b / gcd(a, b);
}
// (d', x', y') = extgcd(b, a mod b)
// return (d', y', x' - floor(a/b)*y')
// x <-> y', y <-> x'
int extgcd(int a, int b, int& x, int & y) {
    int gcd;
    if (b == 0) gcd = a, x = 1, y = 0;
    else gcd = extgcd(b, a%b, y, x), y -= a/b*x;

    return gcd;
}

int main() {

    int a,b; cin>>a>>b;
    int x,y;
    int g = extgcd(a, b, x, y);
    cout << x << " " << y << endl;
}

Measured memory_bytes: 3116
i=0
j=0
N,M = map(int, input().split())
a=sorted(list(map(int,input().split())),reverse=True)
for i in range(M):
    if a[0+i]>=sum(a)/4/M:
        j+=1
if j==M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int sb(int i,int j)
{
	return i>j;
}
int  main()
{
	int n,k,i,x;
	cin>>n>>k;
	for(i=0;i<n;i++) 
	{
	cin>>x;
	a[x]++;
	}
	sort(a,a+n,sb);
	x=0;
	for(i=k;i<=n;i++) x+=a[i];
	cout<<x;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = [int(i) for i in input().split()]
if A[1] > 0:
	total_p = A[0]
	total_n = -A[0]
	B = [A[1],-A[1]]
else:
	total_p = -A[0]
	total_n = A[0]
	B = [-A[1],A[1]]
for i in range(2,N):
	if A[i] > 0:
		(total_p,total_n) = (max(total_p+B[0],total_n+B[1]),max(total_p+B[1],total_n+B[0]))
		B = [A[i],-A[i]]
	else:
		(total_p,total_n) = (max(total_p+B[1],total_n+B[0]),max(total_p+B[0],total_n+B[1]))
		B = [-A[i],A[i]]
print(max(total_n+B[1],total_p+B[0]))




Measured memory_bytes: 14468
from functools import lru_cache

n=int(input())
router={}
for _ in range(n):
    t=[int(i) for i in input().split(" ")]
    r=t[0]
    k=t[1]
    t=t[2::]
    router[r]=t

def transport(s,g):
    distance=[10**10 for i in range(n+1)]
    distance[s]=0
    next=[s]
    for i in range(1,n+1):
        _next=[]
        for j in next:
            _next+=router[j]
        next=list(set(_next))
        for j in next:
            distance[j]=min(i,distance[j])
    return distance[g]+1



p=int(input())
for _ in range(p):
    s,d,v=[int(i) for i in input().split(" ")]
    t=transport(s,d)
    if t<=v:
        print(t)
    else:
        print("NA")



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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

void dfs(const vector<vector<int64_t>>& adjs, vector<bool>& visited,
         vector<int64_t>& path, int64_t v) {
    visited[v] = true;
    path.push_back(v);

    for (auto u : adjs[v]) {
        if (!visited[u]) {
            dfs(adjs, visited, path, u);
            return;
        }
    }
}

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<vector<int64_t>> adjs(n);
    for (auto _ : irange(0L, m)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector<bool> visited(n);
    vector<int64_t> path;
    dfs(adjs, visited, path, 0L);
    reverse(path.begin(), path.end());
    path.pop_back();
    dfs(adjs, visited, path, 0L);

    cout << path.size() << endl;
    cout << path.front() + 1;
    for (auto v : path | sliced(1L, path.size())) {
        cout << " " << v + 1;
    }
    cout << endl;
}

Measured memory_bytes: 11508
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int L = reader.nextInt();
        int min = L + 1 - 1;
        int max = L + N - 1;
        int ans = 0;
        if (min < 0 && 0 < max) {
            // eat 0
            ans = (min + max) * N / 2;
        } else if (min >= 0) {
            // eat min
            ans = (min + 1 + max) * (N - 1) / 2;
        } else {
            // eat max
            ans = (min + max - 1) * (N - 1) / 2;
        }
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21204
N = int(input())

S = [3, 5, 7]

now = N
l = 0

while now>0:
    l = l+1
    now = now//10    

for i in range(l-1):
    L = len(S)
    for j in range(L):
        tmp = S[j]*10+3
        S.append(tmp)
        tmp = S[j]*10+5
        S.append(tmp)
        tmp = S[j]*10+7
        S.append(tmp)
      
S2 = list(set(S))
S2.sort()
ans = 0
        
for i in S2:
    now = str(i)
    s3 = 0
    s5 = 0
    s7 = 0
    l2 = 0
    
    n = i
    
    while n>0:
        l2 = l2+1
        n = n//10
        
    for j in range(l2):
        if now[j]=='3':
            s3 = s3+1
        if now[j]=='5':
            s5 = s5+1
        if now[j]=='7':
            s7 = s7+1
    if s3*s5*s7>0 and s3+s5+s7==l2 and i<=N:
        ans = ans + 1
    elif i>N:
        break

print(ans)

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


ll N, M;
vector<ll> A;


void input() {
    cin >> N >> M;
    A = vector<ll>(N);
    rep(i, N) cin >> A[i];
}


ll m(ll x) {
    ll num = 0;
    rep(i, N) {
        num += A.end() - lower_bound(A.begin(), A.end(), x-A[i]);
    }
    return num;
}


int main() {
    input();
    M = min(N * N, M);
    sort(A.begin(), A.end());
    vector<ll> sum(N+1);
    for (int i = 1; i <= N; i++) sum[i] = sum[i-1] + A[i-1];
    ll left = 2 * A[0] - 1;
    ll right = 2 * A.back() + 1;
    while (right - left != 1) {
        ll center = (left + right) / 2;
        if (m(center) > M) left = center;
        else right = center;
    }
    ll ans = 0;
    rep(i, N) {
        auto itr = lower_bound(A.begin(), A.end(), right-A[i]);
        int x = distance(A.begin(), itr);
        ans += A[i] * (N - x);
        ans += sum.back() - sum[x];
    }
    ans += (M - m(right)) * left;
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

bool ok(const int weight[],long long p,int n,int k){
	int j=0;
	int puton=0;
	for (int i=0;i<n;i++){
		if(p<weight[i]){
			return false;
		}
		puton+=weight[i];
		if(p<puton){
			j++;
			puton=weight[i];
		}
		if(k<=j){
			return false;
		}
	}
	return true;
}

long long answer(int *weight,int n,int k){
	long long left=0;
	long long right=n*10000;
	while(left+1<right){
		long long med=(left+right)/2;
		if(ok(weight,med,n,k)){
			right=med;
		}else{
			left=med;
		}
	}
	return right;
}

int main(){
	int n,k;
	cin >> n >> k;
	int weight[n];
	for (int i=0;i<n;i++){
		cin >> weight[i];
	}
		
	cout << answer(weight,n,k) << endl;
	return 0;
}


Measured memory_bytes: 1548
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    if c == d:
        print("No")
    elif c < d:
        print("Yes" if s[a-1:d+1].count("##") == 0 else "No")
    elif c > d:
        print("Yes" if s[a-1:c+1].count("##") == 0 and s[b-2:d+1].count("...") != 0 else "No")


if __name__ == '__main__':
    solve()


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

int main() {
  int N, a, b, c;
  cin >> N;
  
  a = N / 100;
  b = (N % 100) / 10;
  c = N % 10;
  
  if (a == 7){
    cout << "Yes" << endl;
  }
  else if (b == 7){
    cout << "Yes" << endl;
  }
  else if (c == 7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <map>
#include <utility>
using namespace std;
typedef pair<int, int> P;

int main()
{
	map<int, P> biz;
	char str[32];
	char *p;
	int month = 1;
	
	while ((*str = getchar()) != EOF){
		if (*str == '\n'){
			month++;
			continue;
		}
		p = str + 1;
		while ((*(p++) = getchar()) != '\n');
		int id, day;
		sscanf(str, "%d,%d", &id, &day);
		
		biz[id].first++;
		if (biz[id].second < month) biz[id].second += month;
	}
	for (map<int, P>::iterator i = biz.begin(); i != biz.end(); i++){
		if (i->second.second == 3) printf("%d %d\n", i->first, i->second.first);
	}
	
	return 0;
}

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

int main()
{
	int x;
	cin >> x;
	if (x < 1200)
	{
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ARC" << endl;
	}
	return 0;
}

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

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

int main() {

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    rep(i,N) {
        cin >> A[i];
        sum += A[i];
    }
    int count = 0;
    rep(i,N) {
        if (A[i] * 4 * M >= sum) count++;
    }
    cout << (count >= M ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2604
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, p = Is()
print((a*3+p)//2)

Measured memory_bytes: 63340
#include<bits/stdc++.h>
using namespace std;
int sumOfDigit(int x) {
	int sum=0;
	while(x>0){
      sum += x%10;
      x /= 10;
    }
    return sum;
}
int main(){
  int n;
  cin >> n;
  int sum = sumOfDigit(n);
  if(n%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        String s = ns();
        int n = s.length();

        char[] c = new char[n];
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'd') {
                c[n - 1 - i] = 'b';
            } else if (s.charAt(i) == 'b') {
                c[n - 1 - i] = 'd';
            } else if (s.charAt(i) == 'p') {
                c[n - 1 - i] = 'q';
            } else {
                c[n - 1 - i] = 'p';
            }
        }

        out.println(s.equals(String.valueOf(c)) ? "Yes" : "No");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 11344
N=int(input())
A=list(map(int,input().split()))
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)

Measured memory_bytes: 164536
#include <stdio.h>

int main()
{
    long inputN, inputA, inputB;
    long remainingABalls, aBallsInRow;
    
    scanf("%ld %ld %ld", &inputN, &inputA, &inputB);
    
    remainingABalls = (inputN % (inputA + inputB));
    
    if(remainingABalls > inputA)
    {
        remainingABalls = inputA;
    }
    
    aBallsInRow = (inputN / (inputA + inputB)) * inputA;
    
    aBallsInRow += remainingABalls;
    
    printf("%ld \n", aBallsInRow);
    
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
class P{
    static void Main(){
        var s=Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a=new List<long>();
        for(int i=0;i<s[0];i++){
            a.Add(long.Parse(Console.ReadLine()));
        }
        a.Sort();
        long ans=a.Last()-a[0];
        for(int i=0;i+s[1]-1<s[0];i++){
            ans=Math.Min(ans,a[i+s[1]-1]-a[i]);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17692
#include <stdio.h>

int binarySearch();

int main(){
  int n,m,key,A[100001],i,ct=0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  scanf("%d",&m);
  for(i=0; i<m; i++){
    scanf("%d",&key);
    if(binarySearch(A, key, n) != -1) ct++;
  }
  printf("%d\n",ct);
  return 0;
}

int binarySearch(int A[], int key, int n){
  int left = 0, right = n, mid;
  while (left < right){
    mid = (left + right) / 2;
    if (A[mid] == key) return mid;
    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return -1;
}


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

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    string S,T;
    cin >> S >> T;
    int count=0;
    for(int i=0;i<S.size();i++){
        if(S[i]==T[i])count++;
    }
    cout << count << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    const int H_MAX = 1010, MOD = 1e9+7;
    int H, W, dp[H_MAX][H_MAX];
    string map[H_MAX];

	cin >> H >> W;
    for (int i = 0; i < H; ++i){
        cin >> map[i];
    }
    for (int i = 0; i < H; ++i){
        for (int j = 0; j < W; ++j){
            if (i == 0 && j == 0){
                dp[i][j] = 1;
            } else if (map[i][j] == '#'){
                dp[i][j] = 0;
            } else {
                int res = 0;
                if (i >= 1 && dp[i-1][j] != -1){
                    res = (res + dp[i-1][j]) % MOD;
                }
                if (j >= 1 && dp[i][j-1] != -1){
                    res = (res + dp[i][j-1]) % MOD ;
                }
                dp[i][j] = res;
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
	return 0;
}

Measured memory_bytes: 9484
st = input()
q = int(input())

for i in range(q):
  order = list(map(str, input().split()))
  a = int(order[1])
  b = int(order[2])
  
  if order[0] =='print':
      print(st[a:b+1])
  elif order[0] =='reverse':
      st = st[:a] + st[a:b+1][::-1] + st[b+1:]
  else:
      st = st[:a] + order[3] + st[b+1:]


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

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> ans(N,0);
    for(int i = 1; i <= N; i++){
        for(int j = i + 1; j <= N; j++){
            if(1 <= i && i <= X){
            //始1～X
                if(1 <= j && j <= (X + Y + 1)/2){
                //終1～(X+Y+1)/2
                    ans.at(j - i - 1) += 1;
                }
                if((X + Y + 1)/2 < j && j <= Y){
                //終(X+Y+1)/2～Y
                    ans.at(X - i + Y - j) += 1;   
                }
                if(j > Y){
                //終Y～N
                    ans.at(X - i - Y + j) += 1;
                }
            }
            if(X < i && i <= (X + Y - 1)/2){
            //始X～Y
                if(j <= i + (Y - X + 1)/2){
                //終i～i+(X+Y+1)/4
                    ans.at(j - i - 1) += 1;
                }
                if(i + (Y - X + 1)/2 < j && j <= Y ){
                //終i+(X+Y+1)/4～Y
                    ans.at(Y - X - j + i) += 1;
                }
                if(j > Y){
                //終Y~N
                    ans.at(i - X - Y + j) += 1;
                }
            }
            if(i > (X + Y - 1)/2){
            //始Y～
                ans.at(j - i - 1) += 1;
            }
        }
    } 
    for(int i = 0; i < N - 1; i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict
import math


def kari():
    map(int, input().split())
    list(map(int, input().split()))
    math.ceil()

def main():
    num = int(input())
    ans = 0

    for i in range(1, num):
        if i *(i + 1) + i > num:
            break

        kari_num = num
        kari_num -= i
        if kari_num % i != 0:
            continue

        kari_waru = kari_num // i

        # print(num, kari_num, kari_waru)
        if kari_waru == 0 or kari_waru == 1:
            continue

        if kari_num % kari_waru == 0:
            # print(kari_waru)
            ans += kari_waru

    print(ans)



if __name__ == '__main__':
    main()



Measured memory_bytes: 38640
#include<iostream>

using namespace std;

int main() {
    int x, y;
    while (true) {
        cin >> x >> y;
        if (x==0 && y==0) {
            break;
        }
        else if (x > y) {
            cout << y << " " << x << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(){
int a1,a2,a3,a4,a5,a6,a7,b1,b2,b3,b4,b5,b6,b7;
cin>>a1>>b1>>a2>>b2>>a3>>b3>>a4>>b4>>a5>>b5>>a6>>b6>>a7>>b7;
cout<<a1-b1<<endl<<a2-b2<<endl<<a3-b3<<endl<<a4-b4<<endl<<a5-b5<<endl<<a6-b6<<endl<<a7-b7<<endl;
return 0;
}


Measured memory_bytes: 3092
P=->s{puts s;exit};R,C=gets.split.map &:to_i;N=gets.to_i;M=Hash.new{|h,k|h[k]=[]};N.times{x,y,d=gets.split.map &:to_i;M[x]<<[y+R,d];M[y+R]<<[x,-d]};(a=-1e18;b=1e18;s=M.find{|e|e}[0];t=[[s,0]];m={s=>0};(x,d=t.pop;m[x]=d;M[x].map{|y,c|!m[y]?t<<[y,d+c]:m[y]!=d+c&&P[:No]};x<=R ? a=[a,d].max: b=[b,d].min)while !t.empty?;a>b&&P[:No];m.map{|k,v|M.delete k})while !M.empty?;P[:Yes]

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

int main(){
  int N;
  float T,A;
  cin>>N>>T>>A;
  int ans = 0;
  float diff = 1000010.0;
  float tmp = 0.0;
  vector<int> H(N);
  for(int i=0;i<N;++i){
	  cin>>H[i];
	  }
  for(int i=0;i<N;++i){
	  tmp = T - H[i]*0.006;
    if(abs(tmp-A)<diff){
		  diff=abs(tmp-A);
		  ans = i+1;
	  }
  }
cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
adj_list=[0]*N
for i in range(N):
    adj_list[i]=(A[i])
k=0
node = 1
c=[0]*N
count=1
flag=0
ROOP=[]
roopstart=0
while k<K:
    k+=1
    c[node-1]+=1
    node = adj_list[node-1]
    if c[node-1] ==1:
        if flag ==0:
            roopstart = k
            flag=1
        ROOP.append(node)
    if c[node-1] ==2:
        break
l = len(ROOP)
if l != 0:
    num = (K-l-roopstart) % (l)
    print(ROOP[num])
else:
    print(node)

Measured memory_bytes: 32328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    string s;
    cin >> s;
    if((s[2]==s[3]) && (s[4]==s[5])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl; 
    }  
    return 0;
}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

const ll INF = 1LL << 60;

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 N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
*/

void Main()
{
	int N, K;
	cin >> N >> K;

	ll h[100110];
	for (int i = 0; i < N; ++i) {
		std::cin >> h[i];
	}

	ll dp[100110];
	for (int i = 0; i < 100010; ++i) {
		dp[i] = INF;
	}

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

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

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 5132
#include<stdio.h>
#include<string.h>
int main()
{

    char str[21],a[21];
    int i,j,k;
    scanf("%s",str);
    k=strlen(str)-1;
    for(i=k,j=0;i>=0;i--,j++)
    {    
         a[j]=str[i];
    }
   a[j]='\0';
   puts(a);

   return 0;
}

Measured memory_bytes: 524