akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    ll x; cin>>x;

    ll ans = 0;
    ans += 1000 * (x / 500);

    x %= 500;

    ans += 5 * (x / 5);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll N, M;
  cin >> N >> M;
  ll s[MAX]={};
  ll i;
  map<ll, ll> mp;
  
  mp[0]++;
  for(i=1; i<=N; i++) {
    ll a;
    cin >> a;
    s[i]=(s[i-1]+a)%M;
    mp[s[i]]++;
  }
  
  ll ans=0;
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    ll t=it->sc;
    ans+=t*(t-1)/2;
  }
  
  pt(ans);
}



Measured memory_bytes: 4992
def main():
    import itertools
    n,m = map(int,input().split())
    ls = [[] for i in range(8)]
    stats = [stat for stat in itertools.product(*((0,1) for i in range(3)))]
    for i in range(n):
        x,y,z = map(int,input().split())
        for j,stat in enumerate(stats):
            ls[j].append(x*(-1)**stat[0] + y*(-1)**stat[1] + z*(-1)**stat[2])
    ans = 0
    for i in range(8):
        a_ = sum(sorted(ls[i],reverse=True)[0:m])
        if a_>ans:
            ans = a_
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9356
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <sstream>
#include <cmath>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()

typedef pair<int, int> Pii;
typedef vector<int> V;
typedef long long ll;
const int inf = 1e9;
const int mod = 1e9 + 7;

ll func(ll a, ll b)
{
	if(a < b) swap(a,b);
	if(!b) return -a;
	return 2 * (a/b) * b + func(b,a%b);
}

int main()
{
	ll N, X;
	cin >> N >> X;

	cout << N+func(N-X,X) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a[] = new int[n];
		int ans = 0;
		
		for(int i=0;i<n;i++){
		    a[i] = sc.nextInt();
		}
		
		for(int i=0; i<n; i++){
		        if(a[a[i]-1]==i+1){
		            ans++;
		    }
		}
		
        System.out.println(ans/2);
	}
}


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

int gcd(int A, int B) {
  int a = A, b = B, r;
  while (b) {
    r = a % b; a = b; b = r;
  }
  return a;
}

int main() {
  int K; cin >> K;
  int sum = 0;
  for (int a = 1; a <= K; a++)
    for (int b = 1; b <= K; b++)
      for (int c = 1; c <= K; c++)
        sum += gcd(a, gcd(b, c));
  cout << sum << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string K= "Three";
  for(int i=0 ; i < N ; i++){
    string S;
    cin >> S;
    if (S == "Y"){
      K="Four";
      break;
    }
    else K="Three";
  }
  cout << K << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;cin>>n;
    map<vector<int>,int> s;
    vector<vector<int>> in(n,vector<int>(26,0));
    rep(i,n){
        string t;cin >> t;
        rep(j,10){
            in[i][t[j]-'a']++;
        }
    }
    ll ans=0;
    rep(i,n){
        ans += s[in[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 32256
n = gets.chomp.to_i
x = gets.chomp.split(/\s/).map(&:to_f)
y = gets.chomp.split(/\s/).map(&:to_f)

puts x.zip(y).map {|xi, yi| (xi-yi).abs}.sum
puts Math.sqrt(x.zip(y).map {|xi, yi| (xi-yi).abs ** 2}.sum)
puts Math.cbrt(x.zip(y).map {|xi, yi| (xi-yi).abs ** 3}.sum)
puts x.zip(y).map {|xi, yi| (xi-yi).abs}.max


Measured memory_bytes: 6964
n = int(input())
h = [int(hi) for hi in input().split()]


#%%

#add 0 for both sides


#%%
#singlify 0
def singlify(h):
    # print(h)
    h = [0] + h + [0]
    # print(h)
    newh = []
    zero_flag = False
    for i in range(len(h)):
        if h[i] == 0:
            zero_flag = True
        else:
            if zero_flag:
                newh.append(0)
            newh.append(h[i])
            zero_flag = False
        # print(newh)
    newh.append(0)
    return newh


#%%
def minus_one_and_not_lower_than_zero(h):
    for i in range(len(h)):
        h[i] -= 1
        if h[i] == -1:
            h[i] = 0
    return h
#%%
# h = [3,1,2,3,1]

#%%
ans = 0

while True:
    h = singlify(h)
    # print(h)
    ans += h.count(0)-1
    h = minus_one_and_not_lower_than_zero(h)

    if sum(h) == 0:
        break

print(ans)
#%%


#%%


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

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            var vs = IO.ReadLineToLongList();

            long ans = 0;
            while (vs[1] >= vs[0])
            {
                ans++;
                vs[0] *= 2;
            }

            //ここまで

            Console.WriteLine(ans);
            Console.ReadKey();
        }

    }

    static class Func
    {
        static public long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public long Factorial(long a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(long n,long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

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

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

    double a, b, x;
    cin >> a >> b >> x;

    double result;

    // here decides which side we use for calculation
    // if the cube is larger than lsosceles triangle
    if(x/a > 0.5*a*b){
        result = 180.0 * atan(2.0*(b/a-x/(a*a*a)))/M_PI; // arctangent
    }else{
        result = 180.0 * atan((a*b*b)/(2.0*x))/M_PI;
    }

    // cout << result << endl;
    printf("%10.10lf\n", result);
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n,t;
    cin >> n >> t;
    int a[100001]={};
    int l,r;
    REP(i,n){
        cin >> l >> r;
        a[l]+=1;
        a[r]+=-1;
    }
    int ma=a[0];
    REAP(i,1,100001){
        a[i]+=a[i-1];
        ma=max(ma,a[i]);
    }
    cout << ma << endl;
}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{
   int n;cin>>n;
   vector<int>arr(n);
   for(int i=0;i<n;i++)
   cin>>arr[i];
   int c=0;
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           for(int k=j+1;k<n;k++)
           {
               if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[k]!=arr[i])
               if((arr[i]+arr[j]>arr[k])&&(arr[j]+arr[k]>arr[i])&&(arr[i]+arr[k]>arr[j]))
               c++;
           }
       }
   }
   cout<<c<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    solve();
}


Measured memory_bytes: 3620
n,m,k=gets.split.map &:to_i
as=gets.split.map &:to_i
bs=gets.split.map &:to_i
asum=[0]
bsum=[0]
as.each{|a|asum << asum[-1]+a}
bs.each{|b|bsum << bsum[-1]+b}
res=0
asum.each_with_index do |a,i|
  break if a>k
  while bsum[m]>k-a
    m-=1
  end
  res=[res,i+m].max
end
p res

Measured memory_bytes: 45176
sx, sy, tx, ty = map(int, input().split())
x = tx-sx
y = ty-sy
print("R"*(x) + "U"*(y) + "L"*(x) + "D"*(y+1) + "R"*(x+1) + "U"*(y+1) + "LU" + "L"*(x+1) + "D"*(y+1) + "R")

Measured memory_bytes: 3060
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b=map(int,readline().split())
    
    h=100
    w=100
    ans=[["."]*100 if 0<=i<50 else ["#"]*100 for i in range(100)]
    cnt_b=1
    cnt_w=1
    for i in range(h):
        for j in range(w):
            if i%2==0 and j%2==0 and  ans[i][j]==".":
                if cnt_b<b:
                    ans[i][j]="#"
                    cnt_b+=1
            elif i%2==1 and j%2==0 and ans[i][j]=="#":
                if cnt_w<a:
                    ans[i][j]="."
                    cnt_w+=1

    print(h,w)
    for i in range(h):
        print("".join(ans[i]))

if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 3000;
bool p[MX];
int n;
ll s[100010];
map<ll, int> sqs;

vector<ll> comp(const vector<ll> &m){
	if(m.size() == 0) return m;
	vector<ll> res;
	rep(i, m.size()){
		if(m[i] >= MX){
			if(sqs.count(m[i])) res.pb(sqs[m[i]]);
			else res.pb(m[i] * m[i]);
			continue;
		}
		if(i + 1 < m.size() && m[i] == m[i + 1]) res.pb(m[i++]);
		else { res.pb(m[i]); res.pb(m[i]); }
	}
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	vi prime;
	for(int i = 2; i * i < MX; i++) if(!p[i]) for(int j = i * i; j < MX; j += i) p[j] = 1;
	for(int i = 2; i < MX; i++) if(!p[i]) prime.pb(i);
	for(ll i = 1; i * i <= 1e10; i++) sqs[i * i] = i;
	
	cin >> n;
	rep(i, n) cin >> s[i];
	map<vector<ll>, int> M;
	set<vector<ll>> done;
	int ans = 0;
	
	rep(ii, n){
		ll m = s[ii];
		vector<ll> v;
		
		for(int i = 0; i < prime.size() && (ll)prime[i] * prime[i] <= m; i++) if(m % prime[i] == 0){
			int cnt = 0;
			for(; m % prime[i] == 0; cnt++) m /= prime[i];
			cnt %= 3;
			rep(it, cnt) v.pb(prime[i]);
		}
		if(m > 1) v.pb(m);
		sort(all(v));
		M[v]++;
	}
	
	done.insert(vector<ll>());
	for(auto m: M){
		if(done.count(m.first)) continue;
		auto mm = comp(m.first);
		
		if(M.count(mm)){
			int l = m.second, r = M[mm];
			ans += max(l, r);
			done.insert(mm);
		}
		else ans += m.second;
	}
	if(M.count(vector<ll>())) ans++;
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    int start=0;
    int ans=0;
    int h;cin >>h;
    FOR(i,n-1){
        int h1;cin>>h1;
        if (h1>h){
            ans = max(ans,i-start);
            start=i+1;
        }
        h=h1;
    }
    ans=max(ans,n-1-start);
    cout << ans;

    return 0;
}



Measured memory_bytes: 256
line = raw_input()
vals = map(int, line.split())
K = vals[0]
T = vals[1]
line = raw_input()
A = map(int, line.split())

def cal():
    A.sort()
    A.reverse()

    S = sum(A[1:])
    if S >= A[0] - 1:
        return 0

    return A[0] - 1 - S

print cal()



Measured memory_bytes: 2568
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 1e9;

int main() {
    int N;
    double sum = 0;
   
    cin >> N;
    for (int i = 0; i < N; i++) {
        double x;
        string u;
        cin >> x;
        cin >> u;
        if (u == "JPY")sum += x;
        else sum += x * 380000;
    }

    cout << sum;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << min(B/A,C) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    cout << (s < t ? "Yes" : "No") << endl;
}


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

vector<int> adj[100001];
bool possible;
vector<int> vis(100001,0);
int qw = 0;
void dfs(int s,int k)
{
   vis[s] = 1;
   
   if(s == 2)
   {
   	  possible = true;
   	  qw = k;
   }

   for(auto x : adj[s])
   {
   	   if(vis[x]==0)
     	dfs(x,k+1);
   }
}
int main(void)
{
	 int n,a,b;
	 cin>>n;
     possible = false; 
	 for(int  i =1;i<=n;i++)
	 {
         cin>>a;
         adj[i].push_back(a);
	 }
     dfs(1,0);

     if(possible)
      cout<<qw<<endl;
     else
      cout<<-1<<endl;

}

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

#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<"\n"
#define prints(a) for(auto i: a) cout<<i<<" "; cout<<"\n"
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e]

const int maxN = 1e7;
int d[maxN+1];

int main()
{
	fastio;
	LL n;
	cin>>n;
	for(int i=1; i<=n; i++){
		for(int j=1; j*i<=n; j++)
			d[i*j]++;
	}

	LL ans = 0;
	for(int i=1; i<=n; i++){
		ans += (LL)i*d[i];
	}

	cout<<ans<<"\n";

	exit(0);
}

Measured memory_bytes: 42636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> x;

	y=0;
	y+=(x/500)*1000;
	x%=500;
	y+=(x/5)*5;
	cout<<y<<endl;
}

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

using namespace std;

int dived = 0;
int mod = 0;
long reslut = 0;

int gcd(int dived,int mod){
    if(dived % mod == 0){
        return mod;
    }
    return gcd(mod,dived % mod);
}

int main() {
    int ink = 0;
    cin >> ink;

    for(int i = 1 ; i <= ink ; i++){
        for(int j = 1 ; j <= ink ; j++){
            for(int k = 1 ; k <= ink ; k++){
                reslut += gcd(gcd(i,j),k);
            }
        }
    }
    
    cout << reslut << endl;
    return 0;
}

Measured memory_bytes: 3632
n=int(input())
v=list(map(int,input().split()))
v.sort()
v.reverse()
ans=0
for i in range(n-2):
    v[i]=v[i]/(2**(i+1))
    
v[n-2]=v[n-2]/(2**(n-1))
v[n-1]=v[n-1]/(2**(n-1))

for j in range(n):
    ans+=v[j]
print(ans)


Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in(),a=in(),b=in(),c=in();
    vector<ll>l(n);for(ll i=0;i<n;++i)l[i]=in();
    ll ans=numeric_limits<ll>::max();
    for(ll i=(1<<(2*n))-1;i>=0;--i){
        ll a_len=0,b_len=0,c_len=0;
        ll a_cnt=0,b_cnt=0,c_cnt=0;
        for(ll j=0;j<n;++j){
            ll foo=(i>>(2*j))&3;
            if(foo==1){
                a_len+=l[j];
                ++a_cnt;
            }else if(foo==2){
                b_len+=l[j];
                ++b_cnt;
            }else if(foo==3){
                c_len+=l[j];
                ++c_cnt;
            }
        }
        if(a_cnt*b_cnt*c_cnt){
            ans=min(ans,(a_cnt+b_cnt+c_cnt-3)*10+abs(a-a_len)+abs(b-b_len)+abs(c-c_len));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	string s,s1;
  re(s,s1);
  cout<<s1+s<<"\n";
}


Measured memory_bytes: 256
s = input()
count = 1
tmp = s[0]
i = 1
while i < len(s):
    if tmp != s[i]:
        count += 1
        tmp = s[i]
        i += 1
    elif i == len(s) - 1:
        break
    else:
        count += 1
        tmp = s[i] + s[i+1]
        i += 2
print(count)


Measured memory_bytes: 3500
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;

int main()
{
	
	int n;
	cin >> n;

	vector<P> v;
	rep(i, n)
	{
		P p;
		cin >> p.first >> p.second;
		v.push_back(p);

	}

	vector<int> ns(n);
	iota(ns.begin(), ns.end(), 0);


	double dsum = 0;
	int count = 0;
	do
	{	
		//1つのパターンについて距離を計算
		double d = 0;
		P p_prev = v[ns[0]];

		repl(i, 1, n)
		{
			P p = v[ns[i]];

			d += sqrt(pow(p.first - p_prev.first, 2) + pow(p.second - p_prev.second, 2));

			p_prev = p;
		}

		dsum += d;

		count++;
		
	} while (next_permutation(ns.begin(), ns.end()));


	cout << setprecision(20) << dsum / count << endl;

	return 0;
}

Measured memory_bytes: 256
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

let inline memo2 size1 size2 f =
  let dp = Array2D.create size1 size2 None
  let rec g x y =
    match dp.[x, y] with
    | None ->
      let v = f g x y
      dp.[x, y] <- Some v
      v
    | Some v -> v
  g
// start

let N = readStr().ToCharArray() |> Array.map (int >> (flip (-) (int '0')))
let K = readInt()

let NL = N.Length

let nth n =
  let rec loop n' i =
    if N.[i] = 0
    then if i < (NL-1) then loop n' (i+1) else None
    else
      if n'=1 then Some i
      elif i < (NL-1) then loop (n'-1) (i+1)
      else None
  loop n 0

let combi n k =
  let pnk = [(n-k+1)..n] |> List.fold ( * ) 1
  let factK = [1..k] |> List.fold ( * ) 1
  pnk / factK

let count n =
  let inner i =
    let v = N.[i]
    let rest = max 0 (NL-i-1)
    let nonZero = (v-1) * (pown 9 (K-n)) * (combi rest (K-n))
    let zero = (pown 9 (K-n+1)) * (combi rest (K-n+1))
    nonZero + zero
  nth n |> Option.map inner |> Option.getOr 0

let tmp = [1..K] |> List.sumBy count
if Option.isSome (nth K)
then tmp + 1
else tmp
|> printfn "%d"

Measured memory_bytes: 14172
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	bool flag = 0;
	long int n;
	cin >> n;
	long int a[n];
	for(long int i = 0; i < n; i++){
		cin >> a[i];
		}
	sort(a,a+n);
	
	for(long int i = 0; i < n - 1; i++){
		if(a[i] == a[i + 1]){
			flag = 1;
			break;
			}
		}
		
		if(flag == 0){
			cout << "YES";
			}
		else
		{
			cout << "NO";
		}
	
	}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = getInt(sc);
		int b = getInt(sc);
		String s = getString(sc);

		String regex = "^\\d{" + a + "}-\\d{" + b + "}$";
		if (s.matches(regex)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	long x;
	long tmpCoins;

	public Status(long x, long tmpCoins) {
		this.x = x;
		this.tmpCoins = tmpCoins;
	}
}


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

const double eps = 1e-9;

bool same(double a, double b) { return a == b; }

struct P {
    double x, y;
    P() : x(0), y(0) {}
    P(double x, double y) : x(x), y(y) {}
    P operator + (P b) { return P(x + b.x, y + b.y); }
    P operator - (P b) { return P(x - b.x, y - b.y); }
    P operator * (double b) { return P(x * b, y * b); }
    P operator / (double b) { return P(x / b, y / b); }
    double operator * (P b) { return x * b.x + y * b.y; }
    double operator ^ (P b) { return x * b.y - y * b.x; }
    double abs() { return hypot(x, y); }
    P unit() { return *this / abs(); }
};

struct L{
    // ax + by + c = 0
    double a, b ,c, o;
    P pa, pb;
    L() : a(0), b(0), c(0), o(0), pa(), pb() {}
    L(P pa, P pb) : a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), o(atan2(-a, b)), pa(pa), pb(pb) {}
    P project(P p) { return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs()); }
    P reflect(P p) { return p + (project(p) - p) * 2; }
    double get_ratio(P p) { return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs()); }
    bool inside(P p) {
        double z = get_ratio(p);
        return z >= 0 && z <= 1;
    }
};

bool parallel(L x, L y) { return same(x.a * y.b, x.b * y.a); }

P intersect(L x, L y) { return P(-x.b * y.c + x.c * y.b, x.a * y.c - x.c * y.a) / (-x.a * y.b + x.b * y.a); }

int main() {
    int q; cin >> q; while (q--) {
        P p[4]; 
        for (int i = 0; i < 4; ++i) cin >> p[i].x >> p[i].y;
        if ((p[0] - L(p[2], p[3]).project(p[0])).abs() < eps && L(p[2], p[3]).inside(p[0])) cout << "1" << '\n';
        else if ((p[1] - L(p[2], p[3]).project(p[1])).abs() < eps && L(p[2], p[3]).inside(p[1])) cout << "1" << '\n';
        else if ((p[2] - L(p[0], p[1]).project(p[2])).abs() < eps && L(p[0], p[1]).inside(p[2])) cout << "1" << '\n';
        else if ((p[3] - L(p[0], p[1]).project(p[3])).abs() < eps && L(p[0], p[1]).inside(p[3])) cout << "1" << '\n';
        else if (((p[3] - p[2]) ^ (p[1] - p[2])) * ((p[3] - p[2]) ^ (p[0] - p[2])) < 0 &&
            ((p[1] - p[0]) ^ (p[3] - p[0])) * ((p[1] - p[0]) ^ (p[2] - p[0])) < 0) {
            cout << "1" << '\n';
        } else cout << "0" << '\n';
    }
}



Measured memory_bytes: 3456
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		var dp0 = DFS0(0, V);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp = new long[V];
		var st = new Stack<A0>();
		st.Push(new A0(u, p));
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f.p >= 0)
			{
				dp[f.u] = 1L;
				es[f.u].Remove(f.p);
				if (es[f.u].Count == 0) continue;
				st.Push(new A0(f.u, -1));
				foreach (var v in es[f.u]) st.Push(new A0(v, f.u));
			}
			else foreach (var v in es[f.u]) dp[f.u] = dp[f.u] * (dp[v] + 1) % Mod;
		}
		return dp;
	}
	long[] DFS1(int u, long[] dp0)
	{
		var dp = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		var y = new long[V];
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			if (W == 0) continue;
			y[W - 1] = 1;
			for (var i = W - 1; i >= 1; i--) y[i - 1] = y[i] * (dp0[es[u][i]] + 1) % Mod;
			var x = 1L;
			for (var i = 0; i < W; i++)
			{
				dp[es[u][i]] = (dp[u] + 1) * x % Mod * y[i] % Mod;
				x = x * (dp0[es[u][i]] + 1) % Mod;
			}
			foreach (var v in es[u]) st.Push(v);
		}
		return dp;
	}
}
struct A0 { public int u, p; public A0(int u, int p) { this.u = u; this.p = p; } }


Measured memory_bytes: 35584
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int n, m;
    cin >> n >> m;
    bool flag = false;
    vector<int> ball(n, 1), red(n, 0);
    red[0] = 1;
    for(int i = 0 ; i < m ; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if(red[x] == 1){
            red[y] = 1;
            if(ball[x] == 1){
                red[x] = 0;
            }
        }
        ball[x]--;
        ball[y]++;
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        ans += red[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
from pprint import pprint

import heapq

n, m = map(int, sys.stdin.readline().strip().split(" "))
a = list(map(int, sys.stdin.readline().strip().split(" ")))

q = []
for a_i in a:
    heapq.heappush(q, -1 * a_i)

for _ in range(m):
    price = heapq.heappop(q)
    heapq.heappush(q, ((-1 *price) // 2) * -1)

# pprint(q)
print(-1 * sum(q))

Measured memory_bytes: 64852
package main

import "fmt"

// package main

// import (
// 	"fmt"
// 	"math"
// )

// func main() {
// 	var a, b, c, x, y int
// 	fmt.Scan(&a, &b, &c, &x, &y)

// 	min := a*x + b*y

// 	xyMin := int(math.Min(float64(x), float64(y)))
// 	if ab := xyMin*2*c + (x-xyMin)*a + (y-xyMin)*b; ab < min {
// 		min = ab
// 	}
// 	xyMax := int(math.Max(float64(x), float64(y)))
// 	if abAll := xyMax * 2 * c; abAll < min {
// 		min = abAll
// 	}

// 	fmt.Println(min)
// }

func max(n, m int) int {
	if n >= m {
		return n
	}
	return m
}

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	min := a*x + b*y
	for i := 1; i <= 100000; i++ {
		sum := c*i*2 + max(x-i, 0)*a + max(y-i, 0)*b
		if sum < min {
			min = sum
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
n,u,v = gets.split.map(&:to_i)
road = Array.new(n+1){[]}

(n-1).times do 
    a,b = gets.split.map(&:to_i)
    road[a] << b
    road[b] << a
end

if road[u] == [v]
    puts 0
    exit
end

taka = Array.new(n+1,nil)
taka[u] = 0
queue = [u]
while x = queue.shift
    road[x].each do |e|
        next if taka[e]
        taka[e] = taka[x] + 1
        queue << e
    end
end

aoki = Array.new(n+1,nil)
aoki[v] = 0
queue = [v]
while x = queue.shift
    road[x].each do |e|
        next if aoki[e]
        aoki[e] = aoki[x] + 1
        queue << e
    end
end

max = v
1.upto(n) do |i|
    next if road[i].size != 1 || taka[i] > aoki[i]
    max = i if aoki[max] < aoki[i]
end

puts taka[max] + (aoki[max] - taka[max] - 1)

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

#define ll long long

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

    if (count(s.begin(), s.end(), s[0]) != 2) {
        cout << "No" << endl;
        return 0;
    }

    char x = s[0];
    int i = 0;

    while(x == s[0]){
        i++;
        x = s[i];
    }

    if (count(s.begin(), s.end(), s[i]) != 2) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int r, d, x;
    cin >> r >> d >> x;

    for (int i = 0; i < 10; i++) {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
s=input()
N=len(s)+1

a = [0]*N
for i in range(N-1):
    if(s[i] == "<"):
        a[i+1] = a[i]+1

for j in range(N-2,-1,-1):
    if(s[j] == ">"):
        if(a[j] <= a[j+1]):
            a[j] = a[j+1]+1

print(sum(a))


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

const int MAXN = 2010;
const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int n, K;
int f[MAXN][MAXN], g[MAXN][MAXN], suc[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> K;
	f[n + 1][0] = 1;
	for (int i = n; i; --i) {
		for (int j = n; ~j; --j) {
			reduce(suc[j] = f[i + 1][j] + g[i + 1][j] - mod);
			if (i != 1) reduce(suc[j] += suc[j + 1] - mod);
			reduce(g[i][j + 1] += g[i + 1][j] - mod);
			reduce(g[i][j + 1] += f[i + 1][j] - mod);
			reduce(f[i][j] += suc[j] - mod);
		}
	}
	std::cout << pow(2, std::max(n - K - 1, 0), f[1][n - K]) << std::endl;
	return 0;
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 0 && s.substr(0, n/2) == s.substr(n/2, n/2)) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


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

int main(){
string S;
cin >>S;
if (S[0]==S[1] && S[0]!=S[2] && S[2]==S[3]) cout << "Yes";
else if (S[0]==S[2] && S[0]!=S[1] && S[1]==S[3]) cout << "Yes";
else if (S[0]==S[3] && S[0]!=S[1] && S[1]==S[2]) cout << "Yes";
else cout << "No";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  if(N >= 1000) {
    cout << "ABD" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}

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

int main()
{
    //input
    int N, M;
    cin >> N >> M;
    int a[M], b[M],ans[N+1];
    for (int i = 0; i < M;i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < N+1; i++)ans[i]=0;

    //check
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < N+1;j++)
        {
            if(a[i]==j)ans[j]++;
            if (b[i] == j)ans[j]++;
            //cout <<i<<"---"<<j <<"----"<< ans[j] << endl;
        }
    }
    for (int i = 1; i < N+1;i++)
    {
        cout << ans[i] << endl;
    }
        return 0;
    }

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

int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int an[150];
		int sum = 0;
		for(int i = 1;i <= n;i++)
		{
			scanf("%d",&an[i]);
			sum += an[i];
		}
		int m;
		scanf("%d",&m);
		while(m--)
		{
			int ans = sum;
			int x,y;
			scanf("%d%d",&x,&y);
			ans-=an[x] - y;
			printf("%d\n",ans);
		}
	}
return 0;
}

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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int N = sc.nextInt();
		final int M = sc.nextInt();
		final int L = sc.nextInt();
		
		long[][] combs = new long[M + 1][M + 1];
		combs[0][0] = 1;
		for(int i = 0; i < M; i++){
			for(int j = 0; j < M; j++){
				if(combs[i][j] == 0){
					continue;
				}
				
				combs[i + 1][j    ] += combs[i][j];
				combs[i + 1][j + 1] += combs[i][j];
			}
		}
		
		double[][] probs = new double[N][M + 1];
		double[][] probs_sums = new double[N][M + 1];
		double[][] times = new double[N][M + 1];
		
		
		for(int i = 0; i < N; i++){
			final double P = sc.nextDouble() / 100;
			final int T = sc.nextInt();
			final int V = sc.nextInt();
			
			//init_time
			double time = (double)(L) / V;
			
			for(int j = 0; j <= M; j++){
				times[i][j] = time + j * T;
			}
			
			//init_prob
			for(int j = 0; j <= M; j++){
				probs[i][j] = combs[M][j];
			}
			
			double rest_p = 1.0;
			for(int j = 0; j <= M; j++){
				probs[i][j] *= rest_p;
				rest_p *= P;
			}
			
			double unrest_p = 1.0;
			for(int j = 0; j <= M; j++){
				probs[i][M - j] *= unrest_p;
				unrest_p *= 1 - P;
			}
			
			//sum
			for(int j = 0; j <= M; j++){
				probs_sums[i][j] = (j == 0 ? 0 : probs_sums[i][j-1]) + probs[i][j];
			}
		}
		
		for(int fst = 0; fst < N; fst++){
			double fst_prob = 0;
			
			for(int rest = 0; rest <= M; rest++){
				final double rested_time = times[fst][rest];
				double to_fst_prob = probs[fst][rest];
				
				for(int other = 0; other < N; other++){
					if(fst == other){
						continue;
					}
					
					int pos = Arrays.binarySearch(times[other], rested_time);
					if(pos < 0){
						pos = -(pos + 2);
					}
					
					double win_prob = 0;
					if(pos < 0){
						win_prob = 1;
					}else{
						win_prob = 1 - probs_sums[other][pos];
						win_prob = Math.max(win_prob, 0);
					}
					
					to_fst_prob *= win_prob;
				}
				
				fst_prob += to_fst_prob;
			}
			
			System.out.printf("%.8f\n", fst_prob);
		}
	}

}

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

using namespace std;
typedef unsigned long long ll;
const int INF = 1e9;
const ll mod = 1e9 + 7;

void setup(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
}

int main(){
setup();
	ll T = 1;
	//cin >> T;	
	while (T--){
		ll x,k,d;
		cin >> x >> k >> d;
		ll diff = llabs(x);
		ll ex = diff%d;
		if (k < (diff/d)){
			cout << diff-(k*d);
			return 0;
		}
		if ((diff/d)%2 != k%2) cout << d-ex << endl;
		else cout << ex << endl;

	}
}

Measured memory_bytes: 3612
#include<stdio.h>

int main(void){
   char s[100];
   int k;
   int n=0;

   scanf("%d",&k);
   scanf("%s",s);

   for(int i=0;s[i]!='\0';i++){
      n++;
   }

   if(n<=k){
      printf("%s",s);
   }else{
      for(int j=0;j<k;j++){
        printf("%c",s[j]);
      }
      printf("...");
   }

   return 0;
}


Measured memory_bytes: 1708
N = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

import bisect
ans = 0
for bi in b:
    a_cnt = bisect.bisect_left(a, bi)
    c_cnt = N - bisect.bisect_right(c, bi)
    ans += a_cnt * c_cnt
    #print(a_cnt, c_cnt)

print(ans)

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

struct SegmentTree {
    SegmentTree(vector<int> v, int ini = 0) {
        int sz = v.size();
        n = 1;
        while (n < sz)
            n *= 2;
        node.resize(2 * n - 1, ini);

        for (int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = node[2 * i + 1] + node[2 * i + 2];
        }
    }

    void update(int k, int v) {
        k += n - 1;
        node[k] += v;
        while (k > 0) {
            k = (k - 1) / 2;
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = n;

        if (r <= a || b <= l)
            return 0;
        if (a <= l && r <= b)
            return node[k];

        int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }

private:
    int n;
    vector<int> node;
};

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<vector<int>> cnt(26, vector<int>(N, 0));
    for (int i = 0; i < N; i++) {
        cnt[S[i] - 'a'][i]++;
    }

    vector<SegmentTree> trees;
    for (int i = 0; i < 26; i++) {
        trees.push_back(SegmentTree(cnt[i]));
    }

    int Q;
    cin >> Q;
    while (Q--) {
        int q;
        cin >> q;
        if (q == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            if (S[i] != c) {
                char now = S[i];
                trees[now - 'a'].update(i, -1);
                trees[c - 'a'].update(i, +1);
                S[i] = c;
            }
        } else {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int cnt = 0;
            for (int i = 0; i < 26; i++) {
                if (trees[i].query(l, r + 1) != 0) {
                    cnt++;
                }
            }
            cout << cnt << endl;
        }
    }
}


Measured memory_bytes: 160228
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;
  int ans = 0;
  if(K == 1){
    ans = 0;
  }else{
    ans = N - K;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if (A+B>C+D) {
    cout << "Left" << endl;
  }
  else if (A+B<C+D) {
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}


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

ll pow(ll a, ll x, ll p){
  	ll tmp=1;
  	while(x>0){
    	if(x%2 == 1){
          	tmp = (a*tmp)%p;
        }
      	a = (a*a)%p;
      	x /= 2;
    }
  	return(tmp);
}

ll inv(ll a, ll p){
  	return pow(a,p-2,p);
}

ll factorial(ll n, ll p){
  	ll res = 1;
  	for(ll i=1;i<=n;i++){
      	res = (res*i)%p;
    }
  	return res;
}

/*
ll combination(ll n, ll r, ll p){
    ll res=1;
  	ll tmp1 = fact.at(n);
  	ll tmp2 = fact.at(n-r);
  	ll tmp3 = fact.at(r);
  	res = ( ( (tmp1 * inv(tmp2,p) ) % p) * inv(tmp3,p) ) % p;
  	return res;
}
*/

ll perm(ll n, ll r, ll p){
  ll ans=1;
  for(ll i=1;i<=r;i++){
    ans = (ans*(n-i+1)) % p;
  }
  return ans;
}

ll combination(ll n, ll r, ll p){
  ll ans = 1;
  for(ll i=1;i<=r;i++){
    ll x = (n+1-i)*inv(i,p) % p;
    ans = (ans * x) % p; 
  }
  return(ans);
}

int main() {
  ll n;
  cin >> n;
  if(n<=2){
    cout << 0 << endl;
    return(0);
  }else if(n<=5){
    cout << 1 << endl;
    return(0);
  }
  
  ll k=n/3;
  ll ans=1;
  for(ll i=2;i<=k;i++){
    ans += combination(n-2*i-1,i-1,mod);
    ans = ans%mod;
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 3628