akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int N;
    cin >> N;
    
    int i;
    
    int A[N];
    rep(i,N) cin >> A[i];
    

    
    int B[N];
    for(i = 0; i < N; i++){
         B[A[i]-1] = i+1;
    }

 
    vector <int> v;
    rep(i,N) v.push_back(A[i]);
    
    
    
    sort(v.begin(), v.end());
    
    rep(i,N) cout << B[v[i]-1] << endl;
    
    
    return 0;
}
    
    


Measured memory_bytes: 2168
# -*- coding: utf-8 -*-
"""
Created on Sat Jun  9 13:21:18 2018
ALDS1-9b
@author: maezawa
"""
import math

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

def parent(node):
    return math.floor(node/2)

def left(node):
    return 2*node

def right(node):
    return 2*node+1

def max_heapify(a, i):
    l = left(i)
    r = right(i)
    if l <= h and a[l-1] > a[i-1]:
        largest = l
    else:
        largest = i
    if r <= h and a[r-1] > a[largest-1]:
        largest = r
        
    if largest != i:
        a[i-1], a[largest-1] = a[largest-1], a[i-1]
        max_heapify(a, largest)

def build_max_heap(a):
    for i in list(range(1,h//2+1))[::-1]:
        max_heapify(a, i)
        #print(a)
        
build_max_heap(a)

for i in range(h):
    print(' {}'.format(a[i]),end = '')
print()
    


Measured memory_bytes: 63776
N = int(input())
ans = [0 for i in range(4)]
for i in range(N) :
  s = input()
  if s == "AC" :
    ans[0] += 1
  elif s == "WA" :
    ans[1] += 1
  elif s == "TLE" :
    ans[2] += 1
  else :
    ans[3] += 1
    
print("AC x", ans[0])
print("WA x", ans[1])
print("TLE x", ans[2])
print("RE x", ans[3])

Measured memory_bytes: 9248
#include<cmath>
#include<cstdio>
using namespace std;
typedef unsigned int ui;
int main(){
  int q;
  scanf("%d",&q);
  while(q--){
    ui bit;
    scanf("%x",&bit);
    if(bit >> 31 & 1) putchar('-');
    int Seisu = ( bit & 0x7FFFFFFF ) >> 7;
    int Syosu = ( bit & 0x0000007F );
    double ans = 0.0;
    int keta = 0;
    for(int j = 0 ; j < 7 ; j++){
      if(Syosu & (1 << (6-j))){
        ans += pow(0.5,j+1);
        keta = j;
      }
    }
    printf("%.*lf\n",keta+1,Seisu+ans);
  }
}

Measured memory_bytes: 1080
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static String S = sc.next();
    static String T = sc.next();

    public static void main(String[] args) {
        if (S.length() < 1 || S.length() > 10 || T.length() - S.length() != 1){
            System.out.println("No");
        } else {
            char strS[] = S.toCharArray();
            char strT[] = T.toCharArray();
            for (int i = 0; i < S.length(); i++){
                if (strS[i] != strT[i]) {
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 35560
n,m,k = map(int,input().split())
def nCr(n,r,fac,finv):
    mod = 998244353
    ans = fac[n] * (finv[r] * finv[n-r] % mod) % mod
    return ans
ans = 0
mod = 998244353
fac = [1,1]+[0]*n
finv = [1,1]+[0]*n
inv = [1,1]+[0]*n
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod//i) % mod
    finv[i] = finv[i-1] * inv[i] % mod
for i in range(k+1):
    ans += m*pow(m-1,n-1-i,mod)*nCr(n-1,i,fac,finv) % mod
    ans %= mod
    # print(m*pow(m-1,n-1-i,mod)*nCr(n-1,i,fac,finv) % mod)
print(ans)

Measured memory_bytes: 80152
let n = Int(readLine()!)!
var list = Array(repeating: 0, count: n+1)
for x in 1...n {
    guard x*x <= n else { break }
    for y in 1...n {
        guard x*x+y*(x+y) <= n else { break }
        for z in 1...n {
            let i = x*x+y*(x+y)+z*(x+y+z)
            guard i <= n else { break }
            list[i] += 1
        }
    }
}
for i in 1...n {
    print(list[i])
}


Measured memory_bytes: 7720
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

constexpr int p = 1e9+7;

int N;
int dp[100008];

int main() {
    int K, a;
	scanf("%d%d", &N, &K);
    {
        scanf("%d", &a);
        for(int k=0; k<=a; ++k) {
            dp[k] = 1;
        }
    }
    for(int n=1; n<N; ++n) {
        int sum = dp[0];
        for(int k=1; k<=K; ++k) {
            sum += dp[k];
            if(p<=sum) sum -= p; 
            dp[k] = sum;
        }
        scanf("%d", &a);
        for(int k=K; a<k; --k) {
            int sum = dp[k] - dp[k-a-1];
            if(sum<0) sum += p;
            dp[k] = sum;
        }
    }
    printf("%d\n", dp[K]);
	return 0;
}


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

typedef pair<int, int> P;

int main() {
    int N, K;
    cin >> N >> K;

    int maxNum = (N - 1) * (N - 2) / 2;
    if (maxNum < K) {
        cout << -1 << endl;
        return 0;
    }

    vector<P> res;
    for (int i = 0; i < N - 1; i++) {
        res.push_back(P(i + 1, N));
    }
    int add = maxNum - K;
    vector<P> edge;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < i; j++) {
            edge.push_back(P(i + 1, j + 1));
        }
    }
    for (int i = 0; i < add; i++) {
        res.push_back(edge[i]);
    }
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) {
        cout << res[i].first << " " << res[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>

int main(void){
    long long N, rtN, ans=1e12+1;
    std::cin >> N;
    rtN = std::sqrt(N);

    for (int i=1; i<=rtN; ++i){
        if (N % i == 0){
            long long j = N / i;
            ans = std::min(ans, i + j - 2);
        }
    }
    
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int NA = N*A;
        int[] x = new int[N];
        int[] sumfx = new int[N];
        int sumx = 0;
        for(int i=0;i<N;i++){
            x[i] = sc.nextInt();
        }
        
        long[][][] p = new long[N+1][N+1][2501];
        p[0][0][0] = 1;
        
        for(int i=1;i<=N;i++){
            for(int j=0;j<=N;j++){
                for(int s=0;s<=2500;s++){
                    if(j>0&&(s-x[i-1])>=0){
                        p[i][j][s] = p[i-1][j][s] + p[i-1][j-1][s-x[i-1]];
                    }else{
                        p[i][j][s] = p[i-1][j][s];
                    }
                }
            }
        }
        
        long result = 0;
        for(int k=1;k<=N;k++){
            result += p[N][k][k*A];
        }
        
        System.out.println(result);
        
    }
}


Measured memory_bytes: 64944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

ll factorize_two(ll x) {
  ll res = 0;
  while (x % 2 == 0) {
    res++;
    x /= 2;
  }
  return res;
}

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  map<int, int> mp;
  for (auto itr : a) {
    ll tmp = factorize_two(itr);
    if (tmp >= 2) mp[2] += 1;
    else if (tmp == 1) mp[1] += 1;
    else if (tmp == 0) mp[0] += 1;
  }

  ll s = floor(n / 2);
  if (mp[2] >= s) {
    cout << "Yes" << endl;
  } else {
    ll t = n - 2 * mp[2];
    if (mp[1] >= t) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			int Y = sc.nextInt();
			int M = sc.nextInt();
			int D = sc.nextInt();
			int ans = dm(Y, M) - D + 1;
			for (int j = M + 1; j <= 10; ++j) {
				ans += dm(Y, j);
			}
			for (int j = Y + 1; j < 1000; ++j) {
				for (int k = 1; k <= 10; ++k) {
					ans += dm(j, k);
				}
			}
			System.out.println(ans);
		}
	}

	static int dm(int y, int m) {
		if (y % 3 == 0) return 20;
		return m % 2 == 0 ? 19 : 20;
	}

}

Measured memory_bytes: 21184
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)


int i,j;

int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES";
    else cout<<"NO";
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

struct S {
    int w, s, v;
    void read() {
        scanf("%d%d%d", &w, &s, &v);
    }
    bool operator <(const S& b) const {
        return w + s < b.w + b.s;
    }
};

int main() {
    int n;
    scanf("%d", &n);
    vector<S> in(n);
    int MAX_S = 20123;
    for(int i = 0; i < n; ++i) {
        in[i].read();
        //~ MAX_S = max(MAX_S, in[i].s + in[i].w);
    }
    sort(in.begin(), in.end());
    vector<ll> dp(MAX_S + 1);
    // dp[i] - best score of boxes with total weight i
    for(S block : in) {
        for(int w = block.s; w >= 0; --w) {
            dp[w+block.w] = max(dp[w+block.w], dp[w] + block.v);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= MAX_S; ++i) {
        answer = max(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#define ll long long int
using namespace std;

int main()
{
    int n;
    cin>>n;
    
    int a[n],b[n],i,c=0;
    
    for(i=0;i<n;i++)
    {
    cin>>a[i]>>b[i];
    }
    
    for(i=0;i<n;i++)
    {
    if(a[i]==b[i])
    {
    if(a[i+1]==b[i+1]&&a[i+2]==b[i+2])
    c++;
    }
    
    }
    
    if(c>0)
    cout<<"Yes";
    else
    cout<<"No";
    
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int a = Integer.parseInt(strlist[0]);
		int b = Integer.parseInt(strlist[1]);
		int c = Integer.parseInt(strlist[2]);

		String answer = "NO";

		for(int i=0; i<b; i++){
			if((i*b+c) % a == 0){
				answer = "YES";
				break;
			}
		}
		System.out.println(answer);
	}


}


Measured memory_bytes: 24532
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;

const int MAX = 100005;
int N;
char a[MAX];

struct S
{
    char ch;
    int x;
};
S b[MAX];

int fan(int x)
{
    return x >0?x:-x;
}


int main()
{
    cin>>a;
    int len = strlen(a);
    int bi = 0,xi = 0;
    for(int i = 0;i<len;i++){
        if(a[i]=='x')
            xi++;
        else
        {
            b[bi].ch = a[i];
            b[bi++].x = i;
        }

    }

    for(int i = 0;i < bi/2;i++){
        if(b[i].ch != b[bi-i-1].ch)
        {
            cout<<"-1"<<endl;
            return 0;
        }
    }

    int sum = 0;
    if(bi%2==0){
        int ax = -1,ay = len;
        for(int i = 0;i<bi/2;i++){
           // cout<<b[i].x<<" "<<b[bi-i-1].x<<endl;
            int temp =0;
            temp = b[i].x - ax - 1;
            sum +=fan(temp - (ay - b[bi-i-1].x - 1));
          //  cout<<temp<<" <--> "<<sum<<endl;
            ax = b[i].x;ay = b[bi-i-1].x;
        }
    }
    else{
        int ax = -1,ay = len;
        for(int i = 0;i<bi/2;i++){
            //cout<<b[i].x<<" "<<b[bi-i-1].x<<endl;
            int temp =0;
            temp = b[i].x - ax - 1;
            sum +=fan(temp - (ay - b[bi-i-1].x - 1));
         //   cout<<temp<<" <--> "<<sum<<endl;
            ax = b[i].x;ay = b[bi-i-1].x;
        }
       // cout<<ax<<" "<<ay<<"   "<<bi/2<<endl;
        sum +=fan((b[bi/2].x-ax-1) - (ay-b[bi/2].x-1));
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 1152
// In the name of god
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int n,m,x;
string s[maxn];
map <string,int> mp;
map <string,bool> mp2;
vector <string> ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		mp[s[i]]++;
		m=max(m,mp[s[i]]);
	}
	for(int i=0;i<n;i++){
		if(mp[s[i]]==m&&!mp2[s[i]]){
			mp2[s[i]]=1;
			ans.push_back(s[i]);
		}
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 40816
def check(P, k, w): # 最大積載量Pのトラックがk台ある時、積める荷物の個数
    i = 0 # 返値＝積める荷物の個数のカウンター
    n = len(w) # 積まなければならない荷物の総数
    for _ in range(k):# トラックの台数分のループ
        s = 0 # そのトラックの積載量
        while s + w[i] <= P: # トラックに新たな荷物を積んでもP以下ならば
            s += w[i] # その荷物を積む
            i += 1 # 次の荷物に移る
            if i==n: # もし荷物を全部詰めたら
                return n # 荷物の総数を返す
    return i

def solve(n, k, w): # 二分探索
    left = 0
    right = n*max(w)
    while right - left > 1:
        mid = int((left + right)/2)
        v = check(mid, k, w)
        if v>=n:
            right = mid
        else:
            left = mid
    return right

def main():
    n, k = map(int, input().split())
    w = [int(input()) for i in range(n)]
    answer = solve(n, k, w)
    print(answer)

main()


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

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

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

    vector<int> L(N + 1), R(N + 1);
    L[0] = 0, R[N] = 0;
    for (int i = 0; i < N; i++) {
        L[i + 1] = gcd(L[i], A[i]);
    }
    for (int i = N - 1; i >= 0; i--) {
        R[i] = gcd(R[i + 1], A[i]);
    }

    int res = 0;
    for (int i = 0; i < N; i++) {
        int l = L[i];
        int r = R[i + 1];

        res = max(res, gcd(l, r));
    };

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<stdio.h>
using namespace std;
pair<int,int> dat[1000];
int dp[1000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<1000;i++)dp[i]=0;
		int n=0;
		for(int i=0;i<a;i++){
			int b,c;
			scanf("%d%d",&b,&c);
			dat[n++]=make_pair(b,c);
		}
		scanf("%d",&a);
		for(int i=0;i<a;i++){
			int b,c;
			scanf("%d%d",&b,&c);
			dat[n++]=make_pair(b,c);
		}
		std::sort(dat,dat+n);
		for(int i=0;i<n;i++){
			dp[i]=1;
			for(int j=0;j<i;j++){
				if(dat[j].first<dat[i].first&&dat[j].second<dat[i].second)dp[i]=max(dp[i],dp[j]+1);
			}
		}
		int ret=0;
		for(int i=0;i<n;i++)ret=max(ret,dp[i]);printf("%d\n",ret);
	}
}

Measured memory_bytes: 1040
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) noexcept {
    return b > a && (a = b, true);
}

template <class A, class B> inline bool chmin(A &a, const B &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline vector<T> make_v(const T &initializeValue, size_t sz) {
    return vector<T>(sz, initializeValue);
}

template <class T, class... Args>
inline auto make_v(const T &initializeValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initializeValue, args...))>(sz, make_v<T>(initializeValue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string S; intmax_t K;
    cin >> S >> K;

    size_t one = 0;
    for (const auto e : S) {
        if (e == '1') one++;
        else break;
    }
    dump(one);

    if (S.length() == 1) {
        return cout << S.front() << "\n", 0;
    }

    if (K <= one) {
        cout << 1 << "\n";
    } else {
        cout << S[one] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> Point;

int main() {
    Point pos(0, 0);
    Point unit(0, 1);
    while(true) {
        int r, a;
        char c;
        cin >> r >> c >> a;
        if(r == 0 && a == 0) break;

        pos += unit * (double)r;
        unit *= polar(1.0, -M_PI*a/180);
    }
    cout << (int)pos.real() << endl;
    cout << (int)pos.imag() << endl;
    return 0;
}

Measured memory_bytes: 0
/**
 *    author:  tourist
 *    created: 29.12.2019 23:04:52       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int an = 0;
  for (int bit = 0; bit < 30; bit++) {
    vector<int> c(n);
    for (int i = 0; i < n; i++) c[i] = (a[i] % (1 << (bit + 1)));
    vector<int> d(n);
    for (int i = 0; i < n; i++) d[i] = (b[i] % (1 << (bit + 1)));
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());
    long long ans = 0;
    int j = n;
    for (int i = 0; i < n; i++) {
      while (j > 0 && c[i] + d[j - 1] >= (1 << bit)) --j;
      ans += n - j;
    }
    j = n;
    for (int i = 0; i < n; i++) {
      while (j > 0 && c[i] + d[j - 1] >= 2 * (1 << bit)) --j;
      ans -= n - j;
    }
    j = n;
    for (int i = 0; i < n; i++) {
      while (j > 0 && c[i] + d[j - 1] >= 3 * (1 << bit)) --j;
      ans += n - j;
    }
    if (ans % 2) an ^= (1 << bit);
  }
  cout << an << '\n';
  return 0;
}


Measured memory_bytes: 3456
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getMaxEffectiveBit(ull a)
{
	ll index = -1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

inline ll getSpecifiedBit(ull a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

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

	ll N, A, B;
	cin >> N >> A >> B;

	cout << min(N * A, B) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
ans = 0
for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i
print(ans)

Measured memory_bytes: 68580
#include <iostream>

using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1)!=b.at(0)) cout << "NO";
  else if(b.at(b.size()-1)!=c.at(0))cout << "NO";
  else cout << "YES";
}


Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

int main(){
  int arr[3];
  scanf("%d %d %d", &arr[0], &arr[1], &arr[2]);
  sort(arr, arr+3);
  printf("%lld\n", arr[2]%2? (ll)arr[0]*(ll)arr[1]: 0);
  return 0;
}


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

using namespace std;


int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int a = 1; a <= n; a++){
        for (int b = 1; a * b < n; b++){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a,b;
  cin>>a>>b;
  if(a*b%2==0) {
cout<<"Even"<<endl;
  }
  else {
cout<<"Odd"<<endl;
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }
  
  //1行目
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  
  //2行目～
  for (int i = 0; i < H; i++) {
    cout << "#" << vec.at(i) << "#" << endl;
  }
  
  //最終行
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  
}

Measured memory_bytes: 256
from operator import mul
from functools import reduce

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

def cmb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


lista = [0] * (n + 1)
sum = 0
for j in range(n):
    lista[a[j]] += 1
for i in lista:
    if i >= 2:
        sum += cmb(i, 2)
for i in a:
    print(sum - lista[i] + 1)

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

vector<int> g[30];
char s,t,a[50][50];

int main(){
  int h,w;
  cin>>h>>w>>s>>t;  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if('A'>=a[i][j]||a[i][j]>='Z')continue;
      
      int dx[4]={0,1,0,-1};
      int dy[4]={1,0,-1,0};
      for(int k=0;k<4;k++){
	int tx=i+dx[k],ty=j+dy[k];
	while(1){
	  if(tx<0||h<=tx||ty<0||w<=ty)break;
	  if(a[tx][ty]=='.')break;
	  if(k%2&&a[tx][ty]=='-')break;
	  if(k%2==0&&a[tx][ty]=='|')break;
	  if('A'<=a[tx][ty]&&a[tx][ty]<='Z'){
	    g[a[i][j]-'A'].push_back(a[tx][ty]-'A');
	    g[a[tx][ty]-'A'].push_back(a[i][j]-'A');
	    break;
	  }
	  tx+=dx[k],ty+=dy[k];
	}
      }
    }
  }

  queue<pair<int,int> >q;
  q.push(make_pair(s-'A',0));
  int used[30]={};

  while(q.size()){
    int node=q.front().first;
    int l=q.front().second;
    q.pop();
    //  cout<<node<<endl;
    if(node==t-'A'){
      cout<<l<<endl;
      return 0;
    }
    if(used[node])continue;
    used[node]=1;
    for(int i=0;i<g[node].size();i++){
      
      q.push(make_pair(g[node][i],l+1));
    }
  }
  /*
  for(int i=0;i<30;i++){
    cout<<(char)('A'+i)<<" ";
    for(int j=0;j<g[i].size();j++){
      cout<<g[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  return 0;
}



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

using ull = unsigned long long;

void fail() {
  cout << -1 << endl;
  exit(0);
}

int f(ull x, int k) {
  return x >> k & 1;
}

void on(ull &x, int k) {
  x |= 1ULL << k;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  vector<ull> S(N), T(N), U(N), V(N);
  rep(i, N) cin >> S[i];
  rep(i, N) cin >> T[i];
  rep(i, N) cin >> U[i];
  rep(i, N) cin >> V[i];
  vector<vector<ull>> ans(N, vector<ull>(N));
  auto row_or = [&](int i) {
    ull res = 0;
    rep(j, N) res |= ans[i][j];
    return res;
  };
  auto row_and = [&](int i) {
    ull res = ULLONG_MAX;
    rep(j, N) res &= ans[i][j];
    return res;
  };
  auto col_or = [&](int j) {
    ull res = 0;
    rep(i, N) res |= ans[i][j];
    return res;
  };
  auto col_and = [&](int j) {
    ull res = ULLONG_MAX;
    rep(i, N) res &= ans[i][j];
    return res;
  };
  rep(k, 64) {
    vector<vector<bool>> used(N, vector<bool>(N));
    // 論理積が1
    rep(i, N) rep(j, N) {
      if ((S[i] == 0 and f(U[i], k) == 1) or (T[j] == 0 and f(V[j], k) == 1)) {
        if (used[i][j] and f(ans[i][j], k) != 1) fail();
        used[i][j] = true;
        on(ans[i][j], k);
      }
    }
    // 論理和が0
    rep(i, N) rep(j, N) {
      if ((S[i] == 1 and f(U[i], k) == 0) or (T[j] == 1 and f(V[j], k) == 0)) {
        if (used[i][j] and f(ans[i][j], k) != 0) fail();
        used[i][j] = true;
      }
    }
    // 論理和が1
    rep(i, N) rep(j, N) {
      if ((S[i] == 1 and f(U[i], k) == 1) and (T[j] == 1 and f(V[j], k) == 1)) {
        used[i][j] = true;
        on(ans[i][j], k);
      }
    }
    vector<int> row1, col1, row0, col0;
    rep(i, N) {
      if (S[i] == 1 and f(U[i], k) == 1 and f(row_or(i), k) == 0) row1.push_back(i);
      if (T[i] == 1 and f(V[i], k) == 1 and f(col_or(i), k) == 0) col1.push_back(i);
      if (S[i] == 0 and f(U[i], k) == 0) row0.push_back(i);
      if (T[i] == 0 and f(V[i], k) == 0) col0.push_back(i);
    }
    if (not col0.empty()) {
      int j = 0;
      for (int i : row1) {
        on(ans[i][col0[j]], k);
        j++;
        j %= col0.size();
      }
    }
    if (not row0.empty()) {
      int i = 0;
      for (int j : col1) {
        on(ans[row0[i]][j], k);
        i++;
        i %= row0.size();
      }
    }
  }
  rep(i, N) {
    if (S[i] == 0 and row_and(i) != U[i]) fail();
    if (S[i] == 1 and row_or(i) != U[i]) fail();
    if (T[i] == 0 and col_and(i) != V[i]) fail();
    if (T[i] == 1 and col_or(i) != V[i]) fail();
  }
  rep(i, N) rep(j, N) cout << ans[i][j] << " \n"[j == N - 1];
}

Measured memory_bytes: 7580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    ll a,b,x; cin >> a >> b >> x;
    if(a == 0){
        cout << b/x+1 << endl;
        return 0;
    }
    cout << b/x-(a-1)/x << endl;
}



Measured memory_bytes: 3604
private fun solve() {
    val (a, b, c) = readAtOnce().map { it.toLong() }

    println(if (c - (a - b) > 0 && (4 * a * b) < (c - a - b) * (c - a - b)) "Yes" else "No")
}

fun main(args: Array<out String>) = solve()
private fun readAtOnce(): List<String> = readLine()!!.split(" ")
private fun readInts(): List<Int> = readAtOnce().map(String::toInt)
private fun readLongs(): List<Long> = readAtOnce().map(String::toLong)
private fun zeroArray(size: Int): IntArray = IntArray(size) { 0 }
private fun Int.repeat(predicate: (Int) -> Unit) = repeat(this, predicate)

Measured memory_bytes: 37872
#include<bits/stdc++.h>
using namespace std;
char k[51][51];
int s[51][51],n,m;
int a[8]={-1,-1,-1,0,0,1,1,1};
int b[8]={-1,0,1,-1,1,-1,0,1};
void dfs(int x,int y){
	for(int i=0;i<8;i++){
		int fx=x+a[i],fy=y+b[i];
		if(fx<=n&&fy<=m&&fx>=1&&fy>=1&&k[fx][fy]=='#')
			s[x][y]++;
	}
}
int main(){
	int i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>k[i][j];
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(k[i][j]=='.')dfs(i,j);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)
			if(k[i][j]=='#')cout<<k[i][j];
			else cout<<s[i][j];
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long S;
  scanf("%lld", &S);
  long long W;
  scanf("%lld", &W);
  if (W >= S)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <set>
using namespace std;
#define ele set<int>::iterator
set <int> s;
int n;
int main(){
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		ele fx = s.find(x);
		if (fx == s.end()) s.insert(x);
		else s.erase(x);
	}
	cout << s.size() << endl;
}


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

int main(){
    string s;
    cin >> s;
    int ans = 753;
    for(int i=2; i<(int)s.length(); ++i){
        string t = s.substr(i-2, 3);
        int z = stoi(t);
        ans = min(ans, abs(753-z));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3616
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int alice = 0;
        int bob = 0;

        ArrayList<Integer> list = new ArrayList<>();

        for(int i=0; i<num; i++){
            int n = sc.nextInt();
            list.add(n);
        }

        int count = 1;

        while(list.size() != 0){
            int ans = Collections.max(list);

            if(count % 2 != 0){
                alice += ans;
            } else {
                bob += ans;
            }

            count++;
            list.remove(list.indexOf(Collections.max(list)));
        }

        System.out.println(alice - bob);
    }
}


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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; i ++) {
    for (int j = 0; j <= m; j ++) {
      if (k == i * m + j * n - (i * j) * 2) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
int main() {

    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n+1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    deque<int> ans = {1};
    vector<bool> v(n+1, false);
    v[1] = true;
    // front
    while (true) {
        const auto p = ans.front();
        v[p] = true;
        bool finished = true;
        for (const auto &r : g[p]) {
            if (!v[r]) {
                v[r] = true;
                ans.emplace_front(r);
                finished = false;
                break;
            }
        }
        if (finished) break;
    }
    // back
    while (true) {
        const auto p = ans.back();
        v[p] = true;
        bool finished = true;
        for (const auto &r : g[p]) {
            if (!v[r]) {
                v[r] = true;
                ans.emplace_back(r);
                finished = false;
                break;
            }
        }
        if (finished) break;
    }

    // out
    cout << ans.size() << endl;
    for (size_t i = ans.size(); i--; ) {
        cout << ans[i];
        if (i) cout << " "; else cout << endl;
    }

    
}


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

struct UnionFind {
  vector<int> par;
  vector<int> rank;

  UnionFind(int n):par(n),rank(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=0;
    }
  }

  int find(int x){
    if(par[x]==x){
      return x;
    }else{
      return par[x]=find(par[x]);
    }
  }

  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank[x]<rank[y]){
      par[x]=y;
    }else{
      par[y]=x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void body(){
    rep(i,par.size()){
      cout <<par[i]<<" "<<rank[i]<<" Body"<<i<<endl;
    }
  }
};

int main(){
  int n,k,l;
  cin>>n>>k>>l;
  UnionFind uf(n),uf2(n);
  rep(i,k){
    int p,q;
    cin>>p>>q;
    p--;q--;
    uf.unite(p,q);
  }
  rep(i,l){
    int r,s;
    cin >>r>>s;
    r--;s--;
    uf2.unite(r,s);
  }
  map<P,int> ans;
  rep(i,n){
    ans[make_pair(uf.find(i),uf2.find(i))]++;
  }
  rep(i,n) cout <<ans[make_pair(uf.find(i),uf2.find(i))]<<endl;
}

Measured memory_bytes: 17588
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

void readTime(vector<pair<string, string> >& t)
{
    int k;
    cin >> k;
    t.resize(k);
    for(int i=0; i<k; ++i){
        string s;
        cin >> s;
        t[i].first  = s.substr(0, 5);
        t[i].second = s.substr(6, 5);
    }
}

int main()
{
    vector<pair<string, string> > lesson;
    readTime(lesson);

    int k = lesson.size();
    vector<vector<int> > x(2, vector<int>(k));

    for(int a=0; a<2; ++a){
        int n;
        cin >> n;
        for(int i=0; i<n; ++i){
            vector<pair<string, string> > t;
            readTime(t);
            for(auto& p : t){
                for(int j=0; j<k; ++j){
                    if(p.first <= lesson[j].first && lesson[j].second <= p.second)
                        ++ x[a][j];
                }
            }
        }
    }

    int ans = 0;
    for(int i=0; i<k; ++i)
        ans += min(x[0][i], x[1][i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n,k;cin >> n >> k;
  vec h(n);
  for(ll i=0;i<n;i++) cin >> h[i];
  vec dp(n,inf);
  dp[0]=0;
  for(ll i=0;i<n;i++) {
    for(ll j=1;j<=k&&i+j<n;j++) {
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int n = sc.nextInt();
		if (n == 100) System.out.println((int)Math.pow(100, d) * (n + 1));
		else System.out.println((int)Math.pow(100, d) * n);
	}
}


Measured memory_bytes: 22996
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    fi>>n>>m;
    static int dp[333][333][333];
    const int mod = 1e9 + 7;
    dp[0][1][1] = 1;
    for (int i = 0;i < m;++i)
        for (int j = 1;j <= n;++j)
            for (int k = 1;k <= j;++k)
            {
                if (j < n)
                    (dp[i + 1][j + 1][k] += 1ll * dp[i][j][k] * (n - j) % mod) %= mod;
                (dp[i + 1][j][j] += 1ll * k * dp[i][j][k] % mod) %= mod;
                (dp[i + 1][j][k] += 1ll * (j - k) * dp[i][j][k] % mod) %= mod;
            }
    fo << dp[m][n][n] << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}




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

using namespace std;
const int N = 1e5 + 5;
int a[N];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n), reverse(a, a + n);
    int i = 1;
    while (i + 1 <= a[i]) i++;
    int h = a[i - 1] - i, w = 0;
    while (a[i + w] == i) w++;
    h %= 2, w %= 2;
    cout << ((w|h) ? "First" : "Second") << "\n";

    return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        string m;
        cin >> m;
        vector<pair<int, int> > v;
        for(int i=0; i < n; i++){
            int a, b; cin >> a >> b;
            v.push_back(make_pair(a, b));
        }
        reverse(v.begin(), v.end());
        for(int i=0; i < v.size(); i++){
            int d = abs(v[i].first-v[i].second);
            for(int j=0; j < d; j++){
                m[v[i].first-1]++;m[v[i].second-1]++;
                if('z' < m[v[i].first-1]) m[v[i].first-1] = 'a' + m[v[i].first-1]-'z'-1;
                if('z' < m[v[i].second-1]) m[v[i].second-1] = 'a' + m[v[i].second-1]-'z'-1;
            }
            swap(m[v[i].second-1], m[v[i].first-1]);
        }
        cout << m << endl;
    }
}

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

int main() {
  string s,p;
  int t=0;
  long long ans=0,u=1000000007;
  cin >> s >> p;
  vector<long> a(s.size());
  for (int i=0;i<s.size();i++){
      a.at(i)=0;
  }
  for (int i=p.size()-1;i>-1;i--){
      if (i==p.size()-1) t=1;
      else t=0;
      for (int j=s.size()-1;j>-1;j--){
          int y=a.at(j);
          if (s.at(j)==p.at(i)){
              a.at(j)=t;
          }
          else a.at(j)=0;
          t=(t+y)%u;
      }
  }
  for (int i=0;i<s.size();i++){
      ans=(ans+a.at(i))%u;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3164
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]=='7')
			flag=1;
	}
	if(flag==1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//
int n,Ma,Mb;
int a[50],b[50],c[50];
int dp[50][500][500];
int main(){
        cin>>n>>Ma>>Mb;
        for(int i=0; i<n; i++) {
                cin>>a[i]>>b[i]>>c[i];
        }
        for(int i=0; i<50; i++) {
                for(int j=0; j<500; j++) {
                        for(int k=0; k<500; k++) {
                                dp[i][j][k]=inf;
                        }
                }
        }
        dp[0][0][0]=0;
        for(int i=0; i<n; i++) {
                for(int j=0; j<500; j++) {
                        for(int k=0; k<500; k++) {
                                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
                                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
                        }
                }
        }
        int mindp=inf;
        for(int i=1; i<500; i++) {
                for(int j=1; j<500; j++) {
                        int g=__gcd(i,j);
                        if(i/g==Ma && j/g==Mb) {
                                mindp=min(mindp,dp[n][i][j]);
                        }
                }
        }
        if(mindp==inf) {
                cout<< -1<<endl;
                return 0;
        }
        cout<<mindp<<endl;
}


Measured memory_bytes: 49024
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;

int main()
{
long long w,a,b,c; cin>>w>>a>>b;
if(b<a) swap(a,b);
if(b-(a+w)>0) cout<<b-(a+w);
else cout<<0;
}


Measured memory_bytes: 3620
import math

a, b = map(int, input().split())
"""
ax = range()
bx = range(b*10,b*10+10)
"""

for i in range(10 * a, 1251):
    if (math.floor(i * (8 / 100)) == a and math.floor(i * (10 / 100)) == b):
        print(i)
        break
else:
    print(-1)

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

//??\?????????????¨????????¨????????????????????????????????????????????????????????±??????????????????????????????§?????´???????¨??????????????????§??§?????????????????¢???

int main() {
	int X;
	int Y;
	int S;
	vector<int> A_array;
	vector<int> B_array;

	for (int a = 0; a < 1000; a++) {
		for (int b = 0; b < 1000; b++) {
			if ((a > 0) && (b > 0)) {
				A_array.push_back(a);
				B_array.push_back(b);
			}
			
		}
	}


	while(true) {

	cin >> X >> Y >> S;

	if ((X == 0) && (Y == 0) && (S == 0))
		break;
		
	vector<int> newvalue;
	int maxvalue = 0;

	for(int j = 0; j < A_array.size(); j++) {
		int taxsum = A_array[j]*(X+100)/100 + B_array[j]*(X+100)/100;
		int newtaxsum = A_array[j]*(Y+100)/100 + B_array[j]*(Y+100)/100;
		if ((S == taxsum) && (A_array[j] < S) && (B_array[j] < S) && (S > 10) && (S < 1000))
			newvalue.push_back(newtaxsum);
	}


	for(int k=0; k<newvalue.size(); k++) {
		if (maxvalue < newvalue[k]) {
			maxvalue = newvalue[k];
		}
	}

	cout << maxvalue << endl;

	}

	return 0;
}

Measured memory_bytes: 10800
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
#define N 200010
using namespace std;
ll tree[4 * N], A[N], h[N];
void update(int low, int high, int ind, ll val, int node){
	if(low == high){
		tree[node] = val;
		return;
	}
	int mid = (low + high) / 2;
	if(ind <= mid)
		update(low, mid, ind, val, 2 * node);
	else update(mid + 1, high, ind, val, 2 * node + 1);
	tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}
ll query(int low, int high, int begin, int end, int node){
	if(low > end || high < begin || begin > end)
		return -1e18;
	if(low >= begin && high <= end)
		return tree[node];
	int mid = (low + high) / 2;
	return max(query(low, mid, begin, end, 2 * node), query(mid + 1, high, begin, end, 2 * node + 1));
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> h[i];
	for(int i = 0; i < n; i++)
		cin >> A[i];
	ll maxi = 0;
	for(int i = 0; i < n; i++){
		ll ans = A[i] + query(0, n - 1, 0, h[i] - 1, 1);
		//cerr << ans << '\n';
		update(0, n - 1, h[i], ans, 1);
		maxi = max(maxi, ans);
	}
	cout << maxi << '\n';


}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int to_int(string w){
    int num1=10*(w[0]-'0')+w[1]-'0';
    int num2=10*(w[3]-'0')+w[4]-'0';
    int num3=10*(w[6]-'0')+w[7]-'0';
    return 3600*num1+60*num2+num3;
}

int main() {
    while(1){
        int n;
        cin>>n;
        if(n==0)return 0;
        vi d(3600*24+1,0);
        rep(i,n){
            string w1,w2;
            cin>>w1>>w2;
            int t1=to_int(w1),t2=to_int(w2);
            //cout<<t1<<" "<<t2<<endl;
            d[t1]+=1;
            d[t2]-=1;
        }
        int ans=0;
        int now=0;
        rep(i,3600*24){
            now+=d[i];
            ans=max(ans,now);
        }
        cout<<ans<<endl;
    }
    

    return 0;
}


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

const int MAXD = 40;
int N;
LL K;
LL A[100001];

int main(){
    cin >> N >> K;
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }

    LL answer = 0;
    for (int i = 42; i >= 0; --i){
        int zeroes = 0;
        for (int j = 0; j < N; ++j){
            if ((A[j] & (1LL << i)) == 0){
                zeroes++;
            }
        }
        if (zeroes > N - zeroes && answer + (1LL << i) <= K){
            answer += (1LL << i);
        }
    }
    LL sum = 0;
    for (int i = 0; i < N; ++i){
        sum += (answer ^ A[i]);
    }
    cout << sum << endl;
    return 0;
}

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

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

  return 0;
}


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

int main(){
int N,sum,M,p,x;
  cin >> N;
  int t[N];
  for(int i = 0;i < N;i++){
  cin >> t[i];
  }
  cin >> M;
  for(int i = 0;i < M;i++){
  int sum = 0;
    cin >> p >> x;
    p -= 1;
    
    for(int j = 0; j < N;j++){
    if(j != p){
    sum += t[j];
    }
      else{
      sum += x;
      }
    }
    cout << sum << endl;
  }
  
}

Measured memory_bytes: 256