akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int i,j,minj,N,A[100],B[100],count=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj)
      count++;
    
    B[i]=A[i];
    A[i]=A[minj];
    A[minj]=B[i];
  }

  for(j=0;j<N-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    int x, y, z;
    
    cin >> x >> y >> z;
    
    int ans = (x - z) / (y + z);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    S = list(input().rstrip())
    for l in reversed(range(1, len(S)+1)):
        for d in range(len(S) - l + 1):
            if set(S[d:d+l]).issubset(set(["A", "C", "G", "T"])):
                print(l)
                exit()
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61824
def bubbleSort(A, N) :
    kaisu = 0
    flag = 1
    while flag :
        flag = 0
        for j in range(N-1, 0, -1) :
            if A[j]  < A[j-1] :
                A[j], A[j-1] = A[j-1], A[j]
                flag = 1
                kaisu += 1
    return kaisu

N = int(input())
A = list(map(int, input().split()))
kaisu = bubbleSort(A, N)
for i in range(N) :
    print(A[i], end="")
    if i != N-1 :
        print(" ", end="")
print()
print(kaisu)



Measured memory_bytes: 5628
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[200010];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();long long sum=0;
	for(int i=1;i<=n;i++)a[i]=read(),sum+=a[i];
	long long now=0,ans=-1;
	for(int i=1;i<=n;i++)
	{
		now+=a[i];
		long long ul=abs(sum-2*now);
		if(ans==-1)ans=ul;
		else ans=min(ans,ul);
	}printf("%lld\n",ans);	
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,a,b[1000],ans;
int main()
{
	cin>>n>>a;
	for(int i=1;i<=n;i++)
	{
		int c;
		cin>>c;
		if(c>=a)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
/*Problem Statement

Determine if an N
-sided polygon (not necessarily convex) with sides of length L1,L2,...,LN

can be drawn in a two-dimensional plane.

You can use the following theorem:

Theorem: an N
-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.*/
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t

inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{
	fast();
	lli n,x;
	cin>>n;
	lli sum=0,m1=INT_MIN;
	for(lli i=0;i<n;i++)
	{
		cin>>x;
		sum+=x;
		m1=max(m1,x);
	}
	sum-=m1;
	if(m1<sum)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
# 2つの入力を空白で分割し、数値化
X, Y = map(int, input().split())

money = {}
money = {"1" : 300000, "2": 200000, "3": 100000}

sum = 0


if str(X) in money.keys():
    sum += money[str(X)]

if str(Y) in money.keys():
    sum += money[str(Y)]

if X == 1 and Y == 1:
    sum += 400000

print(sum)

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

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

  ll max_val = -1000000;
  ll min_val = 1000000;
  ll sum_val = 0;

  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;

    max_val = max(max_val, a);
    min_val = min(min_val, a);
    sum_val += a;
  }

  cout << min_val << " " << max_val << " " << sum_val << endl;
  return 0;
}


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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)

#define maxn 200020
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{";
	for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i];
	cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n";
	for (auto& vec : arr)cout << "  " << vec << ",\n";
	cout << "}";
	return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}
ll n,k;
ll a[maxn];
void read(){
	cin >> n >> k;
	REP(i,n)cin >> a[i];
}

bool func(int x){
	ll cnt = 0;
	REP(i,n){
		cnt += ((a[i] + x - 1) / x) - 1;
	}
	// debug2(x,cnt);
	return cnt <= k;
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  read();
  int l = 0,r = 1e9 + 1;

  while(l + 1 != r){
  	int mid = (l + r)/2;
  	// can all len <= mid ?
  	if(func(mid))r = mid;
  	else l = mid;
  }

  cout << r << '\n';

}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector <double> p(n);
  rep(i,n)cin>>p[i];
  rep(i,n){p[i]++;}
  vector <double> s(n+1,0);
  rep(i,n+1){
    i!=0?s[i]=s[i-1]+p[i-1]:s[i]=0;
  }
  double ans =0;
  rep(i,n+1){
    if(i<k)continue;
    double tmp = s[i]-s[i-k];
    ans=max(ans,tmp);
  }
  ans/=2.0;
  printf("%.10f\n", ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m;
  m=0;
  vector<int> a,b;
  cin>>n;
  a.resize(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<0)m++;
  }
  int min=0;
  if(m%2!=0){
  	for(int i=1;i<n;i++){
    	if(abs(a[i])<abs(a[min]))min=i;
  	}
  }
  for(int i=0;i<n-1;i++){
    if(a[i]<0&&m%2!=0&&i==min)continue;
    if(a[i]<0||(a[i]>0&&m%2!=0&&i==min)){
      a[i]*=-1;
      a[i+1]*=-1;
    }
  }
  long sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 640
N = int(input())
A = [int(x) for x in input().split()]
cnt = 0

for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            # ????°???????index?????´??°
            minj = j

    if A[minj] != A[i]:
        cnt += 1
    # i???????????¨???
    buf = A[minj]
    A[minj] = A[i]
    A[i] = buf


print(' '.join(str(x) for x in A))
print(cnt)

Measured memory_bytes: 7728
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		int i=0;
		
		Scanner sc = new Scanner(System.in);
		
		
		while(true){
		    int x = sc.nextInt();
		    if ( x == 0 ) break;  
		
	         i++;
	    	 System.out.println("Case" + " " +i+ "" +":"+" " + x );
	     }

	     }
		
	}


Measured memory_bytes: 41688
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private Scanner sc;

	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(" ");
			
			LinkedList<Double> ll = new LinkedList<Double>(); 
			for (int i = 0; i < nico.length; i++) {
				double r0, r1;
				
				switch(nico[i]) {
				case "+":
					r0 = ll.pop();
					r1 = ll.pop();
					ll.push(r1 + r0);
					break;
					
				case "-":
					r0 = ll.pop();
					r1 = ll.pop();
					ll.push(r1 - r0);
					break;
					
				case "*":
					r0 = ll.pop();
					r1 = ll.pop();
					ll.push(r1 * r0);
					break;
					
				case "/":
					r0 = ll.pop();
					r1 = ll.pop();
					ll.push(r1 / r0);
					break;
					
				default:
					ll.push(Double.parseDouble(nico[i]));
					break;
				}
			}
			System.out.println(ll.pop());
		}
	}
}

Measured memory_bytes: 26196
fun main(args: Array<String>) {
    // n冊、m個のアルゴリズム、x理解度
    val (n, m, x) = readIntList()

    var min = Int.MAX_VALUE
    val arr = Array(n) { listOf<Int>() }
    repeat(n) {
        arr[it] = readIntList()
    }

    fun chk(buy: BooleanArray) { // buy 買うか買わないか
        var plice = 0
        val exp = IntArray(m) { 0 } // 経験値
        val fin = BooleanArray(m) { false } // 目標達成したかしていないか
        repeat(n) {
            if (buy[it]) {
                plice += arr[it][0]
                for (i in 1..m) {
                    exp[i - 1] += arr[it][i]
                    if (exp[i - 1] >= x) fin[i - 1] = true
                }
            }
        }
        if (fin.count { it } == m) min = Math.min(min, plice)
    }

    val buyList = BooleanArray(n) { false }
    fun create(d: Int) {
        arrayOf(true, false).forEach {// 本を買うか買わないかを1冊目からから試す
            buyList[d] = it
            if (d + 1 == n) { // n冊全てに買うか買わないかを設定できたらチェック
                chk(buyList)
            } else {
                create(d + 1) // 再帰で買うか買わないかを設定
            }
        }
    }

    create(0)
    println(if (min == Int.MAX_VALUE) -1 else min)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 39504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 32;

long long d[MAXN], day, year;

int main()
{
    d[0] = 1;
    d[1] = 1;
    d[2] = 2;
    REP(MAXN-3) d[i+3] = d[i]+d[i+1]+d[i+2];
    
    int n;
    while(cin >> n && n)
    {
        day = d[n] / 10;
        if(d[n] % 10  > 0 ) day++;
        year = day/365;
        if(day % 365 > 0) year++;

        cout << year << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int n, q, i, j;
  int *S, *T;
  int found;

  scanf("%d", &n);
  S = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) scanf("%d", &S[i]);

  scanf("%d", &q);
  T = (int *)malloc(sizeof(int) * q);
  for (i = 0; i < q; i++) scanf("%d", &T[i]);

  found = 0;
  for (i = 0; i < q; i++) {
    for (j = 0; j < n; j++) {
      if (S[j] == T[i]) {
        found++;
        break;
      }
    }
  }

  printf("%d\n", found);

  free(S);
  free(T);

  return 0;
}

Measured memory_bytes: 636
import sys
input = sys.stdin.readline


def main():
    MOD = 1000000007
    N = int(input())
    A = [int(x) for x in input().split()]

    ans = 1
    red = 0
    blue = 0
    green = 0

    for i in range(N):
        count = 0
        if red == A[i]:
            count += 1
        if blue == A[i]:
            count += 1
        if green == A[i]:
            count += 1

        if red == A[i]:
            red += 1
        elif blue == A[i]:
            blue += 1
        elif green == A[i]:
            green += 1

        ans = ans * count

    print(ans % MOD)



if __name__ == '__main__':
    main()



Measured memory_bytes: 13980
#include <bits/stdc++.h> 
#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif


using namespace std;
#define M 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define sz(a) (int)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<int>());
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define fi first
#define se second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair
#define endl "\n" 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define check(ds,x) (int)(ds.find(x)!=ds.end()?1:0)
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    vl arr(n);
    rep(i,0,n){
        cin>>arr[i];
    }
    ll high=M;
    ll low=1,mark=M;
    ll mid;
    while(high>=low){
        mid=(high+low)/2;
        //if(high<=13)
        //cout<<low<<" "<<high<<endl;
        int flag=0;
        ll count=0;
        rep(i,0,n){
            if(arr[i]<=mid){
                continue;
            }
            if(arr[i]%mid==0){
                count+=arr[i]/mid-1;
            }
            else{
                ll x=ceil((double(arr[i]))/mid)-1;
                /*if(mid==3){
                    cout<<x<<" ";
                }*/
                count+=x;
            }
        }
        /*if(mid==3){
            cout<<count<<endl;
        }*/
        if(count<=k){
            mark=mid;
            high=mid-1;
        }
        else{
            low=mid+1;
        }
    }
    cout<<mark<<endl;
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    map<string, vector<string> > k;

    string S;
    cin >> S;

    int l = S.length();

    S += "..........";

    k["dream"].push_back("dream");
    k["dream"].push_back("erase");
    k["dream"].push_back("er");

    k["er"].push_back("dream");
    k["er"].push_back("erase");

    k["erase"].push_back("dream");
    k["erase"].push_back("erase");
    k["erase"].push_back("r");

    k["r"].push_back("dream");
    k["r"].push_back("erase");

    int pos = 5;

    string x;

    if(S[0] == 'e') {
        x = "erase";
    } else {
        x = "dream";
    }

    for(int i = 0; i < 5; i++) {
        if(S[i] != x[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    while(pos < l) {
        bool c = true;
        for(int i = 0; i < k[x].size(); i++) {
            bool checker = false;
            for(int j = 0; j < k[x][i].length(); j++) {
                if(S[pos + j] != k[x][i][j]) {
                    checker = true;
                    break;
                }
            }
            if(checker) continue;
            c = false;
            pos += k[x][i].length();
            x = k[x][i];
            cerr << x << endl;
            break;
        }
        if(c) {
            cout << "NO" << endl;
            return 0;
        }
        cerr << pos << endl;
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 512
A,B,C,X,Y = map(int,input().split())

if (A + B) <= 2 * C:
  print( A*X + B*Y)
else:
  if X >= Y:
    if A < 2 * C:
      print(A*(X-Y)+2*C*Y)
    else:
      print(2*C*X)
  else:
    if B < 2 * C:
      print(B*(Y-X)+2*C*X)
    else:
      print(2*C*Y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main(){
 	int n, m;
  cin >> n >> m;
  int sum=0, tmp=0;
  rep(i, m) {
    cin >> tmp;
    sum += tmp;
  }
  if(sum <= n) cout << n - sum << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3632
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}


int main(){
    ll n;
    cin>>n;
    vector<ll> A(n);
    cin>>A;
    multiset<ll> S;
    ll ans=0;
    for(auto &I:A){
        auto it=S.lower_bound(I);
        if(S.size()==0 || it==S.begin()){
            ans++;
            S.insert(I);
        }
        else{
            --it;
            S.erase(it);
            S.insert(I);
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int n;
    cin >> n;
    map<string, int> m;
    rep(i, n){
        string s;
        cin >> s;
        m[s]++;
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", m["AC"], m["WA"], m["TLE"], m["RE"]);
    // printf("%d\n", N);
    return 0;
}

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

int main() {
  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 & w == 0) break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || j == 0 || i == h - 1 || j == w - 1)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define PI 3.14159265358979323846264338327950L
// ------------------ Debugging ------------------
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
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...);
}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
// -----------------------------------------------

signed main(){

    fastIO

    int n;cin >> n;
    int mx = -1, ans = 0;
    for (int i = 0; i < n; i++) {
    	int h;
    	cin >> h;
    	if (mx == -1) {
    		mx = h;
    	} else {
    		if (h > mx) {
    			mx = h;
    		} else {
    			ans += abs(mx - h);
    		}
    	}
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
int main(){
	int i,j;
	int hit=0,blow=0;
	int a[4],b[4];
	while(scanf("%d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
	hit=0;
	blow=0;
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			if(a[i]==b[j])
				blow++;
				}
				if(a[i]==b[i])
					hit++;
			}
			blow-=hit;
		printf("%d %d\n",hit,blow);
		}
		return 0;
}

Measured memory_bytes: 596
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
n = ip()                                     #入力整数1つ
#a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
if a.count('R') > n//2:j(1)
j(0)

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a ; i <= b; i++){
    if (i % k == 0) {
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
  return 0;
}


Measured memory_bytes: 3636
use proconio::*;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    };

    let mut hash = HashMap::new();

    for j in s {
        *hash.entry(j).or_insert(0) += 1;
    }

    for j in &["AC", "WA", "TLE", "RE"] {
        println!("{} x {}", j, hash.entry(j.to_string()).or_default());
    }
}


Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c;
 cin >> a>> b>>c;
 if((a==b&&b!=c)||(a==c&&b!=c)||(b==c&&a!=b)){
     cout << "Yes" << endl;
 }else{
     cout << "No" << endl;
 }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int n; cin >> n;
    int s[n+1];
    rep(i, n) cin >> s[i];
    int q; cin >> q;
    int t[q];
    rep(i, q) cin >> t[i];

    int ans = 0;
    rep(i, q) if(search(s, n, t[i])) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
int gcd(int x,int y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
int prime[1768457]={0};
void sieve(void)
{
 int i,j;
 for(i=0;i<1768457;i++)
        prime[i]=1;
 prime[0]=0,prime[1]=0;
 for(i=2;i<=sqrt(1768457);i++){
     if(prime[i]){
         for(j=i*i;j<1768457;j+=i){
             prime[j]=0;
         }
     }
 }
    
}
void swap(ll &x,ll &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}


void solve()
{   
    ll n;
    cin>>n;
    ll start=1;
    ll prev=start;
    ll k=1;
    ll len=0;
    while(1){
        start+=binpow(26,k);
        if(start>n)
            break;
        prev=start;
        k++;
    }
    start=prev;
    --start;
    string s="";
    while(1){
        if(k==0)
            break;
        for(int i=0;i<26;++i){
            char ch='a'+i;
            ll temp=binpow(26,k-1);
            if(start+temp>=n)
            {
                s+=ch;
                break;
            }
            start+=temp;
        }
        //cout<<start<<'\n';
        --k;
    }
    cout<<s;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}   


Measured memory_bytes: 3672
while True:
    n = int(input())
    if n == 0:
        break
    a = [int(input()) for _ in range(n)]
    ans = a[0]
    for i in range(n):
        tmp = 0
        for j in range(i, n):
            tmp += a[j]
            ans = max(ans, tmp)
    print(ans)

Measured memory_bytes: 7784
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct data{
	int t,next;
}g[410001];
bool v[210001];
int i,j,k,n,m,h[210001],a[210001],b[210001],tot,t1,t2;
void addedge(int x,int y){
	g[++tot].t=y;g[tot].next=h[x];h[x]=tot;
	g[++tot].t=x;g[tot].next=h[y];h[y]=tot;
}
bool dfs(int x,int *a){
	a[++a[0]]=x;v[x]=1;
	int i,k=0;
	for (i=h[x];i;i=g[i].next)
	 if (!v[g[i].t]){
		k++;
		if (dfs(g[i].t,a)) return 1;
	 }
	return !k;
}
int main(){
	scanf("%d%d",&n,&m);tot=0;memset(h,0,sizeof(h));memset(v,0,sizeof(v));
	for (i=1;i<=m;i++){
		scanf("%d%d",&j,&k),addedge(j,k);
		t1=j;t2=k;
	}
	v[t1]=v[t2]=1;
	dfs(t1,a);dfs(t2,b);
	printf("%d\n",a[0]+b[0]);
	for (i=a[0];i;i--) printf("%d ",a[i]);
	for (i=1;i<=b[0];i++) printf("%d ",b[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 5888
group_a = [1, 3, 5, 7, 8, 10, 12]
group_b = [4, 6, 9, 11]
group_c = [2]

x, y = map(int, input().split())
if x in group_a and y in group_a:
    print('Yes')
elif x in group_b and y in group_b:
    print('Yes')
elif x in group_c and y in group_c:
    print('Yes')
else:
    print('No')


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

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 1; i < n; i++) cin >> b[i];
    long long ans = 0;
    ans += b[1];
    ans += b.back();
    for (int i = 1; i < n - 1; i++) ans += min(b[i], b[i+1]);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;

    int X;
    cin >> X;

    for (;;++X) {
        int i;
        for (i = 2; i < X; ++i)
        {
            if (X % i == 0)
                break;
        }
        if (i == X)
            break;
    }

    cout << X << endl;

    return 0;
}


Measured memory_bytes: 256
let input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
let arr = input.split('');
let result = "";
for (let i=0; i<arr.length; i++) {
  let tmp = arr[i];
  if ( arr[i].match(/[a-z]/) ) {
    tmp = arr[i].toUpperCase();
  } else if (arr[i].match(/[A-Z]/) ) {
    tmp = arr[i].toLowerCase();
  }
  result += tmp;
}
console.log(result.trim());


Measured memory_bytes: 16232
n = int(input())
a = list(map(int,input().split()))
M = max(a)
m = min(a)
if M-m >= 2:
  print("No")
elif M == m:
  if a[0] == n-1 or a[0]*2 <= n:
    print("Yes")
  else:
    print("No")
else:
  alone = a.count(m)
  left = n - alone
  if alone >= M:
    print("No")
  elif (M - alone)*2 <= left:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 13964
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()

arr=limii()
sumarr=sum(arr)
xsum=0
ans=10**1000
for i in range(n-1):
    xsum+=arr[i]
    ans=min(ans,abs(xsum-(sumarr-xsum)))
print(ans)









Measured memory_bytes: 96540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

const int MOD = 1'000'000'007;
using mint = Fp<MOD>;

mint dp[710][2010];

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

    // 桁数で場合分け
    for (int i = 1; i < 705; i++)
    {
        dp[i][0] = 1;
    }

    for (int i = 0; i < 705; i++)
    {
        for (int j = 1; j < 2005; j++)
        {
            dp[i + 1][j] = dp[i + 1][j - 1] + dp[i][j];
        }
    }
    mint ans = 0;
    for (int i = 0; i < 700; i++)
    {
        ans += dp[i][s];
        s -= 3;
        if (s < 0)
        {
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 14676
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  char S[4];
  cin >> S;
  string ans;
  int A = (S[0]-'0')*10 + S[1]-'0';
  int B = (S[2]-'0')*10 + S[3]-'0';

  if (0<A && A<=12 && 0<B && B<=12)
    ans = "AMBIGUOUS";
  else if(0 < A && A <= 12)
    ans = "MMYY";
  else if(0 < B && B <=12)
    ans = "YYMM";
  else
    ans = "NA";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        elif i == K-1:
            tmp = xp[i] 
    else:
        continue
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        elif i == K-1:
            tmp = xn[i]
    else:
        continue
    ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 14484
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	int flag=0;
	for(int i=1;i<=50000;i++){
		if((int)(i*1.08)==n){
			cout<<i<<endl;
			flag=1;
			break;
		}
	}
	if(flag==0)cout<<":("<<endl;
} 

Measured memory_bytes: 256
# 各日について、その日のスコアが一番大きくなるようにする
# 365日×26パターン（=）
def main():
    import sys
    import numpy as np
    D = int(sys.stdin.readline())
    Dur = np.zeros(26)
    S = np.zeros((D, 26))
    C = np.array(list(map(int, sys.stdin.readline().split())))
    for i in range(D):
        S[i] = list(map(int, sys.stdin.readline().split()))

    for d in range(D):
        Dur += 1
        cand = 0
        score_mx = -10**30
        loss = np.sum(Dur*C)
        for i in range(26):
            sat = S[d, i]
            score = sat+loss-Dur[i]*C[i]
            if score > score_mx:
                score_mx = score
                cand = i
        
        Dur[cand]=0
        print(cand+1)  # 1-index
main()


Measured memory_bytes: 27308
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;

const int MAX = 2000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){

  int x,y;
  cin >> x >> y;

  if((x+y)%3 != 0){
    cout << 0 << endl;
    return 0;
  }

  ll n,m;
  n = x-(x+y)/3;
  m = y-(x+y)/3;
  COMinit();
  cout << COM(n+m,m) << endl;
  
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int k;
	string s;
	cin>>k>>s;
	int n=s.length();
	if(n<=k){
		cout<<s<<endl;
		return 0;
	}
	s=s.substr(0,k);
	s+="...";
	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int flg[30],i,a;
	for(i=0;i<30;i++) flg[i]=0;
	for(i=0;i<28;i++){
		cin>>a;
		flg[a-1]=1;
	}
	for(i=0;i<30;i++){
		if(flg[i]==0) cout<<i+1<<endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
int main(void){
    long long int N,M;
    scanf("%lld %lld",&N,&M);
    if(N>=2&&M>=2)printf("%lld",(N-2)*(M-2));
    else{
        if(!(N==1&&M==1))printf("%lld",N*M-2);
        else printf("1");
    }
    return 0;
}


Measured memory_bytes: 128
let () = Scanf.scanf "%d %d\n" @@ fun n x ->
  let ls = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun l -> l in
  let (acc, n) = Array.fold_left (fun (acc, n) l ->
    acc + l, n + if acc <= x then 1 else 0) (0, 0) ls in
  Printf.printf "%d\n" @@ n + if acc <= x then 1 else 0

Measured memory_bytes: 2432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int H = Integer.parseInt(line.split(" ")[0]);
        int W = Integer.parseInt(line.split(" ")[1]);

        String[][] craymore = new String[H][W];
        int count = 0;
        while (sc.hasNext()) {
            craymore[count] = sc.nextLine().split("");
            count++;
        }

        sc.close();
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < H; i++) {
            sb.setLength(0);
            for (int j = 0; j < W; j++) {
                if (craymore[i][j].equals("#")) {
                    sb.append("#");
                    continue;
                }
                int mineCount = 0;
                for (int k = -1; k <= 1; k++) {
                    if (i + k < 0 || i + k >= H) {
                        continue;
                    }
                    for (int l = -1; l <= 1; l++) {
                        if (j + l < 0 || j + l >= W || (k == l && k == 0)) {
                            continue;
                        }

                        if (craymore[i + k][j + l].equals("#")) {
                            mineCount++;
                        }

                    }
                }
                sb.append(mineCount);
            }
            System.out.println(sb.toString());
        }
    }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

c = 0
for i in range(n):
      ci = 0
      ci = min(a[i],b[i])
      c += ci
      b[i] -= ci
      ci1 = 0
      ci1 = min(a[i+1],b[i])
      c += ci1
      a[i+1] -= ci1

print(c)

Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int D[100][6];

void roll(int Dice[], char c)
{
    int t;
    if (c == 'E')
    {
        t = Dice[2];
        Dice[2] = Dice[0];
        Dice[0] = Dice[3];
        Dice[3] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'W')
    {
        t = Dice[3];
        Dice[3] = Dice[0];
        Dice[0] = Dice[2];
        Dice[2] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'N')
    {
        t = Dice[4];
        Dice[4] = Dice[0];
        Dice[0] = Dice[1];
        Dice[1] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'S')
    {
        t = Dice[1];
        Dice[1] = Dice[0];
        Dice[0] = Dice[4];
        Dice[4] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'R')
    {
        t = Dice[2];
        Dice[2] = Dice[1];
        Dice[1] = Dice[3];
        Dice[3] = Dice[4];
        Dice[4] = t;
    }
}

int top(int Dice[])
{
    return Dice[0];
}

int front(int Dice[])
{
    return Dice[1];
}

int left(int Dice[])
{
    return Dice[3];
}

int right(int Dice[])
{
    return Dice[2];
}

bool equal(int Dice1[], int Dice2[])
{
    bool flat;
    for (int i = 0; i != 6; ++i)
    {
        for (int j = 0; j != 4; ++j)
        {
            flat = true;
            for (int k = 0; k != 6; ++k)
            {
                if (Dice1[k] != Dice2[k])
                {
                    flat = false;
                    break;
                }
            }
            if (flat)
            {
                return true;
            }
            roll(Dice2, 'R');
        }
        if (i % 2 == 0)
        {
            roll(Dice2, 'N');
        }
        else
        {
            roll(Dice2, 'E');
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        for (int j = 0; j != 6; ++j)
        {
            cin >> D[i][j];
        }
    }
    int l = 0;
    for (int i = l; i < n-1; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            if (equal(D[i], D[j]))
            {
                cout << "No" << endl;
                return 0;
            }
        }
        ++l;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3096
from itertools import combinations

n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(n)]

ans = float('inf')
for i in range(1, n+1):
    for c_books in combinations(books, i):
        scores = [0] * m
        price = 0
        for book in c_books:
            price += book[0]
            for j in range(m):
                scores[j] += book[j+1]
        if all([scores[k] >= x for k in range(m)]):
            ans = min(ans, price)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

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

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

	}
	else
    {
        cout<<"No"<<endl;
    }





	return 0;
}


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

int main() {
    ll n,d,r=0,ans=1;
    cin>>n>>d;
    while(true){
        r+=2*d+1;
        if(r>=n)break;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#lにa回、rにb回進む
x,y = map(int,input().split())
#x = a +2b
#y = 2a+b
#x+y = 3a+3b
#a+b = (x+y)/3
#b=x-a+b
b = x-(x+y)/3
a = (x-2*b)
ans = 0
#print("a:{} b:{}".format(a,b))
if a<0 or b<0 or b-int(b)>0.00001 or a-int(a)>0.00001:
  print(ans)
  exit()
 
MAX = 1000000;
MOD = 1000000007;
 
fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
 
#テーブルを作る前処理
def COMinit():
    fac[0],fac[1] = 1,1
    finv[0],finv[1] = 1,1
    inv[1] = 1
    for i in range(2,MAX):
      fac[i] = fac[i - 1] * i % MOD
      inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
      finv[i] = finv[i - 1] * inv[i] % MOD
 
#二項係数計算
def COM(n,k):
  if n < k:
    return 0
  if n < 0 or k < 0:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
 
COMinit()
print(COM(int(a+b),int(a)))

Measured memory_bytes: 121880
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int R;
	cin >> R;
	string s = "AGC";
	if(R<1200) s="ABC";
	else if(R<2800) s="ARC";
	cout << s << endl;
	
	return 0;
}

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

using namespace std;

int main(){
  int x;
  cin >> x;
  vector<int> isp(100004, 1);
  for(int i = 2; i <= 317; i++){
    for(int j = 2; j <= 100003; j++){
      if(j%i == 0 && i != j) isp[j] = 0;
    }
  }
  for(int i = x; i < 100004; i++){
    if(isp[i]){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char maxLenString(int a,int b){
    return (a>b?'|':'-');
}
string solve(string a,string b){
    int n=a.size();
    int m=b.size();
    vector<vector<char>> chars(n+1,vector<char>(m+1,':'));
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
                continue;
            }else if(a[i-1]==b[j-1]){
                    chars[i][j]='d';
                    dp[i][j]=dp[i-1][j-1]+1;
            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                chars[i][j]=maxLenString(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans="";
    int i=n;
    int j=m;
    while(i>=0 && j>=0){
        if(chars[i][j]=='d'){
            ans.push_back(a[i-1]);
            i--;
            j--;
        }else if(chars[i][j]=='-'){
            j--;
        }else{
            i--;
        }
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
int main(){
	string a,b;
    cin>>a>>b;
    cout<<solve(a,b);
	return 0;
	
}


Measured memory_bytes: 47260
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val board = (1..h).map { readLine()!!.split("").drop(1).take(w).map { if (it == "#" ) it else "0" }.toMutableList() }

    val dy = listOf(-1, 1, 0,  0, -1, 1,  1, -1)
    val dx = listOf( 0, 0, 1, -1,  1, 1, -1, -1)

    for (i in 0 until h) {
        for (j in 0 until w) {
            if (board[i][j] == "#") {
                for (k in 0..7) {
                    val y = i + dy[k]
                    val x = j + dx[k]
                    if (y in 0 until h && x in 0 until w) {
                        if (board[y][x] != "#") {
                            board[y][x] = (board[y][x].toInt() + 1).toString()
                        }
                    }
                }
            }
        }
    }
    print(board)
}

fun <T> print(matrix: List<List<T>>) {
    matrix.forEach { println(it.joinToString("")) }
}

Measured memory_bytes: 39204
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main()
{
    int n,k;
    int r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    string my;
    int ans = 0;
    for(int i=0;i<k;++i)
    {
        if(t[i] == 's')
        {
            my += 'r';
            ans += r;
        }else if(t[i] == 'r')
        {
            my += 'p';
            ans += p;
        }else
        {
            my += 's';
            ans += s;
        }
    }
    for(int i=k;i<n;++i)
    {
        if(t[i] == 's')
        {
            if(my[i-k] == 'r')
            {
                my += '-';
            }else 
            {
                my += 'r';
                ans += r;
            }
        }else if(t[i] == 'r')
        {
            if(my[i-k] == 'p')
            {
                my += '-';
            }else 
            {
                my += 'p';
                ans += p;
            }
        }else{
            if(my[i-k] == 's')
            {
                my += '-';
            }else
            {
                my += 's';
                ans += s;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640