akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	
	int ans = 0;
	inc1(i, n) { if(SI(to_string(i)) % 2 != 0) { ans++; } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main () {
  LL X, Y;
  cin >> X >> Y;
  LL m = 1e9 + 7;
  if ((X + Y) % 3) {
    cout << 0 << endl;
    return 0;
  }
  LL N = (X + Y) / 3;
  X -= N;
  Y -= N;
  if (X < 0 || Y < 0) {
    cout << 0 << endl;
    return 0;
  }
  //cout << X << ' ' << Y << endl;
  LL kj = 1;
  if (X > Y) swap(X, Y);
  for (LL i = 1ll; i <= X; i ++) {
    kj *= i;
    kj %= m;
  }
  LL m_ = m;
  m_ -= 2ll;
  LL k = 2ll;
  LL a = 1ll;
  while (m_) {
    if (m_ % k) a *= kj;
    kj = kj * kj;
    kj %= m;
    a %= m;
    m_ /= k;
    //cout << kj << endl;
    if (a == 0) {
      cout << m_ << ' ' << kj << ' ' << 'B' << endl;
      break;
    }
  }
  if (a == 0) cout << 'n' << endl;
  for (LL i = X + Y; i > Y; i --) {
    a *= i;
    a %= m;
  }
  cout << a << endl;
}



Measured memory_bytes: 256
//Himanshu Manwani
//topological sort concept ..
//G-longest path ..
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
struct graph
{
    vi v;
};
graph G[MAX_];
int ind[MAX_];
bool vis[MAX_];
int dis[MAX_];
void dfs(int start)
{
    vis[start] =1 ;
   // cout<<start<<"     " << dis[start] << "\n";
    for(int i= 0;i<G[start].v.size();i++)
    {
        int t = G[start].v[i];
        dis[t] = max(dis[t],dis[start] + 1);
        ind[t] -- ;
        if(ind[t] == 0)
        {
            dfs(t);
        }
    }

}

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;   cin>>n>>m;
    f(m)
    {
        int x,y;
        cin>>x>>y;
        G[x].v.pb(y);
        ind[y] ++ ;
    }
    memset(vis,false,sizeof(vis));
    for(int i =1;i<=n;i++)
    {
        if(vis[i] == false && ind[i] == 0)
        {
            dfs(i);
        }
    }
    cout << *max_element(dis,dis+n+1);

    
    return 0;
 }

Measured memory_bytes: 11264
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    if not 1 in a:
        print(-1)
        exit()
    else:
        res = 1
        for i in range(n):
            if a[i] == res:
                res += 1
        print(n-res+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 25244
//============================================================================
// Name        : InsertionSort.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

void InsertionSort(vector<int> A,int N)
{
	int v;

	for(size_t i = 0; i < A.size(); ++i){
		if(i == A.size()-1){
			cout << A[i] << endl;
			break;
		}
		cout << A[i] << " ";
	}

	for(int i = 1; i < N ; i++){
		v = A[i];
		int j = i - 1;
		while(j >= 0  && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		for(size_t i = 0; i < A.size(); ++i){
			if(i == A.size()-1){
				cout << A[i] << endl;
				break;
			}
			cout << A[i] << " ";
		}
	}
}

int main() {
	int n;
	vector<int> v;

	cin >> n;
	for(int i = 0; i < n; i++){
		int val; cin >> val;
		v.push_back(val);
	}

	InsertionSort(v,n);

	return 0;
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int n;
long double p[3000];
long double PD[3000][3000];
bool visited[3000][3000] = {false};

long double pd(int i, int heads){
	if(i < 0){
		return heads > n/2 ? 1 : 0;
	}
	long double &ans = PD[i][heads];
	if(visited[i][heads]){
		return ans;
	}
	ans = pd(i-1, heads+1)*p[i] + pd(i-1, heads)*(1-p[i]);
	visited[i][heads] = true;
	return ans;
}

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%Lf", p + i);
	}
	printf("%.10Lf\n", pd(n-1, 0));
	return 0;
}

Measured memory_bytes: 148096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  for(int i = 0, temp; i < n; ++i){
    cin >> temp;
    mp[temp]++;
  }
  vector<long long> v;
  for(auto m: mp){
    if(m.second >= 4) v.push_back(m.first);
    if(m.second >= 2) v.push_back(m.first);
  }
  if(v.size() < 2) cout << 0 << endl;
  else {
    sort(v.rbegin(), v.rend());
    cout << v[0] * v[1] << endl;
  }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
long long dp[12][12];
long long wei[12];
int flag;
void dfs(int ci,int k,int pl,int shangci)
{
    if(flag)return ;
    if(ci==0){flag=1;return ;}
    int qs=0;
    if(pl){qs=1;
    for(int i=qs;i<=9;i++)
    {
        if(k>dp[ci][i])k-=dp[ci][i];
        else
        {
            printf("%d",i);
            dfs(ci-1,k,0,i);
            if(flag)return ;
        }
    }
    }
    else
    {
        for(int i=shangci-1;i<=shangci+1;i++)
        {
            if(i>=0&&i<=9)
            {
                if(k>dp[ci][i])k-=dp[ci][i];
               else
                {
                 printf("%d",i);
                 dfs(ci-1,k,0,i);
                  if(flag)return ;
                 }
            }
        }
    }
}
int main()
{
   //freopen("t5.in","r",stdin);
   //freopen("t5.out","w",stdout);
   //ios::sync_with_stdio(false);
   //cin.tie(0); cout.tie(0);
    int i,j,n,m,k;
    cin>>k;
    memset(dp,0,sizeof(dp));
    memset(wei,0,sizeof(wei));
    for(i=0;i<=9;i++)dp[1][i]=1;
    wei[1]=9;
    flag=0;
    for(i=2;i<=10;i++)
    {
        for(j=0;j<=9;j++)
        {
            if(j-1>=0)dp[i][j]+=dp[i-1][j-1];
            dp[i][j]+=dp[i-1][j];
            if(j+1<10)dp[i][j]+=dp[i-1][j+1];
            if(j!=0)wei[i]+=dp[i][j];
        }

    }
    for(i=2;i<=10;i++)wei[i]+=wei[i-1];
    for(i=0;i<=10;i++)
    {
        if(k>wei[i]);
        else
        {
            dfs(i,k-wei[i-1],1,0);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define int32 int32_t
#define PI 2 * acos(0)

using namespace std;



int32 main() {
    ios_base::sync_with_stdio(false);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double frH = h*30 + m/60 * 30;
    double frM = m * 6;
    double al = frH - frM;
    double res = sqrt(a*a + b*b - 2*a*b*cos(al/180 * PI));
    cout.precision(20);
    cout <<res;
    return 0;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 1000010;
vector <int>vis1(MAXNUM),vis2(MAXNUM);
void sieve() {
	for(ll i=1;i<MAXNUM;i++) 
    if( vis2[i]==1 &&  vis1[i]==0) {
		for(ll j=2*i;j<MAXNUM;j+=i)
         vis1[j]=1;
	}
}
//************************************************************************

void solve()
{
    ll n;
    cin >> n;
    map<int,int> m;
    for(int  i=0;i<n;i++)
    {
        ll x;
        cin >> x;
        if(m.find(x)==m.end())
        m[x]=1;
        else
        m[x]++;
        vis2[x]=1;
    } 
    sieve();
    ll ans=0;
    // for(int i=0;i<30;i++)
    // cout << vis2[i] << " ";
    // cout << endl;
    // for(int i=0;i<30;i++)
    // cout << vis1[i] << " ";
    // cout << endl;
    for(int i=0;i<MAXNUM;i++)
    {
        if(vis2[i]==1  && vis1[i]==0 && m[i]==1)
        ans++;
    }
    cout <<ans << endl;
}   


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 20220
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
string S;
ll X,K,D;
ll L[100];
ll ans;
ll M = 1000000000;
 
 
int main() {
    cin >> X>>K>>D;
    X = abs(X);
        if(X/K>=D){
            cout << X-K*D << endl;
        }else{
            ll a = X%D;
            ll c = X/D;
            if((K-c)&1){
                cout << abs(D-a) << endl;
            }else{
                cout <<a<< endl;
            }
            
        }
}




Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int freq[27];
int main()
{
int win;
string alice,bob,charlie;
cin>>alice>>bob>>charlie;
reverse(alice.begin(),alice.end());
reverse(bob.begin(),bob.end());
reverse(charlie.begin(),charlie.end());
char c=alice.back();
alice.pop_back();
while(true){
    if(c=='a'){
        if(alice.size()>0){
            c=alice.back();
            alice.pop_back();
        }
        else{
            win=1;
            break;
        }
    }
    else if(c=='b'){
        if(bob.size()>0){
            c=bob.back();
            bob.pop_back();
        }
        else{
            win=2;
            break;
        }
    }
    else{
        if(charlie.size()>0){
            c=charlie.back();
            charlie.pop_back();
        }
        else{
            win=3;
            break;
        }
    }
}
if(win==1){
    printf("A\n");
}
else if(win==2){
    printf("B\n");
}
else{
    printf("C\n");
}



    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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 (b<a) { a=b; return true; } return false; }

#define FIND(a,b) find(all(a),b)!=a.end()

int main(){
	ll a,b,k;cin>>a>>b>>k;
	if(k>=a+b){cout<<0<<" "<<0<<endl;return 0;}
	else if(a<=k&&k<a+b){cout<<0<<" "<<b-k+a<<endl;return 0;}
	else {cout<<a-k<<" "<<b<<endl;return 0;}
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;

int bfs(bool x[],int to){
    static queue<int> q;
    for(int i=1;i<10;i++){
        if(x[i])q.push(i);
    }
    while(!q.empty()){
       if(q.front()<to){
        for(int j=0;j<10;j++){
            if(x[j])q.push(q.front()*10+j);
           }
            q.pop();
        }
        else {
            return q.front();
        }
    }
}
void solve(bool x[],int to){
    int ans=bfs(x,to);
    cout<<ans<<endl;
}
int main(){
    int n,k;
    cin>>n>>k;
    bool d[10];
    rep(i,10)d[i]=true;
    rep(i,k){int tmp;cin>>tmp;d[tmp]=false;}
    solve(d,n);
    return 0;
}




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

int H, W;
vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];

int main() {
    // 入力
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];

    // 前処理
    for (int i = 0; i < H; ++i) {
        int cur = 0;
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Left[i][j] = cur;
        }
    }
    for (int i = 0; i < H; ++i) {
        int cur = 0;
        for (int j = W-1; j >= 0; --j) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Right[i][j] = cur;
        }
    }
    for (int j = 0; j < W; ++j) {
        int cur = 0;
        for (int i = 0; i < H; ++i) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Up[i][j] = cur;
        }
    }
    for (int j = 0; j < W; ++j) {
        int cur = 0;
        for (int i = H-1; i >= 0; --i) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Down[i][j] = cur;
        }
    }

    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') continue;
            res = max(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 72448
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()

cnt = 0
ans = 0
for i,si in enumerate(s):
    if si == "W":
        cnt += 1
        ans += (i+1-cnt)
        
print(ans)

Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[MAXN][3], a[MAXN], b[MAXN], c[MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[1][1] = a[1], dp[1][2] = b[1], dp[1][3] = c[1];
    for (int i = 2; i <= n; i++) {
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + a[i];
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + b[i];
        dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + c[i];
    }
    cout << max({dp[n][1], dp[n][2], dp[n][3]}) << "\n";
}


Measured memory_bytes: 35072
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string word;
    cin >> word;
    if (word[word.size() - 1] == 's') {
        cout<<word + "es"<<"\n";
    }
    else if (word[word.size() - 1] != 's') {
        cout << word + "s" << "\n";
    }

}

Measured memory_bytes: 3104
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int nums[] = new int[total];
        sc.nextLine();
        for (int a=0; a<total; a++) {
            nums[a] = sc.nextInt();
        }
        int result = 0;
        int count = nums.length;
        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    if(nums[i] + nums[j] > nums[k]
                        && nums[k] + nums[i] > nums[j]
                        && nums[j] + nums[k] > nums[i]
                        && nums[i] != nums[j]
                        && nums[j] != nums[k]
                        && nums[k] != nums[i]) {
                            result++;
                    }
                }
            }
        }
        System.out.println(result);
        sc.close();
    }
}

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

int main(){
    int n,m,X,Y;cin>>n>>m>>X>>Y;vector<int> x(n),y(m);
    for(int i=0;i<n;i++) cin>>x.at(i);
    for(int i=0;i<m;i++) cin>>y.at(i);
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(Y-x.at(n-1)>0&&y.at(0)-X>0&&y.at(0)-x.at(n-1)>0) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

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

namespace AtCoder0822
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long ans = 0;

            for (var i=0; i<A.Length-1; i++)
            {
                if(A[i] <= A[i + 1]) { continue; }

                ans += (A[i] - A[i+1]);

                A[i + 1] = A[i]; 
            }

       Console.WriteLine(ans);
        }
        }
    }


Measured memory_bytes: 47328
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int dp[10+1][10000];
int memo[10];

void rec(int size, int depth, int sum) {
	if (size + 1 == depth) {
		dp[size][sum]++;
	} else {
		for (int i = 0; i <= 9; i++) {
			if (memo[i] == 0) {
				memo[i] = 1;
				rec(size, depth + 1, sum + i * depth);
				memo[i] = 0;
			}
		}
	}
}

int main() {
	memset(dp, 0, sizeof(dp));

	for (int i = 1; i <= 10; i++) {
		memset(memo, 0, sizeof(memo));
		rec(i, 1, 0);
	}

	int n, s;
	while (cin >> n >> s) {
		cout << dp[n][s] << endl;
	}
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;
// 最大公約数を求める
template <class T>
T gcd(T a, T b) {
    if (b > a) T tmp = a, a = b, b = tmp;
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int main() {
    int K;
    cin >> K;
    lint ans = 0;
    for (int a = 1; a < K + 1; a++) {
        for (int b = 1; b < K + 1; b++) {
            for (int c = 1; c < K + 1; c++) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  int s=0;
  int n=0;
  int i=1;
    while(n<N){
      if(a[n]==i){
        i++;
        n++;
        s++;
      }else n++;
    }
  
  if(s==0)cout<<-1<<endl;
  else cout<<N-s<<endl;
}
    

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

using namespace std;

#define MAXN 1010

char s[MAXN][MAXN];

int n, m, k, ans;

int a[MAXN][MAXN], gap[15], pos[15];

int count(int x) {
	memset(pos, 0, sizeof(pos));
	int ans = 0, now = 1;
	for(int i = 1; i <= n; ++i) {
		gap[i] = now;
		if ((x >> (i - 1)) & 1) ++now;
	}
	for(int i = 1; i <= m; ++i) {
		for(int j = 1; j <=n; ++j) pos[gap[j]] += a[j][i];
		bool flag = 1;
		for(int j = 1; j <= now; ++j)
			if (pos[j] > k) {
				flag = 0;
				break;
			}
		if (!flag) {
			++ans;
			memset(pos, 0, sizeof(pos));
			for(int j = 1; j <= n; ++j) pos[gap[j]] += a[j][i];
			for(int j = 1; j <=now; ++j) if (pos[j]>k) return n + m;
		}
	}
	return ans;
}
int main(){
	scanf("%d%d%d", &n, &m, &k);
	ans = n + m;
	for(int i = 1; i <= n; ++i) {
		scanf("%s", s[i] + 1);
		for(int j = 1; j <= m; ++j) {
			a[i][j] = s[i][j] - '0';
		}
	}
	for(int i = 0; i <= (1 << (n - 1)) - 1; ++i) {
		int num = 0;
		for(int j = 0; j < n - 1; ++j) {
			if ((i >> j) & 1) ++num;
		}
		ans = min(ans, count(i) + num);
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

int main(){
	int m;
	cin>>m;
	if(m%2){
		cout<<"NA"<<endl;
		return 0;
	}
	m/=2;
	int a[50],a1[50],b[50],b1[50];
	for(int i=0;i<m;++i){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<m;++i){
		cin>>a1[i]>>b1[i];
	}
	int ans1=a[0]+a1[0],ans2=b[0]+b1[0];
	for(int i=1;i<m;++i){
		if(a[i]+a1[i]!=ans1){
			cout<<"NA"<<endl;
			return 0;
		}
		if(b[i]+b1[i]!=ans2){
			cout<<"NA"<<endl;
			return 0;
		}
	}
	printf("%f %f",ans1/2.0,ans2/2.0);
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{ 	
    ll n;
    cin>>n;
    ll a[n],mi=LINF,m;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    rep(i,n){
        if(abs(a[n-1]-a[i]*2)<mi)mi=abs(a[n-1]-a[i]*2),m=a[i];
    }
    cout<<a[n-1]<<" "<<m<<endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		System.out.println((n-1) * (m-1));
	}
	static class Scanner{
		StringTokenizer st;BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public String next() throws IOException 
		{while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public boolean ready() throws IOException {return br.ready();}
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,zx,xc,pas,R,G,B;
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    cin>>s;
    for(i=0; i<a; i++){
        if(s[i]=='R') R++;
        if(s[i]=='G') G++;
        if(s[i]=='B') B++;
    }
    pas=R*G*B;
    for(i=0; i<a; i++){
        for(j=i+1; j<a; j++){
            zx=j+j-i;
            if(zx>=a) continue;
            if(s[i]!=s[zx]&&s[i]!=s[j]&&s[j]!=s[zx]) pas--;
        }
    }
    cout<<pas;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;


int main(){
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,M){
        cin >> B[i];
    }
    rep(i,N-M+1){
        rep(j,N-M+1){
            bool flag = true;
            rep(x,M){
                rep(y,M){
                    if (A[i+x][j+y]!=B[x][y]){
                        flag = false;
                    }
                }
            }
            if (flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,M;
  cin>>N>>M;
  VI A(M);
  rep(i,M) cin>>A[i];
  rep(i,M) N-=A[i];
  if(N>=0) cout<<N<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	static class TaskF {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int H = in.nextInt();
			int W = in.nextInt();
			int d = in.nextInt();
			String mode = "RYGB";
			int[][] ans = new int[H][W];
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					int v = (i + j) / d % 2 + (i + W - 1 - j) / d % 2 * 2;
					System.out.print(mode.charAt(v % 4) + (j == W - 1 ? "\n" : ""));
					ans[i][j] = v % 4;
				}
			}

		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskF solver = new TaskF();
		solver.solve(1, in, out);
		out.close();
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}

}

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

int main() {
    int a, b, c, d, e, k;  cin >> a >> b >> c >> d >> e >> k;
    if (abs(a-e) <= k)  cout << "Yay!" << endl;
    else  cout << ":(" << endl;
}

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

int main(){
    string S;
    cin >> S;
    int res = 0;
    for(int i=0;i<S.size();i++){
        if(S.at(i)=='0') res += 0;
        if(S.at(i)=='1') res += 1;
        if(S.at(i)=='2') res += 2;
        if(S.at(i)=='3') res += 3;
        if(S.at(i)=='4') res += 4;
        if(S.at(i)=='5') res += 5;
        if(S.at(i)=='6') res += 6;
        if(S.at(i)=='7') res += 7;
        if(S.at(i)=='8') res += 8;
        if(S.at(i)=='9') res += 9;
    }
    if(res%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();

        int d = a / b;
        int r = a % b;
        double f = (double) a  / (double) b;

        System.out.printf("%d %d %f", d, r, f);
    }
}

Measured memory_bytes: 26492
#include<stdio.h>
main(){
  int n,i,j,l;
  double x1,x2,y1,y2,ans[2];
  scanf("%d",&n);
  for(l=0;l<n;l++){
    for(i=0;i<2;i++){
      scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
      ans[i]=(y2-y1)/(x2-x1);
    }
    if(ans[0]==ans[1]){
      puts("YES");
    }
    else{
      puts("NO");
    }
  }
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.size();
  vector<bitset<26>> g1(26);
  vector<bitset<26>> g2(26);
  for (int i = 0; i < n; i++) {
    int a, b;
    a = s[i] - 'a';
    b = t[i] - 'a';
    g1[a].set(b);
    g2[b].set(a);
  }
  string ans = "Yes";
  for (int i = 0; i < 26; i++) {
    if (g1[i].count() >= 2 || g2[i].count() >= 2) {
      ans = "No";
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll h, n;
  cin >> h >> n;
  ll s = 0;
  REP(i, n) {
    ll a;
    cin >> a;
    s += a;
  }
  cout << (s >= h ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
int main()
{
    fastio();
    int n;
    string s;
    cin>>n>>s;
    int c=0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    if h == eh and w == ew:
        dst[h][w] = d
        break

    if dst[h][w] >= 0 or S[h][w] == '#': continue
    if dst[h][w] == -1 or d < dst[h][w]: dst[h][w] = d

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        dq.appendleft((nh, nw, d))

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        dq.append((nh, nw, d+1))

print(dst[eh][ew])


Measured memory_bytes: 165592
#include<stdio.h>
#include<math.h>
#define Number 100000
int main()
{
	int n;
	int c=0;
	int BB[Number];
	int i ,j ,z;
	int temp=0;


	scanf("%d",&n);

	for(i=0;i<=n-1;i++)
	{
		scanf("%d",&BB[i]);
	}

	for(i=0;i<=n-1;i++)
	{
		for(j=n-1;j>=i+1;--j)
		{
			if (BB[j-1] > BB[j])
			{
				temp=BB[j-1];
				BB[j-1]=BB[j];
				BB[j]=temp;
				c++;
			}
		}
	}

		for(z=0;z<n-1;z++)
	{
		printf("%d ",BB[z]);
	}

	printf("%d\n",BB[n-1]);
	printf("%d\n",c);

	}


Measured memory_bytes: 1968
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

int readInt(){
  return readln.chomp.to!int;
}

int[] readInts(){
  return readln.chomp.split.to!(int[]);
}

void main(){
  int[] balls = readInts();
  int ret;

  for(int i; i <= balls[3] / balls[0]; i++){
    for(int j; j <= balls[3] / balls[1]; j++){
      int req = balls[3] - (balls[0] * i + balls[1] * j);
      if(req >= 0 && req % balls[2] == 0) ret++;
    }
  }

  writeln(ret);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }


int main(){
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    rep(i,n){
        cin >> v[i];
        sum += v[i];
    }
    // sort(ALL(v));
    ll ss = 0;
    ll ans = sum;
    rep(i,n){
        ss += v[i];
        // cout << ss << " " << abs((sum-ss)-ss) << endl;;
        ans = min(ans,abs((sum-ss)-ss));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define MOD 1000000007

using namespace std;

ll lesse[3000+5][3000+5];
ll more[3000+5][3000+5];
ll pref[3000+5][3000+5];


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   string s;
   cin>>s;
   
   if(s.length() == 1)
   {
       cout<<1;
       return 0;
   }
   
   memset(lesse,0,sizeof(lesse));
   memset(more,0,sizeof(more));
   memset(pref,0,sizeof(pref));
   
   for(ll i=1;i<=n;i++)
   {
       lesse[1][i] = (1 == i);
       more[1][i] = lesse[1][i];
   }
   
   
   for(ll i=1;i<=n;i++)
        pref[1][i] = 1;
   
   for(ll i=2;i<=n;i++)
   {
       if(s[i-2] == '>')
       {
           for(ll j=1;j<=i;j++)
           {
               lesse[i][j]+=more[i-1][j];
               lesse[i][j]%=MOD;
           }
           
           for(ll j=i;j>0;j--)
           {
               more[i][j]=lesse[i][j]+more[i][j+1];
               more[i][j]%=MOD;
           }
           
           for(ll j=1;j<=i;j++)
           {
               lesse[i][j]+=lesse[i][j-1];
               lesse[i][j]%=MOD;
           }
       }
       
       else
       {
            for(ll j=1;j<=i;j++)
           {
               lesse[i][j]+=lesse[i-1][j-1];
               lesse[i][j]%=MOD;
           }
           
           for(ll j=i;j>0;j--)
           {
               more[i][j]=lesse[i][j]+more[i][j+1];
               more[i][j]%=MOD;
           }
           
           for(ll j=1;j<=i;j++)
           {
               lesse[i][j]+=lesse[i][j-1];
               lesse[i][j]%=MOD;
           }     
       }
   }
   
   cout<<more[n][1];
   
   
   return 0;
}

Measured memory_bytes: 211968
#include<bits/stdc++.h>
using namespace std;
long n,u,v,root;
long check[100005],a[100005];
vector<long> adj[100005];
bool dfs(int u){
	check[u]=1;
	if(adj[u].size()==1){
		return 1;
	}
	long sum=0, mx=-1;
	for(int v: adj[u]){
		if(check[v]==0){
			if(dfs(v)==0){
				return 0;
			}
			sum=sum+a[v];
			mx=max(mx,a[v]);
		}
	}
	if(a[u]<=sum && sum<=2*a[u] && mx<=a[u]){
		a[u]=2*a[u]-sum;
		if(u==root){
			if(a[u]==0){
				return 1;
			}else{
				return 0;
			}
		}else{
			return 1;
		}
	}else{
		return 0;
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	root=1;
	for(int i=1;i<=n;i++){
		if(adj[i].size() > adj[root].size()){
			root=i;
		}
	}
	if(adj[root].size()==1){
		if(a[1]==a[2]){
			cout<<"YES";
		}else{
			cout<<"NO";
		}
	}else{
		if(dfs(root)==1){
			cout<<"YES";
		}else{
			cout<<"NO";
		}
	}
}

Measured memory_bytes: 12672
#include <stdio.h>
int n,A[50];
int solve(int i, int m){
  int res=0;
  if(m==0) {
    return 1;
  }
  if(i>=n) {
    return 0;
  }
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,M,i;
  scanf("%d" ,&n);
  for(i=0 ; i<n ; i++){
    scanf("%d" ,&A[i]);
  }
  scanf("%d" ,&q);
  for(i=0 ; i<q ; i++){
    scanf("%d" ,&M);
    if(solve(0,M)){
      printf("yes\n");
    }
    else {
      printf("no\n");
    }
  }

  return 0;
}

  



Measured memory_bytes: 2104
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>

using namespace std;

struct Node {
    long long int key;
    Node *prev, *next;
};

Node* nil;

Node* search(long long int x){
    Node* pNode = nil->next;

    while(pNode != nil && pNode->key != x){
        pNode = pNode->next;
    }

    return pNode;   
}
void init(){
    nil = new Node;
    nil->next = nil;
    nil->prev = nil; // 自分自身を指す
}
void insert(long long int x){
    Node *pNode = new Node;
    pNode->key = x;

    // 番兵の直後にノードを追加
    pNode->next = nil->next;
    pNode->prev = nil;
    nil->next->prev = pNode;
    nil->next = pNode;
}
void del(Node* t){
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    delete t;
}
void delFirst(){
    del(nil->next);
}
void delLast(){
    del(nil->prev);
}
void delKey(long long int key){
    del(search(key));
}



int main(){
    long long int n;
    cin >> n;
    string com;
    int key;
    init();
    long long int sum = 0;
    for(int i=0;i<n;i++){
        cin >> com;

        if(com == "insert") {
            cin >> key;
            insert(key);
            sum++;
        }
        if(com == "delete") {
            cin >> key;
            delKey(key);
            sum--;
        }
        if(com == "deleteFirst") {
            delFirst();
            sum--;
        }            
        if(com == "deleteLast") {
            delLast();
            sum--;
        }
    }

    Node* pNode = nil->next;
    int cnt = 0;
    while(true){
        if(pNode == nil) break;
        if(cnt++ > 0) cout << " ";
        cout << pNode->key;
        pNode = pNode->next;
    }
    cout << endl;
}


Measured memory_bytes: 34392
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main()
{
  deque<char> d;
  string s;
  cin >> s;
  rep(i,s.size()) {
    d.push_back(s[i]);
  }
  int q;
  cin >> q;
  bool isRev = false;
  rep(i,q) {
    int t;
    cin >> t;
    if (t == 1) {
      isRev = isRev ? false : true;
    } else {
      int f;
      cin >> f;
      char c;
      cin >> c;
      if (f == 1) {
        if (!isRev) d.push_front(c);
        else d.push_back(c);
      } else {
        if (!isRev) d.push_back(c);
        else d.push_front(c);
      }
    }
  }
  if (isRev) reverse(d.begin(), d.end());
  rep(i,d.size()) {
    cout << d[i];
  }
  cout << endl;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int m = scanner.nextInt();
			int sum = 0;
			while (m-- > 0) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				sum += b - a;
			}
			if (sum >= n)
				System.out.println("OK");
			else
				System.out.println(n - sum);
		}
	}
}

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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  int a=in(),b=in(),c=in();
  cout << a*b/2 << endl; 
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
   int P,Q,R;
   cin>>P>>Q>>R;

   if(R+P>=P+Q){
    if(P+Q>=Q+R){
        cout<<Q+R<<endl;
    }else{
        cout<<P+Q<<endl;
    }
   }else{
    if(R+P>=Q+R){
        cout<<Q+R<<endl;
    }else{
        cout<<R+P<<endl;
    }
   }

       
   
    return 0;
}

Measured memory_bytes: 256
let () =
  let n = read_int () in
  let rec read_vec acc = function
      0 -> acc
    | i -> let f = Scanf.scanf " %f" (fun f -> f ) in
           read_vec (f::acc) (i-1)
  in
  let x = read_vec [] n in
  let y = read_vec [] n in
  let x_y = List.map2 (fun x y -> abs_float (x -. y)) x y in
  let d p = List.fold_left (fun a b -> a +. b ** p ) 0. x_y ** (1. /. p) in
  let d_inf = List.fold_left max 0. x_y in
  Printf.printf "%f\n%f\n%f\n%f\n" (d 1.) (d 2.) (d 3.) d_inf
;;


Measured memory_bytes: 2540
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> A >> B;
	A--; B--;
	cout << 100 << " " << 100 << endl;
	ll fr = A / 50;
	for (int i = 0; i < 2*fr+1; i++) {
		ans++;
		if (i & 1) {
			for (int j = 0; j < 50; j++) {
				cout << '#' << '.';
			}
			cout << endl;
		}
		else {
			for (int j = 0; j < 50; j++) {
				cout << '#' << '#';
			}
			cout << endl;
		}
	}
	int ba = A % 50;
	if (ba != 0) {
		for (int i = 0; i < 50; i++) {
			if (i < ba)
				cout << '#' << '.';
			else cout << '.' << '.';
		}
		cout << endl;
		ans++;
	}
	for (int j = 0; j < 50; j++) {
		cout << '#' << '#';
	}
	cout << endl;
	ans++;
	for (int j = 0; j < 50; j++) {
		cout << '.' << '.';
	}
	cout << endl;
	ans++;

	fr = B / 50;
	for (int i = 0; i < 2*fr+1; i++) {
		ans++;
		if (i & 1) {
			for (int j = 0; j < 50; j++) {
				cout << '#' << '.';
			}
			cout << endl;
		}
		else {
			for (int j = 0; j < 50; j++) {
				cout << '.' << '.';
			}
			cout << endl;
		}
	}
	ba = B % 50;
	if (ba != 0) {
		for (int i = 0; i < 50; i++) {
			if (i < ba)
				cout << '#' << '.';
			else cout << '.' << '.';
		}
		cout << endl;
		ans++;
	}
	for (int i = 0; i < 100 - ans; i++) {
		for (int j = 0; j < 50; j++) {
			cout << '.' << '.';
		}
		cout << endl;
	}
}

Measured memory_bytes: 384