akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

static const int N = 1000;

int lcs(string X, string Y) {
    int C[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();

    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 0; i <= m; i++) {
        C[i][0] = 0;
    }
    for (int i = 1; i <= n; i++) {
        C[0][i] = 0;
    }
    int maxl = -100;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i] == Y[j]) {
                C[i][j] = C[i - 1][j - 1] + 1;
            } else {
                C[i][j] = max(C[i - 1][j], C[i][j - 1]);
            }
            maxl = max(maxl, C[i][j]);
        }
    }

    return maxl;
}

int main() {
    int n;
    string X, Y;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> X >> Y;
        cout << lcs(X, Y) << endl;
    }

    return 0;
}


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

int compare(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}

int main(){
  int n;
  int a[100000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),compare);
  int s = n/3;
  int t = 2*s;
  if(a[0] == 0 && a[s-1] == 0){
    if(a[n-1] == 0){
      printf("Yes");
      return 0;
    }else if(a[s] == a[n-1]){
      printf("Yes");
      return 0;
    }
  }else if(a[0] == a[s-1] && a[s] == a[t-1] && a[t] == a[n-1]){
    if((a[0]^a[s]^a[t]) == 0){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 892
#include<cstdio>
#include<cmath>
using namespace std;

long long x,sum;
int ss;

int main()
{
    scanf("%lld",&x);
    for(int i=sqrt(x);i>0;--i)
        if(x%i==0)
		{
            sum=x/i;
            break;
        }
    while(sum>0)
	{ 
        ++ss;
        sum/=10;
    }
    printf("%d\n",ss);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for (ll b = K + 1; b <= N; b++) {
    ll n = N / b;
    ans += n * max(b - K, 0LL);
    ans += max(N%b - K + 1, 0LL);
  }
  if (K == 0) ans -= N;
  cout << ans << endl;

  return 0;
}

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

int arr[169];

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

 int n,k;
 cin >> n >> k;

 for(int i=1; i<=k; i++){
 	int d;
 	cin >> d;
 	for(int j=1; j<=d; j++){
 		int e;
 		cin >> e;
 		arr[e]++;
 	} 
 }

 int ans = 0;
 for(int i=1; i<=n; i++){
 	if(arr[i]==0) ans++;
 }

 cout << ans << "\n";

}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (sc.hasNext()) {
            solve();
        }
    }
    
    private static void solve() {
        int n = sc.nextInt();
        if (n == 0) return;
        int[] ary = new int[n+1];
        int sum = 0;
        for (int i = 1;i <= n;i++) {
            sum += i;
            ary[i] = sum;
        }
        
        int ret = 0;
        
        for (int i = 0;i <= n;i++) {
            for (int j = i+2;j <= n;j++) {
                if (ary[j]-ary[i]==n) {
                    ret++;
                }
            }
        }
        
        System.out.println(ret);
    }
}

Measured memory_bytes: 26928
#include "bits/stdc++.h"
    #pragma GCC optimize("Ofast")
     
    // Begin {{{
    using namespace std;
     
    #ifndef DEBUG
    #define dump(...)
    #endif
     
    template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
    template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
     
    template <class T>
    inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
    }
     
    template <class T, class... Args>
    inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
    }
     
    constexpr int INF = 0x3f3f3f3f;
    constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
    // }}} End
     
    size_t N, M;
    vector<int> g[int(1e5)];
     
    vector<intmax_t> dp(int(1e5), -1LL);
     
    intmax_t dfs(size_t now) {
    if (~dp[now]) return dp[now];
     
    intmax_t ret = 0;
    for (auto next: g[now]) {
    chmax(ret, dfs(next) + 1);
    }
     
    return dp[now] = ret;
    }
     
    signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
     
    cin >> N >> M;
     
    for (size_t i = 0; i < M; ++i) {
    size_t from, to; cin >> from >> to;
    --from, --to;
    g[from].emplace_back(to);
    }
     
    intmax_t maxv = 0;
    for (size_t node = 0; node < N; ++node) {
    chmax(maxv, dfs(node));
    }
     
    cout << maxv << "\n";
     
    return 0;
    }

Measured memory_bytes: 8704
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        if (s.Contains("keyence")) { Console.WriteLine("YES"); goto exit; }
        if (s.Length == 7 && s!= "keyence") { Console.WriteLine("NO"); goto exit; }
        Console.WriteLine(check(s)? "YES":"NO");
        exit:;
    }
    static bool check (string s)
    {
        var sL = s.Length;
        var t = sL - 7;
        for (int i = 1; i <= 6; i++)
        {
            var w = s.Substring(0, i) + s.Substring(i + t);
            if (w == "keyence") return true;
        }
        return false;
    }
}

Measured memory_bytes: 13140
a = []
for i in range(6):
    a.append(int(input()))

flag = True
for i in range(4):
    for j in range(i+1, 5):
        if abs(a[i] - a[j]) > a[5]:
            flag = False
            break

if flag == True:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    vector<vector<ll>> dp(100005, vector<ll>(13, 0));
    ll l = s.size();
    dp[0][0] = 1;
    for(ll i = 0; i < l; i++){
        ll c;
        if(s[i] == '?') c = -1;
        else c = s[i] - '0';
        for(ll j = 0; j < 10; j++){
            if(c != -1 && c != j) continue;
            for(ll k = 0; k < 13; k++){
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
            }
        }
        for(ll k = 0; k < 13; k++) dp[i + 1][k] %= MOD;
    }
    cout << dp[l][5];
    cout << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r, d, x;
	cin>>r>>d>>x;
	ll prev;
	for(int i = 0; i < 10; i++)
	{
		prev = x;
		x = r*x-d;
		cout<<x<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
using namespace std;

int main(){
    int g,m,n,i,a,b,dp[10001];
    while(cin>>m&&m){
        dp[0]=1;
        for(i=1;i<=1000;i++){
            dp[i]=0;
        }
        for(i=0;i<m;i++){
            cin>>a>>b;
            for(int j=1000;j>=0;j--){
                if(dp[j]){
                    for(int k=1;k<=b;k++){
                        dp[j+k*a]+=dp[j];
                    }
                }
            }
        }
        cin>>g;
        for(i=0;i<g;i++){
            cin>>n;
            cout<<dp[n]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k,num=1;
	int n,curr;
	cin>>n>>k;
	int a[n+1];
	int st[n+1];
	memset(st,0,sizeof(st));
	for(int i=1;i<=n;++i)
		cin>>a[i];
	curr=a[1];
	st[1]=1;
	vector<int> v;
	v.push_back(1);
	/*4 5
3 2 4 1*/
	int i;
	for( i=2;i<=k;i++)
	{
	//	cout<<"num="<<num<<" curr="<<curr<<" a[curr]="<<a[curr]<<" "<<"st[curr]="<<st[curr]<<endl	; 
		num++;
		if(st[curr])
			break;
		v.push_back(curr);
		st[curr]=num;
		//cout<<"num="<<num<<" curr="<<curr<<" a[curr]="<<a[curr]<<" "<<"st[curr]="<<st[curr]<<endl	; 
		curr=a[curr];
	}	
	if (i>k)
	{
		cout<<curr<<endl;
		return 0;
	}
	long long l=st[curr],t=num-st[curr];
	//cout<<"l,t="<<l<<" "<<t<<endl;
	//vector<int>::iterator it;
	//for(it=v.begin();it!=v.end();it++)
	//	cout<<*it<<" ";
	//cout<<endl;
	long long j= ((k-l)+1)%t+l-1;
	if (k<=l) j= k;
	//cout<<j<<endl;
	cout<<v[j]<<endl;	
	return 0;
}	

Measured memory_bytes: 5884
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

ll n, T;
ll t[200005];

int main() {
    cin >> n >> T >> t[0];
    ll ans = T;
    for (int i = 1; i < n; i++) {
        cin >> t[i];
        ans += min(T, t[i] - t[i-1]);
    }

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

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


def dfs(s, m):
    if len(s) == n:
        print(s)
        return 0
    for i in range(m + 1):
        if i < m:
            dfs(s + chr(ord('a') + i), m)
        else:
            dfs(s + chr(ord('a') + i), m + 1)


dfs('', 0)


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

int main()
{
	vector<int> Vec(100);
	int n;
	while(cin>>n){
		Vec[n]++;
	}
	int max_r = 0, ans=0;
	for(int i=0;i<Vec.size();i++){
		max_r = max( max_r, Vec[i]);
	}
	for(int i=0;i<Vec.size();i++){
		if(max_r == Vec[i]){
			cout<<i<<endl;
		}
	}
	
	
	return 0;
}

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

int main(int args, char *argv[])
{
  int A, B, C, X;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;

  int ret = 0;
  for (int i = 0; i <= A; i++)
  {
    for (int j = 0; j <= B; j++)
    {
      for (int k = 0; k <= C; k++)
      {
        if (i * 500 + j * 100 + k * 50 == X)
        {
          ret++;
        }
      }
    }
  }

  cout << ret << endl;
}


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

class Main
{
  public static void main (String[] arg)
  {
    Scanner scan = new Scanner(System.in);
    int n = Integer.parseInt(scan.next()); //整数
    
    int m = n / 2;
    
    if(n % 2 == 1){
      m++;
    }
    
    System.out.println(m);
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    set<pair<int, int>> used;
    int vx = (tx - sx) / abs(tx - sx);
    int vy = (ty - sy) / abs(ty - sy);
    int cx = sx, cy = sy;
    while (cx != tx) {
        cx += vx;
        cout << (vx > 0 ? 'R' : 'L');
    }
    while (cy != ty) {
        cy += vy;
        cout << (vy > 0 ? 'U' : 'D');
    }
    vx *= -1, vy *= -1;
    while (cx != sx) {
        cx += vx;
        cout << (vx > 0 ? 'R' : 'L');
    }
    while (cy != sy + vy) {
        cy += vy;
        cout << (vy > 0 ? 'U' : 'D');
    }
    vx *= -1, vy *= -1;
    while (cx != tx + vx) {
        cx += vx;
        cout << (vx > 0 ? 'R' : 'L');
    }
    while (cy != ty) {
        cy += vy;
        cout << (vy > 0 ? 'U' : 'D');
    }
    cx -= vx;
    cout << (vx < 0 ? 'R' : 'L');
    cy += vy;
    cout << (vy > 0 ? 'U' : 'D');
    vx *= -1, vy *= -1;
    while (cx != sx + vx) {
        cx += vx;
        cout << (vx > 0 ? 'R' : 'L');
    } 
    while (cy != sy) {
        cy += vy;
        cout << (vy > 0 ? 'U' : 'D');
    }
    cx -= vx;
    cout << (vx < 0 ? 'R' : 'L') << endl;
}

Measured memory_bytes: 256
import sys
n,a,b = map(int,input().split())

if a > b:
  print(0)
  sys.exit()
  
if n == 1:
  if a == b:
    print(1)
    sys.exit()
  else:
    print(0)
    sys.exit()

print((b-a)*(n-2)+1)

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

int main() {
    int N, i, l, r, x,
        sum = 0;

    cin >> N;

    for (i = 0; i < N; i++) {
        cin >> l >> r;
        x = (r - l) + 1;
        sum += x;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
n = int(input())
ps = [0] * (n + 1)
for i in range(2, n + 1):
    x = i
    p = 2
    while x > 1:
        while x % p == 0:
            ps[p] += 1
            x //= p
        p += 1
ans = 1
for c in ps:
    ans = (ans * (c + 1)) % 1000000007
print (ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
int main(){
  int n,k;
  int tmp;
  double c=0;
  string s;
  cin >> n >> k;
  int num[n];
  int h=0;
  for(int i=0;i<n;i++){
    cin >> num[i];
  }
  sort(num, num + n,greater<int>());
  for(int i=k;i<n;i++){
    c+=num[i];
  }
  ostringstream sout;
  sout << setprecision(100) << c;
  s = sout.str();
  cout << s << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, p;
  in2(a, p);
  out((a * 3 + p) / 2);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
const ll INF = 1e15;

struct Edge {
  int to;
  ll dist;
  Edge(int to, ll dist) : to(to), dist(dist) {}
};

struct Dijkstra {
  vector<ll> d;
  
  Dijkstra(int s, const vector<vector<Edge>> &g) {
    d.resize(g.size(), INF);
    d.at(s) = 0;
    
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if (d.at(v) < p.first) continue;
      
      for (Edge e : g.at(v)) {
        if (d.at(e.to) > d.at(v) + e.dist) {
          d.at(e.to) = d.at(v) + e.dist;
          que.push(P(d.at(e.to), e.to));
        }
      }
    }
  }  
};

int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  
  vector<vector<Edge>> G(n); // 円の計算用
  vector<vector<Edge>> G2(n); // スヌークの計算用
  
  for (int i = 0; i < m; i++) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    
    G.at(u).push_back(Edge(v, a));
    G.at(v).push_back(Edge(u, a));
    G2.at(u).push_back(Edge(v, b));
    G2.at(v).push_back(Edge(u, b));
  }
  
  Dijkstra di(s, G);
  Dijkstra di2(t, G2);
  
  vector<ll> ans(n + 1, INF);
  for (int i = n - 1; i >= 0; i--) {
    ans.at(i) = min(ans.at(i + 1), di.d.at(i) + di2.d.at(i));
  }
  
  ll tmp = 1e15;
  for (int i = 0; i < n; i++) {
    cout << tmp - ans.at(i) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 20012
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    a, b, c = map(int, input().split())

    if a < b < c:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7772
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)

const int maxn = 100005;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

class Solution
{
public:
	int calculate(string s)
	{
		int len = s.length();
		int res = 0;
		int sign = 1;
		stack<int>st;
		for (int i = 0; i<len; i++)
		{
			if (s[i] == ' ')continue;
			if (s[i] >= '0'&&s[i] <= '9')
			{
				int cur = 0;
				while (i<len&&s[i] >= '0'&&s[i] <= '9')
				{
					cur = cur * 10 + s[i] - '0';
					i++;
				}
				i--;
				res += sign*cur;
			}
			else if (s[i] == '+')
			{
				sign = 1;
			}
			else if (s[i] == '-')
			{
				sign = -1;
			}
			else if (s[i] == '(')
			{
				st.push(sign);
				st.push(res);
				res = 0, sign = 1;
			}
			else if (s[i] == ')')
			{
				int ans = st.top()*res;
				st.pop();
				res = ans + st.top();
				st.pop();
			}
		}
		return res;
	}
};

int n, x;
int val[maxn];
void solve()
{
	sa(n), sa(x);
	repp(i, 1, n)
	{
		sa(val[i]);
	}
	ll res = 0;
	if (val[1] + val[2] >= x)
	{
		int b = val[1] + val[2] - x;
		if (val[2] >= b)
		{
			val[2] -= b;
		}
		else
		{
			val[2] = 0;
		}
		res += b;
	}
	repp(i, 2, n - 1)
	{
		if (val[i] + val[i+1] > x)
		{
			int b = val[i] + val[i + 1] - x;
			if (val[i+1] >= b)
			{
				val[i+1] -= b;
			}
			else
			{
				val[i+1] = 0;
			}
			res += b;
		}
	}
	printf("%lld", res);
}

int main()
{

	solve();
	return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int x = in.nextInt();
		int y = in.nextInt();
		in.close();
		List<Integer> lr = new ArrayList<>();
		List<Integer> ud = new ArrayList<>();
		boolean firstTime = true;
		boolean lrDir = true;
		int count = 0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='F') count++;
			else {
				if(firstTime) {
					x -= count;
					count = 0;
					firstTime = false;
					lrDir = false;
				}else if(lrDir) {
					if(count>0) lr.add(count);
					count = 0;
					lrDir = false;
				}else {
					if(count>0) ud.add(count);
					count = 0;
					lrDir = true;
				}
			}
		}
		if(firstTime) {
			x -= count;
		}else if(lrDir) {
			if(count>0) lr.add(count);
		}else {
			if(count>0) ud.add(count);
		}
		
		int lrsum = 0;
		for(int i=0;i<lr.size();i++) {
			lrsum += lr.get(i);
		}
		Set<Integer> xSet = new HashSet<>();
		if(lrsum>=x && x>=-lrsum) {
			xSet.add(x);
			for(int i=0;i<lr.size();i++) {
				int dist = lr.get(i);
				lrsum -= dist;
				Set<Integer> tmpSet = new HashSet<>();
				for(int nowX:xSet) {
					if(nowX+dist<=lrsum) tmpSet.add(nowX+dist);
					if(nowX-dist>=-lrsum) tmpSet.add(nowX-dist);
				}
				xSet = tmpSet;
			}
		}
		
		int udsum = 0;
		for(int i=0;i<ud.size();i++) {
			udsum += ud.get(i);
		}
		Set<Integer> ySet = new HashSet<>();
		if(udsum>=y && y>=-udsum) {
			ySet.add(y);
			for(int i=0;i<ud.size();i++) {
				int dist = ud.get(i);
				udsum -= dist;
				Set<Integer> tmpSet = new HashSet<>();
				for(int nowY:ySet) {
					if(nowY+dist<=udsum) tmpSet.add(nowY+dist);
					if(nowY-dist>=-udsum) tmpSet.add(nowY-dist);
				}
				ySet = tmpSet;
			}
		}
		
		if(xSet.contains(0) && ySet.contains(0)) System.out.println("Yes");
		else System.out.println("No");

	}

}


Measured memory_bytes: 45280
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int N, H, W;
		cin >> N >> H >> W;
		cout << (N-H+1) * (N-W+1) << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N;
	cin >> N;

	string s[100000];
	long long ac = 0;
	long long wa = 0;
	long long tle = 0;
	long long re = 0;

	for (long long i = 0; i < N; i++)
	{
		cin >> s[i];
		if ("AC" == s[i])
		{
			ac++;
		}
		else if ("WA" == s[i])
		{
			wa++;
		}		
		else if ("TLE" == s[i])
		{
			tle++;
		}		
		else if ("RE" == s[i])
		{
			re++;
		}
	}

	//int A[5]
	//sort(A, A + 5);

	if (true)
	{
		cout << "AC x " << ac << endl;
		cout << "WA x " << wa << endl;
		cout << "TLE x " << tle << endl;
		cout << "RE x " << re << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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; }

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    cin >> A >> B >> C;
    sort(all(A));
    sort(all(B));
    sort(all(C));
    ll cnt = 0;
    rep(i,N){
        ll l = lower_bound(all(A), B[i]) - A.begin();
        ll r = C.end() - upper_bound(all(C), B[i]);
        cnt += l * r;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 5576
#include <cstdio>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;


typedef long long ll;

int main(void) {
  ll N;
  cin >> N;

  int b = 1;
  ll v = 1;
  ll lb = 0;
  ll ub = 1;
  for(;;) {
    if(lb <= N && N <= ub) {
      ll idx = N - lb;
      for(ll i = b-1; i >= 0; --i) {
        printf("%lld", ((idx >> i) & 1LL) ^ i%2);
      }
      puts("");
      break;
    }
    v *= -2;
    ++b;
    lb = min(lb, lb + v);
    ub = max(ub, ub + v);
  }
  return 0;
}


Measured memory_bytes: 256
function main(lines) {
  const N = +lines[0];
  const as = splitN(lines[1]);

  const res = as.filter((v, i) => v%2!=0 && (i+1)%2!=0).length;
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}

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

using ll=long long;
const ll MOD=1000000007;
ll h,w;
typedef pair<int,int> P;
char maze[20][20];
ll d[20][20];
ll dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
ll sx,sy;
ll ans=-1;

ll bfs(int x,int y){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=MOD;
    }
  }
  queue<P> que;
  que.push(P(x,y));
  d[x][y]=0;
  while(que.size()){
    P p=que.front();que.pop();
    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx&&0<=ny&&nx<h&&ny<w&&d[nx][ny]==MOD&&maze[nx][ny]!='#'){
        d[nx][ny]=d[p.first][p.second]+1;
        que.push(P(nx,ny));
      }
    }
  }
  ll maxv=-1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        maxv=max(maxv,d[i][j]%MOD);
    }
  }
  ans=max(ans,maxv);
}

int main() {
  int MAX=0;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> maze[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(maze[i][j]=='.'){
        bfs(i,j);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def C():
    n = int(input())
    a = sorted(list(map(int,input().split())),reverse=True)
    i=0
    longer = 0
    shorter = 0
    while i < len(a)-1:
        if a[i] == a[i+1]:
            if longer == 0:
                longer = a[i]
                i+=1
            elif shorter == 0:
                shorter = a[i]
                i+=1
        i+=1
    print(longer*shorter)
C()

Measured memory_bytes: 14224
// abc085_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, y;
  bool ok = false;
  cin >> n >> y;
  int a, b, c;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int k = n - i - j;
      if (y == 10000 * i + 5000 * j + 1000 * k && k >= 0) {
        a = i, b = j, c = k;
        ok = true;
      }
    }
  }
  if (ok)
    cout << a << " " << b << " " << c << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
    int n;
    cin >>n;
    if(n==0){cout<<1;return 0;}
    vi fib(n+1);
    fib[0]=1;
    fib[1]=1;
    for(int i=2;i <= n;i++){
        fib[i]=fib[i-1]+fib[i-2];
    }
    cout <<fib[n]<<endl;
    return 0;
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

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 main() {
	int N, M;
	cin >> N >> M;
	string S;
	cin >> S;
	string T;
	cin >> T;
	int g = gcd(N, M);
	string x, y;
	for (int i = 0; i < g; i++) {
		x.push_back(S[N / g * i]);
		y.push_back(T[M / g * i]);
	}
	if (x == y) cout << lcm(N, M) << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 512
a,b,c = map(int,raw_input().split())
num = 1
c_div = []
while num<=c :
	if c%num==0 :
		c_div.append(num)
	num += 1
Count = 0
while a <= b :
	for i in c_div :
		if a==i :
			Count += 1
	a += 1
print '%d' % Count

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

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {
	
	int n, m, x, y, z;
	cin >> n >> m >> x >> y;
	vector<int> X(n), Y(m);
	FOR(i, n)cin >> X[i];
	FOR(i, m)cin >> Y[i];

	SORT(X);
	SORT(Y);
	z = min(y, Y[0]);
	bool ans = true;
	if (x >= z)ans = false;
	FOR(i, n) {
		if (X[i] >= z)ans = false;
	}

	if (ans)cout << "No War" << endl;
	else cout << "War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int y, m, d;
        cin >> y >> m >> d;
        int day = 0;
        day += (y % 3 ? (m % 2 ? 21 : 20) : 21) - d;
        for (int j = m + 1; j <= 10; ++j) {
            day += y % 3 ? (j % 2 ? 20 : 19) : 20;
        }
        for (int j = y + 1; j < 1000; ++j) {
            day += j % 3 ? 195 : 200;
        }
        std::cout << day << std::endl;
    }
}

Measured memory_bytes: 1160
/*
 	安部NANA先輩大好き

 */
#include<bits/stdc++.h>

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,ans=0,cake[200],sum = 0;
    cin >> n >> m;
    rep(i,0,m){
        cin >> cake[i];
        sum+=cake[i];
    }
    rep(i,0,m){
        int s = sum - cake[i];
        if((cake[i]+1)>s){
            ans = cake[i]-s-1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int NN = -1;
typedef struct{
	int parent;
	int left;
	int right;
	int depth;
	int height;
}node;
node u[25000];
void checkdepth(int nd, int dp){
	if(nd == NN) return;
	u[nd].depth = dp;
	checkdepth(u[nd].left, dp+1);
	checkdepth(u[nd].right, dp+1);
}

int checkheight(int nd){
	int h1 = 0;
	int h2 = 0;
	if(u[nd].right != NN) h1 = checkheight(u[nd].right)+1;
	if(u[nd].left  != NN) h2 = checkheight(u[nd].left)+1;
	return u[nd].height = max(h1, h2);
}

int getsib(int c){
	if(u[c].parent == NN) return NN;
	if(u[u[c].parent].left == c && u[u[c].parent].right != NN) return u[u[c].parent].right;
	if(u[u[c].parent].right == c && u[u[c].parent].left != NN) return u[u[c].parent].left;
	return NN;
}

int main(){
	int n, x, i, j, l, r;
	int root = 0;
	cin >> n;
	rep(i, n){
		u[i].parent=NN;
	}
	rep(i, n){
		scanf("%d %d %d", &x, &l, &r);
		u[x].left = l;
		u[x].right = r;
		if(l != NN) u[l].parent = x;
		if(r != NN) u[r].parent = x;
	}
	rep(i, n)if(u[i].parent == NN) root = i;
	checkdepth(root, 0);
	checkheight(root);
	rep(i, n){
		j=0;
		cout << "node " << i << ": parent = " <<u[i].parent <<", sibling = "<<getsib(i)<<", degree = ";
			if(u[i].left!=NN)j++;
		if(u[i].right!=NN)j++;
		cout << j << ", depth = " << u[i].depth << ", height = " << u[i].height << ", ";
		if(u[i].parent == NN) cout <<"root" << endl;
		else if(u[i].left ==NN && u[i].right==NN) cout <<"leaf" << endl;
		else cout << "internal node" << endl;
	}
}
		









Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    int r;
    cin >> r;
    cout << r * r << endl;

}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sr = new Scanner(System.in);
		while(true){
			int h = sr.nextInt();
			int w = sr.nextInt();
			if(h==0&&w==0) break;
			for(int y=0; y<h; y++){
				for(int x=0; x<w; x++){
					if((x+y)%2==0){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
		System.out.println();
		}
	}
}

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

struct UnionFind {
    vector<ll> par;  // par[i]: parent of i
    vector<ll> siz;

    UnionFind(ll N) : par(N + 1), siz(N + 1, 1ll) {  // initialize by making every node a root node
        for (int i = 0; i <= N; i++) par[i] = i;
    }

    ll root(ll x) {  // find the root of a given node
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return;
    }

    bool issame(ll x, ll y) {  // return true if x and y belong to the same tree
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
	int n, m;
    cin >> n >> m;
    UnionFind uft(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uft.unite(a, b);
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, uft.size(i));
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 6424
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <queue>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#define rg register
using namespace std;
const int N = 2333;
const int pr = 13331;

struct ios{
	template <typename _tp>
	inline ios operator >> (_tp &x){
		x = 0;int f = 1;char c = getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f = -1;
		for(;c<='9'&&c>='0';c=getchar()) x = (x<<1)+(x<<3)+(c^48);
		x *= f;
		return *this;
	}
	template <typename _tp>
	inline ios operator << (_tp x){
		char s[55];int dgt = 0;
		if(x==0) putchar('0');
		if(x<0) putchar('-'),x = -x;
		while(x) ++dgt,s[dgt] = x%10+'0',x /= 10;
		while(dgt) putchar(s[dgt]),--dgt;
		return *this;
	}
	inline ios operator << (char x){
		putchar(x);return *this;
	}
}io;

int n, m, a, b, btm, atm, qwq;
int mmp[N][N];
int col[N];
int main()
{
	io >> n >> m >> a >> b;
	btm = b, atm = a;
	begin:
	for(rg int i=1;i<=n;++i){
		rg int tot = 0;
		for(rg int j=1;j<=m;++j){
			if (col[j]<b) mmp[i][j] = 1, ++tot, ++col[j];
			if (tot== a) break; 
		}
		if(tot!=a&&tot!=m-a){
			++qwq;break;
		}
		if(i==n){
			rg bool qaq = 1;
			for (rg int j=1;j<=m;++j){
				if (col[j] != b && col[j] != n - b){
					qaq = 0;++qwq;break;
				}
			}
			if(qaq) qwq = 0;
		}
	}
	if(qwq)
	{
		if(qwq==1) b = n-btm, a = atm;
		if(qwq==2) b = btm, a = m-atm;
		if(qwq==3) b = n-btm, a = m-atm;
		if(qwq==4){
			io << -1;return 0;
		}
		for(rg int i=1;i<=n;++i){
			for(rg int j=1;j<=m;++j){
				col[j] = 0,mmp[i][j] = 0;
			}
		}
		goto begin;
	}
	for(rg int i=1;i<=n;++i){
		for(rg int j=1;j<=m;++j){
			io << mmp[i][j];
		}
		putchar('\n');
	}
	return 0;
}

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

 int main()
 {
	int n;
	cin >> n;
	long x;
	long ans = 1;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		if(x == 0)
		{
			ans = 0;
			break;
		}
		if(ans == -1)
			continue;
	
		if(x > (1000000000000000000/ans))
			ans = -1;
		else
			ans *= x;
	}
 
	cout << ans;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
string a; 
int main(){
    cin>>a;
    if(a=="Sunny")printf("Cloudy\n");
    if(a=="Cloudy")printf("Rainy\n");
    if(a=="Rainy")printf("Sunny\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

const int MAX_N = 100;
int d[MAX_N];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	int a, b;
	cin >> a >> b;
	
	int c;
	cin >> c;
	
	for(int i = 0; i < n; ++i){
		cin >> d[i];
	}
	
	sort(d, d + n, greater<int>());
	
	int sum = c;
	int ans = c / a;
	for(int i = 0; i < n; ++i){
		sum += d[i];
		ans = max(ans, sum / (a + b * (i + 1)));
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int F(long a, long b){

    long i = max(a,b);

    int count = 0;
    while( i != 0 ){
         i /= 10;
         count++;
    }
  
    return count;
}

int main() {

    long n;
    cin >> n;

    int min = F(1,n);
    for(int i = 1; i <= sqrt(n); i++){
    
            if( n % i == 0 ){
                int tmp = F(i, n/i);
                if(tmp < min)
                  min = tmp;
            }
                
    }

    cout << min << endl;
}


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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  vector<vector<int>> data(N);
  for (int i = 0; i < N; i++) data[i].resize(3);

  for (int i = 0; i < N; i++) {
    data[i][2] = K + 2 * N + i;
  }
  for (int i = 0; i < (N / 2); i++) {
    data[N / 2 - 1 - i][0] = K + i;
    data[N / 2 - 1 - i][1] = K + 2 * N - 2 - 2 * i;
  }

  int base = (N + 1) / 2;
  for (int i = 0; i < base; i++) {
    data[N - i - 1][0] = K + N / 2 + i;
    data[N - i - 1][1] = K + 2 * N - 1 - 2 * i;
  }

  bool ans = true;
  for (int i = 0; i < N; i++) {
    if (data[i][0] + data[i][1] > data[i][2]) ans = false;
  }
  if (!ans) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    cout << data[i][0] << " " << data[i][1] << " " << data[i][2] << endl;
  }

  return 0;
}

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

ll fact[2000000];
ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
ll C(ll n,ll k){
	return fact[n]*ppow(fact[k],MOD-2)%MOD*ppow(fact[n-k],MOD-2)%MOD;
}

int main(){
	int n;scanf("%d",&n);
	if(n==2){
		puts("1");return 0;
	}
	fact[0]=1;
	for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%MOD;
	ll cnt=0,ans=0;
	for(int k=2;k<=n-1;k++){
		if(k-1<n-k-1)continue;
		ll a=C(k-1,n-k-1)*fact[k]%MOD*fact[n-k-1]%MOD;
		(ans+=k*(a+MOD-cnt)%MOD)%=MOD;
		cnt=a;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8448
object Main extends App {
  val n = readInt
  val a = Array.fill(n)(0)
  val xy:Array[List[(Int,Int)]] = Array.fill(n)(Nil)
  for (i <- 0 until n) {
    a(i) = readInt
    (0 until a(i)).foreach{ _ =>
      xy(i) = (readLine.split(" ").map{_.toInt} match {case x => (x(0)-1,x(1))}) :: xy(i)
    }
  }
  
  def solve(i:Int,honestList:List[Int]):Int = {
    if (i == n) {
      val h = honestList.reverse.toArray
      val ok = (
        for (i <- 0 until n) yield {
          if (h(i)==1) xy(i).map{case (x,y) => h(x) == y}.forall{_ == true} else true
        }).forall{_ == true}
      if (ok) h.sum else 0
    }
    else {
      scala.math.max(solve(i+1,0::honestList),solve(i+1,1::honestList))
    }
  }
  
  println(solve(0,Nil))
}

Measured memory_bytes: 75988
#include <bits/stdc++.h>
using namespace std;
int dp[200005][3];
int main()
{
    int n,a[200005],i,j,k,b[200005],c[200005];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
        
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N, M;
int A[100010], B[100010];
vector<int> G[100010];

int used[100010];
vector<int> ans;
void dfs(int u){
	used[u] = 1;
	ans.pb(u);
	for(auto v : G[u]){
		if(used[v]) continue;
		dfs(v);
		return;
	}
}

bool check(int u){
	for(auto v : G[u]){
		if(!used[v]) return false;
	}
	return true;
}



int main(void){
	cin >> N >> M;
	rep(i, M) cin >> A[i] >> B[i];
	rep(i, M) A[i]--, B[i]--;
	rep(i, M) G[A[i]].pb(B[i]), G[B[i]].pb(A[i]);

	vector<int> v;
	rep(i, N) v.pb(i);
	sort(all(v), [&](int a, int b){return G[a].size() < G[b].size();});

	for(auto start : v){
		ans.clear();
		rep(i, 100010) used[i] = 0;
		dfs(start);
		if(!check(start)) continue;
		printf("%d\n", (int)ans.size());
		for(auto u : ans) printf("%d ", u + 1);
		printf("\n");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 11512