akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
// template <char d = ' ', class T>
// ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, c;
    cin >> n >> c;
    vector<pair<ll, ll>> xvs(n); cin >> xvs;
    auto xvr = xvs;
    reverse(xvr.begin(), xvr.end());
    for(auto& r : xvr){
        r.first = c - r.first;
    }
    ll acc = 0;
    for(int i = 0; i < n; i++){ xvs[i].second -= xvs[i].first - acc; acc = xvs[i].first; }
    acc = 0;
    for(int i = 0; i < n; i++){ xvr[i].second -= xvr[i].first - acc; acc = xvr[i].first; }
    vector<ll> maxs(n + 1), maxr(n + 1);
    acc = 0;
    for(int i = 1; i <= n; i++){
        acc += xvs[i - 1].second;
        maxs[i] = max(maxs[i - 1], acc);
    }
    acc = 0;
    for(int i = 1; i <= n; i++){
        acc += xvr[i - 1].second;
        maxr[i] = max(maxr[i - 1], acc);
    }
    ll ans = 0;
    printd(xvs);
    printd(xvr);
    printd(maxs);
    printd(maxr);
    acc = 0;
    ll accr = 0;
    for(int i = 0; i <= n; i++){
        ans = max(ans, maxr[i]);
        ans = max(ans, maxs[i]);
        ans = max(ans, maxr[i] + maxs[n - i] - acc);
        ans = max(ans, maxs[i] + maxr[n - i] - accr);
        if(i < n){
            acc = xvr[i].first;
            accr = xvs[i].first;
        }
        printd(i, ans);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5504
n,x = map(int,input().split())
l = list(map(int,input().split()))
#print(n,x,l)

c = 1
p = 0
for i in range(n):
  if p + l[i] > x :
    break
  p += l[i]
  c += 1
  #print(p,c)
print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

typedef complex<double> P;

double cross(P& a, P& b){
	return a.real()*b.imag() - a.imag()*b.real();
}
bool signeq(double a, double b){
	if( a+EPS<0.0 && b+EPS<0.0 ) return true;
	if( a-EPS>0.0 && b-EPS>0.0 ) return true;
	return false;
}
int main(){
	double x[4],y[4];
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",x,y,x+1,y+1,x+2,y+2,x+3,y+3)){
		int i;
		double s;
		for(i=0; i<4; i++){
			P A(x[(i+2)%4],y[(i+2)%4]), B(x[(i+1)%4],y[(i+1)%4]), C(x[i],y[i]);
			P AB = A-B;
			P BC = B-C;
			if( i==0 ){
				s = cross(AB,BC);
			}else{
				if( !signeq(s,cross(AB,BC)) ) break;
			}
		}
		puts(i==4?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 0
//
//  abc149_c.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

std::vector<int> permutations;

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

int main() {
  int x;
  std::cin >> x;

  int sieve[2*x];

  for (int i = 2; i < x*2; i++) {
    if (sieve[i] == 1) continue;
    sieve[i] = 0;
    for (int j = 2*i; j < x*2; j+=i) {
      sieve[j] = 1;
    }
  }
  for (int i = x; i < x*2; i++) {
    if (sieve[i] == 0) {
      std::cout << i << std::endl;
      return 0;
    }
  }
  return 0;
}



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

int somesums(int n){
    int ret = 0;
    for (int i = 0; i < 5; i++)
    {
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(somesums(i+1) >=A && somesums(i+1) <= B) ans += i+1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define P pair<int, int>

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    ll tmp = x/500*1000;
    ans += tmp + x%500/5*5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N];
    int[] Y = new int[N];
    for (int i =0; i<N; i++) {
      X[i] = sc.nextInt();
      Y[i] = X[i];
    }
    Arrays.sort(Y);
    int Ysmall = Y[N/2-1];
    int Ylarge = Y[N/2];
    for (int i =0; i<N; i++) {
      if (X[i] <= Ysmall) {
        System.out.println(Ylarge);
      } else {
        System.out.println(Ysmall);
      }
    }                           
  }
}  

Measured memory_bytes: 68980
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  
  map<int, int> cnt;
  vector<int> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = (sum[i] + vec[i]) % m;

  }
  
  ll ans = 0;
  for (int i = 0; i < sum.size(); i++) {
    ans += cnt[sum[i]];
    cnt[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3968
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    /** CHECKLIST:
     * LIMITS (DOES BRUTE FORCE WORK?)
     * CHECK ALL PARAMETERS
     * INT VS LONG
     */
    public static void main(String[] args) {
        int n = r.nextInt(); // number of items
        int w = r.nextInt(); // max capacity
        int[] weights = new int[n];
        int[] values = new int[n];
        for(int i = 0; i < n; i++){
            weights[i] = r.nextInt();
            values[i] = r.nextInt();
        }
        int sum = 0;
        for(int x : values){
            sum += x;
        }
        int[] dp = new int[sum+1]; // dp[i] - the minimum total weight of items with total value exactly i
        Arrays.fill(dp, Integer.MAX_VALUE / 2);
        dp[0] = 0;
        for(int i = 0; i < n; i++){ // i is item
            for(int j = sum - values[i]; j >= 0; j--){ // j is value already
                dp[j + values[i]] = Math.min(dp[j + values[i]], dp[j] + weights[i]);
            }
        }
        int answer = 0;
        for(int i = 0; i <= sum; i++){
            if(dp[i] <= w){
                answer = Math.max(answer, i);
            }
        }
        pw.println(answer);
        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

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

int main(){
  int N;
  cin>>N;
  int X[N];
  for (int i=0;i<N;i++){
    cin>>X[i];
  }
  sort(X,X+N);
  int sum=0;
  int minsum=10000000;
  for(int j=X[0];j<X[N-1]+1;j++){
    sum=0;
    for (int i=0;i<N;i++){
      sum=sum+pow((X[i]-j),2);
    }
    minsum=min(minsum,sum);
  }
  cout<<minsum<<endl;

  return 0;
}


        


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(M), B(M), C(K), D(K);
    //vector<vector<int>> fri(N + 1, vector<int>(0));
    //vector<vector<int>> bro(N + 1, vector<int>(0));
    vector<vector<int>> s(N + 1, vector<int>(0));
    
    UnionFind uf(N + 1);
    
    rep(i, 0, M){
        cin >> A.at(i) >> B.at(i);
        //fri.at(A.at(i)).push_back(B.at(i));
        //fri.at(B.at(i)).push_back(A.at(i));
        uf.unite(A.at(i), B.at(i));
        s.at(A.at(i)).push_back(B.at(i));
        s.at(B.at(i)).push_back(A.at(i));
    }
    rep(i, 0, K){
        cin >> C.at(i) >> D.at(i);
        //bro.at(C.at(i)).push_back(D.at(i));
        //bro.at(D.at(i)).push_back(C.at(i));
        s.at(C.at(i)).push_back(D.at(i));
        s.at(D.at(i)).push_back(C.at(i));
    }
    
    rep(i, 1, N + 1){
        int count = 0;
        rep(j, 0, s.at(i).size()){
            if(uf.same(i, s.at(i).at(j))) count++;
        }
        cout << uf.size(i) - count - 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int a, b, c; cin >> a >> b >> c;
    map<int, int> cnt;
    cnt[a]++, cnt[b]++, cnt[c]++;

    if(cnt[5] == 2 and cnt[7] == 1){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,K = map(int,readline().split())
m = map(int,read().split())
AB = list(zip(m,m))

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

def F(a,b,K):
    INF = 10 ** 9
    if a == b:
        # 中心が1点
        q = deque([a])
        r = K // 2
    else:
        # 中心が辺
        q = deque([a,b])
        r = (K-1)//2
    dist = [INF] * (N+1)
    for x in q:
        dist[x] = 0
    pop = q.popleft; append = q.append
    cnt = len(q)
    while q:
        v = pop()
        dw = dist[v] + 1
        if dw > r:
            break
        for w in graph[v]:
            if dist[w] == INF:
                cnt += 1
                dist[w] = dw
                append(w)
    return N - cnt

if K & 1:
    answer = min(F(a,b,K) for a,b in AB)
else:
    answer = min(F(a,a,K) for a in range(1,N+1))
print(answer)

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

// enum {
//   AST_INT,
//   AST_SYM,
//   AST_STR,
//   AST_FUNCALL,
// };



// double winProb(int Rp, int Rq) {
//     return 1/(1+pow(10, (Rq-Rp)/400.));
// }

// int R[1<<10];
// double dp[12][1<<10];
int n,m;
int a[214514];

int main() {
  cin >> n;
  REP(i,1,n+1) {
      cin >> a[i];
      a[i] = a[i] - i;
  }
  
  sort(a + 1,a + n+1);
  int b = a[(n+1)/2];
//   REP(i,1,n+1) cout << a[i] << endl;
//   cout << b << endl;
  long long sum = 0;
  REP(i,1,n+1) {
      sum += abs(a[i] - b);
  }
  cout << sum << endl;
//   if (sum - n)
}

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

using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define MOD = 1000000007;
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S; cin >>S;

    int counter = 0;
    rep(i, S.size()) {
        counter += S[i] == '0' + (i % 2);
    }
    cout << min(counter, (int)S.size() - counter) << endl;
}


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

  int a,b,c,d,e;
  scanf("%d", &a);
  b = a / 60;
  c = a % 60;
  d = b / 60;
  e = b % 60;
  printf("%d:%d:%d\n", d, e, c);
  return 0;

}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  bool bingo[3][3];
  int card[3][3];
  int n;
  bool ans = false;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> card[i][j];
      bingo[i][j] = false;
    }
  }
  cin >> n;
  for(int i=0;i<n;i++){
    int b; cin >> b;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(card[i][j]==b) bingo[i][j]=true;
      }
    }
  }

  for(int i=0;i<3;i++){
    int h_cnt = 0;
    int w_cnt = 0;
    for(int j=0;j<3;j++){
      if(bingo[i][j]==true) w_cnt++;
      if(bingo[j][i]==true) h_cnt++;
    }

    if(w_cnt == 3 || h_cnt == 3){
      cout<< "Yes" <<endl;
      return 0;
    }
  }
  if(bingo[0][0]==true && bingo[1][1]==true && bingo[2][2]==true) cout<< "Yes" <<endl;
  else if(bingo[0][2]==true && bingo[1][1]==true && bingo[2][0]==true) cout<< "Yes" <<endl;
  else cout<< "No" <<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

const LL MOD = 1000000007;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int k;
    cin >> k;
    
    for(int i = 0; i < min((int)s.size(), k); ++i)
    {
        if (s[i] != '1') 
        {
            cout << s[i] << endl;
            return 0;
        }
        else if (i == (k-1))
        {
            cout << 1 << endl;
            return 0;
        }
        
    }

    return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())
#互いに素の時は1, そうでない時は最小の公約数を出力
def coprime_checker(x,y):
    if min(x,y) == 1:
        return 1
    else:
        for i in range(2,min(x,y) + 1):
            if x % i == 0 and y % i == 0:
                return i
                break
        return 1
#
gcd = 1
x = a
y = b
while coprime_checker(int(x),int(y)) != 1:
    c = coprime_checker(int(x),int(y))
    gcd *= c
    x /= c
    y /= c
least_common_multiple  = (a*b) / gcd
print(int(least_common_multiple))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int a[N], n;
map<int, int> freq[2];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n;
	Foz(i, n) cin >> a[i];
	int cnt[2] = {0, 0};
	Foz(i, n) {
		if (i & 1) { cnt[0]++; freq[0][a[i]]++; }
		else { cnt[1]++; freq[1][a[i]]++; }
	}
	int ans = N;
	Foz(i, 2) {
		int mx = 0, num = N;
		Trav(x, freq[i]) if (ckmax(mx, x.second)) num = x.first;
		int mx1 = 0;
		Trav(x, freq[!i]) if (x.second >= mx1 && num != x.first) mx1 = x.second;
		ckmin(ans, cnt[i] - mx + cnt[!i] - mx1);
	}
	cout << ans << '\n';
}



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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int n, m, k;
int tot, cnt, ans;

int read() {
	int f = 1, s = 0;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 1) + (s << 3) + ((int)ch ^ 48); ch = getchar();}
	return s * f;
}

int a[MAXN], b[MAXN];

string s;

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


Measured memory_bytes: 3728
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

int n;
vector<vector<int> > t;
int memo[(1 << 16)];

int dfs(int cleared) {
	if(cleared == (1 << n) - 1)
		return 0;

	if(memo[cleared] != -1)
		return memo[cleared];

	int res = INT_MAX;
	for(int i = 0; i < n; ++i) {
		if(!(cleared & (1 << i))) {
			const int next = cleared | (1 << i);
			chmin(res, dfs(next) + t[i][0]);

			for(int j = 0; j < n; ++j)
				if(cleared & (1 << j))
					chmin(res, dfs(next) + t[i][j + 1]);
		}
	}

	return memo[cleared] = res;
}

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

	while(cin >> n, n) {
		t.clear();
		t.resize(n, vector<int>(n + 1));
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < n + 1; ++j)
				cin >> t[i][j];

		memset(memo, -1, sizeof(memo));
		cout << dfs(0) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1484
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
int main()
{
	int N;
	int64_t D;
	std::cin >> N >> D;
	const int64_t D2 = D * D;
	int count = 0;
	for (int i = 0; i < N; ++i) {
		int64_t X, Y;
		std::cin >> X >> Y;
		const int64_t d2 = X * X + Y * Y;
		if (d2 <= D2) {
			++count;
		}
	}
	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

int main(){
    ll X;cin >> X;
    ll ans = 0;
    ans += ll(X/500) * 1000;
    ans += ll((X % 500) / 5) * 5;
    cout << ans;
}


Measured memory_bytes: 256
N = int(input()) 
T, A = map(int,input().split())
H = list(map(int,input().split()))

num = H[0]
for i in range(N):
    H[i] = T - H[i]*0.006
    H[i] = abs(A - H[i])
    
    if H[i] < num:
        num = H[i]
        flag = i
print(flag+1)
        





Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=10000001;
int is_prime[maxn],prime[maxn];
int p;
void judge_prime()
{
    p=0;
    for(int i=0;i<maxn;i++)
        is_prime[i]=1;
    is_prime[0]=is_prime[1]=0;
    for(int i=2;i<maxn;i++)
    {
        if(is_prime[i])
        {
            prime[++p]=i;
            for(int j=i*2;j<maxn;j+=i)
                is_prime[j]=0;
        }
    }
}
int search(int n)
{
    int left=1,r=p;
    while((r-left)>1)
    {
        int mid=(left+r)/2;
        if(prime[mid]==n) return mid;
        else if(prime[mid]>n) r=mid;
        else left=mid;
    }
    return left;
}
int main()
{
    int n;
    judge_prime();
    while(scanf("%d",&n)!=EOF)
    {
        if(n<=1)
        {
            int nn=0;
            printf("%d\n",nn);
        }
        else printf("%d\n",search(n));
    }
}

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

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

Measured memory_bytes: 256
import sys

N = int(input())
#print(N)

A = input().split()
#print(A)

L = [int(b.strip()) for b in A]
#print(L)

if 0 in L:
  print(0)
  sys.exit()

ret = 1
for v in L:
  ret = ret * v
  if ret > 1000000000000000000:
    print(-1)
    sys.exit()

print(ret)

Measured memory_bytes: 21656
inf = 10 ** 10

########ワーシャルフロイド法

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,w,L = map(int,input().split()) #n:頂点数　w:辺の数

d = [[inf for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = map(int,input().split())
    x -= 1
    y -= 1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
d = warshall_floyd(d)

D = [[inf for i in range(n)] for i in range(n)]

for i in range(n):
    for j in range(n):
        if i == j:
            D[i][j] = 0
        elif d[i][j] <= L:
            D[i][j] = 1

D = warshall_floyd(D)

Q = int(input())
for i in range(Q):
    s,t = map(int,input().split())
    s -= 1
    t -= 1
    if D[s][t] == inf:
        print(-1)
    else:
        print(D[s][t]-1)


        


Measured memory_bytes: 59608
// problem: "https://atcoder.jp/contests/abc150/tasks/abc150_b"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    string s;

    cin>>n>>s;

    int i,c;
    c = 0;
    for(i=0;i!=n;i++)
    {
        if(s.substr(i,3) == "ABC")
            c++;
    }

    cout<<c;

    return 0;
}


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

ll A, B, C, X, Y;

int main() {
  cin >> A >> B >> C >> X >> Y;

  bool ac = false;
  if ((C * 2) < A) { ac = true; }
  bool bc = false;
  if ((C * 2) < B) { bc = true; }

  bool abc = false;
  if (!ac && !bc) {
    if (A + B > C * 2) { abc = true; }
  }

  ll c = (C * 2);
  if (ac && bc) {
    cout << (X > Y ? c * X : c * Y) << endl;
  } else if (ac) {
    if (X > Y) {
      cout << c * X << endl;
    } else {
      ll y = Y - X;
      cout << c * X + B * y << endl;
    }
  } else if (bc) {
    if (X > Y) {
      ll x = X - Y;
      cout << A * x + c * Y << endl;
    } else {
      cout << c * Y << endl;
    }
  } else {
    if (abc) {
      if (X > Y) {
        ll sum = c * Y;
        ll x   = X - Y;
        cout << sum + (x * A) << endl;
      } else {
        ll sum = c * X;
        ll y   = Y - X;
        cout << sum + (y * B) << endl;
      }
    } else {
      cout << A * X + B * Y << endl;
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Min(a, b) + Math.Min(c, d));

            //Console.Out.Flush();

        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int N;
LL A, B;

int p[10000], pos[10000];

LL dp[6000][6000];

LL cnt[6000][6000];

LL memo(int idx, int largest) {
	if (idx < 0 || largest < 0)
		return 0LL;
		
	LL &ret = dp[idx][largest];
	if (ret != -1)
		return ret;
		
	if (p[idx] == largest)
		return ret = memo(idx - 1, largest - 1);
		
	if (p[idx] > largest)
		return ret = memo(idx - 1, largest);
		
	if (pos[largest] > idx)
		return ret = memo(idx, largest - 1);
		
	ret = A + memo(idx, largest - 1);
	LL tmp = B * (cnt[largest][idx + 1] - cnt[largest][pos[largest]]);
/*	ffor (i, pos[largest], idx + 1)
		if (p[i] < largest)
			tmp += B;*/
	ret = min(ret, tmp + memo(pos[largest] - 1, largest - 1));
	
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> A >> B;
	
	FOR (i, N) {
		cin >> p[i];
		p[i]--;
		pos[p[i]] = i;
	}
	
	FOR (i, N) {
		cnt[i][0] = 0;
		FOR (j, N)
			cnt[i][j + 1] = cnt[i][j] + (p[j] < i);
	}
	
	SET(dp, 255);
	cout << memo(N - 1, N - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 518016
#include <stdio.h>

int kochousinobu(int kanndaakemi) {
	int morigutihiroko = 0;
	while (kanndaakemi > 0) {
		morigutihiroko += kanndaakemi % 10;
		kanndaakemi /= 10;
	}
	return morigutihiroko;
}

int main(void) {
	int N;
	int i;
	int nakagawasyouko = 999999999;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i < N; i++) {
		int nanao = kochousinobu(i) + kochousinobu(N - i);
		if (nanao < nakagawasyouko) nakagawasyouko = nanao;
	}
	printf("%d\n", nakagawasyouko);
	return 0;
}


Measured memory_bytes: 1728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_ABC089_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            int x = int.Parse(str[2]);

            string[] str2 = Console.ReadLine().Split(' ');

            int left = 0;
            int right = 0;

            foreach(var toll in str2)
            {
                int toll_ = int.Parse(toll);
                if (toll_ < x)
                {
                    ++left;
                }
                else
                {
                    ++right;
                }
            }
            Console.WriteLine(left < right? left : right);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;
import java.io.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n, m;
		while(true)
		{
			n = sc.nextInt();
			m = sc.nextInt();
			if(n == 0 && m == 0)
			{
				break;
			}
			for (int i = 0; i < n; i++)
			{
				for (int j =0; j < m; j++)
				{
					if((i+j)%2==0)
					{
						System.out.print("#");
					}
					else
					{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		sc.close();
	}
}


Measured memory_bytes: 33596
#include <cstdio>
static const int INF = 0x3fffffff;
static const int MAXN = 42;
static const int MAXA = 418;
template <typename T> inline void upd_min(T &var, const T val) { if (var > val) var = val; }

int n, ma, mb;
int a[MAXN], b[MAXN], c[MAXN];
int f[MAXA][MAXA];

int main()
{
    scanf("%d%d%d", &n, &ma, &mb);
    for (int i = 0; i < n; ++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);

    for (int i = 0; i < MAXA; ++i)
        for (int j = 0; j < MAXA; ++j) f[i][j] = INF;
    f[0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int p = MAXA - a[i] - 1; p >= 0; --p)
            for (int q = MAXA - b[i] - 1; q >= 0; --q)
                upd_min(f[p + a[i]][q + b[i]], f[p][q] + c[i]);
    }

    int ans = INF;
    for (int i = 1; i * ma < MAXA && i * mb < MAXA; ++i)
        upd_min(ans, f[i * ma][i * mb]);
    printf("%d\n", ans == INF ? -1 : ans);

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
    int n; cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        mp[x]++;
    }
    int start = (n % 2) ? 0 : 1;
    long long ans = 1;
    long long md = 1e9 + 7;
    for (int i = start; i < n; i+= 2) {
        if (mp[i] != 2) {
            if(i == 0 && mp[i] == 1) continue;
            cout << 0;
            return 0;
        }
        ans = (ans * 2) % md;
    }
    cout << ans;
}


Measured memory_bytes: 6584
from sys import stdin
from operator import itemgetter

n = int(stdin.readline().rstrip())

l = []
for i in range(n):
    s, ps = stdin.readline().rstrip().split()
    p = int(ps)
    l.append((i+1, s , p))

l = sorted(l, key=itemgetter(2))
l.reverse()
l = sorted(l, key=itemgetter(1))
for i in range(n):
    print(l[i][0])


Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    //cin.tie(0); ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    map<int, int> mod;
    a[0] %= M;
    mod[a[0]]++;
    for(size_t i = 1; i < N; i++)
    {
        a[i] = (a[i-1] + a[i]) % M;
        mod[a[i]]++;
    }
    ll ret = 0;
    for(auto pair : mod){
        ret += ll(pair.second) * ll(pair.second - 1) / 2;
        if(pair.first==0)
            ret += ll(pair.second);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3584
fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut meets = vec![];
    for _ in 0..n {
        let v = read_vec::<f64>();
        let (x, y, c) = (v[0], v[1], v[2]);
        meets.push((x, y, c));
    }

    let criterion = |t| -> bool {
        let mut circles = vec![];
        for &(x, y, c) in meets.iter() {
            circles.push(Circle {
                c: Point { x: x, y: y },
                r: t / c,
            });
        }
        let mut org_candidates = circles.iter().cloned().map(|x| x.c).collect::<Vec<_>>();

        for i in 0..n {
            for j in i + 1..n {
                let (cross1, cross2) = cross(circles[i], circles[j]);
                org_candidates.push(cross1);
                org_candidates.push(cross2);
            }
        }

        for org_cand in org_candidates {
            let count = meets
                .iter()
                .filter(|&&(x, y, c)| c * (x - org_cand.x).hypot(y - org_cand.y) <= t + 0.0000001)
                .count();
            if count >= k {
                return false;
            }
        }
        true
    };
    let (ok, ng) = binary_search(0.0, 200000.0, criterion);
    println!("{}", ng);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn binary_search<F>(lb: f64, ub: f64, criterion: F) -> (f64, f64)
where
    F: Fn(f64) -> bool,
{
    let mut ok = lb;
    let mut ng = ub;
    while ng - ok > 0.0000002 {
        let mid = (ng + ok) / 2.;
        if criterion(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    (ok, ng)
}

#[derive(Clone, Copy)]
struct Point {
    x: f64,
    y: f64,
}

impl Point {
    fn norm(self) -> f64 {
        self.x.hypot(self.y)
    }

    fn arg(self) -> f64 {
        self.y.atan2(self.x)
    }
}

impl std::ops::Add for Point {
    type Output = Point;
    fn add(self, other: Point) -> Point {
        Point {
            x: self.x + other.x,
            y: self.y + other.y,
        }
    }
}

impl std::ops::Sub for Point {
    type Output = Point;
    fn sub(self, other: Point) -> Point {
        Point {
            x: self.x - other.x,
            y: self.y - other.y,
        }
    }
}

#[derive(Clone, Copy)]
struct Circle {
    c: Point,
    r: f64,
}

fn cross(c1: Circle, c2: Circle) -> (Point, Point) {
    let d = (c1.c - c2.c).norm();
    let a = ((c1.r * c1.r + d * d - c2.r * c2.r) / (2. * c1.r * d)).acos();
    let t = (c2.c - c1.c).arg();
    (c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a))
}

fn polar(a: f64, r: f64) -> Point {
    Point {
        x: r.cos() * a,
        y: r.sin() * a,
    }
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i, n, m, sum=0, x;
    cin>>n>>m;

    for(i=0;i<m;i++)
    {
        cin>>x;
        sum+=x;
    }
    if(sum>n)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li a,b,c;

    cin>>a>>b>>c;

    if(a==b && b!=c)
    {
        cout<<"Yes";
        return 0;
    }

    if(a==c && b!=c)
    {
        cout<<"Yes";
        return 0;
    }

    if(c==b && b!=a)
    {
        cout<<"Yes";
        return 0;
    }

    cout<<"No";

    return 0;
}

Measured memory_bytes: 256
import static java.lang.System.out;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String num = scan.next();
        String[] numbers = num.split("");
        int ans = 0;
        while (!numbers[0].equals("0")) {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        }
    }   
}      

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

using namespace std;

#define DIM 200009
#define INF 1e18+9
#define MODULO 1000000007
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<int,int>
#define fi first
#define se second
#define ld long double

long long i,j,k,l,n,m,res;

long long h[DIM],a[DIM],f[DIM];

void add(long long x,long long d){
    for(int i=x;i<DIM;i+=i&-i)f[i]=max(f[i],d);
}

long long get(long long x){
    long long res=-INF;
    for(int i=x;i>0;i-=i&-i)res=max(res,f[i]);
    return res;
}

int main()
{
    for(i=0;i<DIM;i++)f[i]=-INF;
    cin>>n;
    for(i=1;i<=n;i++)cin>>h[i];
    for(i=1;i<=n;i++)cin>>a[i];

    for(i=1;i<=n;i++){
        k=max(get(h[i]-1),0ll);
        res=max(res,k+a[i]);
        add(h[i],k+a[i]);
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>

main(){
	int a[4][14],n,i,j;
	
	scanf("%d",&n);
	
	for(i=0;i<4;i++){
		for(j=0;j<14;j++){
			a[i][j]=0;
		}
	}
	
	//scanf("%*c");
	
	for(i=0;i<=n;i++){
		char b;
		int c;
		
		scanf("%c %d\n",&b,&c);
		
		if(b=='S'){
			a[0][c]=1;
		}
		else if(b=='H'){
			a[1][c]=1;
		}
		else if(b=='C'){
			a[2][c]=1;
		}
		else if(b=='D'){
			a[3][c]=1;
		}
	}
	
	char pattern[4] = {'S','H','C','D'};
	
	for(i=0;i<4;i++){
		for(j=1;j<14;j++){
			if(a[i][j]==0){
				printf("%c %d\n",pattern[i],j);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

vector<ll> Prime(10000,0);
void sosu(ll n){
  Prime.at(0)=2;
  ll t=1;
  for(ll i=3;i<n;i++){
    rep(j,t){
      if(i%Prime.at(j)==0){
        break;
      }
      if(j==t-1){
        Prime.at(t)=i;
        t++;
      }
    }
  }
}

int main(){
  ll N,a=0,b=0,c=0,d=0,e=0;
  cin >> N;
  sosu(N);
  vector<ll> W(N,0);
  rep(i,N){
    ll t=0,k=i+1;
    while(Prime.at(t)!=0){
      while(k%Prime.at(t)==0){
        W.at(t)++;
        k/=Prime.at(t);
      }
      t++;
    }
  }
  ll t=0;
  while(Prime.at(t)!=0){
    if(W.at(t)>=74){
      e++;
    }
    if(W.at(t)>=24){
      d++;
    }
    if(W.at(t)>=14){
      c++;
    }
    if(W.at(t)>=4){
      b++;
    }
    if(W.at(t)>=2){
      a++;
    }
    t++;
  }
  cout << e+d*(a-1)+c*(b-1)+(b*(b-1)*(a-2))/2 << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

long long int fight(long long int h){

    if(h==1){
        return 1;
    }else{
        return fight(h/2) * 2 + 1;
    }
}

int main(){

    long long int H;
    
    scanf("%lld",&H);
    printf("%lld\n",fight(H));
}



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

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	ll n;
	cin >> n;
	vector<ll> a(n), b(n);
	for(auto& x : a)
		cin >> x;
	for(auto& x : b)
		cin >> x;
	vector<pair<ll,ll>> v;
	for(ll i = 0; i < n; ++i)
		v.emplace_back(a[i], 0);
	for(ll i = 0; i < n; ++i)
		v.emplace_back(b[i], 1);
	sort(v.begin(), v.end());
	vector<ll> t(2, 0);
	sort(v.begin(), v.end());
	ll ans = 1;
	for(auto& p : v){
		ll x = p.second;
		if(t[!x]){
			ans = (ans * t[!x]) % MOD;
			--t[!x];
		}
		else
			++t[x];
	}
	cout <<ans << endl;
}



Measured memory_bytes: 7920
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {

		// 合計を記録するリスト
		ArrayList<Integer> sumList = new ArrayList<Integer>();
		// 入力および終了判定
		while (InputNum()) {
			int sum = 0;
			for (int i = 0; i < input.length(); i++) {
				// 合計に加算(文字列のi番目の文字を数値にしている)
				sum += Character.getNumericValue(input.charAt(i));
			}
			sumList.add(sum);
		}
		// 出力
		sumList.forEach(i -> System.out.println(i));
	}

	// 入力および終了判定
	static boolean InputNum() {
		input = sc.nextLine();
		if (input.equals("0")) {
			return false;
		} else {
			return true;
		}
	}

}



Measured memory_bytes: 31576