akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
bool water[3010], sugar[3010];
double maxparsent;
double small = 0.00000001;
int ans1, ans2;
int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	for (int i = 0; i <= f; i += a) {
		for (int j = 0; j <= f - i; j += b)water[i + j] = true;
	}
	for (int i = 0; i <= f; i += c) {
		for (int j = 0; j <= f - i; j += d)sugar[i + j] = true;
	}
	for (int i = 1; i <= f; i++) {
		for (int j = 1; j <= f - i; j++) {
			if (!water[i] || !sugar[j])continue;
			if ((double)e / (100 + e) < (double)j / (i + j))continue;
			if (maxparsent < (double)j / (i + j) + small) {
				maxparsent = (double)j / (i + j);
				ans1 = i + j;
				ans2 = j;
			}
		}
	}
	if (maxparsent <= 0)cout << a << " " << 0 << endl;
	else cout << ans1 << " " << ans2 << endl;
	return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int d[k];
    for(int i=0;i<k;i++){
        cin>>d[i];
    }
    int t=n;

    bool ok=false;

    while(ok==false){
        ok=true;
        t=n;
        for(int i=0;i<k;i++){
            t=n;
            while(t){
                if(t%10==d[i]){
                    ok=false;
                    break;
                }
                else t/=10;
            }
            if(!ok) break;
        }
        if(ok==false) n++;
        
    }

    cout<<n;

}

Measured memory_bytes: 256
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod 998244353
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 1000005


// Driver code to test above functions
int32_t main()
{
  
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, ans = 0;
    cin >> n;
    map<int, int> mp;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;

        ans += mp[i-x];

        mp[i+x]++;
    }

    cout << ans;

    return 0;

} 


Measured memory_bytes: 26412
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000

int main(){
  string str;
  while(getline(cin,str)){
    vector<double> vec;
    stringstream ss(str);
    int wid,n=0;
    ss >> wid;
    while(!ss.eof()){
      double s;
      ss >> s;
      vec.push_back(s);
      n++;
    }
    double dp[1<<n][n];
    for(int i=0;i<(1<<n);i++){
      for(int j=0;j<n;j++){
	dp[i][j] = INF;
      }
    }
    for(int i=0;i<n;i++){
      dp[(1<<n)-1-(1<<i)][i] = vec[i];
    }
    for(int i=(1<<n)-2;i>-1;i--){
      for(int j=0;j<n;j++){
	if(!(i & (1<<j))){
	  for(int k=0;k<n;k++){
	    dp[i][j] = min(dp[i][j],dp[i | (1<<j)][k] + 2*sqrt(vec[j]*vec[k]));
	  }
	}
      }
    }
    double ans = INF;
    for(int i=0;i<n;i++){
      ans = min(ans,dp[0][i]+vec[i]);
    }
    if(ans <= wid) cout << "OK" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 1652
N, M = map(int, input().split())
A = list(map(int, input().split()))
ans, sA, d = 0, 0, {0: 1}
for a in A:
    sA = (sA + a) % M
    if sA in d:
        d[sA] += 1
    else:
        d[sA] = 1
    ans += d[sA] - 1

print(ans)


Measured memory_bytes: 14424
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

int main()
{
  int X,Y;
  cin >> X >> Y;
  cout << X + Y / 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define sz(x) int (x.size());
//typedef pair<int,int> P;

using namespace std;
const int MOD=1000000007;
const int INF=1001001001;


int main(){
  string s;
  cin>>s;
  string ans="No";
  char c=s[0];
  if (s[1]!=s[0])ans="Yes";
  if (s[2]!=s[0])ans="Yes";
  if (s[1]!=s[2])ans="Yes";
cout<<ans;


}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);

    int i;
    int j;
    int ans=0;
    int wa=0;
    for(i=a;i<=n;i++){
        j=i;

        wa+=j%10;
        j=j/10;
        wa+=j%10;
        j=j/10;
        wa+=j%10;
        j=j/10;
        wa+=j%10;
        j=j/10;
        wa+=j%10;

        if(a<=wa && wa<=b){
            ans+=i;      
        }
        wa =0;
    }
    printf("%d",ans);
        
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <deque>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int from[10];
int to[10];

void PushInt(deque<char> &deq, int M) {
  char str[100];
  sprintf(str, "%u", (unsigned int)M);
  for (int i = 0; str[i]; i++) {
    deq.push_back(str[i]);
  }
}

deque<char> local(int digit, int from, int to) {
  deque<char> ret;
  if (to == 0) { ret.push_back('0'); return ret; }
  int M = 1 << digit;
  for (int i = 0; i <= digit; i++) {
    if (i != 0) {
      ret.push_front('(');
      ret.push_back('&');
    }
    int invM = M / (1 << i);
    // create
    int f = (from >> i) & 1;
    ret.push_back('(');
    ret.push_back('(');
    if (f == 0) {
      ret.push_back('(');
      ret.push_back('~');
      ret.push_back('x');
      ret.push_back(')');
    } else {
      ret.push_back('x');
    }
    ret.push_back('*');
    PushInt(ret, invM);
    ret.push_back(')');
    ret.push_back('&');
    PushInt(ret, M);
    ret.push_back(')');

    if (i != 0) {
      ret.push_back(')');
    }
  }
  return ret;
}

deque<char> solve(int from, int to) {
  deque<char> ret;
  for (int digit = 0; digit < 8; digit++) {
    if (digit != 0) {
      ret.push_front('(');
      ret.push_back('|');
    }
    deque<char> nret = local(digit, from, (to >> digit) & 1);
    FORIT(it, nret) { ret.push_back(*it); }
    if (digit != 0) {
      ret.push_back(')');
    }
  }
  //cout << from << endl;
  //FORIT(it, ret) {
  //  cout << *it;
  //}
  //cout << endl;
  return ret;
}

int main() {
  while (scanf("%d", &n) > 0) {
    deque<char> deq;
    REP(i, n) { scanf("%d %d", &from[i], &to[i]); }
    REP(iter, n) {
      if (iter != 0) {
        deq.push_front('(');
        deq.push_back('|');
      }
      deque<char> nret = solve(from[iter], to[iter]);
      FORIT(it, nret) { deq.push_back(*it); }
      if (iter != 0) {
        deq.push_back(')');
      }
    }
    FORIT(it, deq) {
      putchar(*it);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
  int x[10000];
  int n = 0;
  int i;
  
  do{
    
    scanf("%d", x+n);
    n++;
  }while(*(x+n-1));
  
  for( i = 0; i < n-1; i++ ){
    printf("Case %d: %d\n", i+1, x[i]); 
  }

  return 0;
  
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const int N = 1000005, mod = 1e9 + 7;
const ll inf = 1e18;

void solve(){
    ll i, n;
    cin >> n;
    i = n;
    string ans;
    while(i != 0){
        char c;
        if(i % 26 == 0){
            c = 'z';
            i = i / 26 - 1;
        }
        else{
            c = 'a' + i % 26 - 1;
            i = i / 26;
        }
        ans += c;
    }
    reverse(all(ans));
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<set>
#define ll long long
using namespace std;
int main()
{
	ll n,a,b,x,y;
	scanf("%lld %lld %lld",&n,&a,&b);
	x=n/(a+b);
	y=n%(a+b);
	if(y>a)
	y=a;
	if(a==0)
	printf("0\n");
	else
	printf("%lld\n",x*a+y);
	return 0;

	
 } 
//printf("%d%c",mp[i][j],j==n?'\n':' ');


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

int main(){
	int n; cin>>n;
	vector<int> a;
	a.push_back(1);
	for(int i=9;i<=n;i*=9) a.push_back(i);
	for(int i=6;i<=n;i*=6) a.push_back(i);
	int dp[n+1]; rep(i,n+1) dp[i]=INF;
	dp[0]=0;
	int m=a.size();
	rep(i,n+1){
		for(int j=0;j<m;j++){
			if(i-a[j]>=0){
				dp[i]=min(dp[i-a[j]]+1,dp[i]);
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;

	cin >> N;

	cout << 180 * (N - 2) << endl;

	Never To return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split() ) )
flag = True
ans = 0
while True:
	for i in range(len(A)):
		if A[i] % 2 != 0:
			flag = False
		A[i] = A[i] / 2
	if flag == False:
		break
	ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
    }
    int right = 0; //右側
    int left = 0;
    for (int i = 0; i < n; i++)
    {
        right += w[i];
    }
    int ans = INF;
    chmin(ans, right - left);
    for (int i = 0; i < n; i++)
    {
        right -= w[i];
        left += w[i];
        // cout << right << " " << left << endl;
        chmin(ans, abs(right - left));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i=0;i<n;i++)
		cin >> p[i];
	int cnt=0;
	for(int i=1;i<n-1;i++)
	{
		if(p[i-1]<p[i] and p[i]<=p[i+1])
			cnt++;
		else if(p[i+1]<p[i] and p[i]<=p[i-1])
			cnt++;
	}
	cout << cnt << endl;




}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	//	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

// Data :
type Data struct {
	X string
}

// Datas :
type Datas []Data

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	return p[i].X < p[j].X
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	L := nextInt()
	s := make(Datas, N)

	for i := 0; i < N; i++ {
		s[i].X = nextString()
	}

	out(N, L, s)
	sort.Sort(s)
	out(s)

	ans := ""
	for i := 0; i < N; i++ {
		ans = ans + s[i].X
	}
	fmt.Println(ans)

}


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

int main() {

  double v;
  while(cin >> v) {
  double t = v/9.8;
  double y = 4.9*t*t;
  int n = 0;
  while(1) {
    if(y < 5*n-5) break;
    n++;
  }
  cout << n  <<endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cmath>
#include <cstring>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 5;
pii sx[N];
int ex[N];
int ans[N];
int x[N], d[N];
int n, l, t;
 
void solve() {
    ll c = 0;
    for (int i=0; i<n; ++i) {
        int dir = d[i] == 2 ? -1 : 1;
        ll pos = (ll)x[i] + dir * t;
        c += (pos > 0 ? pos/l : (pos-l+1)/l);
        ex[i] = (pos%l+l) % l;
    }
    c = (c%n+n) % n;
    sort(ex, ex+n);
    for (int i=0; i<n; ++i) {
        ans[sx[i].second] = ex[(i+c)%n];
    }
    for (int i=0; i<n; ++i) {
        printf("%d\n", ans[i]);
    }
}
 
int main() {
    scanf("%d%d%d", &n, &l, &t);
    for (int i=0; i<n; ++i) {
        scanf("%d%d", &x[i], &d[i]);
        sx[i] = pii(x[i], i);
    }
    solve();
    return 0;
}

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


int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int ans=0;
  for(int i=0;i<n;++i){
    int a,b;
    cin >> a >> b;
    if(a>=h && b>=w) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    S = input()
    N = len(S)
    r_counter = 0
    l_counter = 0
    ans = [0] * N

    for i in range(N):
        if S[i] == 'R':
            r_counter += 1
        else:
            if r_counter % 2 == 1:
                ans[i-1] += r_counter // 2 + 1
                ans[i] += r_counter // 2
            else:
                ans[i-1] += r_counter // 2
                ans[i] += r_counter // 2
            r_counter = 0

    for i in range(N-1, -1, -1):
        if S[i] == 'L':
            l_counter += 1
        else:
            if l_counter % 2 == 1:
                ans[i+1] += l_counter // 2 + 1
                ans[i] += l_counter // 2
            else:
                ans[i+1] += l_counter // 2
                ans[i] += l_counter // 2
            l_counter = 0

    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48440
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long r,d,x2000,ii;
  cin >> r >> d >> x2000;

  for(ii=1;ii<=10;ii++){
    x2000 = r*x2000-d;
    cout << x2000 << endl;
  }
  return 0;
}


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

int main() {
    string X;
    cin>>X;
    //vector<int>f(X.size());
    int f=0;
    for(int i=0;i<X.size();i++){
        f+=int(X.at(i))-48;
    }
    int N=0;
    int p=1;
    for(int j=0;j<X.size();j++){
        N += (int(X.at(X.size()-j-1))-48)*p;
        p*=10;
    }
    if(N%f==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long n,m,sum,kk,jk,a[2];
int main(){
	scanf("%lld",&n);
	m=n;
	while(m!=0){
		kk=m%10;
		if(kk!=0){
			++jk;
			a[0]=kk;
		}
		sum+=kk;
		m/=10;
	}
	if(jk==1&&a[0]==1)printf("%lld",sum*10);
	else printf("%lld",sum);
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	cin >> n;
	cout << 3 * n * n << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=405,M=1e9+7;
int n,m,a[N],b[N],f[N][N],dp[N][N];
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)scanf("%lld",&b[i]);
	for (int i=1;i<=400;i++)
		for (int j=0;j<=m;j++)f[i][j]=(f[i-1][j]+ksm(i,j))%M;
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=m;j++)
			for (int k=0;k<=j;k++)
				(dp[i][j]+=dp[i-1][j-k]*(f[b[i]][k]-f[a[i]-1][k]+M))%=M;
	printf("%lld\n",dp[n][m]);			
}

Measured memory_bytes: 2816
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
string s;
int a[100010];
int dfs(int x)
{
	if(x==0)
	{
		if(s[0]=='R'&&s[1]=='L')
		{
			a[0]=0;
			return 0;
		}
		else
		{
			return a[x]=dfs(1);
		}
	}
	if(s[x]=='R'&&s[x+1]=='L'||s[x]=='L'&&s[x-1]=='R')
	{
		a[x]=x;
		return x;
	}
	if(~a[x])
	{
		return a[x];
	}
	int q;
	if(s[x]=='R')
		q=dfs(x+1);
	else
	{
		q=dfs(x-1);
	}
	a[x]=q;
	return q;
}
int b[100010];
int main()
{
	int i,j,k,n,m,x,y;
	cin>>s;
	memset(a,-1,sizeof(a));
	n=s.size();
	for(i=0;i<n;i++)
	{
		x=dfs(i);
		if(abs(x-i)%2==0)
		{
		//	printf("%d ",x);
			b[x]++;
		}
		else
		{
		//	printf("%d ",);
			b[s[x]=='R'?x+1:x-1]++;
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d ",b[i]);
	}
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int ans1 = 0;
		int ans2 = 0;

		if ( A < B ) {
			ans1 = A;
		} else {
			ans1 = B;
		}

		if ( C < D ) {
			ans2 = C;
		} else {
			ans2 = D;
		}
		System.out.println( ans1 + ans2 );
	}
}

Measured memory_bytes: 21844
// AOJ 2783 Parentheses
// 2018.2.2 bal4u

#include <stdio.h>

void pr(long long len, char c) { while (len--) putchar(c); }

int main()
{
	long long a, lo, hi, mi;

	scanf("%lld", &a);
	lo = 0, hi = a+1;
	while (hi - lo > 1) {
		mi = (lo + hi) >> 1;
		if ((mi*(mi+1)>>1) <= a) lo = mi; else hi = mi;
	}
	a -= lo*(lo+1) >> 1;
	if (a) pr(a, ')'), putchar('('), pr(1+lo-a, ')');
	else   pr(lo, ')');
	pr(lo, '('), putchar('\n');
	return 0;
}


Measured memory_bytes: 2080
h,w,m = gets.chomp.split.map(&:to_i)
targets_h = Array.new(h,0)
targets_w = Array.new(w,0)
targets = []
m.times do 
  h,w = gets.chomp.split.map(&:to_i)
  targets_h[h-1] +=1
  targets_w[w-1] +=1
  targets << [h,w]
end
maxh = targets_h.max
maxw = targets_w.max
ans = maxh + maxw
maxcnt = targets_h.count(maxh) * targets_w.count(maxw)
targets.each do |h,w|
  maxcnt -=1 if targets_h[h-1] == maxh && targets_w[w-1] == maxw
end
if maxcnt == 0
  puts ans-1
else
  puts ans
end

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

int main() {
	vector<vector<int>> A(3, vector<int>(3));
	int N;
	vector<int> b(N);

	for (int i = 0; i < 3; i++) {
		cin >> A.at(i).at(0) >> A.at(i).at(1) >> A.at(i).at(2);
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> b.at(i);
	}

	vector<vector<int>> bingo(3, vector<int>(3, 0));
	for (int i = 0; i < N; i++) {
		bool hit = false;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (A[j][k] == b[i]) {
					bingo[j][k] = 1;
					hit = true;
					break;
				}
			}
			if (hit) {
				break;
			}
		}
		hit = true;
	}

	bool bingoed = false;
	int check = 0;
	//横の列
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (bingo[i][j] == 1) {
				check++;
			}
		}
		if (check == 3) {
			bingoed = true;
		}
		check = 0;
	}

	//縦の列
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (bingo[j][i] == 1) {
				check++;
			}
		}
		if (check == 3) {
			bingoed = true;
		}
		check = 0;
	}

	//斜め
	if (bingo[0][0] + bingo[1][1] + bingo[2][2] == 3 || bingo[0][2] + bingo[1][1] + bingo[2][0] == 3) {
		bingoed = true;
	}

	if (bingoed) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

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

    ll ans = 1e18;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ll a = i;
            ll b = N / i;
            ans = min(ans, a + b - 2);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]
import heapq
class DijkstraList():
	#隣接リスト版
	#同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ
	def __init__(self, adj, start):
		self.list = adj
		self.start = start
		self.size = len(adj)

	def solve(self):
		self.dist = [10**30 for _ in range(self.size)]
		self.dist[self.start] = 0
		self.q = []
		self.cnt = 0

		heapq.heappush(self.q, (0, self.start))

		while self.q and self.cnt < self.size:
			u_dist, u = heapq.heappop(self.q)
			if self.dist[u] < u_dist:
				continue
			for v, w in self.list[u]:
				if self.dist[v] > u_dist + w:
					self.dist[v] = u_dist + w
					heapq.heappush(self.q, (self.dist[v], v))
			self.cnt += 1
		return

	def distance(self, goal):
		return self.dist[goal]

while True:
	n, m, l = map(int, input().split())
	if n == 0:
		break
	adj = [[] for _ in range(n*(l+1))]
	for _ in range(m):
		a, b, d, e = map(int, input().split())
		a, b = a-1, b-1
		for i in range(l+1):
			adj[i*n + a].append((i*n + b, e))
			adj[i*n + b].append((i*n + a, e))
			if i >= d:
				adj[i*n + a].append(((i-d)*n + b, 0))
				adj[i*n + b].append(((i-d)*n + a, 0))

	dijk = DijkstraList(adj, l*n)
	dijk.solve()
	ans = 10**7
	for i in range(l+1):
		ans = min(ans, dijk.dist[i*n + n-1])
	print(ans)


Measured memory_bytes: 87452
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

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

	if (C - A - B < 0LL) {
		cout << "No" << endl;
		return 0;
	}

	long long S1 = 4LL * A * B;
	long long S2 = (C - A - B) * (C - A - B);
	if (S1 < S2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List (foldl')
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main :: IO ()
main = do
  n <- readLn
  xs <- replicateM n (map read <$> words <$> getLine)
  solve n xs

solve :: Int -> [[Int]] -> IO ()
solve n xs = do putStrLn "Preorder"
                printList $ preOrder bt
                putStrLn "Inorder"
                printList $ inOrder bt
                putStrLn "Postorder"
                printList $ postOrder bt
  where ti = mkti n xs
        bt = mkBTree ti (findRoot ti)

mkti :: Int -> [[Int]] -> Vector (Maybe Int, Maybe Int, Maybe Int)
mkti n = foldl' f (V.replicate n (Nothing, Nothing, Nothing))
  where f v [i, l, r] = let x = let (bp, _, _) = v ! i in [(i, (bp, if l == (-1) then Nothing else Just l, if r == (-1) then Nothing else Just r))]
                            y = if l == (-1) then [] else let (_, ll, lr) = v ! l in [(l, (Just i, ll, lr))]
                            z = if r == (-1) then [] else let (_, rl, rr) = v ! r in [(r, (Just i, rl, rr))]
                        in v // (x ++ y ++ z)

findRoot :: Vector (Maybe Int, Maybe Int, Maybe Int) -> Maybe Int
findRoot = V.findIndex f
  where f (Nothing, _, _) = True
        f _ = False

data BTree a = Leaf | Node a (BTree a) (BTree a) deriving Show

mkBTree :: Vector (Maybe Int, Maybe Int, Maybe Int) -> Maybe Int -> BTree Int
mkBTree ti rt = f rt
  where f (Just i) = let (_, l, r) = ti ! i in Node i (f l) (f r)
        f Nothing = Leaf

foldPre :: (a -> b -> b) -> b -> BTree a -> b
foldPre f z Leaf = z
foldPre f z (Node x l r) = let y1 = foldPre f z r
                               y2 = foldPre f y1 l
                           in f x y2

foldIn :: (a -> b -> b) -> b -> BTree a -> b
foldIn f z Leaf = z
foldIn f z (Node x l r) = let y1 = foldIn f z r
                              y2 = f x y1
                          in foldIn f y2 l

foldPost :: (a -> b -> b) -> b -> BTree a -> b
foldPost f z Leaf = z
foldPost f z (Node x l r) = let y1 = f x z
                                y2 = foldPost f y1 r
                            in foldPost f y2 l

preOrder :: BTree a -> [a]
preOrder = foldPre (:) []

inOrder :: BTree a -> [a]
inOrder = foldIn (:) []

postOrder :: BTree a -> [a]
postOrder = foldPost (:) []

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . (' ':) . unwords . map show



Measured memory_bytes: 4824
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long long int N,K;
    cin >> N >> K;
    long long int X[100010];
    for(int i = 0;i < N;i++) cin >> X[i];
    long long int memo = 0;
    long long int ans = 9876543210;
    for(int i = 0;i < N-K+1;i++){
        ans = min(ans,abs(X[i]) + abs(X[i+K-1] - X[i]));
        ans = min(ans,abs(abs(X[N-i-1]) + abs(X[N-i-1] - X[N-i-K])));
    }
    cout << ans <<   endl;

}

Measured memory_bytes: 1024
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	if( (H%h) == 0 && (W%w) == 0 ){
		cout << "No" << endl;return;
	}
	vector< vector<int> > v(H,vector<int>(W,0));
	LL sum = 0;
	LL Mnum = (H/h)*(W/w);
	LL Pnum = ((H+h-1)/h) * ((W+w-1)/w);
	LL Plus = (Pnum-1)/(Pnum-Mnum) + 1;
	for(int A=0;A<H;++A){
		for(int B=0;B<W;++B){
			if( A%h == 0 && B%w == 0 ){
				//v[A][B] = 1;
				v[A][B] = Plus;
				sum += v[A][B];
			}
			else if( A%h == h-1 && B%w == w-1 ){
				//v[A][B] = -2;
				v[A][B] = -(Plus+1);
				sum += v[A][B];
			}
		}
	}
	//cerr << sum << endl;
	cout << "Yes" << endl;
	for(int A=0;A<H;++A){
		for(int B=0;B<W;++B){
			if( B ) cout << " ";
			cout << v[A][B];
		}
		cout << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;

int main(){
  int x,y,z;
  cin>>x>>y>>z;

  cout<<z<<" "<<x<<" "<<y;

}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int h[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
    }
    int dp[n + 1];
    dp[1] = 0;
    dp[2] = dp[1] + abs(h[2] - h[1]);
    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] << "\n";
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A[5]; rep(i, 5) cin >> A[i];
    int mn = mod;
    rep(i, 5) if(A[i]%10 > 0) mn = min(mn, A[i]%10);
    int ans = 0;
    rep(i, 5){
        if(A[i]%10 > 0) ans += A[i] + (10-A[i]%10);
        else ans += A[i];
    }
    if(mn != mod) ans -= 10-mn;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
T= int(input())
w = list(map(int, input().split()))

m = sum(w)
b = m
answer = T
for t in range(1, T):
    k = sum(w[0:t+1])
    diff= abs(2*k - m) 
    if diff < b:
        b = diff 
    else:
        break
print(b)

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int h, w, a, b;

int main(){
	scanf("%d %d %d %d", &h, &w, &a, &b);
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			int output = (i <= b) ^ (j <= a);
			printf("%d", output);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1280
#create date: 2020-07-25 09:12

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a = na()
    print(sum(a) - max(a))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

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

  rep(i,s.size()) {
    s[i] = s[i] + n;
    if (s[i] > 'Z') s[i] -= 26;
  }
  
  //rep(i,s.size()) printf("%d%c", s[i], i==s.size()-1?'\n':' ');
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	long long a,b,x;
	cin>>a>>b>>x;
	
	if(a==0)
	{
		cout<<b/x+1;
	}
	
	else 
	cout<<b/x-(a-1)/x;
	
}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;


void solve(){
    int n;
    scanf("%d",&n);
    printf("%.10f\n",((n+1)/2*1.0)/n );
    
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,h,w
    real(8)::a,b
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) h,w
    if (h==1 .or. w ==1)then
        write(*,*)1
        stop
    end if
    if (mod(h*w,2)==0)then
        write(*,*) h*w/2
    else
        write(*,*) h*w/2+1
    end if

  
    stop
end program sample
  



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

long long N;
long long X[20];
long long Y[20];
long long P[20];

#define NO 1
#define YOKO 2
#define TATE 3
long long pat[20];

//   num     , cost
map<long long, long long> memo;

long long xx[20];
long long yy[20];
long long noidx[20];

void cal() {
	long long xxidx = 0;
	long long yyidx = 0;
	long long noidxidx = 0;
	long long sum = 0;

	for(long long i = 0; i < N; i++) {
		if(pat[i] == TATE) {
			xx[xxidx] = X[i];
			xxidx++;
		} else if(pat[i] == YOKO) {
			yy[yyidx] = Y[i];
			yyidx++;
		} else {
			noidx[noidxidx] = i;
			noidxidx++;
		}
	}

	for(long long tmptmp = 0; tmptmp < noidxidx; tmptmp++) {
		long long i = noidx[tmptmp];
		long long tmp = min(abs(X[i]), abs(Y[i]));
		for(long long j = 0; j < xxidx; j++) {
			long long x = xx[j];
			tmp = min(tmp, abs(x - X[i]));
		}
		for(long long j = 0; j < yyidx; j++) {
			long long y = yy[j];
			tmp = min(tmp, abs(y - Y[i]));
		}
		sum += tmp * P[i];
	}

	long long num = xxidx + yyidx;
	memo[num] = min(memo[num], sum);
}

void dfs(long long dep) {
	if(dep == N) {
		cal();
		return;
	}
	pat[dep] = NO;
	dfs(dep+1);
	pat[dep] = YOKO;
	dfs(dep+1);
	pat[dep] = TATE;
	dfs(dep+1);
}


int main(){
	cin >> N;
	for(long long i = 0; i < N; i++) {
		cin >> X[i] >> Y[i] >> P[i];
		memo[i] = LONG_MAX;
	}

	dfs(0);

	for(long long i = 0; i < N + 1; i++) {
		cout << memo[i] << endl;
	}
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
using pp=pair<int,pair<int,int>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  int X;
  cin>>X;
  int x=X/200;
  cout<<10-x<<endl;
}


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

const int MAX_N = 55;
int mp[MAX_N][MAX_N];

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        ++mp[a][b]; ++mp[b][a];
    }
    int load[N];
    for(int i = 0; i < N; ++i) {
        int res = 0;
        for(int j = 0; j < N; ++j) res += mp[i][j];
        load[i] = res;
    }
    for(int i = 0; i < N; ++i) printf("%d\n", load[i]);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
class Main{
  public static int solution(int x){
    if(x == 0)
      return 1;
    return 0;
  }
 
public static void main(String[] args) throws Exception{
		BufferedReader buff=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(buff.readLine());
		System.out.println(solution(n));
	}
}

Measured memory_bytes: 32580
/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Map<Character, Integer> map = new TreeMap<Character, Integer>();

		for (char c = 'a'; c <= 'z'; c++) {
			map.put(c, 0);
		}

		BufferedReader br =
        new BufferedReader(new InputStreamReader(System.in));

        String line = "";
	    while ((line = br.readLine()) != null) {
			for (int i = 0; i < line.length(); i++) {
				char c = line.toLowerCase().charAt(i);
				if (map.containsKey(c)) {
	 				map.put(c, map.get(c) + 1);
				}
			}	    	
	    }

		for (Map.Entry<Character, Integer> entry: map.entrySet()) {
			System.out.println(entry.getKey() + " : " + entry.getValue());
		}
	}
}

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N; cin >> N;
    UnionFind U(N);
    int M; cin >> M;
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        U.merge(a, b);
    }

    int ans = 0;
    rep(i, N){
        int now = U.size(i);
        ans = max(ans, now);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6412
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        logs: [usize; n],
    }
    let mut l = 0;
    let mut r = 1e9 as usize;
    while r - l > 1 {
        let m = (r + l) / 2;
        let f = || {
            let mut s = 0;
            for &a in &logs {
                s += (a - 1) / m;
            }
            s <= k
        };
        if f() {
            r = m
        } else {
            l = m
        }
    }
    println!("{}", r)
}


Measured memory_bytes: 5440
program main
  implicit none
  integer(8) :: n, i, j, k, p, q, m, y(0:5), dp(0:12), dppre(0:12)
  character(10 ** 5) :: s

  m = 10 ** 9 + 7
  y(0:5) = (/1, 10, 9, 12, 3, 4/)
  dp(0) = 1  ! dp(x) は (その桁までの値 % 13) == x となる通りの数
  dp(1:) = 0

  read (*, *) s
  n = len_trim(s)
  do i = 1, n  ! 1の位から順に
    dppre(:) = dp(:)
    dp(:) = 0
    j = n - i + 1
    if (s(j:j) == "?") then
      do p = 0, 9
        q = y(modulo(i - 1, 6_8)) * p  ! これだけ値が増える
        do k = 0, 12  ! もらうDP
          dp(k) = modulo(dp(k) + dppre(modulo(k - q, 13_8)), m)
        end do
      end do
    else
      read (s(j:j), *) p
      q = y(modulo(i - 1, 6_8)) * p  ! これだけ値が増える
      do k = 0, 12  ! もらうDP
        dp(k) = modulo(dp(k) + dppre(modulo(k - q, 13_8)), m)
      end do
    end if
  end do
  write (*, "(i0)") dp(5)
end program main


Measured memory_bytes: 700
local read = io.read
local N, K = read("*n", "*n")
local l = {}
for i = 1, N do
	l[i] = read("*n")
end

table.sort(l, function(x, y) return x > y end)
local out = 0
for i = 1, K do
	out = out + l[i]
end

print(out)


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x, y, z, d;
	cin >> x >> y >> z;
	d = x;
	x = y;
	y = d;
	d = x;
	x = z;
	z = d;
	cout << x << " " << y << " " << z;
	return 0;
}


Measured memory_bytes: 256
import itertools

n,k=map(int,input().split())

N=[i for i in range(n)]
All=list(itertools.combinations(N,k))
Calc=[sum([2**All[i][j] for j in range(k)]) for i in range(len(All))]
Calc_sort=sorted(Calc)

if k==0:
    print("0:")
else:
    while len(All)!=0:
        c=Calc_sort[0]
        x=Calc.index(c)
        print(str(c)+": "+' '.join(map(str,All[x])))
        All.pop(x)
        Calc.pop(x)
        Calc_sort.pop(0)



Measured memory_bytes: 14436
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t; 
    //cin>>t;
    t=1;
    while(t--){
        ll n,k; cin>>n>>k;
        ll h[n];
        rep(i,0,n-1){cin>>h[i];}
        ll dp[n];
        rep(i,0,n-1){dp[i] = INF;}
        dp[0]=0; 
        rep(i,1,n-1){
            rep(j,1,k){
                if(i-j>=0){
            dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]));}
            }
        }
        cout<<dp[n-1];
    }
}


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

long long gcd(ll x, ll y){
	if(x > y) swap(x, y);
	while(x != 0){
		y %= x;
		swap(x, y);
	}
	return y;
}


int main(){
	int K; cin >> K;
	ll ans = 0;
	for(int i=1; i<=K; i++){
		for(int j=1; j<=K; j++){
			for(int p=1; p<=K; p++){
				ans += gcd(i, gcd(j, p));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
# input
N = int(input())
L = []
for n in range(N):
    L.append(int(input()))

def solve():
    L.sort()

    pre = -1
    count = 0
    for l in L:
        if pre != l:
            count += 1
        pre = l

    print(count)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int sum=0;
int jie[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int all=0;
	for(int i=2;i<=n;i+=2){
		all+=a[i];
	}
//	cout<<"sum:"<<sum<<"all:"<<all<<endl;
	jie[1]=(sum/2-all);
	cout<<jie[1]*2<<" ";
	for(int i=2;i<=n;i++){
		jie[i]=a[i-1]-jie[i-1];
		cout<<jie[i]*2<<" ";
	}
	return 0;
} 
//

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

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

    for(ll A = -1000; A <= 1000; A++)
    {
        for(ll B = -1000; B <= 1000; B++)
        {
            if(pow(A,5) - pow(B,5) == X)
            {
                cout << A << ' ' << B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4120
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$a = $sc->nextInt();
$b = $sc->nextInt();
$h = $sc->nextInt();
$m = $sc->nextInt();
$cos_a = null;

// a^2 = b^2 + c^2 − 2bc cos ∠A 
$hour_needle_degree_from_top = (60*$h + $m)/(60 * 12)*360;
$minute_needle_degree_from_top = $m/60*360;
$deg_c = abs($hour_needle_degree_from_top - $minute_needle_degree_from_top);
$cos_c = cos(deg2rad($deg_c));

$c_square = $a*$a + $b*$b - 2*$a*$b*$cos_c;
$c = sqrt($c_square);

echo $c.PHP_EOL;

Measured memory_bytes: 16576
import Data.Array
import Data.List
import Control.Monad

getAB::[Int]->Int->(Int,Int)
getAB ls n = let a:b:_= drop ((div n 2)-1) (sort ls) in (a,b)

solver::Array Int Int -> (Int,Int) -> Int -> Int
solver ar (a,b) i = if (ar!i)<=a then b else a

main::IO()
main=do
  nc<-getLine
  let n = read nc ::Int
  d<-getLine
  let dat = map read (words d)
  let (a,b) = getAB dat n
  let ar = listArray (1,n) dat
  forM_ [1..n] (\i -> print (solver ar (a,b) i))

Measured memory_bytes: 126844
#include<iostream>
#include<string>
#include<cmath>
#include<stack>
#include<algorithm>
using namespace std;
int main()
{
	string s;cin>>s;
	int c=0,n=s.size();
	stack<int> S;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='S')
		{
			S.push(1);
		}
		else
		{
			if(!S.empty())
			{
				S.pop();
				c++;
			}
		}
	}
	cout<<n-c*2<<endl;
	return 0;
}

Measured memory_bytes: 900
using System;
class Program
{
  static void Main (string[] args)
  {
    string[] input1 = Console.ReadLine().Split(' ');
    string[] input2 = Console.ReadLine().Split(' ');
    int H = int.Parse(input1[0]);
    int W = int.Parse(input1[1]);
    int h = int.Parse(input2[0]);
    int w = int.Parse(input2[1]);
    
    int all = H * W;
    int black = (w * H) + (h * W) - (h * w);
    Console.WriteLine(all - black);
  }
}


Measured memory_bytes: 11092