akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 2e5;
ll n,h,w,result;
ll num[100];

ll GetDigit(ll num){
    return std::to_string(num).length();
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i,n+1) {
    if(i < 10) num[i*10+i]++;
    else num[i / (ll)pow(10l,GetDigit(i)-1) * 10 + i % 10]++;
  }
  for(int i = 1; i<10; i++) for(int j = 1; j<10; j++) {
    result += num[i*10+j] * num[j*10+i];
  }
  //rep(i,100) if (num[i] != 0) cout << i << " : " << num[i] << endl;
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;
// Driver code 
int main() 
{ 
    int n,k;
    cin>>n>>k;
    int a[n];
    loop(i,n)
    cin>>a[i];
    bool dp[k+1];
    memset(dp,false,k+1);
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i>=a[j] && !dp[i-a[j]])
                dp[i]=true;
        }
    }
    if(dp[k]) cout<<"First\n";
    else cout<<"Second\n";
} 



Measured memory_bytes: 384
#include<stdio.h>

int main(void){
int a,b;
char c;
while(1){
scanf("%d %c %d",&a,&c,&b);

if(c == '?')break;
if(c == '+')printf("%d",a+b);
if(c == '-')printf("%d",a-b);
if(c == '/')printf("%d",a/b);
if(c == '*')printf("%d",a*b);

printf("\n");
}
return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

public class Main {
    public int getIdx(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 0) {
                return i + 1;
            }
        }
        return -1;
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        int first = scanner.nextInt();
        int second = scanner.nextInt();
        int third = scanner.nextInt();
        int fourth = scanner.nextInt();
        int fifth = scanner.nextInt();

        int answer = solution.getIdx(new int[] { first, second, third, fourth, fifth });
        System.out.println(answer);
    }
}


Measured memory_bytes: 35592
def f_e_dp():
    n = int(input())
    s = input()
    dp = [[0]*(n+1) for _ in range(n+1)]
    for i in reversed(range(n)):
        for j in reversed(range(n)):
            if i>=j:
                continue
            if s[i]==s[j]:
                dp[i][j] = min(j-i, dp[i+1][j+1]+1)
    print(max([sorted(r, reverse=True)[0] for r in dp]))

if __name__ == "__main__":
    f_e_dp()


Measured memory_bytes: 230792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    string s;
    cin >> s;
    int a = s.size();
    if (s[a - 1] == 's')
    {
        cout << s << "es" << endl;
    }
    else
    {
        cout << s << "s" << endl;
    }
}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int n,m;
	cin >> n >> m;
	int l,r;
	int maxl = 0;
	int minr = 100000001;
	for(int i = 0; i < m; i++){
		cin >> l >> r;
		maxl = max(maxl,l);
		minr = min(minr,r);
	}
	cout << max((n - (maxl - 1) - (n - minr)),0) << endl;
	return 0; 
}

Measured memory_bytes: 256
W, H, N=map(int, input().split())
hen=[0,W,0,H]
for _ in range(N):
  x, y, a=map(int, input().split())
  if a==1:
    hen[a-1]=max(hen[a-1], x)
  elif a==2:
    hen[a-1]=min(hen[a-1], x)
  elif a==3:
    hen[a-1]=max(hen[a-1], y)
  elif a==4:
    hen[a-1]=min(hen[a-1], y)
yoko=hen[1]-hen[0]
tate=hen[3]-hen[2]
if yoko<0 or tate<0:
  ans=0
else:
  ans=yoko*tate
print(ans)

Measured memory_bytes: 9168
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_VTX_MAX		8										// 最大頂点数

// 内部構造体 - 頂点情報
typedef struct Vtx {
	int mi1CVNo[D_VTX_MAX + 5];									// 接続頂点
	int miCCnt;													// 接続頂点数
} Vtx;

// 内部変数
static Vtx sz1Vtx[D_VTX_MAX + 5];								// 頂点
static int siVCnt;												// 頂点数
static int siPCnt;												// パス数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// パス数セット
int
fSetPCnt(
	int piVNo					// <I> 接続頂点 1～
	, int *pipVNo				// <I> 接続済頂点
	, int piVCnt				// <I> 接続済頂点数
)
{
	int i;

	// 接続済チェック
	if (pipVNo[piVNo] != D_OFF) {
		return 0;
	}

	// 終了チェック
	if (piVCnt == siVCnt - 1) {
		siPCnt++;
		return 0;
	}

	// 接続
	pipVNo[piVNo] = D_ON;

	// 対象データ
	Vtx *lzpVtx = &sz1Vtx[piVNo];

	// 次の頂点へ
	for (i = 0; i < lzpVtx->miCCnt; i++) {
		fSetPCnt(lzpVtx->mi1CVNo[i], pipVNo, piVCnt + 1);
	}

	// 接続解除
	pipVNo[piVNo] = D_OFF;

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// データ初期化
	memset(sz1Vtx, 0, sizeof(sz1Vtx));							// 頂点
	siPCnt = 0;													// パス数

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 頂点数・辺数取得
	int liECnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d", &siVCnt, &liECnt);

	// 辺取得
	for (i = 0; i < liECnt; i++) {
		int liVNo1, liVNo2;
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
		sscanf(lc1Buf, "%d%d", &liVNo1, &liVNo2);

		// 接続頂点セット
		Vtx *lzpVtx = &sz1Vtx[liVNo1];
		lzpVtx->mi1CVNo[lzpVtx->miCCnt] = liVNo2;
		lzpVtx->miCCnt++;
		lzpVtx = &sz1Vtx[liVNo2];
		lzpVtx->mi1CVNo[lzpVtx->miCCnt] = liVNo1;
		lzpVtx->miCCnt++;
	}

	// パス数セット
	int li1VNo[D_VTX_MAX + 5];
	memset(li1VNo, D_OFF, sizeof(li1VNo));
	fSetPCnt(1, li1VNo, 0);

	// 結果セット
	sprintf(lc1Out, "%d\n", siPCnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
N, M = map(int, input().split())
L = []
for _ in range(M):
    L.append(list(map(int, input().split())))

first = []
second = []
for a, b in L:
    if a == 1:
        first.append(b)
    if b == N:
        second.append(a)
flg = len(set(first) & set(second))
print('POSSIBLE' if flg else 'IMPOSSIBLE')


Measured memory_bytes: 61104
N,K = map(int, input().split())
d = []
n = []
for k in range(K):
    d.append(input())
    n.append(input().split())
def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]
nfu = set(flatten(n))
print(N - len(nfu))

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end() 
#define MOD 1000000007
#define N 100005
#define pll pair<ll,ll>
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

ll modularExponentiation(ll x,ll n)
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%MOD;
        x=(x*x)%MOD;
        n=n/2;
    }
    return result;
}

void solve()
{ 
     ll n,k;
     cin >> n >> k;   // n - length , k = element range
     ll gcdi[k+1];
     memset(gcdi,0,sizeof(gcdi));
     for(ll i=k;i>=1;i--)
     {
          ll ele = k/i;
          ll tot = modularExponentiation(ele,n);
          gcdi[i] = tot;
          for(ll j=i+i;j<=k;j+=i)
          {
               gcdi[i] = (gcdi[i] - gcdi[j] + MOD)%MOD;
          }
     }
     ll ans = 0;
     for(ll i=1;i<=k;i++)
     {
          ans = (ans + (i*gcdi[i])%MOD)%MOD;
     }
     cout<<ans;
}
int main()
{
     FAST;
     ll t = 1;
  ///   cin >> t;
     while(t--)
     {     
          solve();
     }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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 main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans=0;

    for(int i=0; i<1000; ++i) {
        int c[] = { i/100, (i/10) % 10, i%10};
        int f=0;

        for(int k=0; k<n; ++k) {
            if (s[k] == '0' + c[f]) ++f;
            if (f==3) break;
        }

        if (f==3) ++ans;
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x0123456789) cerr<<#x0123456789<<':'<<x0123456789<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x0123456789:v)cerr<<x0123456789<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  int N,M;
  int P,Y;
  cin >> N >> M;
  vector<tuple<int,int,int,string>> v;
  FOR(i,0,M){
    cin >> P >> Y;
    v.pb(make_tuple(P,Y,i,""));
  }
  sort(ALL(v));
  int p = -1;
  int n = 1;
  FOR(i,0,M){
    if(get<0>(v[i]) == p){
      n++;
      get<1>(v[i]) = n;
    }
    else{
      n = 1;
      get<1>(v[i]) = n;
    }
    p = get<0>(v[i]);
  }
  FOR(i,0,M)swap(get<0>(v[i]),get<1>(v[i]));
  FOR(i,0,M)swap(get<0>(v[i]),get<2>(v[i]));
  sort(ALL(v));
  FOR(i,0,M){
    cout << setfill('0') << right << setw(6) << get<1>(v[i]);
    cout << setfill('0') << right << setw(6) << get<2>(v[i]);
    cout << endl;
  }
}

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

int main(){
int a,b,c,x;cin>>a>>b>>c>>x;
int ans=0;
for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
        int n=x-500*i-100*j;
        if(n/50>=0&&n%50==0&&n/50<=c)ans++;
    }
}
cout<<ans;
}

Measured memory_bytes: 256
import sys

def change(p1,p2,p3):
    b=[[val[i][0]*p1,val[i][1]*p2,val[i][2]*p3] for i in range(N)]
    c=[sum(b[i]) for i in range(N)]
    c.sort(reverse=True)
    return max(abs(sum(c[:M])),abs(sum(c[-M:])))


N,M=map(int,input().split())
val=[list(map(int,input().split())) for i in range(N)]
if M==0:
    print(0)
    sys.exit()


ans=max(change(1,1,1),change(1,1,-1),change(1,-1,1),change(1,-1,-1))
print(ans)

Measured memory_bytes: 3444
//
//東京海上日動　プログラミングコンテスト2020
//B - Tag
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

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

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    ll a,v,b,w,t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    string ans = "NO";
    if (v<=w) {
        cout << ans << endl;
        return 0;
    }
    if (abs(a-b) <= t*(v-w)) ans="YES";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import numpy as np

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 1
mn = np.inf
for i, h in enumerate(H):
    if mn > abs(A - (T - h * 0.006)):
        ans = i+1
        mn = abs(A - (T - h * 0.006))
print(ans)

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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

int fac(int x) {
    if (x == 0) return 1;
    return fac(x - 1) * x;
}

int p[10], q[10];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a, b;
    a = b = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> q[i];
    }
    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int j = i + 1; j <= n; j++) {
            if (p[j] < p[i]) cnt++;
        }
        a += cnt * fac(n - i);
    }
    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int j = i + 1; j <= n; j++) {
            if (q[j] < q[i]) cnt++;
        }
        b += cnt * fac(n - i);
    }
    cout << abs(b - a);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        long ini = 2147483647;
        int n = sc.nextInt();
        int q = sc.nextInt();
        long [] L = new long[n];
        Arrays.fill(L,ini);
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<q;i++){
            int com = sc.nextInt();
            if(com==0){
                int x = sc.nextInt();
                long y = sc.nextLong();
                L[x] = y;
            }
            else{
                int x = sc.nextInt();
                int y = sc.nextInt();
                long min = ini;
                for(int j=x;j<=y;j++) if(min>L[j]) min = L[j];
                sb.append(min+"\n");
            }
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 100576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long D, long long N){
  if (D == 2) {
    int ans = 10000 * N;
    if (N == 100) ans += 10000;
    cout << ans << endl;
  } else if (D == 1) {
    int ans = 100 * N;
    if (N == 100) ans+=100;
    cout << ans << endl;
  } else if (D == 0) {
    int ans = N;
    if (N == 100) ans+=1;
    cout << ans << endl;
  }
}

signed main(){
  long long D;
  scanf("%lld",&D);
  long long N;
  scanf("%lld",&N);
  solve(D, N);
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int sum = 1 + 2 + 3 + 4 + 5;
    cout << sum - a - b - c - d - e << "\n";
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#include <chrono>
#include <array>
#include <random>
#include <fstream>
#include <list>
typedef int long long ll;
using namespace std;
int main(){
    vector<bool> ip(100001,true);
    ip[0]=false;
    ip[1]=false;
    ip[2]=true;
    for(int i=2;i<=sqrt(100001);i++){
        if(ip[i]){
            for(int j=2;j*i<=100001;++j){
                ip[i*j]=false;
            }
        }
    }
    ll n;
    cin>>n;
    int dpp[100001];
    dpp[0]=0;
    dpp[1]=0;
    dpp[2]=0;
    for(int i=3;i<=100001;i++){
        if(ip[i]&&ip[(i+1)/2])dpp[i]=1+dpp[i-1];
        else dpp[i]=dpp[i-1];
    }
    
    for(int i=0;i<n;i++){
        ll l,r;
        cin>>l>>r;
        ll ans=0;
        ans=dpp[r]-dpp[l-1];
        cout<<ans<<endl;
    }
    
    
    
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

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

struct Input{
	int x, y, a;
};

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int w, h, n;
	cin >> w >> h >> n;
	vector<Input> in(n);
	rep(i, n)
		cin >> in[i].x >> in[i].y >> in[i].a;

	int up = h;
	int down = 0;
	int right = w;
	int left = 0;
	rep(i, n){
		if(in[i].a == 1){
			left = max(left, in[i].x);
		}
		else if(in[i].a == 2){
			right = min(right, in[i].x);
		}
		else if(in[i].a == 3){
			down = max(down, in[i].y);
		}else if(in[i].a == 4){
			up = min(up, in[i].y);
		}
	}
	int y = up - down;
	int x = right - left;
	bool flg = true;
	if(y < 0 || x < 0) flg = false;
	int s = x * y;

	cout << (flg ? s : 0) << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S == 'SUN':
    print(7)

elif S == 'MON':
    print(6)

elif S == 'TUE':
    print(5)

elif S == 'WED':
    print(4)

elif S == 'THU':
    print(3)

elif S == 'FRI':
    print(2)

else:
    print(1)

Measured memory_bytes: 8772
S = str(input())
K = int(input())
dp = [[[0, 0] for _ in range(4)] for _ in range(105)]
dp[0][0][0] = 1
# iは桁
# jはこれまでの非0の数
# kはNより小さいことが確定しているか否か

for i in range(len(S)):
	nxt_d = int(S[i])
	for j in range(4):
		for k in range(2):
			# 次入る数字を探す（判定）
			for d in range(10):
				nxt_i = i + 1
				nxt_j = j
				nxt_k = k
				if d != 0: # 非0の場合
					nxt_j += 1
				if nxt_j > K: # 非0の数が制限を超えちゃった
					continue
				if k == 0: # Nより小さいことが確定していない
					if d > nxt_d: continue
					if d < nxt_d: nxt_k = 1
				dp[nxt_i][nxt_j][nxt_k] += dp[i][j][k]
ans = dp[len(S)][K][0] + dp[len(S)][K][1]

print(ans)

Measured memory_bytes: 41072
n = int(input())

cake = 4
dounatsu = 7

c = list()
d = list()

c.append(0)
d.append(0)
for i in range(1,100):
    if i * cake > 100:
        break
    c.append(i*cake)

for j in range(1,100):
    if j * dounatsu > 100:
        break
    d.append(j*dounatsu)

for i in range(len(c)):
    for j in range(len(d)):
        if c[i] + d [j] == n:
            print("Yes")
            exit()
        else:
            continue
else:
    print("No")

#print(c)
#print(d)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();

      if (Math.abs(c - a) <= d) {
         System.out.println("Yes");
      }
      else if ((Math.abs(b - a) <= d) && ((Math.abs(b - c) <= d))) {
         System.out.println("Yes");
      }
      else {
         System.out.println("No");
      }
   }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    int n,a,b;
    cin>>n>>a>>b;

    cout<<min(n*a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans;
int n;
struct T{
  int nxy;
  int x[19],y[19];
}t[19];
int gg(int x){
  int ans=0;
  while(x){
    ans+=(x&1);
    x>>=1;
  }
  return ans;
}
bool check(int x){
  for(int i=1;i<=n;i++)
    for(int j=1;j<=t[i].nxy;j++){
      bool flag1=(x>>(i-1))&1;
      if(!flag1)break;
      bool flag2=(x>>(t[i].x[j]-1))&1;
      if(!(flag1^(t[i].y[j]^flag2)))return 0;
    }
  return 1;
}
int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>t[i].nxy;
    for(int j=1;j<=t[i].nxy;j++)cin>>t[i].x[j]>>t[i].y[j];
  }
  for(int i=0;i<(1<<n);i++)if(check(i))ans=max(ans,gg(i));
  cout<<ans<<endl;
  return 0;
}


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

/******************************\
 * The solution is at the top *
 *                            *
 *   Created by : azhar556    *
\******************************/

public class Main {
    static void solve() {
		String s = ns();
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) == s.charAt(i - 1)) {
				out.println("Bad"); return;
			}
		}
		out.println("Good");
    }    

    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        int t;// = ni();
        t = 1;
        while (t-- > 0) solve(); 
        err.println("Time elapsed : " + (System.currentTimeMillis() - time) / 1000F + " s.");
        err.close(); out.close();
    }

	static int[] radixSort(int[] f){ return radixSort(f, f.length); }
	static int[] radixSort(int[] f, int n)
	{
		int[] to = new int[n];
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(f[i]&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[f[i]&0xffff]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(f[i]>>>16)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[f[i]>>>16]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		return f;
	}

    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    static PrintWriter err = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.err)));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer token;
    
    static boolean hasMoreTokens () {
        String sample = null;
		try {
			sample = br.readLine();
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		return sample == null ? false : true;
    }

    static String ns() {
        while (token == null || !token.hasMoreTokens()) {
            try {
                token = new StringTokenizer(br.readLine());
            }
            catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return token.nextToken();
    }
    static char nc() {
        return Character.valueOf(ns().charAt(0));
    }
    static int ni() {
        return Integer.parseInt(ns());
    }
    static double nd() {
        return Double.parseDouble(ns());
    }
    static long nl() {
        return Long.parseLong(ns());
    }
}
// Collections Arrays Math
// Vector HashSet TreeSet HashMap TreeMap ArrayDeque 

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>
#include <iostream>

ll ans;
int N,M;
string S, T;

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

    return GCD(b, a % b);
}

ll LCM(ll a, ll b){
    ll ans;

    if(a > b) ans = (a / GCD(a, b)) * b;
    else ans = (b / GCD(a, b)) * a;

    return ans;
}


void solve(){
    ll tmp = LCM(N, M);
    bool flag = true;

    ll n = tmp / N;
    ll m = tmp / M;

    rep(i, GCD(N, M)){
        // cout << S[d2*i] << " vs " << T[d1*i] << endl;
        if(S[m*i] != T[n*i]){
            flag = false;
            break;
        }
    }
    
    if(flag)    
        cout << tmp << endl;
    else
        cout << -1 << endl;
    }

int main(){
    cin >> N >> M >> S >> T;

    solve();
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int N;
vector<Int> A;
vector<Int> B;
Int sum = 0;

int main(void) {
    cin>>N;
    for(int i = 0;i < N+1;i++) {
        Int a;
        cin>>a;
        A.push_back(a);
    }
    for(int i = 0;i < N;i++) {
        Int b;
        cin>>b;
        B.push_back(b);
    }

    for(int i = 0;i < N;i++) {
        sum += min(A[i],B[i]);
        B[i] -= min(A[i],B[i]);
        sum += min(A[i+1],B[i]);
        A[i+1] -= min(A[i+1],B[i]);
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 2676
//Abhinav ---IIIT_A
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
#define my vector<pii>
ld pie=3.141592653589;
int mod=1e9+7;


bool Compare(pii a, pii b)
{
	return a.ff > b.ff;
}
priority_queue<pii, vector<pii>, function<bool(pii, pii)>> pq(Compare);

void solve(){
	int d,t,s; cin>>d>>t>>s;
	if(d>t*s) cout<<"No";
	else cout<<"Yes";	
}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

Int pow_f(Int x, Int n) {
    Int ret = 1;
    while (n > 0) {
        if (n % 2 == 0) {
            x *= x;
            x %= mod;
            n >>= 1LL;
        }
        else {
            ret *= x;
            ret %= mod;
            n--;
        }
    }
    return ret;
}

int main() {
    COMinit();
    Int n, k;
    cin >> n >> k;
    if (k >= n - 1) {
        Int res = fac[2 * n - 1] % mod;
        res = (res * finv[n]) % mod;
        res = (res * finv[n - 1]) % mod;
        dump(res);
    }
    else {
        Int res = 0;
        for (Int i = 0; i <= k; i++) {
            Int sum = fac[n - 1] % mod;
            sum = (sum * finv[i]) % mod;
            sum = (sum * finv[n - i - 1]) % mod;
            res += (sum * COM(n, i)) % mod;
            res %= mod;
        }
        dump(res);
    }
    return 0;
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;
    cin>>n>>m;
    vl N(n+1,0);
    rep(i,m){
        ll l,r;
        cin>>l>>r;
        l--;
        N[l]++;
        N[r]--;
    }
    rep(i,n)N[i+1]+=N[i];
    ll res=0;
    rep(i,n){
        if(N[i]>=m)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3980
import java.util.Scanner;

public class Main {

    static Scanner in = new Scanner(System.in);

    void solve() {
		char[] s = in.nextLine().toCharArray(), t = in.nextLine().toCharArray();
		for(int i = s.length - t.length; i >= 0; i--){
			boolean f = true;
			for(int j = 0; j < t.length; j++){
				if(s[i + j] != '?' && t[j] != '?' && s[i + j] != t[j]){
					f = false;
				}
			}
			if(f){
				for(int j = 0; j < t.length; j++){
					s[i + j] = t[j];
				}
				for(int j = 0; j < s.length; j++){
					System.out.print(s[j] == '?' ? 'a' : s[j]);
				}
				System.out.println();
				return;
			}
		}
		System.out.println("UNRESTORABLE");
	}
	
    public static void main(String[] args) {
		new Main().solve();
    }
}


Measured memory_bytes: 23252
#include <cstdio>

struct node {
  int key;
  node *left, *right;
  node(int key) : key(key), left(nullptr), right(nullptr) {}
  ~node() {
    delete left;
    delete right;
  }
};

enum order {
  pre,
  in
};

void rec(node *t, order o) {
  if (!t)
    return;
  if (o == pre)
    printf(" %d", t->key);
  rec(t->left, o);
  if (o == in)
    printf(" %d", t->key);
  rec(t->right, o);
}

int main() {
  node *T(nullptr);
  size_t m;
  scanf("%zu\n", &m);
  for (size_t i = 0; i < m; i++) {
    char s[8];
    scanf("%s", s);
    if (s[0] == 'i') {
      int k;
      scanf("%d", &k);
      node *x = T, *y = nullptr, *z = new node(k);
      while (x) {
        y = x;
        x = z->key < y->key ? y->left : y->right;
      }
      (y ? z->key < y->key ? y->left : y->right : T) = z;
    } else {
      rec(T, in);
      puts("");
      rec(T, pre);
      puts("");
    }
  }
  delete T;
  return 0;
}

Measured memory_bytes: 18204
while True:
    m,f,r = map(int,input().split())
    if(m==-1 and f==-1 and r==-1):
        exit()
    if (m==-1 or f==-1):
        print("F")
        continue
    if(m+f>=80):
        print("A")
    elif(m+f>=65):
        print("B")
    elif(m+f>=50):
        print("C")
    elif(m+f>=30):
        if(r>=50):
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll n,m;
    cin >> n >> m;
    ll tot = 0;
    ll a;

    rep(i,m){
        cin >> a;
        tot += a;
    }
    if(tot <= n){
        cout << n-tot <<endl;
    }else{
        cout << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int a[110];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    // it should sort
    int ap=0;
    int bp=0;
    int max=0;
    bool isA = true;
    int tmp = -1;

    for(int j=0; j<N; j++){
        for(int i=0; i<N; i++){
            if(a[i] > max){
                max= a[i];
                tmp = i;
            }
        }
        a[tmp] = -1;
        if(isA){
            ap += max;
        } else {
            bp += max;
        }
        isA = !isA;
        max = 0;
    }
    cout << ap-bp << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  char str[21];
  int i;
  
  while(scanf("%s",str) != EOF)
    {
      for(i = 0 ; str[i+1] != '\0' ; i++);
	  for( ; i != EOF ; i--)
	    {
	      printf("%c", str[i]); 
	    }
      printf("\n"); 
    }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n){
        if(s[i] != s[n-i-1]){
            s[i] = s[n-i-1];
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
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);
}

int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;

signed main(){
	IOS();
	int x,y;
	cin>>W>>H>>x>>y;
	double ans = W*H/2.0;
	if(x*2==W&&y*2==H){
		printf("%.12lf 1\n",ans);
	}else{
		printf("%.12lf 0\n",ans);
	}
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  
  for(int i=0;i<K;i++){
    vector<int> V(N,0);
    for(int j=0;j<N;j++){
      if(j-A[j]<0) V[0]++;
      else V[j-A[j]]++;
      if(j+A[j]+1<N) V[j+A[j]+1]--;
    }
    
    bool ok=true;
    A[0] = V[0];
    if(A[0]!=N) ok=false;
    for(int j=1;j<N;j++){
      A[j] = A[j-1] + V[j];
      if(A[j]!=N) ok=false;
    }
    if(ok) break;
  }
  
  for(int i=0;i<N;i++) cout << A[i] << " ";
  return 0;
}


Measured memory_bytes: 4844
#C問題
S = str(input())
Slist=list(S)
Slen=len(S)
Smax=2**(Slen-1)
ans=0
for i in range(Smax):
    I=bin(i)
    I=I.lstrip("0b")
    Ilen=len(I)
    if Ilen<Slen-1:
        j=0
        for j in range(Slen-Ilen-1):
            I="0"+I
    
    k=0
    Ilist=list(I)
    klist=[]
    now=Slist[0]
    for k in range(Slen-1):
        if Ilist[k]=="0":
            klist.append(int(now))
            now=Slist[k+1]
        else:
            now+=Slist[k+1]
    klist.append(int(now))
    ans+=sum(klist)
print(ans)

Measured memory_bytes: 3064
import queue

def read_input():
    n, k = map(int, input().split())
    s = list(map(int, list(str(input()))))

    return n, k, s


# 0, 1, ....を(0, n1), (1, n2)みたいな形にする
def convert_01(s):
    result = []

    result.append([s[0], 1])
    for ss in s[1:]:
        if result[-1][0] == ss:
            result[-1][1] += 1
        else:
            result.append([ss, 1])

    return result


# index以降の要素、かつ0の数がKを下回るサブリストにある要素をカウントする
def get_count(r,k):
    count = 0
    max_count = 0
    zeros = 0

    q = queue.Queue()

    for e in r:
        if e[0] == 0 and zeros >= k:
        # すでにk回0を操作した
            while True:
                t = q.get()
                count -= t[1]

                if t[0] == 0:
                    zeros -= 1
                    break

        q.put(e)
        count += e[1]

        if e[0] == 0:
            zeros += 1

        if max_count < count:
            max_count = count

    return max_count






if __name__ == '__main__':
    n, k, s = read_input()
    r = convert_01(s)

    print(get_count(r, k))



Measured memory_bytes: 16028
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N, X, T = ints()
from math import ceil
print(ceil(N / X) * T)


Measured memory_bytes: 87312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<power(10, 9) + 7>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? fact[i - 1] * i : 1;
  inv_fact[n] = power(fact[n], mint::mod - 2);
  for (int i = n; i--; ) inv_fact[i] = (i + 1) * inv_fact[i + 1];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template <> mint& mint::operator/=(mint b) {
  return *this *= b.v < minv.size() ? minv[b.v] : power(b, mod - 2);
}

struct dsu {
  int cc;
  vector<int> p, sz, a;
  dsu(int n = 0) : cc(n), p(n, -1), sz(n, 1), a(n) {}
  int root(int v) const {
    while (p[v] != -1) v = p[v];
    return v;
  }
  bool unite(int u, int v) {
    u = root(u), v = root(v);
    ++a[u];
    if (u == v) return false;
    --cc;
    if (sz[u] < sz[v]) swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
    a[u] += a[v];
    return true;
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return sz[root(v)]; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n);
  for (auto&& e : p) {
    cin >> e;
    e -= e != -1;
  }
  prepare(n);
  dsu d(n);
  for (int i = 0; i < n; ++i) {
    if (p[i] != -1) {
      d.unite(i, p[i]);
    }
  }
  vector<int> cs;
  mint res;
  for (int i = 0; i < n; ++i) {
    if (d.root(i) != i) continue;
    if (d.a[i] == d.sz[i]) {
      res += 1;
    } else {
      cs.push_back(d.sz[i]);
    }
  }
  vector<mint> f(n + 1);
  f[0] = 1;
  for (int c : cs) {
    for (int i = n; i--; ) {
      f[i + 1] += f[i] * c;
    }
  }
  for (int m = 1; m <= n; ++m) {
    mint x = f[m];
    if (m == 1) {
      x -= cs.size();
    }
    res += x / power<mint>(n - 1, m) * fact[m - 1];
  }
  res = n - res;
  res *= power<mint>(n - 1, count(begin(p), end(p), -1));
  cout << res.v << '\n';
}


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

using namespace std;
#define int long long
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
const int maxn = 1e5 + 10;
int a[maxn];
int num[maxn];
main(){
	int n;
	cin >> n;
	int sm = 0;
	for(int i=1; i<=n; i++) sm += i;
	int sum = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum += a[i];
	}
	int m = sum / sm;
	if(m * sm != sum){
		cout << "NO" << endl;
		return 0;
	}
	for(int i=0; i<n; i++)
		a[i] -= (i + 1) * m;
	int it = 0;
	while(it < 400){
		it++;
		int tot = 0;
		bool ok = 0;
		for(int i=0; i<n; i++){
			num[i] = 0;
			if(a[i] < 0)
				num[i] = (abs(a[i]) + (n - 2)) / (n - 1);
			if(a[i])ok = 1;
			tot += num[i];
		}
		if(!ok) break;
		for(int i=0; i<n; i++){
			int x = tot - num[i];
			a[i] -= x;
			a[i] += num[i] * (n - 1);
		}
	}
	bool ok = 1;
	for(int i=0; i<n; i++)
		if(a[i]) ok = 0;
	cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int a, b, ans, err;

  err = scanf("%d %d", &a, &b);

  ans = a * b;
  ans = ans > (a + b) ? ans : (a + b);
  ans = ans > (a - b) ? ans : (a - b);

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

  return 0;
}



Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
int n,m,e,a[101]={0},b[101]={0},c[101]={0},d[101]={0};
cin>>n;
cin>>m;
for(int i=0; i<m; i++){
    cin>>e;
    a[e]++;
}
cin>>m;
for(int i=0; i<m; i++)
{
cin>>e;
b[e]++;
}
cin>>m;
for(int i=0; i<m; i++){
    cin>>e;
    c[e]++;
}
for(int i=1; i<=n; i++){
    if(a[i]==0 && c[i]==1||b[i]==1 && c[i]==1)
    d[i]++;
}
        int cnt =0;
        for(int i=1; i<=n; i++){
            if(d[i]==1)
            cnt++;
        }
        cout<<cnt<<endl;
        return 0;
    }


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll n,k,l[100];
  cin>>n>>k;
  rep(i,n)cin>>l[i];
  sort(l,l+n,greater<int>());
  ll ans=0;
  rep(i,k){
    ans+=l[i];
  }

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


Measured memory_bytes: 3640