akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd ( ll a, ll b)
{
    if( b==0)
        return a;
    return gcd( b, a%b);
}
int main()
{
    ll n, x;
    cin>>n>>x;
    ll a[n+1];
    a[0] = x;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a , a+n+1);
    ll temp = a[1] - a[0];
    ll ans =0;
    for(int i=0;i<n;i++)
    {
        ans = gcd( temp , a[i+1] - a[i] );
        temp = ans;
    }
    cout<<ans;
}

Measured memory_bytes: 4296
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#ifdef ZTDebug
#define In scanf_s
#else
#define In scanf
#endif // ZTDebug

#define Ind(d) In("%d", &d)
#define Ind2(a, b) In("%d%d", &a, &b)
#define InD(d) int d; In("%d", &d);
#define InD2(a, b) int a, b; In("%d%d", &a, &b);
#define InDN(n, v) for (auto _i = 0; _i < n; ++_i) In("%d", &v[_i]);
#define OutDNLine(n, v) for (auto _i = 0; _i < n; ++_i) printf("%d%c", *(v + _i), _i + 1 == n ? '\n' : ' ');

typedef double db;
typedef long long LL;
typedef pair<int, int> pii;

const db eps = 1e-6;
const int oo = 0x3f3f3f3f;

const int Max = 200000;
LL h[Max];

int main() {
    int n;
    LL a, b;
    cin >> n >> a >> b;
    a -= b;

    auto sum = 0LL;
    for (auto i = 0; i < n; ++i) {
        cin >> h[i];
        sum += h[i];
    }

    LL s = 0LL, t = 1e9;
    while (s + 1LL < t) {
        auto d = (s + t) / 2LL;
        auto bd = b * d, c = 0LL;
        for (auto i = 0; i < n; ++i)
            if (h[i] > bd) {
                c += (h[i] - bd + a - 1LL) / a;
            }
#ifdef ZTDebug
        cout << d << ": " << c << endl;
#endif // ZTDebug
        if (c > d) s = d; else t = d;
    }
    cout << t << endl;

#ifdef ZTDebug
    system("pause");
#endif // ZTDebug
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 1010;
inline char get() {
	static char buf[10000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 10000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int h, w;
char a[N][N];
int dp[2][N];
inline void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(h); read(w);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      a[i][j] = get();
    }
    get();
  }
  dp[1][0] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (!i && !j) continue;
      dp[1][j] = 0;
      if (a[i][j] == '#') continue;
      if (i) dp[1][j] += dp[0][j];
      if (j) add(dp[1][j], dp[1][j-1]);
      //cerr << dp[i][j] << " ";
    }
    swap(dp[0], dp[1]);
    //cerr << nl;
  }
  cout << dp[0][w-1] << nl;
  return 0;
}


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

# sample1: <>> 3
# sample2: <>>><<><<<<<>>>< 28

s=input()
n=len(s)

a=[0]
tmp=0
for i in range(n):
    if s[i]=='<':
        tmp+=1
    else:
        tmp=0
    a.append(tmp)

arev=[0]
for i in range(n):
    if s[n-i-1]=='>':
        tmp+=1
    else:
        tmp=0
    arev.append(tmp)
arev.reverse()

ans=0
for i in range(n+1):
    ans+=max(a[i], arev[i])

print(ans)


Measured memory_bytes: 27944
//
// Created by zono on 18/10/27.
//

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	long a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 2) {
		cout << abs(a[0] - a[1]) << endl;
		return 0;
	}
	sort(a, a + n);
	vector<int> A;
	A.push_back(a[0] + a[0]);
	bool flag = false;
	long ans1 = 0, ans2 = 0;
	int left = 1, right = n - 1;

	while (left <= right - 1) {
		A.push_back(a[right] + a[right - 1]);
		if (left + 1 < right - 1) A.push_back(a[left] + a[left + 1]);
		else if (left != right - 1) ans1 += max(abs(a[left] - a[left + 1]), abs(a[left] - a[left + 2]));
		left += 2, right -= 2;
	}
	if (left == right) ans1 += max(abs(a[right] - a[right - 1]), abs(a[right] - a[right - 2]));
	for (int i = 0; i < A.size() - 1; i++) {
		ans1 += abs(A[i] - A[i + 1]);
	}

	reverse(a, a + n);

	vector<int> B;
	B.push_back(a[0] + a[0]);
	left = 1, right = n - 1;
	while (left <= right - 1) {
		B.push_back(a[right] + a[right - 1]);
		if (left + 1 < right - 1) B.push_back(a[left] + a[left + 1]);
		else if (left != right - 1) ans2 += max(abs(a[left] - a[left + 1]), abs(a[left] - a[left + 2]));
		left += 2, right -= 2;
	}
	if (left == right) ans2 += max(abs(a[right] - a[right - 1]), abs(a[right] - a[right - 2]));
	for (int i = 0; i < B.size() - 1; i++) {
		ans2 += abs(B[i] - B[i + 1]);
	}

	cout << max(ans1, ans2) << endl;
	return 0;
}

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

int n;
int h[100010];
int dp[100010];


int main(){

    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];

    //dp
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

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

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
	}
	else if (s.size() < 26) {
		map<char,int> mp;
		FOR(i, s.size()) {
			mp[s[i]]++;
		}
		char c;
		FOR(i, 26) {
			if (!mp[(char)('a'+i)]) {
				c = (char)('a'+i);
				break;
			}
		}
		cout << s << c << endl;
	}
	else {
		map<char,int> mp;
		FOR(i, s.size()) {
			mp[s[i]]++;
		}
		for (int i = s.size()-1; i >= 0; i--) {
			char c;
			mp[s[i]]--;
			bool flag = false;
			FOR(j, 26) {
				char x = (char)('a'+j);
				if (x <= s[i]) continue;
				if (!mp[x]) {
					c = x;
					flag = true;
					break;
				}
			}
			if (flag) {
				FOR(j, i) cout << s[j];
				cout << c << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int point_number;
	cin >> point_number;
	vector<vector<int>>v(point_number);
	for (int i = 0;i < point_number;i++) {
		int point;
		cin >> point;
		v[i].push_back(point);
		int rinsetu;
		cin >> rinsetu;
		v[i].push_back(rinsetu);
		for (int j = 0;j < rinsetu;j++) {
			int tunagari;
			cin >> tunagari;
			v[i].push_back(tunagari);
	


		}

	
	
	
}
	vector<vector<int>>ans(point_number,vector<int>(point_number));
	for(int i = 0;i < point_number;i++){
		for (int j = 0;j < v[i][1];j++) {
			ans[v[i][0]-1][v[i][j + 2]-1] = 1;
		}


	}
	for (int i=0;i < point_number;i++) {
		for (int j=0;j < point_number;j++) {
			if (j == 0) {
				cout << ans[i][j];
			}
			else {
				cout << " " << ans[i][j];
			}
		}
		cout << endl;
	}
	
}

Measured memory_bytes: 3124
#include<iostream>

using namespace std;

#define MX 1000000000



int main(){

    long long S; cin >> S;
    long long x1, y1, x2, y2, x3, y3;
    x1 = y1 = 0;
    x2 = 1000000000;
    x3 = 1;

    y3 = (S+x2-1)/x2;
    y2 = y3*x2 - S;

    if (y2 > MX) exit(1);
    if (y3 > MX) exit(1);
    cout << x1 << ' ' << y1 << ' '<< x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;

}


Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

x,y = LI()

flg = False
for i in range(x+1):
    val = 2 * i + 4 * (x-i)
    if(val == y):
        flg = True
        break

if(flg):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9200
n = gets.to_i
min = 99999999999
ary = gets.split().map(&:to_i).sort
for x in ary[0]..ary.last do
  sum = 0
  ary.each do |a|
    y = (a - x) ** 2
    sum += y
  end
  if sum <= min
    min = sum
  end
end
puts min

Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; i++) {
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        jud=True
        for k in range(m):
            if b[k]!=a[i+k][j:j+m]:
                jud=False
                break
        if jud:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::vector<int> a(1 << n);
	for(int i = 0; i <1 << n; i++) cin >> a[i];
	
	int ma = 0;
	for(int i = 1; i < 1 << n; i++) {
		int A = 0, B = 0;
		for(int j = i; j >= 0; j--) {
			j &= i;
			if(a[j] > A) {
				B = A;
				A = a[j];
			} else if(a[j] > B) {
				B = a[j];
			}
		}
		ma = std::max(ma, A + B);
		
		cout << ma << endl;
	}
			
	return 0;
}


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

using namespace std;
int cnt=0,ans=0;
int n,m,q;
int a[100],b[100],c[100],d[100],arr[100];
void solve(int i,int x)
{
    if(x>m) return;
    if(i==n)
    {
        int cnt=0;
        for(int j=0;j<q;j++)
            if(arr[b[j]]-arr[a[j]]==c[j])
                cnt+=d[j];
        ans=max(ans,cnt);
        return;
    }
    arr[i]=x;
    solve(i+1,x);
    arr[i]=x+1;
    solve(i,x+1);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }
    solve(0,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
N, X = gets.strip.split.map(&:to_i)
a = gets.strip.split.map(&:to_i)

s = Array.new(N + 1) { 0 }

N.times do |i|
  s[i + 1] = a[i] + s[i]
end

puts s.select { |i| i <= X }.size


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >>y;
    if(a+b < 2*c){
        cout << a*x+b*y << endl;
    }
    else{
        int i = min(x,y);
        int j = max(x,y);
        if(x > y){
            cout << min(j*2*c,i*2*c+(j-i)*a) << endl;
        }
        else {
            cout << min(j*2*c,i*2*c+(j-i)*b) << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 2001;
ll dp[N][N]; // Ways to divide a balls into b bins

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

	int k, n;
	cin >> n >> k;
	dp[0][0] = 1;
	for (int i = 1; i < N; ++i) {
		for (int j = 1; j <= i; ++j) {
			dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % MOD;
		}
	}
	for (int i = 1; i <= k; ++i) {
		// Ways to divide k balls into i clusters, and n-k balls into i+1 clusters
		ll mult = dp[k][i];
		ll res = 0;
		for (int j = 0; j <= n-k; ++j) {
			ll mult2 = dp[j][i-1];
			if (j < n-k) mult2 = (mult2 * (2 + dp[n-k-j][2])) % MOD;
			res = (res + mult * mult2) % MOD;
		}
		cout << res << '\n';
	}
}


Measured memory_bytes: 30208
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, c: usize,
        stc: [(usize, usize, Usize1); n]
    }

    let mut progs = vec![Vec::new(); c];
    for (s, t, c) in stc {
        progs[c].push((s, t));
    }
    for vec in &mut progs {
        vec.sort();
    }
    let mut st = Vec::new();
    for vec in progs {
        let mut prev_tail = 0;
        for i in 0..vec.len() {
            let (s, t) = vec[i];
            if prev_tail != s {
                st.push((s, t));
            } else {
                st.last_mut().unwrap().1 = t;
            }
            prev_tail = t;
        }
    }

    let mut cum = vec![0i64; 200010];
    for (s, t) in st {
        cum[2*s-1] += 1;
        cum[2*t] -= 1;
    }
    let mut prev = 0;
    for i in 0..cum.len() {
        cum[i] += prev;
        prev = cum[i];
    }
    let ans = cum.into_iter().max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 8372
n = int(input())
a = [int(input()) for _ in range(2 ** n)]
while len(a) > 1:
    b = []
    sz = len(a)
    for i in range(sz // 2):
        p, q = a[2 * i], a[2 * i + 1]
        if p < q:
            p, q = q, p
        b.append(p - q)
    a = b
print(a[0])

Measured memory_bytes: 18664
x,k,d= [int(y) for y in input().split()]
if x<0:
    x=-x

if x==0:
    print(d if k%2 else 0)  
else:
    if k*d<=x:
        print(x-k*d)
    else:
        k2=k-x//d
        print(d-x%d if k2%2 else x%d)


Measured memory_bytes: 9124
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';
int dp[50000];
int find(int sum){
    if(dp[sum] >= 0)return dp[sum];
    
    if(sum == 0)return 1;
    else if(sum < 0) return 0;
    
    int ans=0;
    for(int i  =3  ; i<= 2000 ; i ++ ){
        if(sum-i < 0)break;
        int val = find(sum-i);
        if(val > 0)
            dp[sum-i] = val;
        ans = (ans + val)%MOD;
    }
    
    return ans;
    
}
int32_t main(){
    boost;
    
    int n;
    cin>>n;
    cout<<1-n<<endl;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

ll a[MAXN];
ll b[MAXN];

int main() {
	int n; rd(n);
	for (int i = 1; i <= n; i++)
		rd(a[i], b[i]);
	sort(a+1, a+n+1);
	sort(b+1, b+n+1);

	ll ans = 0;
	if (n%2 == 0) {
		ll lo = a[n/2] + a[n/2+1];
		ll hi = b[n/2] + b[n/2+1];
		ans = hi - lo + 1;
	} else {
		ans = b[n/2+1] - a[n/2+1] + 1;
	}

	printf("%lld\n", ans);

}

Measured memory_bytes: 6880
#include <iostream>

using namespace std;

int pgcd(int a, int b){
    if(b == 0)
        return a;
    return pgcd(b, a % b);
}

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int d = pgcd(a, b);
    int ret = d;
    while(k){
        if(d % ret == 0)
            k--;
        if(k != 0)
            ret--;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <algorithm>

using namespace std;

int a[100000];

int main() {
    int n, t, m = 1e9, x = 0, ans = 0, i;
    set <int> s;
    
    scanf("%d %d", &n, &t);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) {
        m = min(m, a[i]);
        x = max(x, a[i] - m);
    }
    
    for (i = 0; i < n; i++) {
        if (s.count(a[i] - x)) ans++;
        
        s.insert(a[i]);
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 5248
W, H, N = map(int , input().split())
x = [0] * N
y = [0] * N 
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int ,input().split())

board = [[1]*(W) for i in range((H))]
for i in range(N):
    l = [(y,x) for x in range(W) for y in range(H)]
    if a[i] == 1:
        l = list(filter(lambda t: t[1] <= x[i]-1, l))
    elif a[i] == 2:
        l = list(filter(lambda t: t[1] > x[i]-1, l))
    elif a[i] == 3:
        l = list(filter(lambda t: t[0] <= y[i]-1, l))
    elif a[i] == 4:
        l = list(filter(lambda t: t[0] > y[i]-1, l))
    for xy in l:
        board[xy[0]][xy[1]] = 0
ans = sum(map(sum, board))
print(ans)


Measured memory_bytes: 4748
#include <stdio.h>

int main(void) {
	int x, i=0;
	scanf("%d", &x);
	//printf("%d\n", x);
	while (x!=0){
		i++;
		printf("Case %d: %d\n", i, x);
		scanf("%d", &x);
	}
	return 0;
}



Measured memory_bytes: 1968
import sys
from bisect import bisect_left,bisect_right
input = sys.stdin.readline
ide = 0
def func(a,b):
  return max(a,b)
class SegmentTree:
  def __init__(self,ls,commutative = True):
    if commutative == True:
      self.n = len(ls)
      self.tree = [ide for i in range(self.n)]+ls
    else:
      self.n = 2**((len(ls)-1).bit_length())
      self.tree = [ide for i in range(self.n)]+ls+[ide for i in range(self.n-len(ls))]
    for i in range(1,self.n)[::-1]:
      self.tree[i] = func(self.tree[i<<1|0],self.tree[i<<1|1])
  def getall(self):
    return self.tree[1]
  def get(self,l,r):
    lret = ide
    rret = ide
    l += self.n
    r += self.n
    while l < r:
      if l&1:
        lret = func(lret,self.tree[l])
        l += 1
      if r&1:
        rret = func(self.tree[r-1],rret)
      l >>= 1
      r >>= 1
    ret = func(lret,rret)
    return ret
  def update(self,i,x):
    i += self.n
    self.tree[i] = x
    while i > 1:
      i >>= 1
      self.tree[i] = func(self.tree[i<<1|0],self.tree[i<<1|1])
n = int(input())
xd = [list(map(int,input().split())) for i in range(n)]
mod = 998244353
xd.sort()
xls = list(zip(*xd))[0]
rls = [0]*n
st = SegmentTree(rls)
for i in range(n)[::-1]:
  idx = bisect_left(xls,xd[i][0]+xd[i][1])-1
  x = st.get(i,idx+1)
  st.update(i,max(i,x))
dp = [0]*(n)
dp[-1] = 2
for i in range(n-1)[::-1]:
  x = st.get(i,i+1)
  if x == n-1:
    dp[i] = dp[i+1]+1
  else:
    dp[i] = dp[i+1]+dp[x+1]
  dp[i] %= mod
print(dp[0])

Measured memory_bytes: 125704
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
	var input = ReadLine().Split(' ').Select(long.Parse).ToArray();
    var n = input[0];
    var a = input[1];
    var b = input[2];

    long x = n/(a+b);
    long y = n%(a+b);
    long z = 0;
    
    long result = x*a;
    
    if(y >= a){
    	z = a;
    }else{
    	z = y;
    }
      
    Write(result + z);
    
  }
}


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

signed main(void)
{
	int n, k;
	long long ans;
	cin >> n >> k;
	
	ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
			ans *= k;
		else
			ans *= k - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable.ArrayBuffer

object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	val n  = sc.nextInt
	
	val connected = Array.fill(n)(ArrayBuffer.empty[(Int, Int)])
	(0 until n-1) foreach { i =>
		val a, b = sc.nextInt - 1
		connected(a) += (i -> b)
		connected(b) += (i -> a)
	}
	
	val cs = Array.fill(n-1)(-1)
	pw.println(connected.map(_.length).max)
	pw.flush()

	def bfs(q: Seq[(Int, Int)]): Unit = {
		val nexts = q flatMap { case (v, p) =>
			var ci = 1
			connected(v).collect{ case (i, u) if cs(i) == -1 =>
				cs(i) = ci + (if (ci < p) 0 else 1)
				ci += 1
				(u, cs(i))
			}
		}
		if (nexts.nonEmpty) bfs(nexts)
	}

	bfs(Seq((0, n)))
	
	cs foreach (pw.println(_))
	pw.flush()
}

Measured memory_bytes: 119028
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
int A[100];
map<int, int> M;
int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
		M[min(A[i] / 400, 8)]++;
	}

	int sum = 0;
	REP(i, 0, 8) {
		sum += M[i] > 0;
	}
	cout << max(sum, 1) << ' ' << sum + M[8] << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

go = []
back = []
g = []
b = []
def has_duplicates(seq):
    return len(seq) != len(set(seq))


for i in range(len(s)):
  go.append(s[i]+t[i])
  back.append(t[i]+s[i])

go_l = set(go)
back_l = set(back)
go = list(go_l)
back = list(back_l)

#print(go)
#print(back)

for i in range(len(go)):
  g.append(go[i][0])
  b.append(back[i][0])
  
#print(g)
#print(b)
  
ansg = has_duplicates(g)
ansb = has_duplicates(b)

if ansg == True or ansb == True:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 29232
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> x(m),y(m-1);
    for(int i = 0; i < m; i++) cin >> x[i];
    sort(x.begin(),x.end());
    for(int i = 0; i < m-1; i++){
        y[i] = x[i+1]-x[i];
    }
    sort(y.begin(),y.end());
    int ans = 0;
    for(int i = 0; i < max(m-n,0); i++){
        ans += y[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void){

  //入力
  int A, B;
  cin >> A >> B;
  
  //A以上B以下の整数について
  int ans = 0;
  for(int i = A; i <= B; i++){
    //文字列型にして判別していく
    string tmp = to_string(i);
    string rev = tmp;	//反転したやつ
    reverse(rev.begin(), rev.end());
    if(tmp == rev) ans++;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <math.h>
using namespace std;

int main() {
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int w=100*a,s=0;
    int i,j,k,l;
    for(i=1;100*a*i<=f;++i){
        for(j=0;100*a*i+100*b*j<=f;++j){
            for(k=0;100*a*i+100*b*j+c*k<=f;++k){
                for(l=0;100*a*i+100*b*j+c*k+d*l<=f;++l){
                    if((c*k+d*l)*(100+e)<=(100*a*i+100*b*j+c*k+d*l)*e
                       &&s*(100*a*i+100*b*j+c*k+d*l)<w*(c*k+d*l)){
                        s=c*k+d*l;
                        w=100*a*i+100*b*j+c*k+d*l;                }
            }
        }
    }
    }
    cout<<w<<" "<<s<<endl;
    return 0;
}

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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  int x[n],y[n],h[n];
  for(int i=0;i<n;i++) {
    cin>>x[i]>>y[i]>>h[i];
  }
  for(int cx=0;cx<=100;cx++) {
    for(int cy=0;cy<=100;cy++){
      int H;
      for(int i=0;i<n;i++){
        if(h[i]==0){
          continue;
        }
        H = h[i]+abs(x[i]-cx)+abs(y[i]-cy);
        if(H>0){
          break;
        }
      }
      bool flag=true;
      for(int i=0;i<n;i++){
        int tmp_h=max(H-abs(x[i]-cx)-abs(y[i]-cy),0);
        if(tmp_h!=h[i]){
          flag=false;
          break;
        }
      }
      if(flag){
        cout<<cx<<" "<<cy<<" "<<H<<endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <map>

int main(){
  std::map<char,bool> odd;
  std::map<char,bool> even;
  even['L'] = true;
  even['R'] = false;
  even['U'] = true;
  even['D'] = true;
  odd['L'] = false;
  odd['R'] = true;
  odd['U'] = true;
  odd['D'] = true;
  char s[128];
  scanf("%s",s);
  int i=0;
  bool tf = true;
  do{
    if(i%2==1){
      tf = tf && even[s[i]];
    }else{
      tf = tf && odd[s[i]];
    }
    if(!tf) break;
    ++i;
  }while(s[i]!='\0');
  if(tf){
    std::cout << "Yes" << std::endl;;
  }else{
    std::cout << "No" << std::endl;;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
Q= deque()

for _ in range(n):
    str = input()
    if str == "deleteFirst":
        Q.popleft()
    elif str == "deleteLast":
        Q.pop()
    else:
        cmd,key = str.split()
        if cmd == "insert":
            Q.appendleft(key)
        elif cmd == "delete":
            try:
                Q.remove(key)
            except:
                pass
print(" ".join(list(Q)))


Measured memory_bytes: 69736
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll INF = 1e10;

ll n, m;

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> x >> y >> z;
	if (x > 0) {
		ll ans = (x / z);

		if (ans <= y) {
			y -= ans;
			if (y % 2 == 0) {
				cout << x - ans*z;
			}
			else
				cout << abs(x - (ans + 1)*z);
		}
		else {
			cout << x - y*z;
		}
	}
	else {
		x = abs(x);
		ll ans = x / z;
		if (ans <= y) {
			y -= ans;
			if (y % 2 == 0) {
				cout << x - ans*z;
			}
			else
				cout << abs(x - (ans + 1)*z);
		}
		else {
			cout << x - y*z;
		}
	}

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  if ( ( A + B ) < ( C + D ) ){
    cout << "Right" << endl;
  }
  if ( ( A + B ) == ( C + D ) ){
    cout << "Balanced" << endl;
  }
  if ( ( A + B ) > ( C + D ) ){
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;


int c[100010];
int tot=1;
int box[100010];

struct ee{
    int to,pos,next;
}edge[200010];

int add(int a,int b,int i){
    edge[tot].to=b;
    edge[tot].pos=i;
    edge[tot].next=box[a];
    box[a]=tot++;
}

int sear(int now,int last,int col){
    int tmpc=0;
    for (int i=box[now];i;i=edge[i].next){
        if (edge[i].to==last) continue;
        ++tmpc;if (tmpc==col) tmpc++;
        c[edge[i].pos]=tmpc;
        sear(edge[i].to,now,tmpc);
    }
}

int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<n;++i){
        int a,b;scanf("%d%d",&a,&b);
        add(a,b,i);add(b,a,i);
    }
    sear(1,0,0);
    int ans=0;
    for (int i=1;i<n;++i) if (c[i]>ans) ans=c[i];
    printf("%d\n",ans);
    for (int i=1;i<n;++i)
        printf("%d\n",c[i]);
}



Measured memory_bytes: 4864
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf = buf.trim().to_string();
    let mut num_vec: Vec<i64> = Vec::new();
    let mut is_seven_flag = false;

    for num in buf.chars() {
        let num_i64: i64 = num as i64 - 48;
        num_vec.push(num_i64);
    }

    for i in num_vec {
        if i == 7 {
            is_seven_flag = true;
            break;
        }
    }
    if is_seven_flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
    int x_1, y_1, x_2, y_2; cin >> x_1 >> y_1 >> x_2 >> y_2;
    int dif_x = x_2 - x_1;
    int dif_y = y_2 - y_1;
    
    cout << x_2 - dif_y << " " <<  y_2 + dif_x << " " << x_1 - dif_y << " " << y_1 + dif_x;
}

Measured memory_bytes: 256
<?php
$Rectangle=trim(fgets(STDIN));
//????????§??°???????????????
$fget = explode(" ", $Rectangle);
//????????????????¨????????????????
$a=$fget[0];
$b=$fget[1];
$c=$fget[2];
//??°?????????????????£????????´???????¨???????????????????
if(0<=$a && $a<=100 && 0<=$b && $b<=100 && 0<=$c && $c<=100){
    if($a < $b && $b < $c){
        echo "Yes";
    }
    else{
        echo "No";
    }
}
?>

Measured memory_bytes: 15488
using System;

public class Class1
{
    static void Main(string[] args)
    {
        var Class1 = new Class1();
    }

	public Class1()
	{
        string[] Input = Console.ReadLine().Split(' ');
        int[] nums = new int[3];
        int Total = 0;
        for (int i = 0; i < nums.Length; i++)
        {
            nums[i] = int.Parse(Input[i]);
            Total += nums[i];
        }


        for (int i = 0; i < 3; i++)
        {
            if (Total - nums[i] == nums[i])
            {
                Console.WriteLine("Yes");
                break;
            }
            else if (i == 2)
            {
                Console.WriteLine("No");
            }
        }

	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    cout << (N % K == 0 ? 0 : 1) << endl;

    return 0;
}


Measured memory_bytes: 256
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; ++i )
#define         rep1(i,n)      for ( i=1 ; i<=n ; ++i )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         vcl            vector<ll>
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){Faysal

    ll ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>n;
    cnt=0;
    rem=n%500;
    if(n>=500)
    {
        x=n/500;
        cnt=1000*x;
    }
    cnt+=(5*(rem/5));
    cout<<cnt<<nn;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 2e5+1;
const ll VAL_MAX = 1e5+1;
const ll INF=1e14;

ll dp[ARR_MAX];
//dp[i] = maximum possible beauty with height as i.

void solve(){
    int n;cin>>n;
    int h[n];
    ll a[n];
    int base=1;
    while(base<=n){
    	base*=2;
    }
    //base is smallest power of 2 greater than n
    vector<ll> segTree(2*base);
    for(int i=0;i<n;i++){
    	cin>>h[i];
    }
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    for(int i=0;i<n;i++){
    	int x=base+h[i];
    	ll best=0;
    	while(x>1){
    		if(x%2) best=max(best,segTree[x-1]);
    		x/=2;
    	}
    	dp[h[i]] = best+a[i];
    	for(int x=base+h[i];x>=1;x/=2){
    		segTree[x]=max(segTree[x],dp[h[i]]);
    	}
    }
    ll mx=0;
    for(int i=1;i<=n;i++){
    	mx=max(mx,dp[i]);
    }
    cout<<mx<<nl;
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;
const ll MOD=1e9+7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n,0){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]>rank[ry]) par[ry]=rx;
        else par[rx]=ry;
        if(rank[rx]==rank[ry]) rank[ry]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    int cnt(int n){
        int res=0;
        for(int i=0;i<n;++i){
            if(root(i)==i) res++;
        }
        return res;
    }
};

int main(){
    string S,T;cin>>S>>T;
    ll N,M;
    N=(ll)S.size();M=(ll)T.size();
    vector<vector<ll> > st(26);
    for(int i=0;i<N;++i){
        st[S[i]-'a'].push_back(i+1);
    }
    for(int i=0;i<26;++i){
        if(st[i].size()==0) continue;
        st[i].push_back(INF);
    }
    ll cnt=0;
    ll roop=0;
    for(int i=0;i<M;i++){
        if(st[T[i]-'a'].size()==0){
            cout<<-1<<endl;
            return 0;
        }
        cnt=*lower_bound(st[T[i]-'a'].begin(),st[T[i]-'a'].end(),cnt+1);
        if(cnt==INF){
            roop++;
            cnt=*lower_bound(st[T[i]-'a'].begin(),st[T[i]-'a'].end(),1);
        }
    }
    cout<<N*roop+cnt<<endl;
    return 0;
}

Measured memory_bytes: 4648
#include<bits/stdc++.h>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(i,x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 233333333
using namespace std;
/*---------------------------------------*/
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
namespace fib{char b[300000]= {},*f=b;}inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}struct foce{~foce(){pob;fflush(stdout);}} _foce;namespace ib{char b[100];}inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(ll x){out(x);pc('\n');}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
inline ll jdz(ll x){return x>=0?x:-x;}
/*------------------------------------------------------------------------------------------------*/
#define N 200011
ll n,a[N],s[N],xo[N],x,l=1,r,ans=0;
int main(){
	in(n);
	Fur(i,1,n){in(a[i]);s[i]=a[i]+s[i-1];xo[i]=xo[i-1]^a[i];}
	fur(r,1,n){
		while(s[r]-s[l-1]!=(xo[r]^xo[l-1])&&l<=r)l++;
		ans+=r-l+1;
	}
	outn(ans);
}

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

int a[10]={0,2,5,5,4,5,6,3,7,6},b[10],top;
bool ok[10];

map <int,string> f;
map <int,string> qwq;
string s;

string ma(string x,string y){
	if(x.length()>y.length())	return x;
	if(x.length()<y.length())	return y;
	return max(x,y);
}

bool cmp(int x,int y){
    if(a[x]==a[y])  return x>y;
    return a[x]<a[y];
}

int main(){
	int n,m,x,cnt=0,opt;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		scanf("%d",&x),b[++top]=x,ok[x]=1;
	for(int i=1;i<=9;i++)	s.push_back('0'+i),qwq[i]=s,s.erase(0,1);
	sort(b+1,b+1+top,cmp);
    f[0]='0';
	for(int i=9;i;i--){
        if(!ok[i])  continue;
	    for(int j=a[i];j<=n;j++)
	  	    if(f[j-a[i]].size())	f[j]=ma(f[j],f[j-a[i]]+qwq[i]);
	}
	for(int i=1;i<f[n].length();i++)    putchar(f[n][i]);
    putchar('\n');
	return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl;

#define iosbase ios_base::sync_with_stdio(false)
#define tie cin.tie();cout.tie();

#define endl '\n'

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

int n, m;
int main(){
  iosbase;
  tie;

  string s;
  int n;
  cin >> n;
  cin >> s;

  if( n & 1) cout << "No" << endl;
  else{
    bool errou = false;
    for(int i = 0; i < n/2; i++){
      if(s[i] != s[i + (n/2)]){
        errou = true;
        break;
      }
    }

    if(errou) cout << "No" << endl;
    else cout << "Yes" << endl;

  }
}


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

int main(){
    long long N;
    cin>>N;
    long long x=0,p;
    for(long long i=N;i>0;i/=10){
        p=i%10;
        x+=p;
    }
    if(N%x==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

max_length = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    if i == len(S) - 1:
      length = 1
    else:
      for j in range(i+1, len(S)):
        if S[j] in "ACGT":
          length = j - i + 1
        else:
          length = j - i
          break

    if length > max_length:
      max_length = length

print(max_length)

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

int main(){
	int N;
	cin >> N;
	int cnt = 0;
	for(int i = 1; i <= N; i++){
		string S = to_string(i);
		if(S.size() % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int n;
	cin >> n;
	int i, i1, i2, i3, i4, i5, i6;
	for (i = 0; i < n; i++) {
		cout << a + i << endl;
		if (a + i >= b)
			break;
	}
	for (i1 = n; i1 > 0; i1--) {
		if (b - i1 +1 >= a + n)
			cout << b - i1 +1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        Map<String, Integer> cp = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String str = sc.next();
            if( cp.containsKey( str ) ) {
                int x = cp.get(str);
                cp.put(str, ++x);
            } else {
                cp.put(str, 1);
            }
        }
        int M = sc.nextInt();
        for(int i = 0; i < M; i++) {
            String str = sc.next();
            if( cp.containsKey( str ) ) {
                int x = cp.get(str);
                cp.put( str, --x );
            }
        }
        
        int max = 0;
        for( Map.Entry<String, Integer> entry : cp.entrySet() ) {
            max = Math.max( max, entry.getValue() );
        }
        System.out.println( max );
    }
}


Measured memory_bytes: 35728
n = int(input())
dc = {}
for i in range(n):
  s = input()
  if s in dc:
    dc[s] += 1
  else :
    dc[s] = 1
m = int(input())
for i in range(m):
  t = input()
  if t in dc:
    dc[t] -= 1
  else :
    dc[t] = -1
ans = 0
for i in dc:
  ans = max(ans, dc[i])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,b,c,ans=0;
  cin >> a;
  
  for(int i=0;i<a;i++){
    cin >> b >> c;
    ans += c-b+1;
  }
  
  cout << ans <<endl;
      
}

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

int main()
{
	int w,wl[35],n,a,b,c;
	char ch;
	for(int i=0;i<35;i++){
		wl[i]=i;
	}
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>ch;
		cin>>b;
		c=wl[a];
		wl[a]=wl[b];
		wl[b]=c;
	}
	for(int i=0;i<w;i++){
		cout<<wl[i+1]<<endl;
	}
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;


long long t[200010];

int main(void) {

	long long N, T;
	long long ans = 0;

	cin >> N >> T;
	
	int i;
	for (i = 0; i < N; i++) cin >> t[i];

	t[N] = 1000000000+T;

	for (i = 0; i < N; i++) {
		long long offset = t[i + 1] - t[i];
		if (offset >= T) {
			ans += T;
		}
		else {
			ans += offset;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;

char str[N];
int a[N],b[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	int len = read(),ans = INF;
	scanf("%s",str + 1);

	For(i,1,len) a[i] = a[i - 1] + (str[i] == '#');
	Fordown(i,len,1) b[i] = b[i + 1] + (str[i] == '.');
	For(i,0,len) chkmin(ans,a[i] + b[i + 1]);

	printf("%d\n",ans);

	return 0;
}

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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int  n,m;
    cin >> n >> m;
    ll sum = 0;
    sum += n*(n-1)/2;
    sum += m*(m-1)/2;
    
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int d = sc.nextInt();
    int[][] x = new int[n][d];
    int ans = 0;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < d; j++) {
        x[i][j] = sc.nextInt();
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        double tmp = 0;
        for (int k = 0; k < d; k++) {
          tmp += (x[j][k] - x[i][k]) * (x[j][k] - x[i][k]);
        }
        double sq = Math.sqrt(tmp);
        if ((sq - (int) sq) == 0) {
          ans++;
        }
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35840
#include <cstdio>
#include<iostream>
#include<cmath>

using namespace std;
int main() {
	int r,g,b;
	cin>>r>>g>>b;
	if((r*100+g*10+b)%4==0){
		cout<<"YES"<<endl; 
	}
	else {
		cout<<"NO"<<endl;
	}
	return 0;
}





Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>){
    val scanner = Scanner(System.`in`)
    val numberOfLook = scanner.nextInt()
    val votesPairs = Array(numberOfLook){ D1015C.VotesRatioPair(scanner.nextInt(), scanner.nextInt()) }
    val result = D1015C(votesPairs).judge()
    println(result)
}

class D1015C(
  private val votesRatioArray: Array<VotesRatioPair>
){
    fun judge(): Long{
        return votesRatioArray.reduce { interimResult, currentRatio ->
            currentRatio * currentRatio.getMultiplierThatCanExceedTarget(interimResult)
        }.getSum()
    }

    data class VotesRatioPair(
      val takahashi: Long
     ,val aoki:      Long
    ){
        constructor(takahashi: Int, aoki: Int): this(takahashi.toLong(), aoki.toLong())

        operator fun times(value: Long): VotesRatioPair
                = VotesRatioPair(takahashi * value, aoki * value)
        operator fun div(value: VotesRatioPair): VotesRatioPair
                = VotesRatioPair(takahashi = takahashi / value.takahashi
                                ,aoki      = aoki      / value.aoki     )

        fun getMultiplierThatCanExceedTarget(target: VotesRatioPair): Long
            = VotesRatioPair(takahashi = (target.takahashi + takahashi -1) /takahashi
                            ,aoki      = (target.aoki      + aoki      -1) /aoki     )
                .getMax()

        fun getMax() = Math.max(takahashi, aoki)
        fun getSum() = takahashi + aoki
    }
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin >> a >> b >> c;
  bool vis[60];
  memset(vis,false,sizeof(vis));
  int p = 0;
  int t = 0;
  vis[0] = true;
  while(true){
    if(p+a <= 60){
      if(p <= c && c <= p+a){
        cout << t + (c-p) << endl;
        return 0;
      }
    }else{
      if(p <=  c){
        cout << t+(c-p) << endl;
        return 0;
      }
      else if((p+c) % 60 >= c){
        cout << t + (60-p) + c << endl;
        return 0;
      }
    }
    (p += a+b) %= 60;
    t += a+b;
    if(vis[p] == true){
      cout << -1 << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 3208