akhauriyash/Code-Regression huggingface dataset:
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	int N = 0, M = 0, ans = 0, i = 0;
	scanf("%d %d", &N, &M);
	for (i = 1; i < M; i++) {
		ans += i;
		//printf("x%d\n", ans);
	}
	for (i = 1; i < N; i++) {
		ans += i;
		//printf("y%d\n", ans);
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    int N;
    cin >> N;
    deque<ll> A;
    rep(i, N){
        ll ipt;
        cin >> ipt;
        A.push_back(ipt);
    }
    ll left = 0, right = 0;
    while(!A.empty()){
        if(left < right){
            ll num = A.front();
            left += num;
            A.pop_front();
        }else{
            ll num = A.back();
            right += num;
            A.pop_back();
        }
    }
    cout << abs(right - left) << endl;
    return 0;
}


Measured memory_bytes: 1920
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int N = sc.nextInt();

        int max = Math.max(h,w);
        int cnt = 0;
        while(N>0) {
            N -= max;
            cnt++;
        }
	    p(cnt);
    }
    public static <T> void p(T element) {
	    System.out.println(element);
    }
    public static <T> void pe(T element) {
        System.err.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21076
#include <cstdio>
#include <cstring>
#include <iostream>
#include<string.h>
#include<math.h>
using namespace std;
int a[1000000];
int main()
{
	int n=0;
	cin>>n;
	int x=0;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<' ';
	}
}

Measured memory_bytes: 1152
# coding: utf-8
# Your code here!
s=input()
N=len(s)
judge=True

if N<3:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)
    
elif (s[0]==s[1] and s[0]!=s[2]) or (s[0]==s[2] and s[0]!=s[1]) or (s[1]==s[2] and s[1]!=s[0]):
    print(1,3)
    
elif (s[-3]==s[-2] and s[-3]!=s[-1])or (s[-3]==s[-1] and s[-3]!=s[-2])or (s[-2]==s[-1] and s[-2]!=s[-3]):
    print(N-2,N)
    
else:
    for i in range(2,N):
        if (s[i-2]==s[i-1] and s[i-2]!=s[i]) or (s[i-2]==s[i] and s[i-2]!=s[i-1]) or (s[i-1]==s[i] and s[i-1]!=s[i-2]):
            print(i-1,i+1)
            judge=False
            break
    
    if judge:
        print(-1,-1)

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

using ll = long long;
using vi = vector<int>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

    int k, a, b;
    cin >> k >> a >> b;
    int rnd_a = (a / k) * k;
    if (rnd_a < a && rnd_a + k > b) cout << "NG" << endl;
    else cout << "OK" << endl;
    
}


Measured memory_bytes: 3652
n = int(input())
num_list = []
max_num = 0
max_num2 = 0

for x in range(n):
    i = int(input())
    if max_num < i:
        max_num2 = max_num
        max_num = i
    elif max_num2 < i:
        max_num2 = i
    num_list.append(i)

for num in num_list:
    if max_num != num:
        print(max_num)
    else:
        print(max_num2)

Measured memory_bytes: 12532
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
char c[yuzu|10];
int n=read(),ans;
int main(){
scanf("%s",c+1);
for (int i=1;i<=n;++i){
  int cnt1[999]={0},cnt2[999]={0},tmp=0;
  for (int j=1;j<=i;++j) cnt1[c[j]]++;
  for (int j=i+1;j<=n;++j) if (cnt1[c[j]]&&!cnt2[c[j]]++) ++tmp;
  ans=max(ans,tmp);  
  }write(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	if (k <= a) cout << k;
	else if (k <= a + b) cout << a;
	else cout << a - k + (a + b);
	
}



















Measured memory_bytes: 3656
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int b[]= new int[n-1];
    for(int i=0;i<n-1;i++)
    {
      b[i]=sc.nextInt();
    }
    if(n==2){
      System.out.println(b[0]*2);
      System.exit(0);
    }
    int sum=b[n-2]+b[0];
    for(int i=n-2;i>=1;i--){
      sum+=Math.min(b[i],b[i-1]);
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
  int x[5];
  for (int i=0;i<5;i++){
    scanf("%d",&x[i]);
  }
  
  for(int i=0;i<5;i++){
    if(x[i]==0){
      printf("%d",i+1);
    }
  }
  
  return 0;
}


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

using namespace std;

int main() {
	int a;
	int b;
	scanf("%d%d", &a, &b);
	int ans = 0;
	for (int i = a; i <= b; i++) {
		int book[10];
		memset(book, 0, sizeof(book));
		int size = 0;
		int t = i;
		for (size = 1; t; size++) {
			book[size] = t % 10;
			t /= 10;
		}
		size--;
		bool ok = true;
		for (int j = 1; j <= size; j++) {
			if (book[j] != book[size - j + 1]) ok = false;
		}
		ans += ok;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

long int n;
vector<long int> v;
vector<vector<long int>> dp;

long int solve(long int idx, long int skip){
  if(idx >= n){
    if(skip < 2)
      return 0;
    return -1e15;
  }

  if(dp[idx][skip] != -1e15)
    return dp[idx][skip];

  long int ans = -1e15;
  if(skip)
    ans = max({ans, solve(idx + 1, skip - 1), v[idx] + solve(idx + 2, skip)});
  else
    ans = v[idx] + solve(idx + 2, skip);
  
  return dp[idx][skip] =  ans;
}

void setVal(){
  for(long int i = 0;i < dp.size(); i++){
    for(long int j = 0; j < dp[i].size(); j++){
      dp[i][j] = -1e15;
    }
  }
}

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   cin>>n;
   v.resize(n);
   dp.resize(n + 1,vector<long int>(3));

   for(long int i = 0; i < n; i++)
     cin>>v[i];

   long int ans = 0;

   if(n % 2 == 0){
      setVal();
      ans = solve(0,1);
      setVal();
      ans = max(ans,solve(1,0));   
   }
   else{
    setVal();
    ans = solve(0,2);
    setVal();
    ans = max(ans,solve(1,1));
   }

   cout<<ans;

   return 0;
}

Measured memory_bytes: 20352
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=1e5+10;

bool can[maxn][3][3];
string s[3];
int ans;
int lenth[3];

void getcan(int t1,int t2){
	for(int i=0;i<(int)s[t1].size();i++){
		can[i][t1][t2]=true;
		for(int j=i;j<min(i+(int)s[t2].size(),(int)s[t1].size());j++)
			if(s[t1][j]!='?'&&s[t2][j-i]!='?'&&s[t1][j]!=s[t2][j-i]) can[i][t1][t2]=false;
	}
}

void getans(int pos,int t1,int t2,int t3){
	if((pos<lenth[t1])&&(can[pos][t1][t2]==false)) return;
	int len=max(pos+lenth[t2],lenth[t1]);
	for(int i=0;i<=len;i++){
		int l=i,r=i+lenth[t3]-1,r2=pos+lenth[t2]-1;
		bool ft1=true,ft2=true;
		if((i<=lenth[t1]-1)&&(can[i][t1][t3]==false)) ft1=false;
		if((l<=pos)&&(pos<=r)&&(can[pos-l][t3][t2]==false)) ft2=false;
		if((pos<=l)&&(l<=r2)&&(can[l-pos][t2][t3]==false)) ft2=false;
		if(ft1&&ft2) ans=min(ans,max(i+lenth[t3],len));
	}
}

int main(){
	for(int i=0;i<3;i++) cin>>s[i];
	for(int i=0;i<3;i++) lenth[i]=(int)s[i].size();
	for(int t1=0;t1<3;t1++) for(int t2=0;t2<3;t2++) if(t1!=t2) getcan(t1,t2);
	ans=lenth[0]+lenth[1]+lenth[2];
	for(int t1=0;t1<3;t1++) for(int t2=0;t2<3;t2++) if(t1!=t2){
		int t3=3-t1-t2;
		for(int i=0;i<=lenth[t1]+lenth[t3];i++) getans(i,t1,t2,t3);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>
 
using namespace std;
 
int main()
{
	long N,M;
	cin >> N >> M;
	vector<pair<long,long> > V(N);
	for(int i=0;i<N;i++)
	{
	 	int s,t;
		cin >> s >> t;
		V[i] = make_pair(s,t);
	}
	sort(V.begin(),V.end());
	long d = M;
	long sum = 0;
	for(int p=0;p<N;p++)
	{
		if(V[p].second>=d)
		{
			sum = sum + V[p].first*d;
			break;
			
		}
		else if(V[p].second<d)
		{
			d = d - V[p].second;
			sum = sum + V[p].first*V[p].second;
		}
	}
	cout << sum << endl;
		
 
 
}
 


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

int main(void){
  int h,w;
  cin >> h >> w;
  for(int i = 0;i < h;++i){
    for(int j = 0;j < w;++j){
      string s;
      cin >> s;
      if(s == "snuke") {
	cout << (char)('A' + j) << i + 1 << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = 1e9+7;
const int MAX_N=1e5+1;
int N,L,Q;
int x[MAX_N];
vector<int> v[MAX_N];//各点において、右に2^n日かけて行ける最も右の場所を求める。(n=1,2,3,4,)

void solv(int a){//v[a]を求める。
    int* pos=upper_bound(x,x+MAX_N,x[a]+L);
    int po=(int)(pos-x)-1;
    v[a].push_back(po);
    int i=0;
    while(v[po].size() > i){
        v[a].push_back(v[po][i]);
        po=v[po][i];
        i++;
    }
}
int query(int a,int b){//a -> b  (a<b)へかかる時間を求める。
    int res=0;
    while(a<b){
        vector<int>::iterator it1=upper_bound(v[a].begin(),v[a].end(),b);
        if(it1==v[a].end()){
            res += 1<<(v[a].size()-1);
            a=v[a][v[a].size()-1];
        }else if(it1==v[a].begin()){
            int z=(int)(it1-v[a].begin());
            a=*it1;
            res+=1<<z;
        }else{
            it1--;
            int z=(int)(it1-v[a].begin());
            a=*it1;
            res+=1<<z;
        }
        //cout<<a<<' '<<b<<' '<<res<<endl;
    }
    return res;
}

int main(){
    fill(x,x+MAX_N,INF);
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    cin>>L;
    for(int i=N-2;i>=0;i--){
        solv(i);
    }/*
    for(int i=0;i<N;i++){
        cout<<i<<endl;
        for(int j=0;j<v[i].size();j++){
            cout << v[i][j] <<' ';
        }
        cout<<endl;
    }*/
    cin>>Q;
    for(int i=0;i<Q;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        if(a>b){
            swap(a,b);
        }
        int res=query(a,b);
        cout<<res<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string s;
int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	if(s[2]!=s[3]||s[4]!=s[5]){
		cout<<"No";
		re 0;
	}
	cout<<"Yes";
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;cin >> n;
    cout << (n<1000?"ABC":"ABD") << endl;
    return 0;
}

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

int main(){
  int i,j,h,w,n,x,y;
 
  while(cin>>w>>h,h!=0,w!=0){
    int r[21][21]={0};
    r[1][1]=1;

    cin>>n;

    for(i=0;i<n;i++){
      cin>>x>>y;
      r[y][x]=-1;
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(r[i][j]!=-1){
	  if(i!=1&&r[i-1][j]!=-1){
	    r[i][j]+=r[i-1][j];
	  }
	  if(j!=1&&r[i][j-1]!=-1){
	    r[i][j]+=r[i][j-1];
	  }
	}
      }
    }

    /*   for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	//	cout<<"# "<<r[i][j];
	printf("| %3d ",r[i][j]);
      }
      cout<<endl;
    }
    */
    cout<<r[h][w]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>

const int INF = 1001001001;
const long long mod = 1000000007;

int main() {
	int n;
	std::cin >> n;

	long long ans10 = 1;
	for (int i = 0; i < n; i++) ans10 = (ans10 * 10) % mod;

	long long ans8 = 1;
	for (int i = 0; i < n; i++) ans8 = (ans8 * 8) % mod;

	long long ans9 = 1;
	for (int i = 0; i < n; i++) ans9 = (ans9 * 9) % mod;

	long long ans;
	ans = ans10 - ans9 - ans9 + ans8;
	ans %= mod;
  	ans = (ans + mod) % mod;
	std::cout << ans << std::endl;
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<math.h>
using namespace std;
typedef long long int ll;

void solve(){
    int a,b,c,k;cin>>a>>b>>c>>k;
    int ans=0;
    while(b<=a){
       ans++;b*=2;
    }
    while(c<=b){
       ans++;c*=2;
    }
   // cout<<ans;
    if(ans<=k) cout<<"Yes";
    else cout<<"No";
    cout<<"\n";
}

int main()
{
    int t;//cin>>t;
    t=1;
    while(t--)
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_d() {
    ll n;
	ull ans = 0;
    cin >> n;

	if (n % 2 == 0) {
		ans = n / 2 * (n - 1);
	}
	else {
		ans = (n - 1) / 2 * n;
	}

	
	cout << ans << "\n";
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x,k,d;
int main() {
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d > k) cout << x-k*d;
    else {
        k -= x/d;
        x -= (x/d)*d;
        if(k%2 == 0) cout << x;
        else cout << abs(x-d);
    }
    return 0;
}

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

	
	static int multiply(int n) {
		if(n==1) {
			return 1;
		}else {
			return n * multiply(n-1);
		}
		
	}
	
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		int[] y = new int[n];
		
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			y[i] = stdIn.nextInt();
		}
		
		double sum = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i==j) {
					continue;
				}else {
					int dist = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
					sum += Math.sqrt(dist);
				}
			}
		}
		
		double ans = sum / n;
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 23892
#if WATCH_RUNTIME
	#include <ctime>
	clock_t startTime;
#endif

#include <cstdio>
#include <cstring>
int main(void)
{

	#if WATCH_RUNTIME
	startTime=clock();
	#endif

	#if DEBUG 
	freopen("_in","r",stdin);
	#endif

	char blueCard[100][11],redCard[100][11];
	int i,N,M;
	int currValue,maxValue;
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%s",blueCard[i]);
	
	scanf("%d",&M);
	for(i=0;i<M;i++)
		scanf("%s",redCard[i]);

	maxValue=-1;
	for(int index=0;index<N;index++)
	{
		currValue=0;
		for(i=0;i<N;i++)
		{
			if(strcmp(blueCard[index],blueCard[i])==0)
				currValue++;
		}
		for(i=0;i<M;i++)
		{
			if(strcmp(redCard[i],blueCard[index])==0)
				currValue--;
		}
		if(currValue>maxValue)
			maxValue=currValue;
	}
	if(maxValue>0)
		printf("%d\n",maxValue);
	else
		printf("0\n");






	#if WATCH_RUNTIME
	printf("\t+==============\n");
	printf("\t|RUNTIME= %dms.\n",clock()-startTime);
	printf("\t+==============\n");
	#endif

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int x, y;
int cmmdc(int a, int b){
    int r;
    while(b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
int main(){
    cin>> x;
    y = 360 * x / cmmdc(x, 360);
    cout<< y / x;
}


Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
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 (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;
    cout << max(0,A-2*B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; ++i)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define UNIQ(a) a.erase(unique(ALL(a)),a.end())
#define debug(a) cerr<<#a":="<<a<<endl;
#define SZ(a) (int)a.size()
using LL = long long; template<class T> using V = vector <T>; template <class T> using VV = V<V<T>>;
using ll = LL;


template<typename T>// LL がよさそう
struct triangle_cumulativesum {
	vector<T> data;
	const int width = 3;
	triangle_cumulativesum(int N) :data(2 * N, 0) {}
	void build() {// 2回やると三角形になる
		FOR(i, 0, SZ(data) - 1) {
			data[i + 1] += data[i];
		}
	}
	void query_add(T s, T t, T a, T k) {//差分をimos的に管理 [s,t)に[a+k,2a+k,..,]を加算
		data[s] += a + k;
		data[s + 1] += -k;
		data[t] += -(a*(t - s + 1) + k);
		data[t + 1] += a * (t - s) + k;
	}
	void print() {
		cout << "out..." << endl;
		FOR(i, 0, SZ(data)) {
			cout << setw(width) << setfill('.') << data[i] << " ";
		}cout << endl;
	}
};

using VL = vector<LL>;
using VVL = vector<VL>;
int AB[400][400];

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

	LL N, M; cin >> N >> M;
	vector<LL> X(N, 0);
	using PLL = pair<LL, LL>;
	vector<PLL>q(M);
	FOR(i, 0, M) {
		cin >> q[i].first >> q[i].second;
	}
	SORT(q);
	triangle_cumulativesum<LL> ads(N);

	// query幅を考えて、sqrt(100000) = 316
	for (auto query : q) {
		LL A = query.first;
		LL B = query.second;
		A %= B;
		if (B <= 316) { // chien // まとめることができるか？
			AB[query.first][query.second]++;
		}
		else 
		{
			for (LL s = 0; s < N; s += (B-A)) {
				if (s)A = 0;
				LL t = min(N, s + B - A-1);
//				cout << s << "," << t << endl;
				ads.query_add(s, t, 1, A);
			}
		}
	}



	ads.build();
	ads.build();
	FOR(i, 0, N) {
		X[i] += ads.data[i];
	}
	//かいたぶぶん
	FOR(i, 1, 317) {
		ll bmod[i];
		FOR(j, 0, i)bmod[j] = 0;
		FOR(j, 0, i)FOR(k, 0, i)bmod[j] += ((k + j + 1) % i)*AB[k][i];
		FOR(j, 0, N)X[j] += bmod[j%i];
	}
	FOR(i, 0, N) {
		cout << X[i] << endl;
	}
}



Measured memory_bytes: 6664
#include "iostream"

using namespace std;

int N, L;
int num[100002];
int dp[100002];
int ans = 0;

int Search(int fig) {
	if (dp[fig])return dp[fig];
	dp[fig] = L - num[fig];
	if (num[fig] < num[fig - 1])dp[fig] = max(dp[fig], Search(fig - 1) + L - num[fig]);
	if (num[fig] < num[fig + 1])dp[fig] = max(dp[fig], Search(fig + 1) + L - num[fig]);
	return dp[fig];
}

int main() {
	cin >> N >> L;
	for (int i = 1; i <= N; i++)cin >> num[i];
	for (int i = 1; i <= N; i++)ans = max(ans, Search(i));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4972
import sys

N, K = map(int, input().split())
D = [str(i) for i in input().split()]
ans = 0
now = N

for j in range(10**6):
    for i in list(str(now)):
        if i in D:
            now += 1
            break
    else:
        print(now)
        sys.exit()

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    ans = (800 * n) - (n / 15 * 200);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
list = list(input())
a = ['L', 'U', 'D']
b = ['R', 'U', 'D']
isOK = True

for i, name in enumerate(list):
  if i % 2 == 1 and name not in a:
    isOK = False
  elif i % 2 == 0 and name not in b:
    isOK = False
  
print('Yes' if isOK else 'No')
    
    

Measured memory_bytes: 38384
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
    int a,b,i,j;
    while(1){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for(i = 0;i < a;i++){
            for(j = 0;j < b;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
import itertools

N,M = map(int,input().split())

path = [[False]*N for i in range(N)]
ans = 0

for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in list(itertools.permutations(range(N),N)):
    if i[0] == 0:
        for j in range(N):
            if j == N-1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)


Measured memory_bytes: 8052
#include <iostream>
#include <algorithm>
#include <climits>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF LONG_MIN
using namespace std;
typedef long long ll;

string S;
bool op_pri[3][256];
int p;

ll calc(ll n1, char op, ll n2) {
  switch(op) {
    case '*': return n1 * n2;
    case '+': return n1 + n2;
    case '-': return n1 - n2;
  }
  return 0;
}

ll number() {
  ll ret = 0;
  while(p < S.size() && '0' <= S[p] && S[p] <= '9') ret = ret * 10 + (S[p++] - '0');
  return ret;
}

ll expr(int level) {
  ll ret;
  char op;
  if(level < 3) {
    ret = expr(level + 1);
    while(p < S.size() && op_pri[level][S[p]]) {
      op = S[p++];
      ret = calc(ret, op, expr(level + 1));
    }
  } else {
    if(S[p] == '(') {
      p++;
      ret = expr(0);
      p++;
    } else {
      ret = number();
    }
  }
  return ret;
}

int main(void) {
  cin >> S;

  string pri = "*+-||";
  ll ans = -INF;
  ll ret;
  do {
    REP(i, 0, 3) REP(j, 0, 256) op_pri[i][j] = false;
    int k = 0;
    bool f = true;
    int cnt = 0;
    REP(i, 0, pri.size()) {
      if(pri[i] != '|') {
        op_pri[2 - k][pri[i]] = true;
        cnt++;
      } else {
        k++;
      }
    }

    p = 0;
    ret = expr(0);
    ans = max(ans, ret);
  } while(next_permutation(pri.begin(), pri.end()));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3176
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int a,b,n;
    cin>>a>>b>>n;
    if(a+b+n>21){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }
   return 0;
}

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e15;
const int MB = 20;
const int MOD = 1e9 + 7;

int dp[4][3001][3001];

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<vector<int>> a(n + 1, vector<int>(m + 1));
	for (int i = 0; i < k; i++) {
		int x, y, w;
		cin >> x >> y >> w;
		a[x][y] = w;
	}
	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			for (int c = 0; c <= 3; c++) {
				dp[0][i][j] = max(dp[0][i][j], dp[c][i - 1][j]);
				dp[1][i][j] = max(dp[1][i][j], dp[c][i - 1][j] + a[i][j]);
				dp[c][i][j] = max(dp[c][i][j], dp[c][i][j - 1]);
				if (c) dp[c][i][j] = max(dp[c][i][j], dp[c - 1][i][j - 1] + a[i][j]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= 3; i++) ans = max(ans, dp[i][n][m]);
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	//srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 354752
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=100005;

void solve()
{
	ll n,a[N],i;
	cin>>n;
	a[0]=0;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]-1>=a[i-1])
			a[i]--;
		else if(a[i]>=a[i-1]);
		else
		{
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int ans = (N-1 + (K-1) - 1) / (K-1);

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(){

    int k, s;//入力
    cin >> k >> s;
    int ans = 0;

    for (int x = 0; x <= k; x++){//二重ループ
        for (int y = 0; y <= k; y++){
            if (0 <= s - (x + y) && s - (x + y) <= k){//z = s - (x + y)と表現して三重を回避
                ans++;
            }
        }

    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int h, w;

int main()
{
    //h, w w > h
    vector<pair<int, pair<int, int>>> v;
    for (int h = 1; h < 200; h++)
    {
        for (int w = h + 1; w < 200; w++)
        {
            v.push_back({h * h + w * w, {h, w}});
        }
    }
    sort(v.begin(), v.end());

    while (cin >> h >> w)
    {
        if (w == 0 && w == 0)
            return 0;
        for (int i = 0; i < v.size(); i++)
        {
            if (h * h + w * w < v[i].first || (h * h + w * w == v[i].first && h < v[i].second.first))
            {
                cout << v[i].second.first << " " << v[i].second.second << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() { 
  int n,k,s;cin>>n>>k>>s;
  
  rep(i,k){
    cout<<s<<' ';
  }
  rep(i,n-k){
    if(s != 1000000000)cout<<1000000000<<" ";
    else cout<<1<<" ";
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 1280
n_s, a_s, b_s = gets.to_s.strip.split

n_i = n_s.to_i
a_i = a_s.to_i
b_i = b_s.to_i

total = 0

(1..n_i).each do |n|
  n_a = n.to_s.split('').map{|h| h.to_i}
  sum = n_a.inject(:+)
  if a_i <= sum && sum <= b_i
    total += n
  end
end

p total





Measured memory_bytes: 2044
n,m,x = map(int, input().split())
text = [list(map(int, input().split())) for _ in range(n)]
ans = 10**9
for bit in range(1<<n):
    skills = [0]*m
    yen = 0
    for i in range(n):
        if (bit>>i)&1:
            yen += text[i][0]
            for j in range(m):
                up = text[i][j+1]
                skills[j] += up
    for k in range(m):
        if skills[k] < x:
            break
    else:
        ans = min(yen,ans)
else:
    if ans == 10**9:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int k = kb.nextInt();
		String s = kb.next();
		String q = "";
		for (int i = 0; i < s.length(); i++) {
			if (i < k) {
				q += s.charAt(i);
			} else {
				q += "...";
				break;
			}
		}
		System.out.println(q);
		kb.close();
	}

}


Measured memory_bytes: 27088
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

//深さ優先
vector<int> seen;
vector<ll> h;

//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み

    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }

    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}

int main(){
    /*
    int n,m;
    cin>>n>>m;

    h.assign(n,0);
    rep(i,0,n) cin>>h[i];

    Graph G(n);
    rep(i,0,m){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    seen.assign(n,-1);

    rep(i,0,n){
        if(seen[i]==-1){
            dfs(G,i);
        }
    }

    int sum=accumulate(all(seen),0);

    cout<<sum<<endl;*/

    int n,a,b; cin>>n>>a>>b;

    int na=n*a;
    cout<<min(na,b)<<endl;

}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll max = 0;
  for(ll i=0;i<n;i++){
    cin >> a[i];
    if(max<a[i]) max = a[i];
  }

  sort(a.begin(), a.end());

  vector<ll> c(max+1,0);

  for(ll i=0;i<n;i++){
    if(c[a[i]]==1) c[a[i]] = -1;
    else if(c[a[i]]==0){
      c[a[i]] = 1;
      ll k = a[i]+a[i];
      while(k<max+1){
        c[k] = -1;
        k += a[i];
      }
    }
  }

  ll ans = 0;
  for(ll i=1;i<max+1;i++){
    if(c[i]==1) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 12764
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol i[10000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e=0,f=0;
  vector<string> s;
  string w;
  lol ans=0;
  cin >>a;
  for(int n=0;n<a*2;n++) cin >>i[n];
  sort(i,i+a*2);
  for(int n=0;n<a*2;n+=2) ans+=i[n];
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int64_t a; std::cin >> a;
  fin(a*(1+a*(1+a)));
  return 0;
}


Measured memory_bytes: 3644
def gyakugen( a, m ):
  b = m
  x, y = 1, 0
  while b>0:
    q = a // b
    a, b = b, a-q*b
    x, y = y, x-q*y
  return x if x>0 else x+m

m=10**9+7
n,k=map(int,input().split())
ans=n-k+1
print(ans)
for i in range(2,k+1):
  ans=(((ans*(k-i+1)*(n-k+2-i))%m)*((gyakugen(i-1,m)*gyakugen(i,m))%m))%m
  print(ans)

Measured memory_bytes: 3316
fun main(args: Array<String>) {
    val n = readInt()
    val p = readIntList().toMutableList()

    var ans = 0
    var i = 0
    while (i < n - 1) {
        if (p[i] == i + 1) {
            var tmp = p[i]
            p[i] = p[i + 1]
            p[i + 1] = tmp
            ans++
        }
        i++
    }
    if (p[n - 1] == n) ans++
    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 50680
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

ll n,m,q,a[100010],b[100010],v[100010],d[100010],c[100010],f[100010]={};
bool al[100010][11]={};
vector<ll> t[100010];

void nuri(ll v,ll d,ll c){
  if(al[v][d]>0) return;
  fr(i,d+1) al[v][i]=1;
  if(f[v]==0) f[v]=c;
  if(d>0){
    for(auto i=t[v].begin();i!=t[v].end();i++){
      nuri(*i,d-1,c);
    }
  }
  return;
}

int main(){
  cin>>n>>m;
  fr(i,m){
    cin>>a[i]>>b[i];
    t[--a[i]].push_back(--b[i]);
    t[b[i]].push_back(a[i]);
  }
  cin>>q;
  fr(i,q) cin>>v[q-1-i]>>d[q-1-i]>>c[q-1-i];
  fr(i,q) nuri(--v[i],d[i],c[i]);
  fr(i,n) cout<<f[i]<<endl;
}

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

int n;
int a[234567];
int pos[234567];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pos[a[i]] = i;
    }
    int cnt = 0;
    int maxx = -1;
    int cur = 0;
    for (int i = 1; i <= n; i++) {
        if (pos[i] > cur) {
            cur = pos[i];
            cnt++;
        } else {
            cur = pos[i];
            cnt = 1;
        }
        maxx = max(maxx, cnt);
    }
    cout << n - maxx << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    int n, m;
    int a[100], b[100], cnt[100];

    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n; ++i){
        cnt[i] = 0;
    }
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
        scanf("%d", &b[i]);
        cnt[a[i]]++;
        cnt[b[i]]++;
    }

    for(int i = 1; i <= n; ++i){
        printf("%d\n", cnt[i]);
    }

    return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>
#include <string.h>

int main(void)

{	
	int i;
	char s[20];
	scanf("%s",s);
	
	for(i=0;i<=4;i++){
		printf("%c",s[i]);
	}
	printf(" ");
	for(i=6;i<=12;i++){
		printf("%c",s[i]);
	}
	printf(" ");
	for(i=14;i<=18;i++){
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128