akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <list>
#include <string>
#include <complex>
using namespace std;

#define DOWN 92
#define UP 47
#define FLAT 95

struct slope {
  int type;
  int height;
};

int main() {
  string input;
  cin >> input;
  int n = input.length();

  list<slope> shape;
  slope tmp;
  int current_height = 0;
  for (int i = 0; i < n; i++) {
    switch (input[i]) {
    case DOWN:
      tmp.type = DOWN;
      tmp.height = current_height--;
      break;
    case UP:
      tmp.type = UP;
      tmp.height = ++current_height;
      break;
    case FLAT:
      tmp.type = FLAT;
      tmp.height = current_height;
      break;
    }
    shape.push_back(tmp);
  }

  //for (list<slope>::iterator i = shape.begin(); i != shape.end(); i++) {
  //  cout << i->type << " " << i->height << endl;
  //}

  list<float> area_all;
  float area_total = 0;
  while (1) {
    if (shape.size() == 0) {
      break;
    }

    if (shape.begin()->type == UP || shape.begin()->type == FLAT) {
      shape.pop_front();
      continue;
    }

    float area = 0.5;
    int start_height = shape.begin()->height;
    int delete_num = 0;
    shape.pop_front();
    for (list<slope>::iterator i = shape.begin(); i != shape.end(); i++) {
      delete_num++;
      int current_height = i->height - start_height;
      switch (i->type) {
      case DOWN:
        area += abs(current_height) + 0.5;
        break;
      case UP:
        area += abs(current_height) + 0.5;
        break;
      case FLAT:
        area += abs(current_height);
        break;
      }
      //cout << current_height << " " << start_height << endl;
      if (i->height == start_height) {
        for (int j = 0; j < delete_num; j++) {
          shape.pop_front();
        }
        area_all.push_back(area);
        area_total += area;
        break;
      }
    }

    //cout << shape.size() << endl;
  }

  //cout << area_all.size() << endl;
  cout << int(area_total) << endl;
  cout << area_all.size();
  for (list<float>::iterator i = area_all.begin(); i != area_all.end(); i++) {
    cout << " " << int(*i);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3868
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;
 
//#include "atcoder.hpp"
 
long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}
 
int main() {
    int A,B,C;
    
    cin >> A >> B >> C;
    if (A>B)swap(A,B);
    cout << ((A < C) && (C < B) ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
struct node
{
    int x,y;
    int step;
};
int h,w,sx,sy,ex,ey;
deque<node> q;
char s[1005][1005],vis[1005][1005];
int nextx[]={0,-1,0,1},nexty[] = {-1,0,1,0};
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    scanf("%d%d",&h,&w);
    scanf("%d%d",&sx,&sy);
    scanf("%d%d",&ex,&ey);
    for(int i=1; i<=h; ++i){
        for(int j=1; j<=w; ++j)
            scanf(" %c",&s[i][j]);
    }
    /*
    for(int i=1; i<=h; ++i){
        for(int j=1; j<=w; ++j)
            printf("%c",s[i][j]);
        putchar('\n');
    }*/

    vis[sx][sy] = 1;
    q.push_back((node){sx,sy,0});
    //cout<<q.front().x<<' '<<q.front().y;
    //getchar();
    int ans = -1;
    while(!q.empty()){
        struct node t = q.front();
        q.pop_front();
        vis[t.x][t.y] = 1;
        if(t.x==ex&&t.y==ey){
            ans = t.step;
            break;
        }

        for(int i=0; i<4; ++i){
            int tx,ty;
            tx = t.x + nextx[i];
            ty = t.y + nexty[i];
            if(tx>0&&tx<=h&&ty>0&&ty<=w&&s[tx][ty]=='.'&&!vis[tx][ty]){
                q.push_front((node){tx,ty,t.step});
            }
        }

        for(int tx=t.x-2; tx<=t.x+2; ++tx){
            for(int ty=t.y-2; ty<=t.y+2; ++ty){
                if(tx>0&&tx<=h&&ty>0&&ty<=w&&s[tx][ty]=='.'&&!vis[tx][ty]){
                    q.push_back((node){tx,ty,t.step+1});
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 11948
N,K = map(int, input().split())
A = list(map(int, input().split())) 
A.sort()
A.reverse() 
x = A[0]   
for i in range (1, N):
  while A[i] != 0:
    x , A[i] = A[i] , x % A[i]
if K > A[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')
    

Measured memory_bytes: 19804
package main

import (
	"fmt"
	"math"
)

var N, K, X, Y int

func main() {
	fmt.Scan(&N, &K, &X, &Y)
	x := min(K, N) * X
	y := max((N-K), 0) * Y

	fmt.Println(x + y)
}

/*  ----------------------------------------  */

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


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

typedef long long ll;
typedef unsigned long long ull;

bool pair_comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  if (a.second == b.second) {
    return a.first > b.first;
  }
  return a.second < b.second;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> ab(n);
  for (ll i = 0; i < n; ++i) {
    ll a, b;
    cin >> a;
    cin >> b;
    ab[i] = pair<ll, ll>(a, b);
  }
  sort(ab.begin(), ab.end(), pair_comp);

  ll t = 0;
  for (ll i = 0; i < ab.size(); ++i) {
    t += ab[i].first;
    if (t > ab[i].second) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=9 and a>=1){
        if(b<=9 and b>=1){
            cout<<a*b<<endl;
        }
        else cout<<-1<<endl;
    }
    else cout<<-1<<endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			String words[] = new String[n];
			
			for(int i = 0; i < n; i++){
				words[i] = br.readLine();
			}
			
			System.out.println(solve(words));
		}
	}
	
	static int solve(String[] words){
		int n = words.length;
		
		int start = 0;
		
		int[] rules = {5,7,5,7,7};
		
		for(int i = 0; i < n; i++){
			int[] rulesCopy = Arrays.copyOf(rules, 5);
			int ruleIndex = 0;
			for(int j = i; j < n && ruleIndex < 5; j++){
				rulesCopy[ruleIndex] -= words[j].length();
				if(rulesCopy[ruleIndex] == 0){
					ruleIndex++;
				}
				else if(rulesCopy[ruleIndex] < 0){
					break;
				}
			}
			
			if(rulesCopy[4] == 0){
				start = i + 1;
				break;
			}
		}
		
		return start;
	}

}

Measured memory_bytes: 24524
#include<bits/stdc++.h>
using namespace std;
long long k,n,a[55],ans;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=k;i++)
    	ans+=a[i];
    cout<<ans;
    return 0;
}
//https://ke.qq.com/webcourse/index.html?cid=696459&term_id=100794550&lite=1&from=800021724

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n  = fs.nextInt();
		int ans = 0;
		
		for(int i = 1; i <= n; i++) {
			ans += i;
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string S, T; cin >> S >> T;
    if (S + T[T.size() - 1] == T) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=105;
int n,s,t,tot=1,a[N],head[N],nex[N*N*4],to[N*N*4],flow[N*N*4];
void add(int u,int v,int f)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;flow[tot]=f;
    to[++tot]=u;nex[tot]=head[v];head[v]=tot;flow[tot]=0;
}
int d[N];
int bfs()
{
    memset(d,0,sizeof(d));
    queue<int>q;
    q.push(s);
    d[s]=1;
    while(!q.empty())
    {
        int u=q.front();q.pop();
        for(int i=head[u];i;i=nex[i])
        {
           int v=to[i];
           if(!d[v]&&flow[i])
           {
               d[v]=d[u]+1;
               q.push(v);
           }
        }
    }
    return d[t];
}
int dfs(int u,int f)
{
    if(u==t) return f;
    int ans=0;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i],y;
        if(d[v]==d[u]+1&&flow[i]&&(y=dfs(v,min(f,flow[i]))))
        {
            flow[i]-=y;
            flow[i^1]+=y;
            ans+=y;
            f-=y;
            if(f==0) return ans;
        }
    }
    if(ans==0) d[u]=-1;
    return ans;
}
ll Dinic()
{
    ll ans=0;
    while(bfs())
        while(int val=dfs(s,inf))
        ans+=val;
    return ans;
}
int main()
{
    scanf("%d",&n);
    s=n+1;t=n+2;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=0) add(s,i,a[i]),ans+=a[i];
        else add(i,t,-a[i]);
    }
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j+=i)
        add(j,i,inf);
    printf("%lld\n",ans-Dinic());
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import sqrt
from itertools import permutations

n = ni()
xy = [list(li()) for _ in range(n)]

zton = [i for i in range(n)]
lst = permutations(zton)

total = 0
for route in lst:
    dist = 0
    for st, ed in zip(route[:-1], route[1:]):
        dist += sqrt((xy[ed][0] - xy[st][0])**2 + (xy[ed][1] - xy[st][1])**2)
    total += dist

bunbo = 1
for i in range(1,n+1):
    bunbo *= i

print(total / bunbo)

Measured memory_bytes: 3064
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define debug(args...){ string _s = #args;replace(_s.begin(),_s.end(),',', ' ');stringstream _ss(_s);istream_iterator<string>_it(_ss);err(_it, args);}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb              push_back
#define eb              emplace_back
#define ff              first
#define ss              second
#define NL              printf("\n");
#define bug(a)          cout<<#a<<" "<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **



ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
bitset<N>B;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc=1,in,loc,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
//cin>>tc;
rep(t,tc)
{
    cin>>n;
        ll last=0;
    rep(i,n)
    {
        cin>>a;
        b=a+last;
        ans+=b/2;
        if(b%2==1 && a!=0)last=1;
        else last=0;
    }
    cout<<ans<<endl;
}
}
    return 0;
}

/*


*/
/// Check for constraint 0 or 1?
/// Division MOD needs BigMod(a,n-2)
/// long long or double? sqrt or division will work fine??
/// sort(begin(v), end(v), [] (int a, int b) { return a > b; });    /// Lambda Function for manual Sort


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[100005];
int main()
{
    int n;
    cin>>n;
    int i;
    long long a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n]<<endl;
}


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

int main() {
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int>A(Q);
  for(int i=0;i<Q;i++){
    cin>>A.at(i);
  }
  vector<int>a(N,K-Q);
  for(int i=0;i<Q;i++){
    a.at(A.at(i)-1)++;
  }
  for(int i=0;i<N;i++){
    if(a.at(i)>0){
      cout<<"Yes"<< endl;
    }
    else{
      cout<<"No"<< endl;
    }
  }
}

Measured memory_bytes: 1408
#include <bits/stdtr1c++.h>

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 5e5;
const int maxM = 3e5 + 10;
const int oo = 2e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    int n;
    cin >> n;
    int b[n];
    for (int i = 1; i < n; i++) cin >> b[i];
    int Res = b[1];
    for (int i = 2; i <= n; i++) {
        if (i == n) Res += b[n - 1];
        else {
            if (b[i - 1] <= b[i]) Res += b[i - 1];
            else Res += b[i];
        }
    }
    cout << Res;
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


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

using namespace std;

int main(){
    long int n, h, a, b, ak = 0, ans = 0;
    cin >> n >> h;
    vector<long int> B;
    for (long int i = 0; i < n; i++)
    {
        cin >> a >> b;
        ak = max(a, ak);
        B.push_back(b);
    }
    sort(B.begin(), B.end(),greater<long int>());
    for (long int i = 0; i < n; i++)
    {
        if(B[i] < ak){
            break;
        }
        if(h <= 0){
            break;
        }
        h -= B[i];
        ans += 1;
    }
    while(h > 0){
        h -= ak;
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
using System;
class Atcoder_Templete
{
    static void Main(string[] args)
    {
        string input_string = Console.ReadLine();
        long input_int = long.Parse(input_string);
        decimal rootOfInputDouble = (decimal)Math.Sqrt(input_int);
        long result = 0;
        long niceX = 0;
        long niceY = 0;
        long rootOfInputInt = (long)rootOfInputDouble;
            for (long i = rootOfInputInt ; 0 < i; i--)
            {
                if (input_int % i == 0)
                {
                    niceX = i;
                    niceY = input_int / i;
                    break;
                }
            }
            result = niceX + niceY - 2;
        //出力
        Console.WriteLine(result);
    }


}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

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

    cout<<(s.find("AC")!=string::npos?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3592
while True:
    n,p = map(int,input().split())
    if n==p==0: break
    s,c = [0]*n,p
    i = 0
    while True:
        if c:
            c-=1
            s[i%n]+=1
            if s[i%n]==p: break
        else:
            c+=s[i%n]
            s[i%n] = 0
        i+=1
    print(i%n)

Measured memory_bytes: 7544
n = int(input())
l = []
for i in range(n):
    a, b = map(int, input().split())
    l.append((a,b))
nl = sorted(l,key=lambda x: x[1])
t = 0
for a, b in nl:
    t += a
    if t > b:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 33372
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }
#define EPS 1e-9
signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	double H, W; cin >> H >> W;
	double x, y; cin >> x >> y;

	bool f = abs(H / 2 - x) < EPS and abs(W / 2 - y) < EPS;

	cout << H * W / 2 << " " << f << endl;


	return 0;
}


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

int main() {
  int N, T;
  cin >> N >> T;
  multimap<int, int> mp;
  for (int i = 0; i < N; ++i) {
    int c, t;
    cin >> c >> t;
    mp.insert(make_pair(c, t));
  }
  int ans = 10000;
  for (const auto& kv : mp) {
    if (kv.second <= T) {
      ans = min(ans, kv.first);
    }
  }
  if (ans == 10000) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    float n;
    cin>>n;
    float t,a;
    cin>>t>>a;
    float arr[(int)n];
    for(int i=0;i<n;i++)cin>>arr[i];
    float ans=1e7,h;
    for(int i=0;i<n;i++){
        if(fabs(a-(t-arr[i]*0.006))<ans){
            ans=fabs(a-(t-arr[i]*0.006));
            h=i+1;
        }
    }
    cout<<h;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string a, b;
   cin >> a >> b;
   for(int i = 0;i < a.length()-1;i++) {
       cout << a[i] << b[i];
   }
   if(a.length()==b.length()) {
       cout << a[a.length()-1] << b[b.length()-1] << endl; 
   } else {
       cout << a[a.length()-1] << endl;
   }
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<utility>
#include<cstdlib>
#include<iterator>
#include<queue>
#include<stack>
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
typedef unsigned int uint;
#define int long long
const int INF = 9223372036854775807;


namespace G{
}

signed main() {
	string ngo;
	cin >> ngo;
	for (int i = 0; i < ngo.size(); ++i){
		if (ngo[i] != ngo[ngo.size() - 1 - i]){
			cout << "No" << endl;
			exit(0);
		}
	}cout << "Yes" << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
const int N=1e5+10;
const ll mod=1e9+7;

int n;
ll ans;
int vis[29];
char s[N];

void dfs(int k, ll sum) {
	if (k==26) {
		ans+=sum;
		ans%=mod;
		return;
	}
	if (vis[k])	dfs(k+1, sum*vis[k]%mod);
	dfs(k+1, sum);
}

int main() {
	scanf("%d", &n);
	scanf("%s", s+1);
	for(int i=1; i<=n; i++) {
		vis[s[i]-'a']++;
	}
	dfs(0, 1);
	cout<<ans-1<<endl;
	return 0;
}


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

using namespace std;

int main() {
//	freopen("input.txt","r",stdin);// <--Remove Before Submit
	int a,b,c,d;
	cin >>a>>b>>c>>d;
	int e = max(a,c);
	int f = min(b,d) - e;
	cout << (f > 0?f:0) << endl;
}


Measured memory_bytes: 256
//*Author : Franklin*
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const int N = 2e5;
#define deb(x) cout << #x << "=" << x << "\n"
#define debug(a) for(auto &x:a) cout << x << " "
#define debugg(p) for(auto &x:p) cout << "(" << x.first << "," << x.second << ")" << "\n"

int w[105];
int v[105];
long long dp[100005];

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

    int n,W;
    scanf("%d%d",&n,&W);
    for(int i=0; i<n; i++) scanf("%d%d",w+i,v+i);

    for(int i=0; i<n; i++) dp[i] = 0;
    for(int i=0; i<n; i++) {
        for(int j=W; j>=0; j--) {
            if(j>=w[i]) dp[j] = max(dp[j],v[i]+dp[j-w[i]]);
        }
    }
    cout<<dp[W]<<"\n";

    return 0;
}


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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

struct BinarySearchTree {
    BinarySearchTree *left = nullptr, *right = nullptr;
    int value;
    BinarySearchTree(int value) : value(value) {}
};

BinarySearchTree* insert(BinarySearchTree *root, BinarySearchTree *z) {
    BinarySearchTree *y = nullptr;
    BinarySearchTree *x = root;

    while (x != nullptr) {
        y = x;
        if (z->value < x->value) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    if (y == nullptr) {
        return z;
    } else if (z->value < y->value) {
        y->left = z;
    } else {
        y->right = z;
    }

    return root;
}

bool find(BinarySearchTree *root, int value) {
    BinarySearchTree *x = root;
    while (x != nullptr) {
        if (value == x->value) {
            return true;
        } else if (value < x->value) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return false;
}

void preorder_print(BinarySearchTree *node) {
    if (node == nullptr) { return; }
    cout << " " << node->value;
    preorder_print(node->left);
    preorder_print(node->right);
}

void inorder_print(BinarySearchTree *node) {
    if (node == nullptr) { return; }
    inorder_print(node->left);
    cout << " " << node->value;
    inorder_print(node->right);
}

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

    int n;
    cin >> n;

    string command;
    int value;
    BinarySearchTree *root = nullptr;

    FOR(i,0,n) {
        cin >> command;
        if (command == "insert") {
            cin >> value;
            auto z = new BinarySearchTree(value);
            root = insert(root, z);
        } else if (command == "find"){
            cin >> value;
            bool isexist = find(root, value);
            if (isexist) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        } else {
            inorder_print(root);
            cout << endl;
            preorder_print(root);
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 15624
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  vector<vector<int>> d(h,vector<int>(w,INF));
  rep(i,h) cin >> s[i];
  
  int ng = 0;
  rep(i,h)rep(j,w){
    if(s[i][j] == '#') ng++;
  }
  
  d[0][0] = 1;
  queue<pair<int,int>> q;
  q.push({0,0});
  
  while(!q.empty()){
    int x,y;
    tie(x,y) = q.front();q.pop();
    rep(i,4){
      int nx = x+dx[i], ny = y+dy[i];
      if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if(s[ny][nx] == '#') continue;
      if(d[ny][nx] != INF) continue;
      d[ny][nx] = d[y][x] + 1;
      q.push({nx,ny});
    }
  }
  
  if(d[h-1][w-1] == INF) cout << -1 << endl;
  else cout << h*w - d[h-1][w-1] - ng << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    typedef long long ll;
    #define pb push_back
    #define f first
    #define s second
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define endl '\n'
    #define mem(a , v)  memset(a , v , sizeof(a))

using namespace std;
const int MAX=1e5+2;
const int inf = 1e9+77;
const int MOD = 1e9+7;
ll x[MAX];

char ALPH[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};


char ALPH_C[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char vowels[6]={'a','e','i','o','u','y'};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y%2==1)
         s*=x;
         return s;
}
void sortString(string &str)
{
   sort(str.begin(), str.end());
   //cout << str;
}
//ll const s=100;
ll dp[MAX];
int n,k;
ll solve(int i){
    if(i==n-1) return 0;
    ll &res=dp[i];
    if(res!=-1) return res;
     if(i<n-k){
        res= solve(i+1)+abs(x[i]-x[i+1]);
        for(int j=i+2;j<=i+k;j++){
            res=min(res,solve(j)+abs(x[i]-x[j]));
         }
        //res=min(solve(i+1)+abs(x[i]-x[i+1]),solve(i+2)+abs(x[i]-x[i+2]));
     }
     else {
            res=solve(i+1)+abs(x[i]-x[i+1]);
            for(int j=i+2;j<n;j++){
            res=min(res,solve(j)+abs(x[i]-x[j]));
              }

         }


     return res;


}


int main()
{  IOS
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);

//    int n;
    cin>>n;
    cin>>k;
    for(int i=0;i<n;i++) {
        cin>>x[i];
    }
    /*for(int i=0;i<MAX;i++){
        //for(int j=0;j<100;j++)
        dp[i]=-1;
    }*/


    mem(dp,-1);
    cout<<solve(0);



    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int N; cin >> N;
    vl a(N), b(N); rep(i,N) cin >> a[i];
    ll S = a[0];
    rep(i,N-1){
        S ^= a[i+1];
    }

    rep(i,N) cout << (S^a[i]) <<" ";

    return 0;
}


Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n;cin>>n;
    vi v(n,-1);
    ll m;cin>>m;
    if(n==1){
        ll ans=-1;
        rep(i,m){
            ll s,c;cin>>s>>c;
            if(ans!=-1&&ans!=c){out(-1);return 0;}
            ans=c;
        }
        if(ans==-1)out(0);
        else out(ans);
        return 0;
    }
    rep(i,m){
        ll s,c;cin>>s>>c;
        s--;
        if(v[s]!=-1&&v[s]!=c){
            out(-1);
            return 0;
        }
        v[s]=c;
    }
    rep(i,n){
        if(i==0){
            if(v[i]==-1)v[i]=1;
            if(v[i]==0){
                out(-1);return 0;
            }
        }
        else{
            if(v[i]==-1)v[i]=0;
        }
    }
    rep(i,n)cout<<v[i];
    cout<<endl;
}

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

int main() {
    //
    long long a, b;

    cin >> a >> b;
    if(a == b){
        cout << 0;
    } else if (abs(abs(a) - abs(b)) == 0) {
        cout << 1;
    } else if (a > b) {
        //
        if ((a >= 0 && b <= 0) || (a <= 0 && b >= 0)) {
            cout << abs(abs(a) - abs(b)) + 1;
        }else{
            cout << abs(abs(a) - abs(b)) + 2;
        }

    } else {
        if ((a > 0 && b < 0) || (a < 0 && b > 0)) {
            cout << abs(abs(a) - abs(b)) + 1;
        } else {
            cout << abs(abs(a) - abs(b));
        }
    }

    //
}


Measured memory_bytes: 3616
using System;

namespace ABC026A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (a%2 != 0 && b%2 != 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 200100;

stack <int> s;

string p;

int main() {
	cin >> p;
	REP(i, (int)p.size()) {
		if (s.empty() || s.top() == 'T' || p[i] == 'S') s.push(p[i]);
		else {
			if (s.top() == 'S') {s.pop(); continue;}
			else s.push(p[i]);
		}
	}

	printf("%d\n",(int)s.size());
	return 0;
}


Measured memory_bytes: 1284
#include<bits/stdc++.h>
#define ll long long
const ll inf=1e9+10;
const int maxn=1e5+10;
using namespace std;

ll a[maxn],b[maxn];
ll dp[maxn];
int main()
{
	int h,n;
	cin>>h>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=maxn;i++) dp[i]=inf;
	dp[0] = 0;
	for(int i=1; i<=n;i++)
	{
		for(int j=0;j<=maxn;j++)
		{
				if(j>=a[i]) dp[j]= min(dp[j],dp[j-a[i]]+b[i]);
		}
	}
	ll ans=dp[h];
	for(int i=h;i<=maxn;i++)
	{
		ans=min(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
const int size = 1e5+10;
ll a[3];


int main(){
    bool f = false;
    for(int i = 0; i < 3; i++){
        cin >> a[i];
        if(a[i]%2 == 0) f = true;
    }
    sort(a,a+3);
    ll ans = a[0]*a[1];
    if(f)  ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    A, B, K = map(int, input().split())
    div = list()
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            div.append(i)
    div.sort(reverse=True)
    print(div[K-1])
main()

Measured memory_bytes: 2940
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0
if x == sum(a):
    print(n)
    quit()
elif x > sum(a):
    print(n-1)
    quit()
else:
    for i in range(n):
        if x - a[i] < 0:
            break
        x -= a[i]
        ans += 1
print(ans)


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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;


int solve(LL N, vector<LL> &A) {
    LL ans = 0;
    sort(RALL(A));

    bool change = true;
    while (change) {
        change = false;
        FOR(i, 0, A.size()) {
            LL n = A[i] / N;
            A[i] -= (n * N);
            FOR(j, 0, A.size()) {
                if (i != j) {
                    A[j] += n;
                }
            }
            ans += n;
            change |= (n >= 1);
        }
    }

    cout << ans << endl;

}


int main() {
    LL N;
    cin >> N;
    vector<LL> A(N);
    FOR(i, 0, N) {
        cin >> A[i];
    }
    solve(N, A);

    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;

	vector<int> x(n);
	for (auto &v : x) {
		cin >> v;
	}

	int ans = INF;
	for (int l = 0; l <= n - k; l++) {
		int r = l + k - 1;
		ans = min(ans, x[r] - x[l] + min(abs(x[l]), abs(x[r])));
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

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

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int x, y; cin >> x >> y;
	cout << x + y / 2 << endl;
	return 0;
}

Measured memory_bytes: 3580
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int d=sc.nextInt();
		int x=sc.nextInt();
		for (int i=1;i<=n;i++){
			int a=sc.nextInt();
			x+=Math.floor((d-1)/a+1);
		}
		System.out.println(x);
	}
}

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

int main() {

  int N , K;
  cin >> N >> K;

  int A=0 , B=0;

  vector<int> l(N);

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

  sort(l.begin() , l.end());
  reverse(l.begin() , l.end());

  int ans = 0;

  for(int i=0;i<K;i++ ){
    ans += l[i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {    
    
  private static int limit = 50;
  
  static int N,M;
  static int a[] = new int[limit];
  static int b[] = new int[limit];
  
  static boolean graph[][] = new boolean[limit][limit];
  static boolean visited[] = new boolean[limit];  
  
  static void dfs(int v){
      visited[v] = true;
      for(int v2 = 0;v2 < N;v2++){
          if(!graph[v][v2])continue;
          if(visited[v2])continue;
          dfs(v2);
      }      
  }
  
  public static void main(String[] args){
      
      Scanner sc =new Scanner(System.in);
     
      N = sc.nextInt();
      M = sc.nextInt();
      
      for(int i = 0;i < M;i++){
          a[i] = sc.nextInt() - 1;
          b[i] = sc.nextInt() - 1;
          graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;          
      }
      
      int ans = 0;
      
      for(int i = 0;i < M;i++){
          graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
          
          for(int j = 0;j < N;j++)visited[j] = false;
          
          dfs(0);
          
          boolean bridge = false;
          for(int j = 0;j < N;j++){
              if(!visited[j]){
                  
                  bridge = true;
              }
          }
          if(bridge){
              ans++;
          }
          
          graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
      }
      
      System.out.println(ans);
  }
  
}
        
        
        

Measured memory_bytes: 22996
#include <stdio.h>

int get_l(int n) {
	char buf[8];
	int i,j,r;
	char t;
	sprintf(buf,"%04d",n);
	for(i=3;i>0;i--) {
		for(j=0;j<i;j++) {
			if(buf[j]<buf[j+1]) {
				t=buf[j];buf[j]=buf[j+1];buf[j+1]=t;
			}
		}
	}
	sscanf(buf,"%d",&r);
	return r;
}

int get_s(int n) {
	char buf[8];
	int i,j,r;
	char t;
	sprintf(buf,"%04d",n);
	for(i=3;i>0;i--) {
		for(j=0;j<i;j++) {
			if(buf[j]>buf[j+1]) {
				t=buf[j];buf[j]=buf[j+1];buf[j+1]=t;
			}
		}
	}
	sscanf(buf,"%d",&r);
	return r;
}

int main(void) {
	int n,count;
	while(scanf("%d",&n)==1 && n>0 && n<10000) {
		if(get_l(n)==get_s(n)) {
			puts("NA");
			continue;
		}
		for(count=0;n!=6174;count++) {
			n=get_l(n)-get_s(n);
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

class pqComp
{
public:
    bool operator()(pair<int, int> &a, pair<int, int> &b)
    {
        return a.second < b.second;
    }
};

bool sorting(pair<int, int> a, pair<int, int> b)
{
    return a.second < b.second;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie();
    cout.tie();
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    int n;
    cin >> n;
    switch (n % 10)
    {
    case 3:
        cout << "bon\n";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon\n";
        break;

    default:
        cout << "hon\n";
        break;
    }


    return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y=0,z,n,m=0,k,h,w,sum=0,ans=0,Max=0,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> k;
    VL a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n-(k-1)){
        if(a[i]<0 && a[i+k-1]<=0){
            x = abs(a[i]);
        }
        else if(a[i]<0 && a[i+k-1] > 0){
            if(abs(a[i]) < a[i+k-1]){
                x = abs(a[i])*2 + a[i+k-1];
            }
            else{
                x = abs(a[i]) + a[i+k-1]*2;
            }
        }
        else {
            x = a[i+k-1];
        }
        chmin(Min,x);
    }    
    cout << Min << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
set<int>s;
const int N = 1e5 + 5;
void solve(int n){
    if(n < 0){
        return;
    }
    if(n > 3234566667){
        return;
    }
    s.insert(n);
    int last = n % 10;
    if(last == 9){
        int x = n * 10;
        solve(x + 8);
        solve(x + last);
    }else if(last == 0){
        int x = n * 10;
        solve(x + 1);
        solve(x);
    }else{
        int x = n * 10;
        solve(x + last + 1);
        solve(x + last - 1);
        solve(x + last);
    }
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    set<int>now;
    for(int i=1;i<=9;i++){
        solve(i);
        for(auto x:s){
            now.insert(x);
        }
        s.clear();
    }
    vector<int>v(now.begin(),now.end());
    int n;
    cin>>n;
    cout<<v[n-1]<<endl;
    return 0;
    
}



Measured memory_bytes: 5888
#include<iostream>
#include<math.h>
#include<algorithm>
#include<cstdio>
using namespace std;
const double drs=1e-10;
int a,b,xx;
double ans;
int main(){
	//ios::sync_with_stdio(false);
	cin>>a>>b>>xx;
	double x=xx;
	double mid=(a*a*b)/2;
//	cout<<mid<<endl;
	if (mid-x>=-drs) {
		double now=x*2.0/a/b;
		//cout<<b/now<<endl;
		ans=atan(b*1.0/now)/M_PI*180;
		//cout<<b<<" "<<now<<endl;		
	}
	else {
		double now=a*a*b-xx;
		now=now*2/(a*a);
		ans=atan(now/a*1.0)/M_PI*180;
	}
	printf("%.8lf\n",ans);
	//scout<<atan(1);
	return 0;
}

Measured memory_bytes: 256