akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define pi pair<int,int>
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vec() vector<ll int>v1,v2
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
   ll int n,res=0,sq;
   cin>>n;
   sq=sqrt(n);
   for(int i=1;i<n;i++)
   {
       for(int j=1;i*j<n;j++)
       {
           res++;
       }
   }
   cout<<res<<endl;


}


Measured memory_bytes: 3676
/*双方向連結リスト*/

#include <cstdio>
#include <cstdlib>
#include <cstring>

typedef struct node
{
    unsigned int key;
    struct node *next;
    struct node *prev;
} Node;

typedef Node *NodePointer;

NodePointer nil; //番兵　基準となる(リストの先頭、末尾)　実データには含めない

NodePointer listSearch(int key)
{
    NodePointer cur = nil->next;
    while (cur->key != key && cur != nil)
    {
        cur = cur->next;
    }
    return cur;
}

void init()
{
    nil = new Node;
    nil->next = nil;
    nil->prev = nil;
}

void printList()
{
    NodePointer cur = nil->next;
    int isfirst = 1;
    while (cur != nil)
    {
        if (isfirst == 0)
        { //最初は空白を入れない
            printf(" ");
        }
        printf("%d", cur->key);
        cur = cur->next;
        isfirst = 0;
    }
    printf("\n");
}

void deleteNode(NodePointer t)
{
    if (t == nil)
    {
        return;
    }
    t->prev->next = t->next;
    t->next->prev = t->prev;
    delete t;
}

void deleteFirst()
{
    deleteNode(nil->next);
}

void deleteLast()
{
    deleteNode(nil->prev);
}

void deleteKey(int key)
{
    deleteNode(listSearch(key));
}

void insert(int key)
{
    NodePointer x;
    x = new Node;
    x->key = key;

    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main()
{
    int key, n, i;
    int size = 0;       //要素の大きさ
    char com[20];       //コマンド命令文字列
    int np = 0, nd = 0; //Insert回数とDelete回数

    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++)
    {
        scanf("%s%d", com, &key);
        if (com[0] == 'i')
        { //Insert
            insert(key);
            np++;
            size++;
        }
        else if (com[0] == 'd')
        {
            if (strlen(com) > 6)
            {
                if (com[6] == 'F')
                {
                    deleteFirst();
                }
                else if (com[6] == 'L')
                {
                    deleteLast();
                }
            }
            else
            {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }

    printList();
    delete nil;

    return 0;
}


Measured memory_bytes: 33852
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        // 主処理
        for (int i = 0; i < k; i++) {
            if (i % 2 == 0) {
                if (a % 2 == 1) {
                    a--;
                }
                b += a / 2;
                a /= 2;

            } else {
                if (b % 2 == 1) {
                    b--;
                }
                a += b / 2;
                b /= 2;
            }

        }
        String result = a + " " + b;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

int main()
{
  int n, flag;
  int ans = 1;
  cin >> n;
  int h[110];
  for (int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int i=1;i<n;i++)
  {
    flag = 0;
    for (int j=0;j<i;j++)
    {
      if(h[i] < h[j])
      {
        flag = 1;
      }
    }
    if(flag == 0)
    {
      ans += 1;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
[X,K,D]=[int(_) for _ in input().split()]
X=abs(X)
Y=X//D
if Y <= K:
  X-=Y*D
  if (K-Y)%2 != 0:
    X = abs(X-D) if abs(X-D) < abs(X+D) else abs(X+D)
else:
  X-=K*D
print(X)

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

int n,ans,col;
int a[200010],b[200010],c[200010],d[200010],fa[200010],used[200010];
int sa[200010];

int find(int i)
{return fa[i]==i?i:fa[i]=find(fa[i]);
}

int main()
{int i,j,k,p,s,x,y,fx,fy,flag;
 
 scanf("%d",&n);
 for(i=1;i<=n;i++) scanf("%d",&a[i]);
 for(i=1;i<=n;i++) scanf("%d",&b[i]);
 for(i=1;i<=n;i++) a[n+1]^=a[i];
 for(i=1;i<=n;i++) b[n+1]^=b[i];
 
 flag=1;
 for(i=1;i<=n;i++)
 	if(a[i]!=b[i])
 	{	flag=0;
 		break;
 	}
 if(flag)
 {	printf("%d\n",0);
 	return 0;
 }
 
 for(i=1;i<=n+1;i++) c[i]=a[i];
 for(i=1;i<=n+1;i++) d[i]=b[i];
 sort(c+1,c+n+2);
 sort(d+1,d+n+2);
 flag=1;
 for(i=1;i<=n+1;i++)
 	if(c[i]!=d[i])
 	{	printf("%d\n",-1);
 		return 0;
 	}
 
 for(i=1;i<=n+1;i++) sa[i]=c[i];
 
 for(i=1;i<=n+1;i++) fa[i]=i;
 
 ans=n;
 for(i=1;i<=n;i++)
 	if(a[i]==b[i])
 		ans--;
 	else
 	{	x=lower_bound(sa+1,sa+n+2,a[i])-sa;
 		y=lower_bound(sa+1,sa+n+2,b[i])-sa;
 		fx=find(x);
 		fy=find(y);
 		if(fx!=fy) fa[fx]=fy;
 	}
 for(i=1;i<=n;i++)
 	if(a[i]!=b[i])
	{	x=lower_bound(sa+1,sa+n+2,a[i])-sa;
		x=find(x);
		if(used[x]==0)
		{	used[x]=1;
			ans++;
		}
	}
 x=lower_bound(sa+1,sa+n+2,a[n+1])-sa;
 x=find(x);
 if(used[x]==1) ans--;

 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 5248
#include<algorithm>
#include<iostream>
#include<queue>
#include<ctype.h>
#include<limits.h>

int h, w, n;
int sx, sy;
int gx, gy;
char map[1002][1002];
int d[1001][1001];
bool visited[1001][1001];
int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };
int ans;

void bfs()
{
	d[sx][sy] = 0;
	visited[sx][sy] = true;
	std::queue<std::pair<int,int> > q;
	q.push( std::make_pair<int,int>( sx, sy ) );
	
	while( !q.empty() ){
		std::pair<int,int> p = q.front(); q.pop();
		int x = p.first;
		int y = p.second;
		
		for( int i = 0; i < 4; i++ ){
			int ix = x + dx[i];
			int iy = y + dy[i];
			
			if( ix >= 1 && ix <= w && iy >= 1 && iy <= h && map[ix][iy] != 'X' && !visited[ix][iy] ){
			 	d[ix][iy] = d[x][y] + 1;
				q.push( std::make_pair<int,int>( ix, iy ) );
				visited[ix][iy] = true;
			}
		}	
	}

	return;
}

int main()
{
	std::cin >> h >> w >> n;
	
	for( int i = 1; i <= h; i++ ){
	 	for( int j = 1; j <= w; j++ ){
			std::cin >> map[j][i];
			if( map[j][i] == 'S' ){
			 	sx = j;
				sy = i;
			}
		}
	}
	
	for( int k = 1; k <= n; k++ ){
		for( int i = 1; i <= h; i++ ){
		 	for( int j = 1; j <= w; j++ ){
			 	d[j][i] = INT_MAX / 4;
				visited[j][i] = false;
			}
		}	
		
		bfs();
		
		for( int i = 1; i <= h; i++ ){
		 	for( int j = 1; j <= w; j++ ){
				if( map[j][i] == k + '0' ){
				 	gx = j;
					gy = i;
				}
			}
		}
		
		ans += d[gx][gy];
		
		sx = gx;
		sy = gy;
	}
	
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 7088
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>

using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b;
    if((a*b*3)%2!=0){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";


    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    int X;
    cin >> X;
    cout << (X/500*1000 + (X%500)/5*5 ) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
考虑把竞赛树建出来。那么合法的充要条件是：对于从1到根每个分叉出去的子树，子树中（叶子节点）最小值不在A中
计数考虑容斥，钦定一些A中的元素不合法。设这些元素大到小排序后为a1, a2, ..., an，ai占用的子树大小为S(ai)，那么这时候的方案数就是按照这个顺序算个组合数乘起来
那么状压dp容斥过程，设F(i, S)表示考虑到了Ai，当前用了S集合中的子树大小
*/

#include <cstdio>
#include <cstring>

using namespace std;
const int Max_N(16);
const int MOD(1000000000 + 7);
typedef long long int LL;

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

void exgcd(int a, int b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

int N, M, A[Max_N + 5], Fac[(1 << Max_N) + 5], Inv[(1 << Max_N) + 5], F[2][1 << Max_N];

inline int P(int n, int m)
{
	return 0 <= m && m <= n ? Mult(Fac[n], Inv[n - m]) : 0;
}

int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 1;i <= M;++i)
		scanf("%d", A + (M - i + 1));
	Fac[0] = 1;
	for (int i = 1;i <= (1 << N);++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[1 << N] = inverse(Fac[1 << N]);
	for (int i = (1 << N) - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	F[0][0] = 1;
	for (int i = 1, now = 0, lst = 1;i <= M;++i)
	{
		now ^= 1, lst ^= 1, memset(F[now], 0, sizeof(F[now]));
		for (int S = 0, SumS;S < (1 << N);++S)
		{
			if (!F[lst][S])
				continue;
			F[now][S] = Add(F[now][S], F[lst][S]);
			SumS = 0;
			for (int j = 0;j <= N - 1;++j)
				if (S & (1 << j))
					SumS += (1 << j);
			for (int j = 0;j <= N - 1;++j)
				if ((S & (1 << j)) == 0)
					F[now][S | (1 << j)] = Sub(F[now][S | (1 << j)], Mult(F[lst][S], Mult(1 << j, P((1 << N) - A[i] - SumS, (1 << j) - 1))));
		}
	}
	int Ans(0);
	for (int S = 0, SumS;S < (1 << N);++S)
	{
		SumS = 0;
		for (int i = 0;i <= N - 1;++i)
			if (S & (1 << i))
				SumS += (1 << i);
		Ans = Add(Ans, Mult(F[(M & 1)][S], Mult(1 << N, Fac[(1 << N) - SumS - 1])));
	}
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 1152
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int MOD = 1e9 + 7;

class Modint {
public:
	long long val;

	Modint (long long _val = 0)
		: val(_val % MOD) {}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, int k) {
	if (k == 0) {
		return Modint(1);
	} else if (k % 2 == 0) {
		Modint half = exp(a, k / 2);
		return half * half;
	} else {
		return a * exp(a, k - 1);
	}
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}


int main() {

	int n; cin >> n;
	vector<int> c(n + 1, 0); for (int i = 1; i <= n; i++) cin >> c[i];
	sort(c.begin() + 1, c.end());

	Modint ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += Modint(n - i + 2) * Modint(c[i]);
	}

	cout << exp(2, 2 * n - 2)*ans;

	return 0;
}

Measured memory_bytes: 3556
N=int(input())
S=[]
for x,y in zip(map(int,input().split()), range(1,N+1)):
 if x==y: S.append(y)

S.append('$')
L=len(S)

l=[S[0]]
i=1
a=0
while i<L:
  if S[i]=='$':a+=1
  elif l[0]+1!=S[i]:
     a+=1
     l=[S[i]]
  else:l.append(S[i])
  i+=1
print(a)

Measured memory_bytes: 19968
#include<vector>
#include<string>
#include <iostream>
using namespace std;
int main()
{
	int h,w,x,y;
	cin>>h>>w>>x>>y;
	if ((h*w) % 2 != 0 && (x+y)%2!=0)
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
	}
    return false; 
}


Measured memory_bytes: 3104
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    int n=0;
    cin>>n;
    double p[n+1];
    memset(p,0,sizeof(p));
    for(int i=1;i<=n;i++) cin>>p[i];
    double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if (j==0) dp[i][j]=dp[i-1][j]*(1.0-p[i]);
            else dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=n;j++)
    //        cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    double result=0;
    cout.precision(10);
    for(int j=(n+1)/2;j<=n;j++)
       result+=dp[n][j];
    cout<<result<<endl;
	return 0;
} 

Measured memory_bytes: 74076
s = str(input())

ans = 'AC'

if s[0] != 'A':
    ans = 'WA'

for i in range(1, len(s)):
    if s[i].isupper():
        if i == 1 or i == len(s) - 1 or s[i] != 'C':
            ans = 'WA'

if s.count('C') != 1:
    ans = 'WA'

print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String buffer[] = new String[2];
        int N,X,ans;
 
        while(true){
 
            try {
                buffer = br.readLine().split("\\s+");
                N = Integer.parseInt(buffer[0]);
                X = Integer.parseInt(buffer[1]);
 
                if(N == 0 && X == 0)break;
 
                ans = 0;
 
                for(int a = 1; a <= N-2; a++){
                    for(int b = a+1; b <= N-1; b++){
                        for(int c = b+1; c <= N; c++){
                            if(a+b+c == X){
                                ans++;
                            }
                        }
                    }
                }
 
                System.out.printf("%d\n", ans);
 
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var XYZ = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ret = XYZ[0] / (XYZ[1] + XYZ[2]);

            if (ret * (XYZ[1] + XYZ[2]) + XYZ[2] <= XYZ[0])
                Console.WriteLine(ret);
            else
                Console.WriteLine(ret - 1);
        }
    }
}


Measured memory_bytes: 13268
def padding(S, T, i):
    ans = S[:i] + T + S[i+len(X):]
    return ans.replace("?","a")

if __name__ == '__main__':
    
    S = input()
    T = input()

    if len(S) < len(T):
        print("UNRESTORABLE")
        exit(0)

    sizeX = len(T)
    ans = []
    for i in range(len(S) - len(T) + 1):
        X = S[i:i+sizeX]
        for j in range(len(T)):
            if X[j] == "?" or X[j] == T[j]:
                if j == sizeX - 1:
                    ans.append(padding(S, T, i))
            else:
                break

    if ans:
        print(sorted(ans)[0])
    else:
        print("UNRESTORABLE")

Measured memory_bytes: 3064
def main():
    H, W, A, B = map(int, input().split())
    for _ in range(B):
        tmp = ['0']*A + ['1']*(W-A)
        print(''.join(tmp))
    
    for _ in range(H-B):
        tmp = ['1']*A + ['0']*(W-A)
        print(''.join(tmp))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int N,a[1000010],i,sum=0;;
	cin>>N;
	a[0]=0;a[N]=0;
	for(i=1;i<=N;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<=N+1;i++)
	{
		sum+=abs(a[i+1]-a[i]);
	}
	for(i=1;i<=N;i++)
	{
		int s;
		s=sum-abs(a[i]-a[i-1])-
abs(a[i+1]-a[i])+
abs(a[i+1]-a[i-1]);
		cout<<s<<endl;
	}
	return 0;
}


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

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

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

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll all = b - a + 1;
  ll x = b / c - (a - 1) / c;
  ll y = b / d - (a - 1) / d;
  ll lcm_val = lcm(c, d);
  ll z = b / lcm_val - (a - 1) / lcm_val;
  cout << all - (x + y - z) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,d,x;
  cin>>n>>d>>x;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    x+=(d-1)/a+1;
  }
  cout<<x<<endl;
  return 0;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>b){
        if(a>c && b<c)cout << "Yes" << endl;
        else cout << "No" << endl;
    }else if(a<b){
        if(a<c && b>c)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll s1 = (a1 - b1) * t1, s2 = (a2 - b2) * t2;
    ll u = s1 + s2;
    if (u == 0) {
        cout << "infinity" << endl;
        return 0;
    }
    if (signbit(s1) == signbit(u)) {
        cout << 0 << endl;
        return 0;
    }
    if (u > 0) {
        u *= -1;
        s1 *= -1;
    }
    ll l = 0, r = 1e6;
    /*while (r - l > 1) {
        ll mid = l + (r - l) / 2LL;
        if (mid * u + s1 >= 0)
            l = mid;
        else
            r = mid;
    }*/
    double x = s1, y = u;
    l = ceil(-1 - x / y);
    if (s1 % u == 0)
        l = -s1 / u;
    ll ans = 2LL * l - 1;
    if (l * u + s1 == 0)
        ans++;
    else if (l * u + s1 > 0)
        ans += 2;
    cout << ans << endl;

    return 0;
}

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

class Main{
	public static void main(String[] args) {



		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] data = new int[N];

		for(int i = 0;i < N;i++){
			data[i] = scanner.nextInt();
		}

		int[] copy = data.clone();


		Arrays.sort(copy);



		int[] plus = new int[N];
		int[] minus = new int[N];

		int p = 0;					//配列plusのインデックス
		int m = 0;					//配列mnusのインデックス

		int pnum = 0;				//配列plusの中の最大値のインデックス
		int mnum = 0;				//配列の中の最大値のインデックス

		for(int i = 0;i < N;i++){			//マイナスとプラスの値をそれぞれの配列にコピー
			if(copy[i] <= 0){
				minus[m] = copy[i];
				m++;
			}else{
				plus[p] = copy[i];
				p++;
			}
		}
		m--;
		p--;

		if(p == -1){
			p = 0;
		}
		if(m == -1){
			m = 0;
		}


		for(int i = 0;i < N;i++){				//絶対値の大きさが最大のとこのindexを見つける
			if( data[i] == plus[p] ){
				pnum = i;
			}else if(data[i] == minus[0]){
				mnum = i;

			}
		}


		int absplus = Math.abs(plus[p]);
		int absminus = Math.abs(minus[0]);

		int[] ans1 = new int[2*N];
		int[] ans2 = new int[2*N];
		int a1 = 0;
		int a2 = 0;

		if(Math.abs(minus[0]) > plus[p]){				//絶対値が一番大きいのがマイナスのやつ
			int key = minus[0];

			for(int i = 0;i < N;i++){
				//全部に最大値をマイナスして、全部を負の値にする
				data[i] += key;
				ans1[a1] = mnum;
				ans2[a2] = i;
				a1++;
				a2++;

			}
			//			
			//			for(int i = 0;i < N;i++){
			//				System.out.println(data[i]);
			//			}
			//			
			//			System.out.println();


			for(int i = N-1;i > 0;i--){

				data[i-1] += data[i];
				ans1[a1] = i;
				ans2[a2] = i-1;
				a1++;
				a2++;

				//					for(int j = 0;j < N;j++){
				//						System.out.println(data[j]);		
				//					}
				//					System.out.println();


			}



		}else{					//絶対値が一番大きいのがプラスのやつ

			int key = plus[p];

			for(int i = 0;i < N;i++){
				//全部に最大値をプラスして、全部を正の値にする
				data[i] += key;
				ans1[a1] = pnum;
				ans2[a2] = i;
				a1++;
				a2++;

			}
			//			for(int i = 0;i < N;i++){
			//				System.out.println(data[i]);
			//
			//			}
			//			System.out.println();

			for(int i = 0;i < N-1;i++){
				data[i+1] += data[i];
				ans1[a1] = i;
				ans2[a2] = i+1;
				a1++;
				a2++;


			}
		}




		System.out.println(a1);

		for(int i = 0;i < a1;i++){
			System.out.println((ans1[i]+1) + " "+ (ans2[i]+1));
		}

		//		
		//		for(int i = 0;i < N;i++){
		//			System.out.println(data[i]);
		//
		//		}
		//
		//
		//




	}




}

class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main()
{
  int A, B = 0;
  cin >> A >> B;
  
  int a, b, c = 0;
  a = A + B;
  b = A - B;
  c = A * B;
  
  int max = a;
  if (max <= b){
    max = b;
  }
  
  if(max <= c){
    max = c;
  }
  cout << max << endl;
}

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

int main(){
  string s;
  cin >> s;
  bool p = s[0] == 'R';
  bool q = s[1] == 'R';
  bool r = s[2] == 'R';
  if(p and q and r){
    cout << 3 << endl;
  } else if((p and q) or (q and r)){
    cout << 2 << endl;
  } else if(p or q or r){
    cout << 1 << endl;
  } else{
    cout << 0 << endl;
  }
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n, m; cin>>n>>m;

    vpint ans(m);


    repr(i,m){
        ll x = i+1;
        ll l,r;
        ll cnt = (m-1-i)/2;
        if(x%2==0){
            r = n - cnt;
            l = r - x;
        }else{
            l = 1 + cnt;
            r = l + x;
        }
        ans[i] = mp(l,r);
    }


    for(auto p:ans){
        cout<<p.first<<" "<<p.second<<endl;
    }



    return 0;

}

Measured memory_bytes: 4488
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int i = 0, j = s.size() - 1;
    while (s[i++] != 'A');
    while (s[j--] != 'Z');
    cout << j - i + 3 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int w[101], v[101];
ll dp[101][100001];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, W; cin >> N >> W;
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= w[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}
	ll ans = -2e18;
	for (int i = 0; i <= W; i++) ans = max(ans, dp[N][i]);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 78336
<?php

$s = trim(fgets(STDIN));
$q = trim(fgets(STDIN));

$rev = 0;

$start = [];
$end = [];

for($i = 0; $i < $q; ++$i) {
    $inputs = explode(' ', trim(fgets(STDIN)));

    if ($inputs[0] === '1') {
        // strrev使うと実行時間に引っかかる
        // $s = strrev($s);
        $rev = ($rev + 1) % 2;
        continue;
    } 

    if ($inputs[1] === '1') {
        if ($rev === 0) {
            $start[] = $inputs[2];
        } else {
            $end[] = $inputs[2];
        }
    } else {
        if ($rev === 0) {
            $end[] = $inputs[2];
        } else {
            $start[] = $inputs[2];
        }
    }
}

$start_str = implode('', $start);
$end_str = implode('', $end);

if ($rev === 0) {
    echo strrev($start_str) . $s . $end_str;
} else {
    echo strrev($end_str) . strrev($s) . $start_str;
}


Measured memory_bytes: 20980
const MOD = Int64(10^9 + 7)

function main()
  n, m = map(s -> parse(Int64, s), split(readline()))
  answer = Int64(1)
  i = Int64(2)

  while i * i <= m
    if m % i == 0
      count = Int64(0)
      while m % i == 0
        count += 1
        m /= i
      end
      answer *= comb(n + count - 1, count)
      answer %= MOD
    end
    i += 1
  end

  if m > 1
    answer *= n
    answer %= MOD
  end

  println(answer)
end

function comb(n::Integer, k::Integer)
  if (n - k < k) return comb(n, n - k) end
  nume = Int64(1)
  deno = Int64(1)
  for i = 0:k - 1
    nume *= n - i
    deno *= i + 1
    nume %= MOD
    deno %= MOD
  end
  return nume * modpow(deno, MOD - 2) % MOD
end

function modpow(a::Integer, p::Integer)
  if p == 0
    return 1
  elseif p % 2 == 0
    return modpow(a, Int64(p / 2))^2 % MOD
  else
    return a * modpow(a, p - 1) % MOD
  end
end

main()


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

int main(){

    int n,m;
    int ans=0;
    cin>>n>>m;
    vector<int> a(n,-1);
    for(int i=0;i<m;i++){
        int s,c;
        cin>>s>>c;
        if(a[s-1]==-1) a[s-1]=c;
        else if(a[s-1]!=c) ans=-1;
    }
    if(n!=1&&a[0]==0) ans=-1;

    if(ans==0){
        for(int i=0;i<n;i++){
            if(a[i]==-1){
                if(i==0&&n>=2) a[i]=1;
                else a[i]=0;
            }
            ans+=a[i]*(pow(10,n-i-1)+0.0001);
        }
    }


    cout<<ans<<endl;




    return 0;
}

Measured memory_bytes: 256
import numpy as np

H, W = map(int, input().split(" "))
# True or False
SL = np.array([list(input()) for _ in range(H)]) == "."

L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)

for i in range(H):
    U[i] = (U[i-1] + 1) * SL[i]
    D[-i-1] = (D[-i] + 1) * SL[-i-1]
for i in range(W):
    L[:, i] = (L[:, i-1] + 1) * SL[:, i]
    R[:, -i-1] = (R[:, -i] + 1) * SL[:, -i-1]   
print(np.max(L+R+U+D) - 3)

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool solve(vector<int>& a, vector<int>& b){
  int N = a.size();
  sort(a.begin(), a.end(), greater<int>());
  sort(b.begin(), b.end(), greater<int>());
  for(int i = 0; i < N; i++){
    int x = a[i];
    if(x == 0) break;
    if(x > N) return false;
    if(b[x - 1] <= 0) return false;
    if(x != N && b[x] == b[x - 1]) return false;
    for(int j = 0; j < x; j++){ b[j] --; }
    sort(b.begin(), b.end(), greater<int>());
  }
  for(int i = 0; i < N; i++) if(b[i] != 0) return false;
  return true;
}

int main(){
  int N;
  while(cin>>N && N){
    vector<int> a(N), b(N);
    REP(i, N) cin>>a[i];
    REP(i, N) cin>>b[i];
    if(solve(a, b)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin>>a.at(i);
  }
  vector<int> ans(n,0);
  for(int i=0; i<n; i++){
    int j;
    j=a.at(i);
    ans.at(j-1)=i+1;
  }
  for(int i=0; i<n; i++){
    cout<<ans.at(i)<<" ";
  }
}


Measured memory_bytes: 4032
N = int(input())
a = list(map(int, input().split()))
num0 = 0
num1 = sum(a)

ans = 10**10
for i in range(0, N):
    num0 += a[i]
    num1 -= a[i]
    if ans > abs(num1-num0):
        ans = abs(num1-num0)
print(ans)


Measured memory_bytes: 31432
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007 
#define slld(x) scanf("%lld",&x)
ll t = 1 ;
void solve()
{
    ll a , b , ans = 0 , cur = 1 ;
    cin >> a >> b ;
    while( cur*a < b ){
        ans+=cur;
        cur*=a;
    }
    while(cur<b){
        cur--;
        cur+=a;
        ans++;
    }
    cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		int b = Integer.parseInt(br.readLine());
		
		System.out.println(6-a-b);

	}

}


Measured memory_bytes: 21332
N, K = map(int, input().split())
d = []
A = [[] for i in range(K)]
for _ in range(K):
    D = int(input())
    d.append(D)
    A[_] = list(map(int, input().split()))

list = []

for a in A:
    for num in a:
        if num in list:
            continue
        list.append(num)

ans = N - len(list)

print(ans)

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

#define ll long long
#define ull unsigned long long
#define mod 1e9+7
#define INF 1 << 30
#define MAX (1 << 20)
#define NINF (-(1 << 30))
#define Point pair<int, int>
#define triplet pair<pair<int, int>, int>

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;

    ll ans = 0;

    for (int c = 1; c < n; c++) {
        int num = n - c;

        int lim = sqrt(num);

        for(int i = 1; i <= lim; i++) {
            if(!(num%i)) {
                if(i != (num/i))
                    ans += 2;
                else
                    ans++;
            }
        }
    }

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

Measured memory_bytes: 3660
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
string s;
ll n;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>s;n = s.size();ll sum1 = 0;
		for(ll i=0;i<n;i++)
		{
			sum1 += s[i]-'0';
		}
		if(sum1%9==0)cout<<"Yes"<<endl;
		else cout<<"No";
}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 10780
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



ll dp[110][15][2000];

void make() {
	dp[0][0][0] = 1;
	
	for_(t, 0, 101) {
		for_(i, 0, 10) {
			for_(s, 0, 1000) {
				dp[t+1][i][s] += dp[t][i][s];
				dp[t+1][i+1][s+t] += dp[t][i][s];
			}
		}
	}
}

int main() {
	int n, s;
	minit(dp, 0); make();
	
	while (1) {
		cin >> n >> s; if (n==0 && s==0) break;
		
		cout << dp[101][n][s] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 26944
//?????´???????????????????°??????????(min)?????´????????¬??\????????¨??????????????????
//??????????????????min??????????°??????????(s0)??¨????????????min?????£?????????s0??§??????????????????????????????min??¨s0???????????????????????????????????????????????´??????????????????????????????????????????????????????
#include<stdio.h>
#include<limits.h>

void swap(int *a, int *b){
	int temp = *a;
	*a = *b;
	*b = temp;
	return;
}

void show(int A[], int n){
	int i;
	for( i = 0; i < n; i++ ){ printf("%5d", A[i]); }
	printf("\n");
	return;
}

void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];
	int i, j, k;
	for( i = 0; i < n1; i++ ){ L[i] = A[left+i]; }
	for( i = 0; i < n2; i++ ){ R[i] = A[mid+i]; }
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	i = 0;
	j = 0;
	for( k = left; k < right; k++ ){
		if( L[i] <= R[j] ){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
	return;
}

void mergeSort(int A[], int left, int right){
	if( left+1 <  right ){
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
	return;
}

int minimumCostSort(int A[], int sorted[], int n){
	int i, j;
	int min, minj, target, targetj;
	int cost = 0, addCost, addCost2;
	int swaptimes = 0;
	for( i = 0; i < n; i++ ){
		min = sorted[i];
		//sorted???i?????????????´????A??????????????????(minj)????????????
		for( j = 0; j < n; j++ ){
			if( A[j] == min ){
				minj = j;
				break;
			}
		}
		addCost = 0;
		addCost2 = 2 * (A[minj] + sorted[0]);
		while( minj != i ){
			target = sorted[minj];
			for( j = 0; j < n; j++ ){
				if( A[j] == target ){
					targetj = j;
					break;
				}
			}
			addCost += A[minj] + A[targetj];
			addCost2 += sorted[0] + A[targetj];
			swap(&A[minj], &A[targetj]);
			swaptimes++;
			minj = targetj;
			//show(A, n);
		}
		//????°???????????????£??????????????£????????????????????????????????????????????????????????????????????§?????????????????§?????????
		/*
		if( 2 * (sorted[i]+sorted[0]) + swaptimes * sorted[0] < swaptimes * sorted[i] ){
			cost += 2 * (sorted[i]+sorted[0]) + swaptimes * sorted[0] - swaptimes * sorted[i];
		}
		*/
		cost += (addCost<addCost2?addCost:addCost2);
		swaptimes = 0;
	}
	return cost;
}

int main(){
	int n, i;
	int w[1000], sorted[1000];
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%d", &w[i]);
		sorted[i] = w[i];
	}
	mergeSort(sorted, 0, n);
	//show(w, n);
	//show(sorted, n);
	printf("%d\n", minimumCostSort(w, sorted, n));
	return 0;
}

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

struct OBJ
{
    int value;
    char name[10];
};
int head, tail, TIME=0;
int main()
{
    int n, q;
    queue<OBJ> Q;
    OBJ t;
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d", t.name, &t.value);
        Q.push(t);
    }
    tail = n;
    while (head != tail)
    {
        t = Q.front(); Q.pop();
        t.value -= q;
        if (t.value <= 0)
        {
            TIME += q + t.value;
            printf("%s %d\n", t.name, TIME);
        }
        else
        {
            TIME += q;
            Q.push(t);
            tail ++;
        }
        head ++;
    }
}


Measured memory_bytes: 3688
def main():
    N = int(input())
    in_p_list = list(map(int, input().split()))
    p_list = [0 if i+1 == p else 1 for i,p in enumerate(in_p_list)]

    cnt = 0
    for i in range(N-1):
        p1 = p_list[i]
        p2 = p_list[i+1]
        if p1 == 0:
            cnt += 1
            p_list[i] = 1
            p_list[i+1] = 1
    cnt += 1 if p_list[-1] == 0 else 0

    print(cnt)


if __name__ == "__main__":
    main()

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const int limit = 5010;

const ll inf = 1LL << 50;
ll dp[limit];



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

	using tll = tuple<ll, ll, ll>;
	vector<tll> ary;

	rep(i, n) {
		ll h, p;
		cin >> h >> p;
		ary.push_back(tll(p + h, h, p));
	}

	sort(begin(ary), end(ary));
	rep(i, limit) dp[i] = inf;
	dp[0] = 0LL;

	for (auto &elem : ary) {
		ll ph, p, h;
		tie(ph, h, p) = elem;
		rrep(i, n)  if (dp[i] <= h) chmin(dp[i + 1], dp[i] + p);
	}

	int ans = 0;
	rep(i, n + 1) if (dp[i] < inf) ans = i;
	cout <<  ans << endl;

	return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;
  cin>>n>>m;
  ll step=m*1900+(n-m)*100;
  cout<<step*(1LL<<m)<<endl;

  return 0;

}


Measured memory_bytes: 256
//stay in this moment
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int ans=0;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<3;++i)
	if(s[i]==t[i])
	ans++;
	cout<<ans;
}
void q2(){
	int a,b;
	cin>>a>>b;
	int ans=(b+a-2)/(a-1);
	cout<<ans;
}
void q3(){
	int n;
	cin>>n;
	int arr[n],fre[n];
	for(int i=0;i<n;++i)
	{cin>>arr[n-i-1];fre[i]=1;}
	for(int i=1;i<n;++i)
	if(arr[i]>=arr[i-1])
	fre[i]+=fre[i-1];
	int mx=-1;
	for(int i=0;i<n;++i)
	mx=max(mx,fre[i]);
	cout<<mx;
}
void q4(){
	int n;
	cin>>n;
	n*=(n-1);
	cout<<n/2;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q4();
	return 0;
}
	


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
dic = defaultdict(int)
for i in range(M):
    a, b = map(int, input().split())
    dic[a] += 1
    dic[b] += 1
if any([x&1 for x in dic.values()]):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 53596
def abc():
    n, x = map(int, input().rstrip().split())
    donuts = []
    for i in range(n):
        donuts.append(int(input().rstrip()))
    if sum(donuts) > x:
        print(0)
        return
    donuts.sort()
    x -= sum(donuts)
    print(x // donuts[0] + n)


abc()


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(final String[] args) {
		@SuppressWarnings("resource")
		final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		final int N = in.nextInt();
		final int K = in.nextInt();
		System.out.println(N - K + 1);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
#define MAX 50

int brigde[MAX][MAX]={0};
int visited[MAX]={0};
int n, m;
int a[MAX], b[MAX];
void dfs(int a);

int main(void) {
    cin >> n >> m;
    int i, j;
    int cnt=0;
    for(i=0; i<m; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        brigde[a[i]][b[i]]=brigde[b[i]][a[i]]=1;
    }
    
    for(i=0; i<m; i++) {
        brigde[a[i]][b[i]]=brigde[b[i]][a[i]]=0;
        dfs(0);
        for(j=0; j<n; j++) {
            if(visited[j]==0) {
                cnt++;
                break;
            }
        }
        brigde[a[i]][b[i]]=brigde[b[i]][a[i]]=1;
        for(j=0; j<n; j++)
            visited[j]=0;
    }
    cout << cnt << endl;
    return 0;
}

void dfs(int a) {
    int i;
    visited[a]=1;
    
    for(i=0; i<n; i++) {
        if(brigde[a][i]==0);
        else if(visited[i]==1);
        else dfs(i);
    }
}



Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 1369.cc: Distribution Center
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = 100000;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

pii ps[MAX_M];
int ls[MAX_N], rs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++)
    scanf("%d%d", &ps[i].first, &ps[i].second);
  sort(ps, ps + m);

  for (int i = 0; i < n; i++) ls[i] = i, rs[i] = i + 1;

  for (int i = 0; i < m; i++) {
    int i1 = ps[i].second, i0 = i1 - 1;
    ls[i1] = ls[i0];
    rs[i0] = rs[i1];
  }

  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", rs[i] - ls[i]);
  }
  putchar('\n');
  return 0;
}



Measured memory_bytes: 5508