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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin>>n>>m;

    vector<int> h(n);
    vector<int> visited(n,false);
    vector<int> isgood(n,true);

    vector<vector<int>> adj(n);

    rep(i,n)cin>>h[i];

    rep(i,m){
        int a,b;cin>>a>>b; --a;--b;
        adj[a].eb(b);
        adj[b].eb(a);
    }


    rep(i,n){
        //cout<<i<<"s turn"<<endl;
        int idx = i;
        int cmx = h[i];

            for (int j = 0; j < adj[i].size(); j++){
                int nex=adj[i][j];

                //cout<<nex<<" is visited"<<endl;
                if(cmx <= h[nex]){isgood[i]=false;break;}
            }
    }
    

    rep(i,n){
        if(isgood[i]){
            ++ans;
        }
    }

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 9596
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto p = n % 2 == 0 ? 0.5 : ((n+1) / 2).to!double / n;

    writefln("%.10f", p);
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

B = [-1 for _ in range(N)]
ans = []

for i in range(N, 0, -1):
    tmp_sum = 0
    tmp_i = 2 * i
    while N >= tmp_i :
        tmp_sum += B[tmp_i - 1]
        tmp_i += i

    # print(i, tmp_sum)
    if A[i-1] == tmp_sum % 2:
        B[i-1] = 0
    else:
        ans.append(i)
        B[i-1] = 1

print(len(ans))
if len(ans):
    print(" ".join(map(str, ans[::-1])))

Measured memory_bytes: 113092
#!/usr/bin/env python3

def main():
    n = int(input())
    a = list(map(int, input().split()))
    negatives = sum((1 if x < 0 else 0) for x in a)
    if negatives % 2 == 0:
        print(sum(abs(x) for x in a))
    else:
        print(sum(abs(x) for x in a) - 2 * min(abs(x) for x in a))

if __name__ == "__main__":
    main()


Measured memory_bytes: 14332
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans=0;
	for(int i=l;i<=r;i++)
	{
		if(i%d==0) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
	
	while(1)
	{
		int w,h; cin >> w >> h;
		if(w == 0) return 0;
		int f[20][20]={};
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				cin >> f[i][j];
			}
		}
		ll dp[20][20]={};
		for(int i=1;i<=w;i++) if(f[1][i] != 1) dp[1][i] = 1LL;
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(!dp[i][j]) continue;
				if(f[i][j] == 0)
				{
					if(j != 1)
					{
						if(f[i+1][j-1] == 0 && i+1 <= h) dp[i+1][j-1] += dp[i][j];
					}
					if(f[i+1][j] != 1 && i+1 <= h) dp[i+1][j] += dp[i][j];
					if(j != w)
					{
						if(f[i+1][j+1] == 0 && i+1 <= h) dp[i+1][j+1] += dp[i][j];
					}
				}
				else if(f[i][j] == 2)
				{
					if(f[i+2][j] != 1 && i+2 <= h) dp[i+2][j] += dp[i][j];
				}
			}
		}
		ll res = 0;
		for(int i=1;i<=w;i++) if(f[h-1][i] == 2) res += dp[h-1][i];
		for(int i=1;i<=w;i++) res += dp[h][i];
		cout << res << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;
const double PI = acos(-1);

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    double a, b, h, m;
    cin >> a>> b >> h >> m;
    double x = (h*360/12+m/60*30)*PI/180;
    double y = m*360/60*PI/180;
    double z = max(x, y) - min(x, y);
    cout << fixed << setprecision(15);
    cout << sqrt(a*a+b*b-2*a*b*cos(z)) << '\n';
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define fst first
#define scd second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 100000
//---------------------

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << *ite << " ";return os;}

ll a,b,c,d;

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

ll lcm(ll a,ll b){
	return a*b/gcd(a,b);
}

ll getmultnum(ll divisor, ll maxnum){
	return maxnum/divisor;
}

ll getnottwomultnum(ll div1,ll div2, ll maxnum){
	return maxnum-getmultnum(div1,maxnum)-getmultnum(div2,maxnum)+getmultnum(lcm(div1,div2),maxnum);
}

int main(){
	cin>>a>>b>>c>>d;
	ll ret=getnottwomultnum(c,d,b)-getnottwomultnum(c,d,a);
	if((a%c!=0) && (a%d!=0)) ret++;
	cout<< ret <<endl;
	return 0;
}

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

#define lli long long int
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define pi pair<lli,lli>
void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
}

int main()
{
  fast();
 lli x;cin>>x;
  if(x>=30)cout<<"Yes\n";else cout<<"No\n";
 return 0; 
}

Measured memory_bytes: 3648
N=int(input())
h=list(map(int,input().split()))

DP=[100000]*N

DP[0]=0
DP[1]=abs(h[1]-h[0])

for i in range(2,N):
    DP[i]=min(DP[i-2]+abs(h[i]-h[i-2]),DP[i-1]+abs(h[i]-h[i-1]))

print(DP[N-1])

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        a[i] = (int)abs(s[i] - s[i + 1]);
    }
    n--;
    vector<int> cnt(3, 0);
    for (int x : a) {
        cnt[x] += 1;
    }
    int coeff = 1;
    if (cnt[1] == 0) {
        coeff *= 2;
        for (int& x : a) {
            x >>= 1;
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (((n - 1) & i) == i) {
            res ^= a[i];
        }
    }
    cout << (res & 1) * coeff << endl;
    return 0;
}

Measured memory_bytes: 5252
#include<iostream>
using namespace std;

int main() {
	int n, in, min=1e9 + 1, max=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> in;
		if (min > in)
			min = in;
		if (max < in)
			max = in;
	}
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
		
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H[] = new int[N];
		// []:配列　{2, 3 ,4}   { , , , , }
		for(int i=0;i<N;i++) {
			H[i]=sc.nextInt();
		}		
		sc.close();
		
		// 入力例　1 2 1 1 3　の時
		// H = {1, 2 ,1 ,1 3}
		boolean out = false;
		H[0]--;
		for(int i=0;i<N-1;i++) {
			
			if(H[i+1]<H[i]) {
				out = true;
			}
			
			if(H[i+1]-1>=H[i]) {
				H[i+1]--;
			}
		}
		
		if(out)System.out.println("No");
		else System.out.println("Yes");
		
//		for(int i=0;i<N;i++) {
//			System.out.print(H[i] + " ");
//		}
		
	}
	
}

Measured memory_bytes: 50536
#include <stdio.h>
#include <string.h>

int main(void) {
	char str[257];
	char ans[257];
	int number;
	int i, j;
	int a, b;
	int n;
	_Bool find;
	scanf("%d", &n);
	getchar();
	while (n--) {
		for (i = 0; i < 257; i++)
			str[i] = str[i] = '\0';
		gets(str);
		find = 0;
		a = 1;
		number = strlen(str);
		while (!find) {
			for (i = 0, b = 0; i < 26 && !find; i++, b++) {
				for (j = 0; j < number; j++) {
					if (str[j] == ' ')
						ans[j] = ' ';
					else
						ans[j] = (a * (str[j] - 'a') + b) % 26 + 'a';
				}
				ans[j] = '\0';
				for (j = 0; j < number-3; j++) {
					if (strncmp(&ans[j], "that", 4) == 0 || strncmp(&ans[j], "this", 4) == 0) {
						find = 1;
						break;
					}
				}
			}
			a++;
		}
		printf("%s\n", ans);
	}
	return 0;
}

Measured memory_bytes: 588
a[31];
main(w,n,x,y,z){
for(w=1;w<31;w++)a[w]=w;
scanf("%d%d",&w,&n);
for(;n--;z=a[x],a[x]=a[y],a[y]=z)scanf("%d,%d",&x,&y);
for(n=1;n<=w;n++)printf("%d\n",a[n]);
exit(0);}

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

long ans;
string S;

int main(void) {

    cin >> S;

    for (long i = 0; i < S.length(); i++) {
        for (long j = 1; j <= S.length() - i; j++) {
            string s = S.substr(i, j);
            bool f = true;
            for (auto e: s) {
                if (e != 'A' && e != 'T' && e != 'C' && e != 'G') {
                    f = false;
                    break;
                }
            }

            if (f) {
                ans = max(ans, j);
            }
        }
    }

    cout << ans << endl;

    return 0;

}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e6)+3;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;


int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1*60+m1, t2 = h2*60+m2;
    cout << max(t2-t1-k, 0) << endl;
    return 0;
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    p = list(map(int, input().split()))
    for i in range(100):
        if x-i not in p:
            print(x-i)
            return
        elif x+i not in p:
            print(x+i)
            return


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 61964
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	string t = s;
	
	reverse(t.begin(), t.end());
	for(int i = 0; i < t.size(); i++){
		if(t[i] == 'b') t[i] = 'd';
		else if(t[i] == 'd') t[i] = 'b';
		else if(t[i] == 'p') t[i] = 'q';
		else if(t[i] == 'q') t[i] = 'p';
	}
	if(s == t) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 512
s=sorted(list(input()))
t=sorted(list(input()),reverse=True)
n=min(len(s),len(t))
flag=False
if s[:n]==t[:n] and len(s)<len(t):
  flag=True
else:
  for i in range(n):
    if ord(s[i])<ord(t[i]):
      flag=True
      break
print(['No','Yes'][flag])

Measured memory_bytes: 3064
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [k, n] <- readInt
  a      <- readInt
  print $ solve k n a

solve k n a = k - b
 where
  a' = f (a ++ [k + head a]) 0 []
  b  = maximum a'

f []       _   ans = reverse ans
f (a : as) acc ans = f as a (a - acc : ans)


Measured memory_bytes: 41340
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

typedef vector<ll> vec;
typedef vector<vec> mat;

mat matmul(mat &A, mat &B)
{
    mat C(A.size(), vec(B[0].size()));
    size_t nr = A.size(), nint = B.size(), nc = B[0].size();
    REP(i, nr){
        REP(k, nint){
            REP(j, nc){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
            }
        }
    }
    return C;
}

mat matpow(mat A, ll n)
{
    mat B(A.size(), vec(A.size()));
    REP(i, A.size()) B[i][i] = 1;
    while(n > 0){
        if(n & 1) B = matmul(B, A);
        A = matmul(A, A);
        n >>= 1;
    }
    return B;
}

int N;
ll K;
mat A;

void solve()
{
    ll ans = 0;
    A = matpow(A, K);
    REP (i, N) {
        REP (j, N) {
            ans += A[i][j];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    A.resize(N, vec(N));
    REP (i, N) REP (j, N) cin >> A[i][j];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut v = read_vec::<usize>();
    v.sort();
    let mut ans = v[0] as f64;
    for i in 1..n {
        ans = (ans + v[i] as f64) / 2.0;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	ll sum = 0;
	
	vi v(n);
	rep(i , n){
		cin >> v[i];
		sum += v[i];
	}
	
	ll ans = LLONG_MAX;
	ll e = v[0];
	
	repf(i , 1 , n){
		ll cur = sum - e;

		ans = min(ans , llabs(cur - e));
		e += v[i];
		
	}
	

	ans = min(ans , llabs(sum - 2ll * v[n - 1]));
//	reverse(all(v));
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
using namespace std;
typedef long long ll;

int main() {
    int C[3][3], a[3], b[3];
    bool flag = true;

    REP(i, 3){
        REP(j, 3){
            cin >> C[i][j];
        }
    }

    a[0] = 0;
    a[1] = C[1][0] - C[0][0];
    a[2] = C[2][0] - C[0][0];
    b[0] = C[0][0];
    b[1] = C[0][1];
    b[2] = C[0][2];

    REP(i, 3){
        REP(j, 3)
        if (a[i] + b[j] != C[i][j]){
            flag = false;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[102][100009];
struct item{
        ll value, weight;
        item(ll _value, ll _weight)
        {
            value = _value;
            weight = _weight;
        }
};
vector <item> v;

ll knapSack(ll n, ll cap)
{
    if(n==-1 )
        return 0;
    else if(dp[n][cap]==-1)
    {
        if(cap-v[n].weight>=0)
        {
             ll temp2 = v[n].value + knapSack(n-1, (cap - v[n].weight));
             dp[n][cap]= max(temp2, dp[n][cap]);
        }

        ll temp1 = knapSack(n-1, cap);
          dp[n][cap]= max(temp1, dp[n][cap]);

    }
    return dp[n][cap];
}
int main()
{
        ll n, cap,x,y;
        cin>>n>>cap;
        memset(dp, -1, sizeof(dp));
        for(ll i=0; i<n; i++)
        {
            cin>>x>>y;
            v.push_back(item(y,x));
        }
        cout<<knapSack(n-1,cap)<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    char a, b;
    cin >> a >> b;

    char c;
    if (a == 'H') {
        c = b;
    }else {
        if (b == 'H') {
            c = 'D';
        }else {
            c = 'H';
        }
    }

    cout << c << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 256
#include <iostream>
#include <vector>

const int max_num = 1000000;

int calc(const int &n)
{
    if(n % 2 == 0)
    {
        return n / 2;
    }

    return (n * 3) + 1;
}

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

    std::vector<int> vec { s };
    int previous = 0;
    for(int i = 0; i <= max_num; ++i)
    {
        if(i == 0)
        {
            int tmp = calc(s);
            previous = tmp;
            vec.push_back(tmp);
        }
        else
        {
            int tmp = calc(previous);
            previous = tmp;
            vec.push_back(tmp);
        }
    }

    int m = 1;
    while(true)
    {
        for(int i = 0; i < m; ++i)
        {
            if(vec[i] == vec[m])
            {
                printf("%d\n", m + 1);
                return 0;
            }
        }

        ++m;
    }
}


Measured memory_bytes: 6256
# -*- coding: utf-8 -*-
import math
k = int(input())
#a = [int(i) for i in input().split()]

ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        tmp = math.gcd(i, j)
        for k in range(1, k + 1):
            #tmp = math.gcd(i, j)
            tmp2 = math.gcd(tmp, k)
            ans += tmp2
print(ans)


Measured memory_bytes: 9112
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    ll x;
    cin >> x;

    ll k = 100;
    ll i = 1;
    for(; k < x; i++) {
        k += k/100;
    }
    cout << --i << "\n";
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0)break;
        for ( int i = 0; i < H; i++ ){
            for ( int j = 0; j < W; j++ ){
                cout << "#";
            }
            cout << endl;
        }
     cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
using namespace std;
long int d[100000];
int main()
{
    long long int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>d[i];
	}
	sort(d,d+n);
	if(n%2==1)
	{
	cout<<"1"<<endl;
    return 0;
}
else
{
	cout<<d[(n/2)]-d[(n/2)-1];
}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<limits.h>
#include<queue>
#include<string>
using namespace std;

vector< vector<int> > L(105);
vector<int> d(105,-1);
vector<bool> checked(105,0);

void BFS(int s){
	queue<int> Q;
	int i;
	int v;
	
	Q.push(s);
	d[s]=0;
	while(!Q.empty()){
		v=Q.front();
		Q.pop();
		
		for (i=0;i<L[v].size();i++){
			if (d[L[v][i]]==-1){
				Q.push(L[v][i]);
				d[L[v][i]]=d[v]+1;
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,i,j;
	cin >> n;
	
	int id, deg, v;
	for (i=0;i<n;i++){
		cin >> id >> deg;
		for (j=0;j<deg;j++){
			cin >> v;
			L[id-1].push_back(v-1);
		}
	}
	
	BFS(0);
	
	for (i=0;i<n;i++){
		cout << i+1 << " " << d[i] << endl;
	}
	return 0;
	
}

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

int main()
{
    int n,k;
    double ans,mul=0;
    cin>>n>>k;
    
    for(int i=1;i<=n;i++)
    {
        double d=1.0/n;
        int x=i;
        while(x<k)
        {
            x=x*2;
            d=d/2;
        }
        ans+=d;
    }
    
    printf("%.12f",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  double cnt;
  cin >> cnt;
  cout << fixed << setprecision(6);
  cout << 2*cnt*3.1415926 << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;
 
int n,k;
vector<int> adj[2005];
 
 
 
int bfs(int v,int r,int prv=-1){
	if(r>=0){
		int sum=1;
		for(int i=0;i<adj[v].size();i++){
			if(adj[v][i]!=prv){
				int s=bfs(adj[v][i],r-1,v);
				sum+=s;
			}
		}
	return sum;
	}
	else return 0;	
}
 
 
 
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	if(k%2==0){
		int r=k/2,mint=1e6;
		for(int i=1;i<=n;i++){
			mint=min(mint,n-bfs(i,r));
		}
		printf("%d\n",mint);
	}
	else{
		int r=k/2,mint=1e6;
		for(int i=1;i<=n;i++){
                        int maxm=0;
			for(int j=0;j<adj[i].size();j++){
				maxm=max(maxm,bfs(i,r)-bfs(adj[i][j],r-1,i)+bfs(adj[i][j],r,i));
			}
                        mint=min(mint,n-maxm>0?n-maxm:0);
		}
		printf("%d\n",mint);
	}
return 0;
}

Measured memory_bytes: 384
import itertools
n, m, x = map(int, input().split())
a = [0] * n
ans = 100000000
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(1, n+1):
    for j in itertools.combinations(range(n), i):
        b = [0] * m
        c = 0
        for k in list(j):
            for l in range(m):
                b[l] += a[k][l+1]
            c += a[k][0]
        if sum(y >= x for y in b) == m:
            ans = min(ans, c)
if ans == 100000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 69464
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s,t;
  cin >> s >> t;
  
  int ans = 0;
  for(int i=0;i<3;i++){
    if(s[i] == t[i]) ans++;
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
N,M = map(int,input().split())
N_List = []
O_List = []

for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        N_List.append(b)
    if b == 1:
        N_List.append(a)
    if a == N:
        O_List.append(b)
    if b == N:
        O_List.append(a)

print(("IMPOSSIBLE","POSSIBLE")[len(set(N_List) & set(O_List)) > 0])

Measured memory_bytes: 27780
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int res = 0;
        
        
        res = (1000 - N%1000)%1000; 
        
        System.out.println(res);
                
            
        
        
        
        
        
        }
    }

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

using namespace std;

int main(){
    int N;
    long long int ans = 0;
    cin >> N;
    vector<long long int> L(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
    }

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i] && L[k]<(L[j]+L[i]) && L[j]<(L[k]+L[i]) && L[i]<(L[j]+L[k])){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
struct edge{
	int from;
	int to;
	int cost;
	edge(int f,int t,int c){
		from=f;
		to=t;
		cost=c;
	}
};
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;
	int i,j;
	int a,b,c;
	vector<edge> Edge;
	int **A=new int*[N];
	for (i=0;i<N;i++){
		A[i]=new int[N];
	}
	for (i=0;i<N;i++){
		for (j=0;j<N;j++){
			if (i==j){
				A[i][j]=0;
			}else{
				A[i][j]=1e9;
			}
		}
	}
	for (i=0;i<M;i++){
		cin>>a>>b>>c;
		A[a-1][b-1]=c;
		A[b-1][a-1]=c;
		Edge.push_back(edge(a-1,b-1,c));
	}
	for (int k=0;k<N;k++){
		for (i=0;i<N;i++){
			for (j=0;j<N;j++){
				A[i][j] = min(A[i][j],A[i][k]+A[k][j]);
			}
		}
	}
	int aw=M;
	for (i=0;i<Edge.size();i++){
		if (A[Edge[i].from][Edge[i].to]==Edge[i].cost){
			aw--;
		}
	}
	cout<<aw<<endl;

	for (i=0;i<N;i++){
		delete[] A[i];
	}
	delete[] A;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N;
	cin >> N;
	int l = 0, m = 0, r = N;
	vector<string> res(N);
	REP(i, 20) {
		cout << m << endl;
		cin >> res[m];
		if (res[m] == "Vacant") return 0;
		if ((l + m) % 2 == 0) {
			if (res[m] == res[l]) {
				l = m;
			} else {
				r = m;
			}
		} else {
			if (res[m] == res[l]) {
				r = m;
			} else {
				l = m;
			}
		}
		m = (l + r) / 2;
	}

	return 0;
}

Measured memory_bytes: 1620
N, M = [int(_) for _ in input().split()]
KS = [[int(_) for _ in input().split()] for i in range(M)]
p = [int(_) for _ in input().split()]

result = 0

def check(i, j):
    x = sum((i >> (s - 1)) & 1 for s in KS[j][1:])
    return x % 2 == p[j]

for i in range(2**N):
    result += all(check(i, j) for j in range(M))

print(result)


Measured memory_bytes: 41968
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,ans=-INF;
    cin >> n;
    ll f[n][10],p[n][11];
    for (ll i=0;i<n;i++){
        for (ll j=0;j<10;j++)cin >> f[i][j];
    }
    for (ll i=0;i<n;i++){
        for (ll j=0;j<=10;j++)cin >> p[i][j];
    }
    for (ll bit=1;bit<(1LL<<10);bit++){
        ll count=0;
        for (ll j=0;j<n;j++){
            ll c=0;
            for (ll i=0;i<10;i++){
                if (bit&(1<<i)){
                    if (f[j][i]){
                        c++;
                    }
                }
            }
            count+=p[j][c];
        }
        ans=max(ans,count);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
#define Yes "Yay!"
#define No ":("
signed main() {
	int n; cin >> n;
	vel a(n); int sum = 0;
	rep(i, n) { cin >> a[i]; sum += a[i]; }
	int ans = sum;
	int nsum = 0;
	rep(i, n) { nsum += a[i]; mmin(ans, abs(sum - 2 * nsum)); }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long long n;
    cin >> n;
    long long ans = 0;
    for(long long a=1;a<=n;a++){
        long long ok = 0, ng = n;
        while(ok + 1 < ng){
            int m = (ok + ng)/2;
            if(a*m < n) ok = m;
            else ng = m;
        }
        ans += ok;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196
#include<iostream>
#include<cstdlib>

using namespace std;

int main()
{
int x,y,i=0,j=0;
cin>>x;
cin>>y;
j=y/2-x;
i=2*x-y/2;
if(y%2==0)
{
if(x==1 && (y==2 || y==4))
{
  cout<<"Yes";
}
else if(i>=0 && j>=0)
{
  cout<<"Yes";
}
else{
  cout<<"No";
}
}
else {
  cout<<"No";
}


return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;

int main(void) {
    int a[3][3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    int n;
    cin >> n;
    int b[n];
    for (int j = 0; j < n; j++) {
        cin >> b[j];
    }
    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            for (int z = 0; z < n; z++) {
                if (a[x][y] == b[z]) {
                    a[x][y] = 0;
                }
            }
        }
    }
    for (int k = 0; k < 3; k++) {
        if (a[k][0] + a[k][1] + a[k][2] == 0 || a[0][k] +a[1][k] + a[2][k] == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (a[0][0] + a[1][1] + a[2][2] == 0 || a[0][2] + a[1][1] + a[2][0] == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

DoD = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"]


def getPNoD(n):
  if n == 1:
    return 0
  elif n == 3:
    return 29 + getPNoD(n-1)
  elif (n % 2 == 0 and n <= 8) or (n % 2 != 0 and n > 8):
    return 31 + getPNoD(n-1)
  else:
    return 30 + getPNoD(n-1)


for line in sys.stdin:
  m, d = [int(i) for i in line.split()]
  if m == 0:
    break
  n = getPNoD(m) + d - 1
  print(DoD[n % 7])

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    puta(n*n);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define MAXN 200000

int is[2][MAXN];
int main(){
    int n,m,a,b,temp;
    scanf("%d %d",&n,&m);
    while(m--){
        scanf("%d %d",&a,&b);
        if(a==1||a==n||b==1||b==n){
            if(b==1||b==n){
                temp=b;
                b=a;
                a=temp;
            }
            if(a==1)is[0][b]=1;
            else if(a==n) is[1][b]=1;
        }
    }
    for(int i=0;i<MAXN;i++){
        if(is[1][i]==1&&is[0][i]==1){
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");


    return 0;}


Measured memory_bytes: 1664
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n")[0].split("");
    let ans = [];
    for (let i = 0; i < input.length; i++) {
        if (input[i] == "B") {
            ans.pop();
        } else {
            ans.push(input[i]);
        }
    }
    console.log(ans.join(""));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;

#define pb push_back
const ll mod = 1e9 + 7;

vi dp(10012, -1);
vector<pair<ll, ll>> p;
ll n;
ll solve(ll nn) {
    ll minn = LONG_LONG_MAX;
    if (nn <= 0)return 0;
    if (dp[nn] != -1)return dp[nn];
    for (ll i = 0; i < n; ++i) {
        minn = min(minn, p[i].second + solve(nn - p[i].first));
    }
    return dp[nn] = minn;
}

signed main() {
    ll h;
    cin >> h >> n;
    p = vector<pair<ll, ll>>(n);
    for (ll i = 0; i < n; ++i) {
        cin >> p[i].first >> p[i].second;
    }
    cout << solve(h);
}

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

using namespace std;
typedef long long ll;
const int N = 30;
int letters[N];
int tmp_letters[N];
const int INF = 1e6;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    fill(letters, letters + N, INF);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        fill(tmp_letters, tmp_letters + N, 0);
        for (int j = 0; j < s.size(); j++) {
            tmp_letters[s[j] - 'a']++;
        }
        for (int j = 0; j < N; j++)
            letters[j] = min(letters[j], tmp_letters[j]);
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < letters[i]; j++)
            cout << (char)('a' + i);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int dx[] = { 1,-1,0,0 };
const int dy[] = { 0,0,-1,1 };
const int maxn = 2e5+5;
int h,w,n,sr,sc; string S,T;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> h >> w >> n >> sr >> sc >> S >> T) {
        S = ' ' + S; T = ' ' + T; n++;
        int L = sc, R = sc, U = sr, D = sr;
        bool ans = true;
        FOR(i,1,n) {
            L -= S[i] == 'L';
            R += S[i] == 'R';
            U -= S[i] == 'U';
            D += S[i] == 'D';
            if (L <= 0)
                ans = false;
            if (R > w)
                ans = false;
            if (U <= 0)
                ans = false;
            if (D > h)
                ans = false;
            L += T[i] == 'R'; L = min(w,L);
            R -= T[i] == 'L'; R = max(1,R);
            U += T[i] == 'D'; U = min(h,U);
            D -= T[i] == 'U'; D = max(1,D);
        }
        const string res = ans ? "YES" : "NO";
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 984
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int g[N];
int n;
int main()
{
    cin>>n;
    // a*b+c=n -> b=(n-c)/a
    int res=0;
    for(int i=1;i<=n;i++)//枚举A
        for(int j=1;j<=n/i;j++)//枚举B
        {
            int c=n-i*j;
            if(c && i*j+c == n) res++;
        }
    
    cout<<res;
    
 
    
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		String ans = "";

		if ( (B-A) <= 0 ) {
			ans = "delicious";
		} else if (Math.abs(B-A) <= X) {
			ans = "safe";
		} else {
			ans = "dangerous";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716