akhauriyash/Code-Regression huggingface dataset:
/*
 http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1612807
 */

#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <limits>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

long exc;
int L[100001];
int R[100001];

void merge2(vector<int> &arr, int left, int mid, int right) {
    int leftlen = mid - left;
    int rightlen = right - mid;
    REP(i,leftlen) L[i] = arr[left+i];
    REP(i,rightlen) R[i] = arr[mid+i];
    L[leftlen] = R[rightlen] = 2e9;
    int i = 0, j = 0;
    FOR(k, left, right) {
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
            exc+=j;
        }else {
            arr[k] = R[j];
            j++;
        }
    }
}

void mergesort2(vector<int> &arr, int left, int right) {
    if (left+1 < right) {
        int mid = (left + right) / 2;
        mergesort2(arr, left, mid);
        mergesort2(arr, mid, right);
        merge2(arr, left, mid, right);
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> v;
    PUSH(n,v);
    mergesort2(v, 0, n);
    cout << exc << endl;
    return 0;
}

Measured memory_bytes: 2844
import itertools

n,m,q = map(int, input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
highScore = 0

for i in range(q):
    a[i],b[i],c[i],d[i] = map(int, input().split())

for A in itertools.combinations_with_replacement(range(1,m+1),n):
    score = 0
    for o in range(q):
        if A[b[o]-1] - A[a[o]-1] == c[o]:
            score += d[o]
    highScore = max(score,highScore)

print(highScore)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    
    vector<int> V(N);
    rep(i, N) cin >> V.at(i);
    sort(all(V));

    long double ans = V.at(0);
    rep(i, N - 1) {
        ans += V.at(i + 1);
        ans /= 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int k = s.nextInt();
		int n = s.nextInt();
		int[] a = new int[n];

		for(int i=0;i<n;i++) {
			a[i]=s.nextInt();
		}
		int[] diff = new int[n];

		diff[0]=a[0]+k-a[n-1];
		for(int i=1;i<n;i++) {
			diff[i] =  a[i]-a[i-1];
		}
		int max = 0;
		for(int i=0;i<n;i++) {
			if(diff[i]>max) 
				max = diff[i];
		}
		System.out.println(k-max);
	}

 }

	

Measured memory_bytes: 76564
#include<iostream>
using namespace std;
int main(){
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int a, b;

	fgets(str, 100, stdin);
	sscanf(str, "%d %d\n", &a, &b);

	int n = b - a;

	printf("%d\n", n*(n-1)/2 - a);

	return 0;
}


Measured memory_bytes: 128
def treeunprocess(tstr,lv):
    d=0
    if len(tstr)==0:
         return []
    for i in range(len(tstr)):
        if tstr[i]=="(":
            d+=1
        elif tstr[i]==")":
            d-=1
        elif tstr[i]=="," and d==1:
            return [lv]+treeunprocess(tstr[1:i], 2*lv+1) + treeunprocess(tstr[i+1:-1], 2*lv+2)

def treeprocess(tlst, lv):
    #if 2*lv+1 not in tlst and 2*lv+2 not in tlst:
    if lv not in tlst:
        return ""
    return "("+treeprocess(tlst,2*lv+1)+","+treeprocess(tlst,2*lv+2)+")"

while(1):
    try:
        IN=raw_input().split()
    except:
        break
    cmd=IN[0]
    T=IN[1:]
    D=[[],[]]
    for i in range(2):
        t=T[i]
        D[i]=treeunprocess(t,0)
    if cmd=="i":
        E=sorted([d for d in D[1] if d in D[0] ])
    else:
        E=sorted(D[0] + [d for d in D[1] if d not in D[0]  ] )
    print treeprocess(E,0)

Measured memory_bytes: 6508
#include<bits/stdc++.h>
using namespace std;
long long int dp[102][100005];
long long int coin[105];
long long int cost[105];
int main()
{
        long long int i,j,n,m,t,mx=0;
    cin>>t>>n;
    for(i=1;i<=t;i++){
        cin>>coin[i]>>cost[i];
    }
    for(j=1;j<=t;j++){
        for(i=1;i<=n;i++){
            if(i>=coin[j]&&dp[j-1][i-coin[j]]+cost[j]>dp[j-1][i]){
                dp[j][i]=dp[j-1][i-coin[j]]+cost[j];
            }
            else
                dp[j][i]=dp[j-1][i];
        }
    }
    for(i=1;i<=100000;i++)
    mx=max(mx,dp[t][i]);
    cout<<mx<<endl;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());

	int ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i]+l[j]>l[k] && l[i]!=l[j] && l[j]!=l[k]) {
                    ans++;
                }
            }
        }
    }
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <unordered_map>

using namespace std;

typedef long long LL;

int n;
const int MAXN = 10;

vector<string> strs;
int s[MAXN];

int main() {
    cin >> n;
    s[0] = 0;
    strs.push_back("a");
    s[1] = 1;
    for (int i = 1;i < n;i ++) {
        s[i] = strs.size();
        for (int j = s[i-1];j < s[i];j ++) {
            int h[27];
            memset(h, 0, sizeof(h));
            for (int k = 0;k < strs[j].size();k ++) {
                h[strs[j][k]-'a'] ++;
            }
            int ll = 0;
            for (int k = 0;k < 27;k ++) {
                if (h[k] > 0) ll ++;
            }
            for (int k = 0;k <= ll;k ++) {
                char c = k + 'a';
                strs.push_back(strs[j] + c);
            }
        }
    }
    for (int i = s[n-1];i < strs.size();i ++) {
        cout << strs[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int dp[1001001];
int dp2[1001001];
const int INF = 1001001001;

int main() {
  vector<int> v;
  vector<int> v2;
  int ret = 1;
  while(1){
    if(ret*(ret+1)*(ret+2)/6>1000000) break;
    v.PB(ret*(ret+1)*(ret+2)/6);
    if((ret*(ret+1)*(ret+2)/6)%2==1) v2.PB(ret*(ret+1)*(ret+2)/6);
    ++ret;
  }
  sort(v.begin(),v.end(),greater<int>());
  sort(v2.begin(),v2.end(),greater<int>());
  FOR(i,1,1000000) dp[i] = INF;
  FOR(i,1,1000000) dp2[i] = INF;
  for(auto x: v){
    dp[x] = 1;
    FOR(i,0,1000000-x){
      if(dp[i]!=INF) chmin(dp[i+x],dp[i]+1);
    }
  }
  for(auto x: v2){
    dp2[x] = 1;
    FOR(i,0,1000000-x){
      if(dp2[i]!=INF) chmin(dp2[i+x],dp2[i]+1);
    }
  }

  while(1){
    int n; cin >> n;
    if(n==0) break;
    cout << dp[n] << " " << dp2[n] << "\n";
  }
  

  

}



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

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a >= b){
		for(int i = 1; i <= a; i++)
			cout << b;
	}
	else{
		for(int i = 1; i<= b; i++)
			cout << a;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

using namespace std;

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

  long max_val;
  scanf("%ld", &max_val);

  for (int i = 1; i < n; ++i) {
    long current;
    scanf("%ld", &current);
    if (current - max_val < -1) {
      printf("No\n");
      return 0;
    }
    max_val = max(max_val, current);
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    print(pow(k, n, MOD))


if __name__ == '__main__':
    main()



Measured memory_bytes: 7296
# D - Face Produces Unhappiness

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
S = input()

prev_c = None
score = 0
for c in S:
    if c == prev_c:
        score += 1
    prev_c = c

score += 2 * K

print(min((N - 1, score)))


Measured memory_bytes: 39152
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}n..
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}


void solve()
{
    
    
    string s,t;cin>>s>>t;
    if(t.substr(0,s.length())==s)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}
signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}



Measured memory_bytes: 3656
N = int(input())
H = [ int(n) for n in input().split() ]

count = 0
res = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        res += 1
        if res > count:
            count = res
    else:
        res = 0
    #print(res, count)

print(count)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    ll n; cin >> n;
    vector<ll> c(n);
    rep(i,n) cin >> c[i];
    sort(c.begin(),c.end());

    mint ans=0;
    vector<mint> two(n+1);
    two[0] = 1;
    rep(i,n) two[i+1] = two[i] * 2;
    rep(i,n){
        int l = i, r = n-i-1;
        mint now = two[l];
        if (r>0) now *= (two[r-1]*(r+2));
        else now *= two[r];
        ans += now * c[i];
        //ans += c[i] * 2^(i-1) * (2^(n-i-1)*(i+2));
    }

    ans *= two[n];
    cout << ans.x << endl;

    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
string s;cin>>s;
if(s == "SSS")cout<<0<<endl;
else if(s == "RSR"||s == "SRS"||s=="SSR"||s=="RSS") cout<<1<<endl;
else if(s=="RRR") cout<<3;
else{
    cout<<2<<endl;
}
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    if (A == B)
    {
        cout << A + A << endl;
    }
    else
    {
        int tmp = max(A, B);
        cout << tmp + tmp - 1 << endl;
    }
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}



signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n;
    cin>>n;

    int ans=0;
    REP(i,1,n+1){
        if(i%3!=0 && i%5!=0) ans += i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
	unsigned long long dp[1001][1001];
int main(){
	int n,m,d[1001],c[1001];
	cin>>n>>m;
	/*for(int i=0;i<=n+1;i++){
		for(int j=0;j<=m+1;j++){
			dp[i][j]=0;
		}
	}*/
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		cin>>d[i];
	}
	for(int i=1;i<=m;i++){
		cin>>c[i];
	}
	for(int i=0;i<n;i++){
		for(int j=1+i;j<=m;j++){
			if(dp[i+1][j+1]==0){
				dp[i+1][j+1]+=dp[i][j]+c[j]*d[i+1];
				//cout<<dp[i+1][j+1]<<endl;
			}
			if(dp[i][j]!=0&&dp[i][j]<dp[i][j+1]){
				dp[i][j+1]=dp[i][j];
			}
		}
	}
	unsigned long long minx=164764153;
	for(int i=m-n+1;i<=m+1;i++){
		//minx=min(dp[n][i],minx);
		if(dp[n][i]<minx&&dp[n][i]!=0)minx=min(dp[n][i],minx);
	}
	/*for(int i=0;i<n+2;i++){
		for(int j=1;j<=m+1;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
		
	cout<<minx<<endl;
}

Measured memory_bytes: 10916
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long h,w;
    cin >> h >> w;
    if(w==1||h==1){
        cout << 1 << endl;
        return 0;
    }
    if(h%2==0||w%2==0) cout << (h*w)/2 << endl;
    else cout << (h*w+1)/2 << endl;
}

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

bool used[26];

int main(){
	string s;
	cin >> s;
	if(s.size() < 26){
		for(int i = 0; i < s.size(); i++){
			used[s[i]-'a'] = true;
		}
		for(int i = 0; i < 26; i++){
			if(!used[i]) {
				s += (char)(i+'a');
				cout << s << endl;
				return 0;
			}
		}
	} else {
		if(s == "zyxwvutsrqponmlkjihgfedcba"){
			cout << -1 << endl;
			return 0;
		}
		string new_string = s;
		next_permutation(new_string.begin(),new_string.end());
		for(int i = 0; i < s.size(); i++){
			cout << new_string[i];
			if(new_string[i] != s[i])
				break;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
bool e[123456 * 2+1];
int main() {
	for (int i = 2; i <= 123456 * 2; i++){
		if (!e[i]){
			for (int j = i + i; j <= 123456 * 2; j += i)
				e[j] = true;
		}
	}
	int n;
	while (cin >> n, n){
		int count=0;
		for (int i = n + 1; i <= n * 2; i++)
			if (!e[i])count++;
		cout << count << endl;
	}
	
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    string S; cin >> S;
    bool can = true;
    rep(i,S.size()){
        if(i%2==0){
            if(S[i]=='L') {
                can = false; break;
            }
        }
        else if(S[i]=='R') {
            can = false; break;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val k= readLine()!!.toInt()
    val x= readLine()!!.split(" ").map { it.toInt() }

    val ans=x.map { 2 * Math.min(it,Math.abs(k-it)) }.sum()
    println(ans)

}

Measured memory_bytes: 35976
//20/01/2020
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b push_back
#define m_p make_pair

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll c,w;
};
vector<Node>v;

ll we[1003],co[1003];
ll dp[1003][10004];
ll n,h;


bool cmp(Node a,Node b){
    if(a.w==b.w){
        return a.c>=b.c;
    }
    return a.w<=b.w;
}

ll KS(ll pos,ll w){
    if(pos>n){
        if(w>=h) return 0;
        else return INT_MAX;
    }

    if(w>=h) return 0;

    if(dp[pos][w]) return dp[pos][w];

    ll x=co[pos]+ KS(pos,w+we[pos]);
    ll y=KS(pos+1,w);

    return dp[pos][w]=min(x,y);
}

int main(){
    _fastio
    cin>>h>>n;
    for(ll i=1;i<=n;i++){
        cin>>we[i]>>co[i];
        Node x;
        x.w=we[i];
        x.c=co[i];
        v.push_back(x);
    }

    sort(v.begin(),v.end(),cmp);

    for(ll i=1;i<=n;i++){
        we[i]=v[i-1].w;
        co[i]=v[i-1].c;
    }

    ll ans=KS(1,0);

    cout<<ans<<endl;



    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M;
  cin>>N>>M;
  map<int,int>m;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    m[a]++;
    m[b]++;
  }
  bool ok=true;
  for(auto it:m)if(it.second%2)ok=false;
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A;
  int B;
 cin >>A >>B;
  string S;
  cin >>S;
  
  int count=0;
  int x=S.size();
  
  if (S.at(A) != '-') {
    cout << "No"<< endl;
  }
  else if (S.at(A) == '-') {
    for(int i=0; i<x; i++) {
   if (S.at(i) == '-') {
     count ++;
   }
    }
  if (count ==1) {
    cout << "Yes" << endl;
  }
    else {
      cout <<"No" << endl;
    }
  }
  
}   
    
   

Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val ab = inputs.head.split(" ").map(_.toInt)
  val a = ab(0)
  val b = ab(1)

  println(solve(a, b))

  private def solve(a: Int, b: Int): Int = {
    val sum = a + b
    val dis = a - b
    val s = a * b

    Math.max(sum, Math.max(dis, s))
  }
}

Measured memory_bytes: 54844
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
#include <complex>
using namespace std;

#define ll long long
#define f first
#define s second
typedef pair<int , int > pii;
const ll MOD = 1e9+7;


void min_self(ll &a , ll b){
    a=min(a,b);
}

void max_self(ll &a, ll b){
    a=max(a,b);
}

ll add(ll x, ll y)
{
    return (x + y) % MOD;
}

ll sub(ll x, ll y)
{
    return add(x, MOD - y);
}

ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}

ll inv(ll x)
{
    return binpow(x, MOD - 2);
}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

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

}
// BIT //
const int MAXN=2*1e5+10;
vector<int> bit(MAXN,0);
int sump(int idx) {
    int ret = 0;
    for (++idx; idx > 0; idx -= idx & -idx)
        ret += bit[idx];
    return ret;
}

int sum(int l, int r) {
    return sump(r) - sump(l - 1);
}

void upd(int idx, int delta) {
    for (++idx; idx < MAXN; idx += idx & -idx)
        bit[idx] += delta;
}
/////-----//////

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    int INF=1e7;
    int ans=INF;
    int diff=INF;
    int x,n; cin>>x>>n;
    vector<int> vis(301,false);
    for(int i=0; i<n; i++){
        int y ; cin>>y;
        vis[y]=true;
    }
    for(int i=0; i<=300; i++){
        int y=i;
        if( !vis[y] && abs( y - x) < diff ){
            ans=y;
            diff=abs(y-x);
        }

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








Measured memory_bytes: 3876
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    int n, x, count;

    while(true){
        cin >> n >> x;
        if(n==0 && x==0){
            break;
        }
        count = 0;
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int h=j+1; h<=n; h++){
                    if(i+j+h==x){
                        count += 1;
                    }
                }
            }
        }
        cout << count << endl;
    }





    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>

int main(void){
    int a;
    scanf("%d",&a);
    double A[a];
    double S=0;
    for(int i=0;i<a;i++)
    scanf("%le",&A[i]);

    for(int i=0;i<a;i++)
    A[i]=1/A[i];

    for(int i=0;i<a;i++)
    S=S+A[i];

    S=1/S;

    printf("%le\n",S);

}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] data = {111,222,333,444,555,666,777,888,999};

    for (int i = 0;i < 9;i++) {
      if (data[i] >= n) {
        System.out.println(data[i]);
        break;
      }
    }
  }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n, m, cnt=0;
    cin >> n >> m;
    vector<ll> a(200000,0);
    rep(i,m){
        ll l, r;
        cin >> l >> r;
        a[--l]++;
        a[r]--;
    }
    rep(i,200000) a[i+1] += a[i];
    rep(i,200000) if(a[i]>=m) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4840
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    MOD = 10 ** 9 + 7
    sumA = sum(A)
    ans = 0
    for n in range(N-1):
        sumA -= A[n]
        ans += sumA * A[n]
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31612
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            if (a == 0 && b == 0) break;
            var dp = new int[a + 1, b + 1];
            for (int i = 0; i < a + 1; i++)
                for (int j = 0; j < b + 1; j++) dp[i, j] = -1;
            dp[1, 1] = 1;
            var n = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < n; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var za = int.Parse(line2[0]);
                var zb = int.Parse(line2[1]);
                dp[za, zb] = 0; 
            }
            for (int i = 1; i <= a; i++)
                for (int j = 1; j <= b; j++)
                {
                    if (dp[i, j] == -1)
                    {
                        if (i != 1 && j != 1) dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                        else if (i == 1 && j != 1) dp[i, j] = dp[i, j - 1];
                        else if (i != 1 && j == 1) dp[i, j] = dp[i - 1, j];
                    }
                }
            Console.WriteLine(dp[a, b]);
        }
    }
}

Measured memory_bytes: 9192
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}
void fprint() { std::cout << '\n'; }
template <class H, class... T> void fprint(H &&head, T &&... args) {
    std::cout << std::fixed << std::setprecision(10) << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    fprint(std::forward<T>(args)...);
}

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

    ld r;
    scan(r);
    fprint(2 * PI * r);

    return 0;
}

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

const int limit = 50;

int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
  visited[v] = true;
  for (int v2 = 0; v2 < n; v2++) {
    if (graph[v][v2] == false) continue;
    if (visited[v2] == true) continue;
    dfs(v2);
  }
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;
  for (int i = 0; i < m; i++) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    for (int j = 0; j < n; j++) {
      visited[j] = false;
    }
    dfs(0);
    bool bridge = false;
    for (int j = 0; j < n; j++) {
      if (visited[j] == false) {
        bridge = true;
        break;
      }
    }
    if (bridge) {
      ans++;
    }
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <unordered_set>

using namespace std;

typedef long long int li;
typedef vector<char> vc;


int main()
{
    string s;
    cin >> s;
    int mod = 2019;
    map<int, int> mods;
    int po = s[s.size()-1]-'0', N = 0, mult = 1;
    mods[po] += 1;
    mods[0]  += 1;

    for (int i = s.size()-2; i >= 0; --i)
    {
        mult = (mult* 10) % mod;
        po += (s[i] - '0') * mult;
        po = po % mod;
        
        N += mods[po];
        mods[po] += 1;
    }
    cout << N;
    return 0;
}


Measured memory_bytes: 3720
#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() {
    vector<int> a(3);
    rep(i,3)cin >> a.at(i);
    sort(a.begin(),a.end());
    int ans=3;
    rep(i,2){
        if(a.at(i)==a.at(i+1))ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	long long int n, k;
	scanf("%lld%lld", &n, &k);
	long long int a = n % k;
	long long int b = k - a;
	long long int ans;
	if (a < b) ans = a;
	else ans = b;
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 505;

int N;
bool A[MAX][MAX];

ll solve() {
    bool exsits_black = false;
    REP (h, N) REP (w, N) exsits_black |= A[h][w];
    if (!exsits_black) return -1;

    int c = 0;
    REP (w, N) {
        bool exsits_white = false;
        REP (h, N) exsits_white |= (!A[h][w]);
        if (exsits_white) c++;
    }

    int min_op = 1e9;
    REP (h, N) {
        int count = 0;
        REP (w, N) if (!A[h][w]) count++;
        // h列目が全部白ならもう一回
        bool check = false;
        REP (i, N) check |= A[i][h];
        if (!check) count++;
        CHMIN (min_op, count);
    }

    return min_op + c;
}

int main() {
    cin >> N;
    REP (h, N) {
        string s;
        cin >> s;
        REP (w, N) A[h][w] = (s[w] == '#');
    }
    cout << solve() << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int cost, n;
int marume(double a)
{
    int b;
    b = (int)(a*10);
    if(b%10 > 4) return (int)(a+1);
    else return (int)a;
}
int main()
{
    int sum=0;
    int count=0;
    double sumn=0;
    char comma;
    while(cin >> cost >> comma >> n)
    {
        sum += cost * n;
        sumn += n;
        ++count;
    }
    cout << sum << endl;
    cout << marume(sumn/count) << endl;
}

Measured memory_bytes: 1160
a = input()
b = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
     "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
c = []
d = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
     "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
e = set()
for i in a:
    b.remove(i)
if len(b) > 0:
    print(a+b[0])

else:
    try:
        for j in a:
            c.append(j)
        for l in reversed(range(26)):
            e.add(c[l])
            del c[l]
            if len(c) == 0:
                print(-1)
                raise Exception
            memo = c[l-1]
            for k in range(len(d) - 1):
                if c[l - 1] == d[k]:
                    c[l - 1] = d[k + 1]
                    if c[l - 1] in e:
                        print("".join(c))
                        raise Exception
            c[l-1] = memo
    except Exception:
        pass

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define pb(x) push_back(x)
#define fi first
#define se second
#define mp(x,y) make_pair(x,y);

/*struct comp
{
    bool operator()()
    {
        
    }
};*/

int32_t main() {
    int t=1;
    //cin>>t;
    while(t--)
    {
     int N;
     cin>>N;
     map<int,int> MAP;
     int x;
     cin>>x;
     MAP[1+x]=1;
     int cnt=0;
     for(int j=2;j<=N;j++)
     {
         cin>>x;
       if(MAP.find(j-x)!=MAP.end())
         cnt+=MAP[j-x];
         MAP[j+x]++;
     }
     cout<<cnt<<endl;

        
    }
    return 0;
}

Measured memory_bytes: 16100
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int V[20];
int C[20];
int main(){
  int i, res=0;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(V[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<N;KL2GvlyY++){
      rd(C[KL2GvlyY]);
    }
  }
  for(i=0;i<N;i++){
    if(V[i]-C[i] > 0){
      res += V[i]-C[i];
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190601-1

// --- original code ---
// int N, V[20], C[20];
// {
//   int i, res = 0;
//   rd(N,V(N),C(N));
//   rep(i,N) if(V[i]-C[i] > 0) res += V[i]-C[i];
//   wt(res);
// }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int n[6];
char move[100];
void dice_S()
{
  int tmp;
  tmp = n[2];
  n[2]=n[1];
  n[1]=n[5];
  n[5]=n[6];
  n[6]=tmp;
}
void dice_N()
{
  int tmp;
  tmp = n[6];
  n[6]=n[5];
  n[5]=n[1];
  n[1]=n[2];
  n[2]=tmp;
}
void dice_W()
{
  int tmp;
  tmp = n[6];
  n[6]=n[4];
  n[4]=n[1];
  n[1]=n[3];
  n[3]=tmp;
}
void dice_E()
{
  int tmp;
  tmp = n[6];
  n[6]=n[3];
  n[3]=n[1];
  n[1]=n[4];
  n[4]=tmp;
}
void test()
{
  int i;
  dice_E();
  for(i=1; i<=6; i++)
  printf("%d ",n[i]);
  putchar('\n');
  dice_E();
  for(i=1; i<=6; i++)
  printf("%d ",n[i]);
  dice_S();
  putchar('\n');
  for(i=1; i<=6; i++)
  printf("%d ",n[i]);
  dice_W();
  for(i=1; i<=6; i++)
  printf("%d ",n[i]);
  putchar('\n');
  dice_N();
  for(i=1; i<=6; i++)
  printf("%d ",n[i]);
  putchar('\n');
}
int main()
{
  int i;
  for(i=1; i<=6; i++) scanf("%d",&n[i]);
   scanf("%s",move);
   for(i=0; i<strlen(move); i++){
    if('S'==move[i])dice_S();
    else if('E'==move[i])dice_E();
    else if('W'==move[i])dice_W();
    else if('N'==move[i])dice_N();
    }
   printf("%d\n",n[1]);
  //   test();
  return 0;
}


Measured memory_bytes: 2108
from collections import deque

N, M = map(int, input().split())
graph = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    graph[a].append(b)
    graph[b].append(a)
    
dist = [-1] * N
dist[0] = 0
    
queue = deque([0])

while queue:
    v = queue.popleft()
    for nv in graph[v]:
        if (dist[nv] != -1):
            continue
        dist[nv] = v
        queue.append(nv)
        
print("Yes")
for i in dist[1:]:
    print(i+1)

Measured memory_bytes: 34572
package main

import (
	"bufio"
	"fmt"
	"os"
)

type pair struct{ x, y int }

var (
	sc = bufio.NewScanner(os.Stdin)
	bw = bufio.NewWriter(os.Stdout)
)

const inf = 1 << 60
const mod int = 1e9 + 7

func init() {
	sc.Split(bufio.ScanWords)
}

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func pln(a ...interface{}) {
	_, _ = fmt.Fprintln(bw, a...)
	return
}

func main() {
	defer bw.Flush()
	n, k := ri(), ri()
	mx := (n - 1) * (n - 2) / 2
	if k > mx {
		pln(-1)
		return
	}
	star := make([]pair, 0, mx+(mx-k))
	for i := 2; i <= n; i++ {
		star = append(star, pair{1, i})
	}
	ii, jj := 2, 3
	for ct := 1; ct <= mx-k; ct++ {
		star = append(star, pair{ii, jj})
		jj++
		if jj == n+1 {
			ii++
			jj = ii + 1
		}
	}
	pln(len(star))
	for _, s := range star {
		pln(s.x, s.y)
	}
}


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

int main() {
  int H,N;
  cin >> H >> N;
  int i;
  int SUM=0;
  for(i=0;i<N;i++){
    int A;
    cin >> A;
    SUM += A;
  }
  if(SUM>=H){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[36+5];
 string str[36+5];
 
 int arr2[36+5];
 string str2[36+5];
 string str3[36+5];
 //string str4[36+5];

 int main()
 {
   int N;
   cin>>N;
   for(int i=0;i<N;i++) cin>>str[i];
   for(int i=0;i<N;i++) arr[i]=(str[i].at(1)-'0');
   for(int i=0;i<N;i++) str3[i]=str[i].at(0);
   for(int i=0;i<N;i++) str2[i]=str[i];
   for(int i=0;i<N;i++) arr2[i]=arr[i];
   for(int i=0;i<N;i++)
   {
     for(int j=N-1;j>=i+1;j--)
     {
       if(arr[j]<arr[j-1])
       {
         swap(arr[j],arr[j-1]);
         swap(str[j],str[j-1]);                   
       }        
     }        
   }
   bool flag=true;
   bool flag2=true;
   for(int i=0;i<N-1;i++) cout<<str[i]<<" ";
   cout<<str[N-1];
   cout<<endl;    
   cout<<"Stable"<<endl;
   //else cout<<"Not Stable"<<endl;
   for(int i=0;i<N;i++)
   {
     int mini=i;
     for(int j=i;j<N;j++)
     {
       if(arr2[j]<arr2[mini])
       {
         mini=j;                     
       }        
     }        
     swap(arr2[i],arr2[mini]);
     swap(str2[i],str2[mini]);
   } 
   for(int i=0;i<N-1;i++) cout<<str2[i]<<" ";
   cout<<str2[N-1];
   cout<<endl;
   for(int i=0;i<N;i++)
   {
     if(str2[i][0]!=str[i][0])
     {
       flag2=false;
       break;                                  
     }          
   }
   if(flag2) cout<<"Stable"<<endl;
   else cout<<"Not stable"<<endl;
   //while(1);
   return 0;
 }
 
 

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

bool is_prime[1000000];
int prime[1000000];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i < 1000000; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j < 1000000; j += i)is_prime[j] = false;
		}
	}
	int n, P;
	while (scanf("%d%d", &n, &P), ~n) {
		int d = upper_bound(prime, prime + p, n) - prime;
		vector<int>v;
		for (int i = 0; i <= P; i++)for (int j = i; j <= P; j++) {
			v.push_back(prime[d + i] + prime[d + j]);
		}
		sort(v.begin(), v.end());
		printf("%d\n", v[P - 1]);
	}
}

Measured memory_bytes: 4520
S = list(input())

uniq = list(set(S))

if len(uniq) != 2 :
    print('No')
else :
    count = {}
    for s in S :
        if s in count :
            count[s] += 1
        else :
            count[s] = 1

    if count[uniq[0]] == 2 :
        print('Yes')
    else :
        print('No')

Measured memory_bytes: 3060
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	int n,k;
	char s[55];

	//よく使う変数
	int i,j,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d",&n,&k);
//	scanf_s("%d %d",&n,&k);

	scanf("%s",&s);
//	scanf_s("%s",&s,55);


/*	for(i=1;i<=n;i++){
//		scanf("%c",&a,&b,&f);
		scanf_s("%c",&a,&b,&f);
	}*/



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	s[k-1]=s[k-1]+32;

	//	printf("計算部分終了\n");

	//出力

	printf("%s",s);



	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int p,q,r;
  int a[3];
  scanf("%d%d%d",&p,&q,&r);
  a[0]=p+q;
  a[1]=q+r;
  a[2]=r+p;
  int min=200;
  for(int i=0;i<3;i++){
    if(a[i]<min){
      min=a[i];
    }
  }
  printf("%d",min);
  return 0;
}
  

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

using ll = long long;
const int INF = 1e9+100;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int> a(n);
	for (auto &it: a){
		cin>>it;
	}
	ll ans = 0;
	for (int i = 1; i < n; i++){
		if (a[i] < a[i-1]){
			ans += a[i-1]-a[i];
			a[i] = a[i-1];
		}
	}
	cout<<ans<<'\n';
	return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n, k;
		cin >> n >> k;
		cout << n - k + 1 << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256