akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int n,x;
    while(true){
        cin>>n>>x;
        int count=0;
        if(n==0&&x==0) break;
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x) count++;
               }
            }
        }
        cout<<count<<'\n';
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll x = 1;
    ll ans = 0;
    while(x <= n) {
        x *= k;
        ans++;
    }

    out(ans);
    re0;
}

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

int main(){
 int n,k;
 cin >> n >> k;
 string s;
 cin >> s;
 s[k-1] = tolower(s[k-1]);
 cout << s << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    int ans = 100_000;
    for (int i = 0; i < n; i++) {
        ans = ans * 105 / 100;
        if (ans % 1000 > 0) {
            ans += 1000 - (ans % 1000);
        }
    }
    writeln(ans);
}



Measured memory_bytes: 2364
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int cnt_1 = 0, cnt_2 = 0, size_s, n_1 = 0, n_2 = 0, n_3 = 0;
    for (int i = 0; i < n; i++) {
        size_s = s[i].size();
        for (int j = 0; j < size_s - 2; j++) {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
                cnt_1 += 1;
            }
        }

        if (s[i][0] == 'B' && s[i][size_s - 1] == 'A') {
            n_1 += 1;
        } else if (s[i][0] == 'B') {
            n_2 += 1;
        } else if (s[i][size_s - 1] == 'A') {
            n_3 += 1;
        }
    }
    if (n_2 == 0 && n_3 == 0) {
        if (n_1 > 0) {
            cnt_2 = n_1 - 1;
        }
    } else {
        cnt_2 = min(n_2 + n_1, n_3 + n_1);
    }
    int ans = cnt_1 + cnt_2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import math
number=list(map(int,input().split()))
H_l,M_l,H,M=number[0],number[1],number[2],number[3]
H_c=math.cos(math.radians(float(H/12)*360+float(M/60)*30))
H_s=math.sin(math.radians(float(H/12)*360+float(M/60)*30))
M_c=math.cos(math.radians(float(M/60)*360))
M_s=math.sin(math.radians(float(M/60)*360))

H_x,H_y=float(H_l*H_c),float(H_l*H_s)
M_x,M_y=float(M_l*M_c),float(M_l*M_s)
answer=float((H_x-M_x)**2+(H_y-M_y)**2)**float(1/2)
print(answer)

Measured memory_bytes: 62464
def kaijou(n):
  result = 1
  for i in range(1, n+1):
    result *= i
  return result

def nanbanme(l, n):
  for i in range(len(l)):
    if l[i] == n:
      return i
  
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
p_n = [i for i in range(1, n+1)]
q_n = [i for i in range(1, n+1)]

pp, qq = 1, 1

for i in range(n):
  if p[i] != min(p_n):
    pp += kaijou(n-i-1) * nanbanme(p_n, p[i])
  p_n.remove(p[i])
    
  if q[i] != min(q_n):
    qq += kaijou(n-i-1) * nanbanme(q_n, q[i])
  q_n.remove(q[i])
    
print(abs(pp-qq))

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    string a,b,c;cin>>a>>b>>c;
    int a1,b1;
    a1 = a.size();
    b1 = b.size();
    if(a[a1-1]==b[0] && b[b1-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        esc:while(true) {
            int a = scn.nextInt();
            String op = scn.next();
            int b = scn.nextInt();
            switch(op) {
              case "+":
                System.out.println(a + b);
                break;
              case "-":
                System.out.println(a - b);
                break;
              case "*":
                System.out.println(a * b);
                break;
              case "/":
                System.out.println(a / b);
                break;
              case "?":
                break esc;
            }
        }
    }
}

Measured memory_bytes: 26260
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

const ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T binpow( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}


int main()
{
	int a, b;
	cin >> a >> b;

	int c = b - a;
	int ans = 0;
	reps( i, c )
	{
		ans += i;
	}

	cout << ans - b << endl;

	return ( 0 );
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int k,s; cin >> k >> s;
  int ans = 0;
  int z;
  rep(i,k+1) rep(j,k+1){
    z = s - i - j;
    if(0 <= z && z <= k) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
//#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
const int MAX_N=55;
char mp[MAX_N][MAX_N];
int dist[MAX_N][MAX_N];
pii pre[MAX_N][MAX_N];
bool on_path[MAX_N][MAX_N];
queue <tuple<int,int,int> > q;
int H,W;
bool in(int x,int y)
{
	return x>=1 && y>=1 && x<=H && y<=W;
}
void find_path(int x,int y)
{
	on_path[x][y]=true;
	if(pre[x][y]==make_pair(x,y))return;
	find_path(pre[x][y].fi,pre[x][y].se);
}
int main()
{
	cin>>H>>W;
	For(i,1,H)
	{
		scanf("%s",mp[i]+1);
	}
	memset(dist,0x3f,sizeof(dist));
	pre[1][1]=make_pair(1,1);
	q.push(mt(0,1,1));
	dist[1][1]=0;
	on_path[1][1]=true;
	while(!q.empty())
	{
		int dis,x,y;
		tie(dis,x,y)=q.front();
		q.pop();
		rep(d,0,4)
		{
			int nx=x+dx[d],ny=y+dy[d];
			if(in(nx,ny) && mp[nx][ny]=='.' && dis+1<dist[nx][ny])
			{
				q.push(mt(dis+1,nx,ny));
				dist[nx][ny]=dis+1;
				pre[nx][ny]=make_pair(x,y);
			}
		}
	}
	if(dist[H][W]>=INF)
	{
		puts("-1");
		return 0;
	}
	find_path(H,W);
	int ans=0;
	For(i,1,H)
	{
		For(j,1,W)
		{
			if(mp[i][j]=='.' && !on_path[i][j])ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            int n = ReadAndParseInt();
            string s = Console.ReadLine();
            int x = 0;
            int ans = 0;
            for(int i=0;i<s.Length;++i)
            {
                if( s[i] == 'I')
                {
                    x++;
                }
                else
                {
                    x--;
                }
                ans = Math.Max(ans, x);
            }
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

typedef long long ll;
ll MOD = 1000000007;

ll GCD(ll a,ll b){
  if(a < b){
    return GCD(b,a);
  }
  ll r = 10000000000000000;
  while(r){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

int main(){
  ll N,M;
  string S,T;
  cin >> N >> M >> S >> T;
  if(N < M){
    swap(N,M);
    swap(S,T);//Nの方が常に大きい
  }
  if(S[0] != T[0]){
    cout << -1 << endl;
    return 0;
  }
  if(GCD(N,M) == 1){
    cout << N * M << endl;
    return 0;
  }
  if(GCD(N,M) == M){
    bool freg = 1;
    for(int i = 0;i < M;i++){
      if(S[i*N/M] != T[i]){
        freg = 0;
      }
    }
    if(freg){
      cout << N << endl;
      return 0;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  bool frag = 1;
  ll n = N / GCD(N,M),m = M/GCD(N,M);
  for(int i = 0;i < GCD(N,M);i++){
    
    if(S[n * i] != T[m*i]){
      frag = 0;
    }
  }
  if(frag){
      cout << GCD(N,M) * n * m << endl;
    }else{
      cout << -1 << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#include <sstream>

using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
#define rep(n) for(ll i=0; i<n; i++)
#define MAX_V 100001
const ll INF = 1e+9;

ll intPow(ll x, ll a)
{
  if(a==0)
  {
    return 1;
  } else {
    return x * intPow(x, a-1);
  }
}

int main()
{
  ll a;
  string b;
  cin >> a >> b;
  int pointPos = b.find(".");
  int bint;
  ll mod = 1;
  if(pointPos!=-1)
  {
    mod = intPow(10, b.length() - pointPos - 1);
    b.erase(pointPos, 1);
  }
  istringstream ss1;
  ss1 = istringstream(b);
  ss1 >> bint;
  cout << (a*bint)/mod << endl;
  return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll n, m, k; std::cin >> n >> m >> k;
    vl a(n), b(m);
    rep(i, n) std::cin >> a[i];
    rep(i, m) std::cin >> b[i];

    int ans = 0;
    ll remain = k;
    int ac = 0, bc = 0;
    while (ac < n && remain-a[ac] >= 0) {
        remain -= a[ac];
        ac++;
    }
    ans = ac;
    while (bc < m) {
        while (remain < b[bc] && ac > 0) {
            ac--;
            remain += a[ac];
        }
        if (remain < b[bc]) {
            break;
        }
        remain -= b[bc];
        bc++;
        chmax(ans, ac+bc);
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 6264
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
a = intl()

for i in range(n):
	if a[i]%2 == 0:
		if a[i]%3 != 0 and a[i]%5 !=0:
			print("DENIED")
			exit()
print("APPROVED")

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
using namespace std;

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


const long long INF = 1LL << 60;
long long c[110][210];
long long dp[210];


//bucket1
// bool ch[10] = {0};
// bool check(int n){
//     while(n!=0){
//         if(ch[n%10]) return false;
//         n /= 10;
//     }
//     return true;
// }



// --------write my code!!!!!----------//

int main(){
    int N; cin >> N;
    int a[N]; for(int i=0; i<N; ++i) cin >> a[i];
    long res = 10000000000;

    //２次元配列に計算結果を格納
    for(int j=-100; j<=100; ++j){
        long cost = 0;
        for(int i=0; i<N; ++i){
            cost += pow(abs(a[i]-j),2);
        }
        res = min(res,cost);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_149c
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            
            while (true)
            {
                bool judge = true;
                for (int i=2;i<input;i++)
                {
                    if (input % i == 0)
                    {
                        judge = false;
                        break;
                    }
                }

                if (judge)
                {
                    Console.WriteLine(input);
                    break;
                }
                
                input++;
            }
            Console.Read();
        }
    }
}


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

int main(void){
    int n;
    string s;
    cin >> n >> s;
    if(n%2==1){cout << "No" << endl; return 0;}
    n /= 2;

    bool ok = true;
    for(int i=0;i<n;i++){
        if(s[i]!=s[i+n]) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

const int N = 2 * 1000 * 100 + 10;
int n, st[N], en[N], cnt, vert[N];
long long L[N], R[N], res[N];
vector<int> adj[N];

void dfs(int root, int par = -1) {
	st[root] = ++cnt;
	vert[cnt] = root;
	for (auto u: adj[root])
		if (u ^ par)
			dfs(u, root);
	en[root] = cnt;
}

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int Q;
	cin >> n >> Q;
	for (int i = 1, v, u; i < n; i++) {
		cin >> v >> u;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	dfs(1);
	while (Q--) {
		int p, v;
		cin >> p >> v;
		L[st[p]] += v;
		R[en[p]] += v;
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += L[i];
		ans -= R[i - 1];
		res[vert[i]] = ans;
	}
	for (int i = 1; i <= n; i++)
		cout << res[i] << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 29696
a,b,c,k=map(int,input().split())
ans=0
if k>a+b:
    ans+=a
    k-=(a+b)
    if k<=c:
        print(ans-k)
    else:
        print(ans-c)
    
else:
    if k>=a:
        print(a)
    else:
        print(k)

Measured memory_bytes: 9188
package main

import "fmt"

func main() {
	ss()
}

func ss() {
	var s string
	fmt.Scan(&s)
	for i:=len(s)-1; i>=0; i-- {
		if isEvenString(s[:i]) {
			fmt.Println(i)
			return
		}
	}
	fmt.Println("0")
}

func isEvenString(s string) bool {
	if len(s)%2!=0 {
		return false
	}
	return s[:len(s)/2] == s[len(s)/2:]
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e15
ll N, X, b[101010];
ll l[101010], u[101010];
vector<pll> mxv;
ll mk[101010];
ll i, j, k,aa,bb,dd,bs,ans;
int main(){
    scanf("%lld%lld", &N,&X);
    bs = 0;
    fornum(i,0,N){
        scanf("%lld%lld%lld", &b[i], &l[i], &u[i]);
        bs += l[i] * b[i];
        mxv.push_back({u[i] * (X - b[i]) + l[i] * b[i], i});
    }
    sort(mxv.begin(), mxv.end(), greater<pll>());
    //printf("%lld\n", bs);
    if(bs==0){
        printf("0");
        return 0;
    }
    while(bb<N&&aa<bs){
        aa += mxv[bb].first;
        ll a = mxv[bb].second;
        mk[a] = 1;
        dd += X;
        //printf("%lld %lld\n", mxv[i].second, bs);
        bb++;
    }
    bb--;
    ans = INF;
    fornum(i,0,bb){
        ll cc = bs-(aa - mxv[i].first);
        ll ii = mxv[i].second;
        ll a = dd-X;
        if(cc<=b[ii]*l[ii]){
            a += (cc - 1) / l[ii] + 1;
        }else{
            a += (cc - b[ii] * l[ii] - 1) / u[ii] + 1 + b[ii];
        }
        if(a<ans){
            ans = a;
        }
        //printf("%llda\n", ans);
    }
    fornum(i,bb,N){
        ll cc = bs-(aa - mxv[bb].first);
        ll ii = mxv[i].second;
        ll a = dd - X;
        if(cc<=b[ii]*l[ii]){
            a += (cc - 1) / l[ii] + 1;
        }else{
            a += (cc - b[ii] * l[ii] - 1) / u[ii] + 1 + b[ii];
        }
        if(a<ans){
            ans = a;
        }
        //printf("%lld\n", ans);
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 5232
t_health, t_attack, a_health, a_attack = map(int, input().split())

is_t_turn = True
while(t_health > 0 and a_health > 0):
    if is_t_turn:
        a_health -= t_attack
    else:
        t_health -= a_attack

    is_t_turn = not is_t_turn

if t_health <= 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=1e5;
static const int NMAX=50;
static const int MMAX=50;
int N,a[MAX];
ll cunt2,cunt1,sum;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    
        sum=0ll;
    //偶数が正
        for(int i=0;i<N;i++){
            if(i%2==0&&sum+a[i]<=0){//sumは負
                cunt1+=(-1)*sum+1-a[i];
                sum=1;
            }else if(i%2!=0&&sum+a[i]>=0){
                cunt1+=a[i]+sum+1;
                sum=-1;
            }else sum+=a[i]; //操作必要なし
            
        }
    //奇数が正
    sum=0ll;
    for(int i=0;i<N;i++){
        if(i%2!=0&&sum+a[i]<=0){
            cunt2+=(-1)*sum+1-a[i];;
            sum=1;
        }else if(i%2==0&&sum+a[i]>=0){
            cunt2+=a[i]+sum+1;
            sum=-1;
        }else sum+=a[i]; //操作必要なし

    }
    
    cout<<min(cunt1,cunt2)<<"\n";
    
    
    return 0;
}



Measured memory_bytes: 640
//#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
map<ll,ll> costmin;
ll N,A,B,C,D;
ll f(ll n){
	debug(n);
	if(n==0) return 0;
	if(n==1) return D;
	if(costmin.count(n)) return costmin[n];
	ll l2=n/2*2,r2=(n/2+n%2)*2;
	ll l3=n/3*3,r3=(n/3+(n%3!=0))*3;
	ll l5=n/5*5,r5=(n/5+(n%5!=0))*5;
	ll cost=INFl;
	if((double)n*D<=1e+18) cost=min(cost,n*D);
	cost=min(cost,llabs(l2-n)*D+A+f(l2/2));
	cost=min(cost,llabs(r2-n)*D+A+f(r2/2));
	cost=min(cost,llabs(l3-n)*D+B+f(l3/3));
	cost=min(cost,llabs(r3-n)*D+B+f(r3/3));
	cost=min(cost,llabs(l5-n)*D+C+f(l5/5));
	cost=min(cost,llabs(r5-n)*D+C+f(r5/5));
	costmin[n]=cost;
	debug(n,cost);
	return cost;
}
int main(){
	int T;
	scan(T);
	rep(t,T){
		costmin.clear();
		scan(N>>A>>B>>C>>D);
		ll ans=f(N);
		prin(ans);
	}
	return 0;
}


Measured memory_bytes: 4452
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k,m=10000000;
	bool xx = false;
	cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (x[i] >= 0&&xx==false) {
			xx = true;
			m = i;
		}
	}
	if (m == 10000000) {
		cout << -x[n - k];
		return 0;
	}
	int q = min(k+m-1, n-1);
	int ans=800000000;
	if (m+k<=n) {
		ans = x[q];
		for (int i = q - 1; m <= i; i--) {
			int left = i - k + 1;
			if (left<0) {
				break;
			}
			int dis1 = x[i];
			int dis2 = -x[left];
			int dis = min(dis1, dis2);
			int dism = max(dis1, dis2);
			ans = min(ans, 2 * dis + dism);
		}
	}
	else {
		for (int i = q; m <= i; i--) {
			int left = i - k + 1;
			if (i < 0 || left<0) {
				break;
			}
			int dis1 = x[i];
			int dis2 = -x[left];
			int dis = min(dis1, dis2);
			int dism = max(dis1, dis2);
			ans = min(ans, 2 * dis + dism);
		}
	}
	
//	cout << ans << " sss" << endl;
	
	if (0 <= m - k) {
		ans = min(ans, -x[m - k]);
	}
	cout << ans;
	return 0;
	
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL A, B, K;

int main()
{
	in >> A >> B >> K;
	LL n;
	for (n = A; n <= std::min(A + K - 1, B); ++n) out << n << std::endl;
	for (n = std::max(B - K + 1, n); n <= B; ++n) out << n << std::endl;
	return 0;
}


Measured memory_bytes: 384
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        for j in range (w):
            if(i + j) % 2 == 0:
                print("#", end = '')
            else:
                print(".", end = '')     
        print()
    print()


Measured memory_bytes: 7000
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
sm=0
for i in range(n):
  b1=bisect.bisect_left(a,b[i])
  c1=n-bisect.bisect_left(c,b[i]+1)
  sm+=b1*c1
print(sm)
  

Measured memory_bytes: 101904
import sys

def check_YYMMorMMYY(str_date):
    str1=str_date[:2]
    str2=str_date[2:]
    num1=int(str1)
    num2=int(str2)
    # if 1<=num1<=12 and 1<=num2<=12:                                                      
    #     print("AMBIGUOUS")                                                               
    # elif 13<=num1<=99 and 1<=num2<=12:                                                   
    #     print("YYMM")                                                                    
    # elif 1<=num1<=12 and 13<=num2<=99:                                                   
    #     print("MMYY")                                                                    
    # elif 13<=num1<=99 and 13<=num2<=99:                                                  
    #     print("NA")                                                                      
    # elif num1==0 or num2==0:                                                             
    #     print("NA")                                                                      
    if 1<=num1<=12:
        if 1<=num2<=12:
            print("AMBIGUOUS")
        else :
            print("MMYY")
    else:
        if 1<=num2<=12:
            print("YYMM")
        else:
            print("NA")

str_S=input()


if str_S.isdecimal()==0 or len(str_S)!=4 :
    print("Unexpected S")
    sys.exit()

check_YYMMorMMYY(str_S)


Measured memory_bytes: 3060
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back

using namespace std;

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

const int N = 107;
const int oo = 1e9;

int n, m, par[N], dis[N], pidx[N];
vector<int>edge[N], cost[N], idx[N];
map< int, int> mp;

void bfs(int at){
	priority_queue<pii>q;
	q.push(pii(0, at));
	rep(i, N) par[i] = -1, dis[i] = oo, pidx[i] = -1;
	dis[at] = 0;
	while(!q.empty()){
		pii f = q.top(); q.pop();
		int u = f.second;
		rep(i, edge[u].size()){
			int v = edge[u][i], c = cost[u][i], dx = idx[u][i];
			if(dis[v] > dis[u] + c){
				dis[v] = dis[u] + c;
				par[v] = u;
				pidx[v] = dx;
				q.push(pii(-dis[v], v));
			}
		}
	}
	repn(i, n){
		int cur = i;
		while(cur != at){
			mp[ pidx[cur] ] = 1;
			cur = par[cur];
		}
	}
}

int main(){
	int x, y, c;
	scanf("%d %d", &n, &m);
	repn(i, m){
		scanf("%d %d %d", &x, &y, &c);
		edge[x].pb(y);
		edge[y].pb(x);
		cost[x].pb(c);
		cost[y].pb(c);
		idx[x].pb(i);
		idx[y].pb(i);
	}
	repn(i, n) bfs(i);
	int ret = 0;
	repn(i, m) ret += (mp[i] == 0);
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int main()
{
  int n;
  long long a[N], b[N], cnt = 0;
  cin >> n;
  for (int i=0; i<n+1; i++) cin >> b[i];
  for (int i=0; i<n; i++) cin >> a[i];
  for (int i=0; i<n; i++){
     if ( a[i] >= b[i]){
        cnt += (b[i]);
        a[i]-=b[i];
        b[i]=0;
     }
     else {
        cnt += (a[i]);
        b[i]-=a[i];
        a[i]=0;
     }
     if ( a[i] >= b[i+1]){
        cnt += (b[i+1]);
        a[i]-=b[i+1];
        b[i+1]=0;
     }
     else {
        cnt += (a[i]);
        b[i+1]-=a[i];
        a[i]=0;
     }
  }
  cout << cnt;
    return 0;
}


Measured memory_bytes: 1792
import math
A, B, H, M = map(int, input().split())


def f(x, y, theta):
    nx = x * math.cos(theta) - y * math.sin(theta)
    ny = x * math.sin(theta) + y * math.cos(theta)
    return nx, ny


y1, x1 = f(A, 0, math.radians(H * 30.0 + M * 0.5))
y2, x2 = f(B, 0, math.radians(M * 6.0))

# print('radian1', math.radians(H * 30))
# print('radian2', math.radians(M * 6))
# print(x1, y1, x2, y2)
# print(x2 - x1)
# print(y2 - y1)
d = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
# d = ((x2 - x1)**2 + (y2 - y1)**2)**0.5

print(d)


Measured memory_bytes: 9516
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    static int N, K;
    static int[] arr;

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inStr = br.readLine().split(" ");
        N = Integer.parseInt(inStr[0]);
        K = Integer.parseInt(inStr[1]);
        arr = new int[N];
        inStr = br.readLine().split(" ");
        for (int i = 0; i < N; i++) {
            arr[i] = Integer.parseInt(inStr[i]);
        }

        int min = Integer.MAX_VALUE;
        int left, right, num;
        for (int i = 0; i < N - K + 1; i++) {
            left = arr[i];
            right = arr[i + K - 1];
            if (right < 0) {
                num = Math.abs(left);
                min = Math.min(min, num);
                continue;
            }
            if (left >= 0) {
                num = right;
                min = Math.min(min, num);
                continue;
            }
            if (left < 0 && right >= 0) {
                num = Math.min(Math.abs(left) * 2 + right, Math.abs(left) + right * 2);
                min = Math.min(min, num);
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 37844
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
typedef long long LL;
typedef long double db;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

LL sum(LL s) {
	LL res = 0;
	for (; s; s /= 10) res += s % 10;
	return res;
}

db eval(LL x) {
	return (db)x / sum(x);
}

int main() {

	vector<LL> v;
	LL las = 1;
	for (int i = 1; i <= 14; ++i, las *= 10) {
		rep (i, 1, 99999) v.push_back((i+1) * las - 1);
	}

	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	vector<LL> stk;
	for (LL x : v) {
		while (!stk.empty() && eval(stk.back()) > eval(x)) stk.pop_back();
		stk.push_back(x);
	}

	For (i, 0, ri()) printf("%lld\n", stk[i]);

	return 0;
}


Measured memory_bytes: 18664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  cout << v[N-1]-v[0] << endl;
}

Measured memory_bytes: 256
S = [int(n) for n in input()]
l = len(S)
ans = 0
for i in range(l):
    for j in range(l - i):
        if (i + j) == (l - 1):
            t = 1
        else:
            t = 2
        ans += S[i] * 10**j * 2**(l - j - t)
print(ans)


Measured memory_bytes: 2940
using System;
class Program {
	static void Main() {
		int[] a = new int[10];
		int[] b = new int[10];
		for(int i = 0; i < 10; i++) a[i] = int.Parse(Console.ReadLine());
		for(int i = 0; i < 10; i++) b[i] = int.Parse(Console.ReadLine());
		Array.Sort(a);
		Array.Sort(b);
		Console.WriteLine((a[7] + a[8] + a[9]) + " " + (b[7] + b[8] + b[9]));
	}
}

Measured memory_bytes: 9332
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const D EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> II;


/** Problem0242 : Input Candidates
 なぜかWrongAnswer **/
 typedef pair<int, string> PP;

bool cmp(const PP &a, const PP &b){
	if(a.first != b.first) return a.first > b.first;
	else return a.second < b.second;
}

int main()
{
	int N;
	while (cin>>N, N) {
		map<string, int> list;
		string s;
		cin.ignore();
		rep(k, N) {
			getline(cin, s);

			stringstream ss(s);
			while (!ss.eof()) {
				string tmp; ss>>tmp;
				list[tmp]++;
			}
		}
		vector<PP> v;
		map<string, int>::iterator it = list.begin();
		for (; it!=list.end(); it++) {
			v.push_back(PP(it->second, it->first));
		}
		sort(v.begin(), v.end(), cmp);
		
		vector<PP>::iterator it2 = v.begin();
	
		char c; cin>>c;
		bool first=true;
	
		int num=0;
		for(;it2!=v.end(); it2++) {
			if (num>=5) break;
			if (it2->second[0]==c) {
				if (num>0) cout << " ";
				cout << it2->second;
				num++;
			}
		}
		if (num==0) cout << "NA";
		cout << endl;
	}
}

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

using namespace std;

int main() {
	string o, e;
	cin >> o >> e;
	int len = o.size() + e.size();
	int j=0, k=0;
	for (int i = 0; i < len; i++) {
		if (i % 2 == 0) {
			cout << o[j];
			j++;
		}else{
			cout << e[k];
			k++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n,m,a,b,c,d,x,y,z;
  string s,t;
  //

  // ここから
  IN2(a,b);
  OUT((a+b)%24);
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

solve :: [String] -> String
solve (n:ls) =
    let (l,r) = foldl' duel (0,0) $ map words ls in
    show l ++ " " ++ show r
    where
    duel :: (Int,Int) -> [String] -> (Int,Int)
    duel (pl,pr) [cl,cr]
        | cl < cr = (pl, pr+3)
        | cl > cr = (pl+3, pr)
        | otherwise = (pl+1, pr+1)

main =
    putStrLn =<< solve . lines <$> getContents

Measured memory_bytes: 4032
import sys
input = lambda : sys.stdin.readline().strip()
a,b,c,k = map(int,input().split())
ans = 0
ans+=min(a,k)
k-=min(a,k)
k-=min(b,k)
ans-=min(c,k)
k-=min(c,k)
print(ans)

Measured memory_bytes: 9184
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	string s; int i, j;
	while (getline(cin, s)) {
		if (s == ".")break;
		bool f = true;
		int mark[100];
		int len = s.length();
		for (i = 0; i < len; i++) {
			if (s[i] == '(') {
				mark[i] = 1;
			}
			else if (s[i] == '[') {
				mark[i] = 2;
			}
			else if (s[i] == ')') {
				mark[i] = -1;
			}
			else if (s[i] == ']') {
				mark[i] = -2;
			}
			else mark[i] = 0;
		}
		for (i = 0; i < len; i++) {
			if (mark[i] < 0) {
				for (j = i - 1; j >= 0; j--) {
					if (mark[i] + mark[j] == 0) {
						mark[i] = mark[j] = 0; break;
					}
					else if (mark[j] != 0) {
						f = false; break;
					}
				}
				if (j == -1)f = false;
			}
		}
		for (i = 0; i < len; i++) {
			if (mark[i] != 0)f = false;
		}
		if (f)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}


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

using namespace std;

int ac = 0, wa = 0, tle = 0, re = 0;
string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        if (s == "AC") ++ac;
        else if (s == "WA") ++wa;
        else if (s == "TLE") ++tle;
        else if (s == "RE") ++re;
    }
    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main(){
  int n, x, min=1000;
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> x;
	int j=0;
    while(x%2==0){
      x/=2;
      ++j;
    }
    
    if(min>=j){
      min=j;
    }
    if(min==0) break;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <bitset>
using namespace std;

int main() {
    int k, s, z, c=0;
    cin>>k>>s;
    for (int x=0; x<=k; ++x) {
        if (x>s) break;
        for (int y=0; y<=k; ++y) {
            if (y>s) break;
            z=s-x-y;
            if (z>=0 && z<=k) ++c;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int n,a,b;
int main(){
  cin>>n>>a>>b;
  if (a>b) swap(a,b);
  if ((b-a)&1) puts("Borys");
  else puts("Alice");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX 1000000001
const llong mod = 1000000000 + 7;

int main()
{
  llong X;
  scanf("%lld", &X);
  int min = -120, max = 120;
  int a = 0, b = 0;
  for (llong i = min; i < max; i++)
  {
    int flag = 0;
    for (llong j = min; j < i; j++)
    {
      if (i * i * i * i * i - j * j * j * j * j == X)
      {
        flag = 1;
        a = i;
        b = j;
        break;
      }
    }
    if (flag)
    {
      break;
    }
  }
  printf("%d %d", a, b);

  return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n; cin >> n;
  int a[n];
  for(int i= 0;i < n;i++) cin >> a[i];
  int dp[n];
  memset(dp,0,sizeof(dp));
  dp[1] = abs(a[1]-a[0]);
  for(int i = 2; i < n;i++){
	dp[i] = min( dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i-2]-a[i]));
  }
  cout << dp[n-1] << endl;
}
                                                      

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

int main(){
  int i, j, minj, n, temp, count = 0, flag = 0, *array;
  
  scanf("%d",&n);
  
  array = (int *)malloc(n * sizeof(int));
  
  for(i = 0; i < n; i++){
    scanf("%d",&array[i]);
  }
  
  for(i = 0; i < n  - 1; i++){
    minj = i;
    for(j = i + 1; j < n; j++){
      if(array[minj] > array[j]){
	minj = j;
	flag = 1; 
      }
    }
    if(flag == 1){
      temp = array[i];
      array[i] = array[minj];
      array[minj] = temp;
      count++;
    }
    flag = 0;
  }
  
  for(i = 0; i < n - 1; i++){
    printf("%d ",array[i]);
  }
  printf("%d\n",array[n - 1]);
  
  printf("%d\n",count);
  
  return 0;
}


Measured memory_bytes: 2100
///created: 12/Jun/2019 18:54:53

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
#define db(x) cerr << "debug: " << #x << " = " << x << '\n';
template<class __Ty> bool minimize(__Ty& a, __Ty b) {
	if (a > b) { a = b; return true; }
	return false;
}
template<class __Ty> bool maximize(__Ty& a, __Ty b) {
	if (a < b) { a = b; return true; }
	return false;
}

int n, dp[76] = {0}, cnt[101] = {0}, ip[101];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 2; i <= 100; ++i)
		ip[i] = 1;
	for (int i = 2; i * i <= 100; ++i)
		if (ip[i])
			for (int j = i * i; j <= 100; j += i)
				ip[j] = 0;
	for (int i = 2; i <= n; ++i)
		if (ip[i])
			for (int j = i; j <= n; j *= i)
				cnt[i] += n / j;
	dp[1] = 1;
	for (int i = 2; i <= n; ++i)
		if (ip[i])
			for (int j = 75; j >= 1; --j)
				for (int k = 1; k <= cnt[i]; ++k)
					if (j * (k + 1) <= 75)
						dp[j * (k + 1)] += dp[j];
	cout << dp[75];				
	return 0;
}


Measured memory_bytes: 256
s=input()
op=["+","-"]
tolal=0
for i in op:
    for j in op:
        for k in op:
                total=eval("{}{}{}{}{}{}{}".format(s[0],i,s[1],j,s[2],k,s[3]))
                if total ==7:
                    print("{}{}{}{}{}{}{}=7".format(s[0],i,s[1],j,s[2],k,s[3]))
                    exit()

Measured memory_bytes: 3064
from sys import setrecursionlimit

setrecursionlimit(10**9+7)

n,m= map(int,input().split())

root = [-1] * n

def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x,y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = r(x)
    return -root[x]

for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x,y)

max_size = 0
for i in range(n):
    max_size = max(max_size,size(i))

print(max_size)

Measured memory_bytes: 35780
var
	ch:string;
	n,i:longint;
	ans,s,f:real;
begin
	readln(n);
	ans:=0;
	for i:=1 to n do
	begin
		read(s); readln(ch);
		if pos('JPY',ch)<>0 then f:=1
		else f:=380000;
		ans:=ans+s*f;
	end;
	writeln(ans:0:7);
end.

Measured memory_bytes: 256
function main(input) {
  const s = input[0];
  const t = input[1];

  if(((s.length+1)===(t.length)) && (t.substr(0,s.length)===s)){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 29616
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int b[100010];
int dp[100010] = {0};
signed main(){

    int n,m;
    
    cin >> n >> m;
    rep(i,m){
        int a;
        cin >> a;
        b[a] = 1;
    }

    dp[0] = 1;
    for(int i = 0;i < n;i++){
        if(i+1 <= n && b[i+1] == 0)dp[i+1] = (dp[i+1]+dp[i])%MOD;
        if(i+2 <= n && b[i+2] == 0)dp[i+2] = (dp[i+2]+dp[i])%MOD;
    }
    cout << dp[n] << endl;
    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc129.contest.atcoder.jp/tasks/abc129_a

Measured memory_bytes: 1792