akhauriyash/Code-Regression huggingface dataset:
#set
n = gets.chomp.to_i
x_arr = []
y_arr = []
0.upto(n - 1) do |i|
  x_arr[i],y_arr[i] = gets.chomp.split(" ").map(&:to_i)
end

length_sum = 0
answer = 0

#main
0.upto(n - 1) do |i|
  0.upto(n - 1) do |j|
    length_sum += Math.sqrt(((x_arr[i] - x_arr[j]) ** 2) + ((y_arr[i] - y_arr[j]) ** 2))
  end
end

answer = length_sum / n
print ("#{answer}\n")

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

int main(){
    //最小公倍数
    ll a,b; cin>>a>>b;
    for(int i=1;i<=b;i++){
        if((a*i)%b==0){
            cout<<a*i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
import sys
input = sys.stdin.buffer.readline


class BIT:
    """区間加算、一点取得クエリをそれぞれO(logN)で答えるデータ構造"""
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    info[i] = info[i][0], info[i][1], info[i][1] - info[i][0] + 1
info = sorted(info, key=itemgetter(2))

bit = BIT(m + 1)
l_info = 0
ans = n
res = [0] * m
for d in range(1, m + 1):
    while True:
        if l_info < n and info[l_info][2] < d:
            l, r, _ = info[l_info]
            bit.add(l, r + 1, 1)
            l_info += 1
            ans -= 1
        else:
            break
    cnt = ans
    for i in range(0, m + 1, d):
        cnt += bit.get_val(i)
    res[d - 1] = cnt

print('\n'.join(map(str, res)), end='\n')


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

int main() {
 int a , b;
  cin >> a >> b;
 vector<int> v(a) ;
  for(int i=0; i<a;i++){
    cin >> v.at(i);
  }
  
  sort(v.begin(),v.end());
  
  
  
  for(int i=0; i<min(a,b);i++){
    v.at(v.size()-i-1) = 0;
  }
  int long long ans =0;
  for(int i=0; i<a;i++){
   ans+= v.at(i);
  }
  cout << ans;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i < a + k; i++) {
        if (i > b) {
            continue;
        }
        cout << i << endl;
    }
    for (int i = b - k + 1; i <= b; i++) {
        if (i < a + k) {
            continue;
        }
        else if (i < a) {
            continue;
        }
        else {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l,r,res;
string s;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

//全ての10000円札と5000円札の組を試し、1000円札で帳尻が合うか調べる。

int main(){
    cin>>a>>b>>x;
    p((a<=x && x<=a+b)?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << "[" << pa.first << ", " << pa.second << "]";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  os << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "}";
  return os;
}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

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

  ll k;
  std::cin>>k;

  std::vector<ll> d(k,MOD);
  std::deque<P> que;

  d[1]=0;
  que.push_front({0,1});

  while(!que.empty()){
    P p=que.front();que.pop_front();
    if(d[p.second]<p.first)continue;

    if(d[(p.second+1)%k]>d[p.second]+1){
      d[(p.second+1)%k]=d[p.second]+1;
      que.push_back({d[(p.second+1)%k],(p.second+1)%k});
    }

    if(d[(10*p.second)%k]>d[p.second]){
      d[(10*p.second)%k]=d[p.second];
      que.push_front({d[(10*p.second)%k],(10*p.second)%k});
    }
  }

  std::cout<<d[0]+1;

  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

namespace ABC127 {
	class Program {
		struct Rule : IComparable<Rule>
		{
			public int b,
			c;
			public Rule(int i_b, int i_c)
			{
				b = i_b;
				c = i_c;
			}
			public int CompareTo(Rule other)
			{
				// intと降順と昇順を逆にしたいので工夫する
				int cCompareTo = this.c.CompareTo(other.c);
				if (cCompareTo != 0)
				{
					return -cCompareTo;
				}
				int bCompareTo = this.b.CompareTo(other.b);
				return -bCompareTo;
			}
		}
		static void Main (string[] args) {
			// 入力
			int N, M;
			int[] firstArray = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			N = firstArray[0];
			M = firstArray[1];
			int[] secondArray = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			List<int> A = new List<int> (N);
			for (int i = 0; i < N; i++) {
				A.Add (secondArray[i]);
			}
			List<Rule> rules = new List<Rule> (M);
			for (int i = 0; i < M; i++) {
				int[] array = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
				rules.Add (new Rule (array[0], array[1]));
			}
			// 処理・出力
			/*	正攻法はこう
				- 0~M-1に対して以下の処理
					- A[]をソート
					- A[0]~A[B[i]]のうち、C[i]以下のものをC[i]に書き換え(これのせいでO(n^2)となる)
				- これで最大の時の結果が出る。あとは和を求めればよい。
				こいつの非効率なところは「同じ値を書き換えまくる」である。
				A[i]は１回しか書き換えないようなアルゴリズムは、こう。
				- A[]をソート
				- B[i],C[i]をC[i]が大きい順にソート
				- A[]を上から順に「B[i]個だけC[i]に書き換える、ただしA[j]>=C[i]となったらもう書き換えない」をする
			 **/
			// Aをソート
			A.Sort ();
			// B,Cをソート
			rules.Sort ();
			// Aを書き換え
			int rulesIndex = 0;
			int aIndex = 0;
			while (aIndex < N && rulesIndex < M) {
				for (int i = aIndex; i < aIndex + rules[rulesIndex].b; i++) {
					if (i >= N) {
						// 書き換え終了
						break;
					}
					if (A[i] < rules[rulesIndex].c) {
						A[i] = rules[rulesIndex].c;
					} else {
						// 書き換え終了
						aIndex = N;
						break;
					}
				}
				aIndex += rules[rulesIndex].b;
				rulesIndex++;
			}
			// 合計値の計算
			Int64 total = 0;
			for (int i = 0; i < N; i++) {
				total += A[i];
			}
			Console.WriteLine (total);
		}
	}
}

Measured memory_bytes: 28224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool checkpal(string s)
{
    string r=s;
    reverse(r.begin(),r.end());
    return r==s;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll n=s.length();
    if(checkpal(s)&&checkpal(s.substr(0,(n-1)/2)) && checkpal(s.substr((n+1)/2)))
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    ll n; cin >> n;
    ll a,b;
    for (ll i = 1; i*i <= n;i++) {
        if (n % i==0) {
            a = i;
            b = n / i;
        }
    }
    cout << a + b - 2 << endl;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std ;
int main ()
{
    string name ;

    //cout << "Enter the name of the day " << endl ;
    cin >> name ;




    if (name == "SUN" )
    {
        cout << 7 << endl ;
    }
    else if ( name == "MON" )
    {
        cout << 6 << endl ;
    }

    else if (name == "TUE" )
    {
        cout << 5 << endl ;
    }

    else if (name == "WED" )
    {
        cout << 4 << endl ;
    }

    else if (name == "THU" )
    {
        cout << 3 << endl ;
    }

    else if (name == "FRI" )
    {
        cout << 2 << endl ;
    }

    else if (name == "SAT" )
    {
        cout << 1 << endl ;
    }

    return 0 ;

}


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

int main() {
  bool cards[4][13] = { false };

  string n, in;
  cin >> n;
  int n_num = stoi(n);
  for (int i = 0; i < n_num; i++) {
    string type;
    int num;
    cin >> type >> num;
    if (type == "S") {
      cards[0][num - 1] = true;
    } else if (type == "H") {
      cards[1][num - 1] = true;
    } else if (type == "C") {
      cards[2][num - 1] = true;
    } else if (type == "D") {
      cards[3][num - 1] = true;
    }
  }

  for (int i = 0; i < 4; i++) {
    string type;
    if (i == 0) {
      type = "S";
    } else if (i == 1) {
      type = "H";
    } else if (i == 2) {
      type = "C";
    } else if (i == 3) {
      type = "D";
    }
    for (int j = 0; j < 13; j++) {
      if (cards[i][j] == false) {
        cout << type << " " << j + 1 << endl;
      }
    }
  }
}


Measured memory_bytes: 3164
import sys

def main(inp):
    food=[int(next(inp).split()[0]) for _ in range(5)]
    
    ichi=[food[i]%10 for i in range(5)]
    for i in range(5):
        if(ichi[i]==0): ichi[i]=10
            
    lastfood=ichi.index(min(ichi))
    
    ans=0
    for i in range(5):
        if(i==lastfood or food[i]%10==0): ans+=food[i]
        else: ans+= (food[i]//10 +1)*10
            
    return ans
  
print(main(sys.stdin))

Measured memory_bytes: 3064
n = int(input())
t, a = map(int,input().split())
pList = list(map(int,input().split()))
tList = []
for i in range(n):
  tList.append(abs(a-(t-pList[i]*0.006)))

result = 0
for i in range(1,n):
  if tList[result] > tList[i]:
    result = i

print(result+1)


Measured memory_bytes: 3060
#include<stdio.h>
#define MOD 1000000007;
int N, i, j;
char S[100001], c;
long long int dp[100001][4];
int main(){
	c=getchar(); while(c!=10){S[N++]=c; c=getchar();}

	dp[N][3]=1;
	for(i=N-1; i>=0; --i){
		{
			dp[i][3] = dp[i+1][3] * (S[i] == '?' ? 3LL : 1LL);
			dp[i][3] %= MOD;
		}
		for(j=2; j>=0; --j){
			if(S[i]=='?'){
				dp[i][j] = dp[i+1][j]*3;
			}else{
				dp[i][j] = dp[i+1][j];
			}
			if(S[i] == '?' || S[i] == j+'A'){
				dp[i][j] += dp[i+1][j+1];
			}
			dp[i][j] %= MOD;
		}
	}
	printf("%lld\n", dp[0][0]);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

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

	int n, k, s;
	cin >> n >> k >> s;
	int x = s / 2;
	int y = s - x;
	vi a(n);
	if (k == n)
	{
		rep(i, n)a[i] = s;
	}
	else if (s == 1)
	{
		rep(i, n)
		{
			a[i] = i < k ? 1 : 2;
		}
	}
	else
	{
		rep(i, n)
		{
			if (i <= k)
			{
				a[i] = i % 2 == 0 ? x : y;
			}
			else
			{
				a[i] = y + 1 != s ? y + 1 : y + 2;
			}
		}
	}
	rep(i, n)cs(a[i]);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second

const int N=1000000000;
vector<vector<int>>adj;
int dis[100005][3];
main() {
	int n, m;
	cin>>n>>m;
	adj.resize(n+1);
	for(int i=0; i<m; i++){
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		
	}
	int s, t;
	cin>>s>>t;
	for(int i=1; i<=n; i++){
		for(int j=0; j<3; j++){
			dis[i][j]=N;
		}
	}
	dis[s][0]=0;
	queue<pair<int, int>>q;
	q.push({s, 0});
	while(!q.empty()){
		int node=q.front().f;
		int t1=q.front().s;
		int t2=(t1+1)%3;
		q.pop();
		for(auto u:adj[node]){
			
			if(dis[u][t2]>1+dis[node][t1]){
				dis[u][t2]=1+dis[node][t1];
				q.push({u, t2});
			}
		}
	}
	if(dis[t][0]==N){
		cout<<-1;
		return 0;
	}
	cout<<(dis[t][0])/3;
	return 0;
}

Measured memory_bytes: 11176
#include "bits/stdc++.h"
using namespace std;

int main(){
	
	int N;
    vector<int> B;

	
    cin >> N;

    vector<int> A(N);
    int tmp;
    for (int i = 0; i < N-1; i++){
        cin >> tmp;
        B.push_back(tmp);    
    }

    for (int i = 0; i < N; i++){
        if (i ==0){
            A[i]=B[0];
        }else if (i==N-1){
            A[i]=B[N-2];
        }else{
            A[i]=min(B[i-1],B[i]);
        }
        
    }
    int sum = 0;
    for (int i = 0 ; i < N ; i++){
        sum += A[i];
    }
    cout << sum <<endl;


	return 0;
}



Measured memory_bytes: 256
n = int(input())
total = n * (n + 1) // 2
fizz = n // 3 * (n // 3 + 1) // 2 * 3
buzz = n // 5 * (n // 5 + 1) // 2 * 5
fizzbuzz = n // 15 * (n // 15 + 1) // 2 * 15
print(total - fizz - buzz + fizzbuzz)

Measured memory_bytes: 9176
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
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
#include<bits/stdc++.h>
using namespace std;

struct node{
	int a,b,c,d;
}Q[51];

int A[51],ans=0;

int main(){
    int n,m,q,s=0;
    cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>Q[i].a>>Q[i].b>>Q[i].c>>Q[i].d;
	for(int i=1;i<=n;i++)
	    A[i]=1;
	while(A[0]==0){
		int sum=0;
		for (int i=1;i<=q;i++)
			if(A[Q[i].b]-A[Q[i].a]==Q[i].c)
			    sum+=Q[i].d;
		ans=max(ans,sum);
		for(int i=n;i>=0;i--){
			if(A[i]<m){
				A[i]++;
				for(int j=i+1;j<=n;j++)
				    A[j]=A[j-1];
				break;
			}
		}
	}
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 3604
n = int(input())
a = ord("a")

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for i in range(a, mx + 2):
            if i != mx + 1:
                dfs(s + chr(i), mx)
            else:
                dfs(s + chr(i), mx + 1)

dfs("a", a)

Measured memory_bytes: 9028
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int s;
  cin >> s;
  int ans = 0;
  vector<int> vec(1000001);

  int cnt = 1;
  if(s == 1 || s == 2){
    cout << 4 << endl;
    return 0;
  } else {
    for (int i = 0; i < 1000000; i++) {
      if(s%2 == 0){
        s = s/2;
        vec.at(i) = s;
      } else {
        s = 3*s+1;
        vec.at(i) = s;
      }
      cnt++;
      if(s == 1) break;
    }
    cout << cnt+1 << endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 7160
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	string s;
	cin>>n>>s;
	int a=0,b=0;
	string h=s;
	for(int i=0;i<n;i++){
		if(s[i]=='('){
			a++;
		}
		else{
			b++;
		}
		if(b>a){
			h="("+h;
			a++;
		}
	}
	for(int i=0;i<a-b;i++){
		h+=")";
	}
	cout<<h<<endl;
}


Measured memory_bytes: 256
/*
USER: caoash3
LANG: JAVA
TASK: 
*/

import java.io.*;
import java.util.*;

public class Main {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {

			int N = br.nextInt();
			
			double[] in = new double[N];
			
			for(int i = 0; i < N; i++) {
				in[i] = br.nextDouble();
			}
			
			double[][] dp = new double[N+1][N+1]; //i = coin, j = num heads, dp[i][j] = probability
			
			dp[0][0] = 1;
			
			for(int i = 1; i <= N; i++) {
				dp[i][0] = dp[i-1][0] * (1-in[i-1]);
			}
			
			for(int i = 1; i <= N; i++) {
				for(int j = 1; j <= N; j++) {
					dp[i][j] = (double)(((double)(dp[i-1][j-1] * in[i-1])) + ((double)(dp[i-1][j] * ((double)(1-in[i-1])))));
				}
				
			}
			
			double ans = 0;
			
			for(int i = ((N/2)+1); i <= N; i++) {
				ans += dp[N][i];
			}
			
			pw.println(ans);
			
			
			pw.close();
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



Measured memory_bytes: 132692
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+2;
const int inf=1e15+2;
const int inf1=1e18+2;
int it[N<<2],lazy[N<<2],query[N],a,b,it1[N<<2],lazy1[N<<2];
void init(int idx,int l,int r){
	if(l==r){
		if(l==b){
			it[idx]=0-l;
			it1[idx]=0+l;
		}
		else{
			it[idx]=inf-l;
			it1[idx]=inf+l;
		}
		return;
	}
	init(2*idx,l,(l+r)/2);
	init(2*idx+1,(l+r)/2+1,r);
	it[idx]=min(it[2*idx],it[2*idx+1]);
	it1[idx]=min(it1[2*idx],it1[2*idx+1]);
}
void push_down1(int idx,int l,int r){
	if(l<r){
		lazy1[2*idx]+=lazy1[idx];
		lazy1[2*idx+1]+=lazy1[idx];
		it1[2*idx]+=lazy1[idx];
		it1[2*idx+1]+=lazy1[idx];
	}
	lazy1[idx]=0;
}
void add1(int idx,int l,int r,int lef,int rig,int val){
	if(l>rig||r<lef){
		return;
	}
	if(l>=lef&&r<=rig){
		it1[idx]+=val;
		lazy1[idx]+=val;
		return;
	}
	push_down1(idx,l,r);
	add1(2*idx,l,(l+r)/2,lef,rig,val);
	add1(2*idx+1,(l+r)/2+1,r,lef,rig,val);
	it1[idx]=min(it1[2*idx],it1[2*idx+1]);
}
void gan1(int idx,int l,int r,int pos,int val){
	if(l>pos||r<pos){
		return;
	}
	if(l==r){
		it1[idx]=min(it1[idx],val);
		return;
	}
	push_down1(idx,l,r);
	gan1(2*idx,l,(l+r)/2,pos,val);
	gan1(2*idx+1,(l+r)/2+1,r,pos,val);
	it1[idx]=min(it1[2*idx],it1[2*idx+1]);
}
int getmin1(int idx,int l,int r,int lef,int rig){
	if(l>rig||r<lef){
		return inf1;
	}
	if(l>=lef&&r<=rig){
		return it1[idx];
	}
	push_down1(idx,l,r);
	return min(getmin1(2*idx,l,(l+r)/2,lef,rig),getmin1(2*idx+1,(l+r)/2+1,r,lef,rig));
}
void push_down(int idx,int l,int r){
	if(l<r){
		lazy[2*idx]+=lazy[idx];
		lazy[2*idx+1]+=lazy[idx];
		it[2*idx]+=lazy[idx];
		it[2*idx+1]+=lazy[idx];
	}
	lazy[idx]=0;
}
void add(int idx,int l,int r,int lef,int rig,int val){
	if(l>rig||r<lef){
		return;
	}
	if(l>=lef&&r<=rig){
		it[idx]+=val;
		lazy[idx]+=val;
		return;
	}
	push_down(idx,l,r);
	add(2*idx,l,(l+r)/2,lef,rig,val);
	add(2*idx+1,(l+r)/2+1,r,lef,rig,val);
	it[idx]=min(it[2*idx],it[2*idx+1]);
}
void gan(int idx,int l,int r,int pos,int val){
	if(l>pos||r<pos){
		return;
	}
	if(l==r){
		it[idx]=min(it[idx],val);
		return;
	}
	push_down(idx,l,r);
	gan(2*idx,l,(l+r)/2,pos,val);
	gan(2*idx+1,(l+r)/2+1,r,pos,val);
	it[idx]=min(it[2*idx],it[2*idx+1]);
}
int getmin(int idx,int l,int r,int lef,int rig){
	if(l>rig||r<lef){
		return inf1;
	}
	if(l>=lef&&r<=rig){
		return it[idx];
	}
	push_down(idx,l,r);
	return min(getmin(2*idx,l,(l+r)/2,lef,rig),getmin(2*idx+1,(l+r)/2+1,r,lef,rig));
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,ans=inf,q;
	cin>>n>>q>>a>>b;
	query[0]=a;
	init(1,1,n);
	for(i=1;i<=q;i++){
		cin>>query[i];
	}
	for(i=1;i<=q;i++){
		j=min(getmin(1,1,n,1,query[i])+query[i],getmin1(1,1,n,query[i],n)-query[i]);
		add(1,1,n,1,n,abs(query[i]-query[i-1]));
		add1(1,1,n,1,n,abs(query[i]-query[i-1]));
		gan(1,1,n,query[i-1],j-query[i-1]);
		gan1(1,1,n,query[i-1],j+query[i-1]);
//		for(j=1;j<=n;j++){
//			cout<<getmin(1,1,n,j,j)+j<<' '<<getmin1(1,1,n,j,j)-j<<endl;
//		}
	}
	for(i=1;i<=n;i++){
		ans=min(ans,min(getmin(1,1,n,i,i)+i,getmin1(1,1,n,i,i)-i));
	}
	cout<<ans;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());

int main()
{
    int a,b;
    cin>>a>>b;
    int ans=1;
    rep(i,a){
        ans=min(ans+b,ans*2);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> a(n);
    for (int i = 0;i < n;++i) cin >> a[i].first >> a[i].second;
    ll l = 0,r = 2e18+1;
    while (r-l > 1) {
        ll mid = l+(r-l)/2;
        ll sum = 0;
        for (int i = 0;i < n;++i) sum += max(0LL,mid-a[i].first+a[i].second-1)/a[i].second;
        // cout << l << " " << r << " " << mid << " " << sum << endl;
        (sum < k ? l : r) = mid;
    }
    cout << l << endl;
}

Measured memory_bytes: 1792
from collections import defaultdict
import itertools
import copy

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

def p(arr,b="\n",e="\n"):
  print(b,end="")
  for i in arr:
    for j in i:
      print(j,end="")
    print()
  print(e,end="")

h,w = readInts()
a = [list(input()) for i in range(h)]

for i in range(h-1,-1,-1):
  boo = 1
  for j in range(w-1,-1,-1):
    if a[i][j]=="#":
      boo = 0
  if boo==1:
    del a[i]

for i in range(len(a[0])-1,-1,-1):
  boo = 1
  for j in range(len(a)-1,-1,-1):
    if a[j][i]=="#":
      boo = 0
  if boo==1:
    for j in range(len(a)-1,-1,-1):
      del a[j][i]

p(a,b="",e="")

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

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w * h;
    ans /= 2;
    int ans1 = 0;
    if(2 * x == w && 2 * y == h){
        ans1 =1;
    }
    printf("%.6f %d\n", ans, ans1);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var l = int.Parse(Console.ReadLine());

        Console.WriteLine(Math.Pow(l / 3d, 3).ToString("F12"));
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int test[12345678];
signed main() {
	for (int z = 0; z < 5; z++) {
		int n, d, m, a, b, ans = 0;
		cin >> d >> n >> m;
		vector<int> v; v.push_back(0);
		for (int h = 1; h < n; h++) {
			cin >> a; v.push_back(a);
		}
		v.push_back(d);
		sort(v.begin(), v.end());
		for (int h = 0; h < m; h++) {
			cin >> b;
			int ma = abs(v[lower_bound(v.begin(), v.end(), b) - v.begin()] - b);
			int mi = abs(b - v[lower_bound(v.begin(), v.end(), b) - v.begin() - 1]);
			ans += min(mi, ma);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	string s;
	int i = 1;
	getline(cin, s);
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (islower(s[i])) {
			s[i]=toupper(s[i]);
		}
		else if (isupper(s[i])) {
			s[i]=tolower(s[i]);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long H, long long W, std::vector<std::vector<long long>> a)
{
    ll cnt = 0;
    vector<pair<int, int>> f;
    vector<pair<int, int>> t;
    for (int i = 0; i < H - 1; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (a[i][j] % 2 != 0)
            {
                cnt++;
                f.push_back(make_pair(i + 1, j + 1));
                t.push_back(make_pair(i + 2, j + 1));
                a[i][j]--;
                a[i + 1][j]++;
            }
        }
    }
    for (int j = 0; j < W - 1; j++)
    {
        if (a[H - 1][j] % 2 != 0)
        {
            cnt++;
            f.push_back(make_pair(H, j + 1));
            t.push_back(make_pair(H, j + 2));
            a[H - 1][j]--;
            a[H - 1][j + 1]++;
        }
    }
    cout << cnt << endl;
    for (int i = 0; i < cnt; i++)
    {
        cout << f[i].first << " " << f[i].second << " " << t[i].first << " " << t[i].second << endl;
    }
}

int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    std::vector<std::vector<long long>> a(H, std::vector<long long>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    solve(H, W, std::move(a));
    return 0;
}


Measured memory_bytes: 6212
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = []
    for _ in range(N):
        a = int(input())
        A.append(a)

    B = sorted(A, key=lambda x: -x)
    for a in A:
        if a == B[0]:
            print(B[1])
        else:
            print(B[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 23296
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMultiplication1 solver = new AMultiplication1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMultiplication1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.readInt();
            int b = in.readInt();

            System.out.println(a * b);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    ll n;   cin >> n;
    vector<pair<ll, ll>> a(n);
    REP(i, n){
        ll x, l;    cin >> x >> l;
        a[i] = {x-l, x+l};
    }
    sort(ALL(a));
    ll x=a.back().first, res=1;
    //REP(i, n)   cout << a[i].first << ' ' << a[i].second << endl;
    REPD(i, n-1){
        if(a[i].second<=x){
            res += 1;
            x = a[i].first;
        }
    }
    cout << res << endl;
    
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
using namespace std;

ll dp[3000][3000];
int a[3000];

ll solve(int l,int r,int ply)
{
	if(l==r)
		return a[l];
	if(dp[l][r]!=-1)
		return dp[l][r];
	if(ply==0)
		return dp[l][r]=max(a[l]-solve(l+1,r,1),a[r]-solve(l,r-1,1));
	else if(ply==1)
		return dp[l][r]=max(a[l]-solve(l+1,r,0),a[r]-solve(l,r-1,0));
}

int main()
{
	int n,i,j;
	cin>>n;
	f(i,0,n)
		cin>>a[i];
	if(n==1)
	{
		cout<<a[0];
		return 0;
	}
	f(i,0,n)
		f(j,0,n)
			dp[i][j]=-1;
	solve(0,n-1,0);
	/*f(i,0,n)
	{
		f(j,0,n)
			cout<<dp[i][j]<<' ';
		cout<<endl;
	}*/
	cout<<dp[0][n-1];
}

Measured memory_bytes: 70656
# https://atcoder.jp/contests/abc140/tasks/abc140_d

# 性質ちゃんと考える
# 連長圧縮したあとならば、r-lが奇数である組み合わせをひっくり返すのに価値がある
# 反転しても中の幸福度は変化しない。
# 幸福度が改善するのはLR or RLでなくなった部分だけ

# LLLLLL (幸福度5(max))
# LRLRRL (幸福度1 (4人死んでるので)) #一回の操作が最善ならば必ず2人改善する(l==rの場合は1人改善)
# LLRLLL (幸福度3 (1から2人復活したので))


# もしラストをひっくり返すことで幸福度が上がるなら？
# ラストに0文字のLをfillする必要がある？
# LRRLRLRRLRLLR (max 12) (N-1) (今は3)
# 3回操作によって＋6なので9となる

# 10 1
# LLLLLRRRRR (max9) (いま8)
# そうかL→RとR→Lの個数をカウントすればいいんだ

N, K = list(map(int, input().split()))
S = input()

score = -1
LtoR = 0
RtoL = 0
pre = S[0]
for s in S:
    if pre == s:
        score += 1
    elif pre == 'L':
        LtoR += 1
    elif pre == 'R':
        RtoL += 1
    else:
        raise ValueError('something wrong')
    pre = s

# print(score, LtoR, RtoL)
if K <= min(LtoR, RtoL):
    print(score + 2 * K)
else:
    print(score + LtoR + RtoL)


Measured memory_bytes: 39536
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    cout << "ABC" << N << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String s1= sc.next();
		if (s.length()>s1.length()) {
			System.out.println("GREATER");
			return ;
		}
		if (s.length()<s1.length()) {
			System.out.println("LESS");
			return ;
		}
		for (int i=0;i<s.length();i++) {
			if(s.charAt(i)>s1.charAt(i)) {
				System.out.println("GREATER");
				return ;
			}
			if(s.charAt(i)<s1.charAt(i)) {
				System.out.println("LESS");
				return ;
			}
		}
		System.out.println("EQUAL");
		return ;
	}
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

int main(){
    string S;
    cin >> S;

    int L = S.size();
    int ans = 0;
    int left = 0, right = 0;
    while(right < L){
        while(right < L && (S[right] == 'A' || S[right] == 'C' || S[right] == 'G' || S[right] == 'T')){
            right++;
        }
        ans = max(ans, right - left);
        if(left == right) right++;
        left = right;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    int X, max=0, i, j;

    cin >> X;

    for(i=1; i<=1000; i++){
        for(j=2; j<=20; j++){
            if(pow(i, j) <= X && pow(i, j) > max){
                max = pow(i, j);
            }
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int>v(5);
    for(int& i : v)cin>>i;
    for(int i = 0 ; i < 5; ++i){
        //cout<<v[i]<<endl;
        if(v[i] == 0){
            cout<<(i + 1)<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3624
import itertools
H,W,m = map(int,input().split())
hs = [0 for _ in range(H)]
ws = [0 for _ in range(W)]
data = set()

for j in range(m):
	h,w = map(int,input().split())
	data.add((h-1, w-1))
	hs[h-1] += 1
	ws[w-1] += 1

#print(hs, ws)

maxhs = 0
maxws = 0
maxhsindex = []
maxwsindex = []

for i in range(H):
	targ = hs[i]
	if targ > maxhs:
		maxhs = targ
		maxhsindex = [i]
	elif targ == maxhs:
		maxhsindex.append(i)

for i in range(W):
	targ = ws[i]
	if targ > maxws:
		maxws = targ
		maxwsindex = [i]
	elif targ == maxws:
		maxwsindex.append(i)


for i, j in itertools.product(maxhsindex, maxwsindex):
	#print(i, j)
	if (i, j) not in data:
		print(max(hs)+max(ws))
		exit()
print(max(hs)+max(ws)-1)

Measured memory_bytes: 166720
// バケット法による解
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

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

    vector<int> d(N, 0);  // input
    for (int i = 0; i < N; ++i) cin >> d[i];

    vector<int> num(N+10, 0);  // バケット

    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  // d[i] が 1 個増える
    }

    sort(num.begin(), num.end(), greater<int>());

    int res = 0;  // 答えを格納
    for (int i = K; i < N; ++i) {
        if (num[i]) {  // 0 より大きかったら
            res += num[i];
        }
        else{
        	break;
        }
    }
    cout << res << endl;
}


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

ll dp[100000+10];
ll h[100000+10],n;



int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    for(int i=3;i<=n;i++)
    {
    	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
    cout<<dp[n];
    
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a.at(i) * 4 * m >= sum) count++;
  }
  
  if (count >= m) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int cnt(int v, int d) {
  int result = 0;
  while(v * result + 1 <= d) {
    result++;
  }

  return result;
}

int main(){
  int in(n, d, x);
  int list_input(a, n);

  int sum = 0;
  forin(v, a) {
    sum += cnt(v, d);
  }
  out(sum + x);
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		Set<Integer> s = new HashSet<Integer>();
		s.add(sc.nextInt()); s.add(sc.nextInt()); s.add(sc.nextInt());
		System.out.println(s.size());
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35488
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class BEasyLinearProgramming {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll a,b,c,k;
        in>>a>>b>>c>>k;
        if(k<=a) out<<k<<endl;
        else if(k<=a+b) out<<a<<endl;
        else out<<a-(k-a-b)<<endl;
	}
};


int main() {
	BEasyLinearProgramming solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3192