akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  int n; cin >> n;
  int a[n];
  FOR(i,0,n-1) cin >> a[i];
  int m; cin >> m;
  int b[m];
  FOR(i,0,m-1) cin >> b[i];
  map<int,int> mp;

  FOR(b,0,bit(n)-1){
		int now = 0;
		FOR(i,0,n-1){
			if(b & (1<<i)){
				now += a[i];
			}
		}
    ++mp[now];
	}

  FOR(i,0,m-1){
    if(mp[b[i]]) cout << "yes" << endl;
    else cout << "no" << endl;
  }


}





Measured memory_bytes: 3116
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: i32,
        x: i32,
    }
    for i in x - k + 1..x + k {
        println!("{}", i);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b

typedef long long ll;

int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a>b && a>c){
        printf("%d\n",b*c/2);
    } else if (b>a && b>c){
        printf("%d\n",a*c/2);
    } else {
        printf("%d\n",a*b/2);
    }
    return 0;    
}


Measured memory_bytes: 128
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 100000 + 5;
const int M = 3000 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, m;
Pair a[N];
int fa[N], size[N];
ll ans[N];

inline int find(int x) { return x == fa[x] ? fa[x] : fa[x] = find(fa[x]); }
inline ll merge(int x, int y) {
    int fx = find(x), fy = find(y);
    if (fx == fy) return 0;
    ll res = (ll)size[fx] * size[fy];
    fa[fx] = fy;
    size[fy] += size[fx];
    return res;
}

int main() {
    n = read();
    m = read();
    for (int i = 1; i <= n; i++) {
        fa[i] = i;
        size[i] = 1;
    }
    for (int i = 1; i <= m; i++) {
        a[i].fir = read();
        a[i].sec = read();
    }
    for (int i = m; i >= 1; i--) {
        // printf("%lld\n", merge(a[i].fir, a[i].sec));
        ans[i] = merge(a[i].fir, a[i].sec);
    }
    for (int i = 1; i <= m; i++) {
        ans[i] += ans[i - 1];
        printf("%lld\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[N+1][3];

		boolean S = true;
		for(int i = 1 ; i <= N ; i++){
			A[i][1] = sc.nextInt();
			A[i][2] = sc.nextInt();
			if(A[i][1] > A[i][2]){
				S = false;
				break;
			}
		}

		sc.close();

	    Arrays.sort(A, new Comparator<int[]>() {
	        public int compare(int[] o1, int[] o2) {
	            return o1[2] - o2[2];    //[0] をキーにソート(降順)
	        }
	    });

	    boolean T = true;
	    long AI = 0;
	    long BI = 0;
	    for(int i = 1 ; i <= N ; i++){
	    	AI += A[i][1];
	    	BI = Math.max(BI, A[i][2]);
	    	if(AI>BI){
	    		T = false;
	    		break;
	    	}
	    }

	    if(AI<=BI && S && T){
	    	System.out.println("Yes");
	    }
	    else{
	    	System.out.println("No");
	    }
	}
}


Measured memory_bytes: 113244
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int s, int d, Weight w)
    : src(s), dst(d), weight(w) {
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addEdge(Graph &g, int a, int b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
  g[b].emplace_back(b, a, w);
}

void addArc(Graph &g, int a, int b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
}

void solve() {
  int n;
  cin >> n;
  Graph g(n);
  rep(i, n) {
    int u, k;
    cin >> u >> k;
    u--;
    while (k--) {
      int v;
      cin >> v;
      v--;
      addArc(g, u, v);
    }
  }
  int c = 1;
  vi done(n);
  vpii time(n);
  function<void(int)> dfs = [&](int x) {
    if (done[x]) return;
    done[x]    = true;
    time[x].fi = c++;
    for (Edge e : g[x]) {
      dfs(e.dst);
    }
    time[x].se = c++;
  };
  rep(i, n) dfs(i);
  rep(i, n) {
    cout << i + 1 << ' ' << time[i].fi << ' ' << time[i].se << endl;
  }
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
 
#define PI 3.1415926
 
int main(int, char**)
{
    float n;
 
    cin >> n;
 
    cout << 2 * n * PI << endl;
 
    return 0;
}

Measured memory_bytes: 3784
#include<iostream>
using namespace std;
int main(){
    int n,b,f,r,v;
    int test1[3][10]={};
    int test2[3][10]={};
    int test3[3][10]={};
    int test4[3][10]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        if (b==1){
            test1[f-1][r-1]+=v;
        }
        if (b==2){
            test2[f-1][r-1]+=v;
        }
        if (b==3){
            test3[f-1][r-1]+=v;
        }
        if (b==4){
            test4[f-1][r-1]+=v;
        }
    }
    for(int i=0;i<3;i++){
        for(int x=0;x<10;x++){
            cout<<" "<<test1[i][x];
            if (x%10==9){
                cout<<endl;
            }
        }
    }
    for(int x=0;x<20;x++){
        cout<<"#";
    }
    cout<<endl;
    for(int i=0;i<3;i++){
        for(int x=0;x<10;x++){
            cout<<" "<<test2[i][x];
            if (x%10==9){
                cout<<endl;
            }
        }
    }
    
    for(int x=0;x<20;x++){
    cout<<"#";
    }
    cout<<endl;
    for(int i=0;i<3;i++){
        for(int x=0;x<10;x++){
            cout<<" "<<test3[i][x];
            if (x%10==9){
                cout<<endl;
        }
    }
    }
    for(int x=0;x<20;x++){
    cout<<"#";
    }
    cout<<endl;
    for(int i=0;i<3;i++){
    for(int x=0;x<10;x++){
        cout<<" "<<test4[i][x];
        if (x%10==9){
            cout<<endl;
        }
    }
    }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}

int main()
{
	int n=read(),m=read();
	printf("%d\n",n*(n-1)/2+m*(m-1)/2);
}

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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n],pos=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>=0){
            pos++;
        }
    }
    int i=n-k;
    int left=a[i],right=a[i+k-1];
    long long ans=0ll;
    ans=min(abs(left)+abs(right-left),abs(right)+abs(left-right));
    while(i>0){
        // cout<<ans<<endl;
        i--;
        left=a[i];
        right=a[i+k-1];
        ans=min(ans,1ll*min(abs(left)+abs(right-left),abs(right)+abs(left-right)));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4000
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>

using namespace std;

int A[200000];

int main()
{
    char c;

    scanf("%c", &c);
    if(c >= 'a' && c <= 'z')
        printf("a");
    else
        printf("A");

    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ; cin >> n ;

    int ans = 0 ;
    for ( int i=1 ; i < n + 1 ; i++ )
    {
        string s = to_string ( i ) ;
        int z = s.size() ;

        if ( z % 2 ) ans ++ ;
    }

    cout << ans ; line
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int n;
vector<ll> a(400);
vector<vector<ll>> dp(401, vector<ll>(401, -1));
vector<vector<ll>> s_size(401, vector<ll>(401, 0));

ll rec(int l = 0, int r = n) {
  if(r-l <= 1) return 0;
  if(r-l == 2) return a[l]+a[l+1];

  if(dp[l][r] != -1) return dp[l][r];

  ll &ret = dp[l][r];
  ret = INF64;
  for(int c = l+1; c < r; ++c) chmin(ret, s_size[l][r] + rec(l, c) + rec(c, r));
  return ret;
}

int main()
{
  cin >> n;
  rep(i, n) cin >> a[i];

  for(int l = 0; l < n; ++l) {
    s_size[l][l+1] = a[l];
    for(int r = l+2; r <= n; ++r) s_size[l][r] = s_size[l][r-1] + a[r-1];
  }
  cout << rec() << endl;

}

Measured memory_bytes: 2816
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 40816
#include <cstdio>
const int MAXN = 2005, mod = 1e9 + 7;
inline int powmod(int a, int x) {
    long long cur = a, res = 1;
    while(x) {
        if(x & 1) res = (res * cur) % mod;
        cur = (cur * cur) % mod;
        x >>= 1;
    }
    return (int)res;
}
int n, k, f[MAXN][MAXN];
int fac[MAXN * MAXN], rev_fac[MAXN * MAXN];
inline int commod(int n, int m) {
    return ((((long long)fac[n] * rev_fac[m]) % mod) * rev_fac[n - m]) % mod;
}
int main() {
    fac[0] = 1;
    rev_fac[0] = powmod(fac[0], mod - 2);
    for(int i = 1; i < MAXN * MAXN; i++) {
        fac[i] = ((long long)fac[i - 1] * i) % mod;
        rev_fac[i] = powmod(fac[i], mod - 2);
    }
    scanf("%d%d", &n, &k);
    int ans;
    if(k == 1) {
        ans = 1;
    }
    else {
        for(int i = 0; i <= n; i++) {
            for(int j = i; j <= n; j++) {
                if(i == 0 && j == 0) f[i][j] = 1;
                if(i - 1 >= 0) f[i][j] = f[i - 1][j];
                if(j > i) {
                    int t = ((long long)f[i][j - 1] * commod(i + j * (k - 1) - 1, k - 2)) % mod;
                    f[i][j] += t;
                    if(f[i][j] >= mod) f[i][j] -= mod;
                }
            }
        }
        ans = ((long long)fac[n] * f[n][n]) % mod;
    }
    printf("%d\n", ans);
    return 0;
}

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

//使用する配列の最大要素数
#define MAX_SIZE_N 10000
//使用する変数の宣言と初期化
int n;
string S;
char s[MAX_SIZE_N]={0};
int result=1;

int main()
{
  cin >> n;
  cin >> S; 
  for(int i = 0; i < n-1; ++i){
    if(S[i]!=S[i+1]) result++;
}
 
  cout << result;
    
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007



int main()
{
 //O_O ;
   string s;
   cin>>s;
ll   ans=0;
   for(ll i=0;i<3;i++){
   if(s[i]=='R'&&ans==0)
   {
       ans++;
       i++;
       if(s[i]=='R'&&i<3)
       {
           ans++;
           i++;
           if(s[i]=='R'&&i<3){
            ans++;i++;
       }
       }
   }


   }
   cout<<ans<<nn;


    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A+B>C+D) cout << "Left" << endl;
    else if(A+B==C+D) cout << "Balanced" << endl;
    else cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    vector<int> number(3);
    cin >> number;
    vector<pi> input(N);
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        pi temp = {S[0] - 'A', S[1] - 'A'};
        if (temp.first > temp.second) swap(temp.first, temp.second);
        input[i] = temp;
    }
    vector<int> ans;
    for (int i = 0; i < N; i++) {
        pi &now = input[i];
        if (number[now.first] == number[now.second] && number[now.first] == 0) {
            cout << "No" << endl;
            return 0;
        }
        auto update = [&](pi &now, bool is_first) {
            if (is_first) {
                ans.push_back(now.first);
                number[now.first]++;
                number[now.second]--;
            } else {
                ans.push_back(now.second);
                number[now.first]--;
                number[now.second]++;
            }
        };
        if (number[now.first] == 0) {
            update(now, true);
        } else if (number[now.second] == 0) {
            update(now, false);
        } else {
            if (i + 1 == N) {
                update(now, now.first == 0);
                continue;
            }
            if (now == input[i + 1]) {
                update(now, true);
            } else {
                if (now.first == input[i + 1].first) {
                    update(now, true);
                } else if (now.first == input[i + 1].second) {
                    update(now, true);
                } else {
                    update(now, false);
                }
            }
        }
    }
    cout << "Yes" << endl;
    for (auto now : ans) {
        cout << (char) (now + 'A') << endl;
    }
    return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main(){

	string s;
	map<string,string> a;
	a["11"]="a";
	a["12"]="b";
	a["13"]="c";
	a["14"]="d";
	a["15"]="e";
	a["21"]="f";
	a["22"]="g";
	a["23"]="h";
	a["24"]="i";
	a["25"]="j";
	a["31"]="k";
	a["32"]="l";
	a["33"]="m";
	a["34"]="n";
	a["35"]="o";
	a["41"]="p";
	a["42"]="q";
	a["43"]="r";
	a["44"]="s";
	a["45"]="t";
	a["51"]="u";
	a["52"]="v";
	a["53"]="w";
	a["54"]="x";
	a["55"]="y";
	a["61"]="z";
	a["62"]=".";
	a["63"]="?";
	a["64"]="!";
	a["65"]=" ";
	
	while(cin>>s){
		string t="";
		int f=0;
		if(s.size()%2==0){
			for(int i=0;i<s.size();i=i+2){
				string y="";
				y=y+s[i]+s[i+1];
				if(a[y]==""){
					f=1;
					break;
				}
				else
					t=t+a[y];
			}
		}
		else
			f=1;
		if(f==1)
			cout<<"NA"<<endl;
		else
			cout<<t<<endl;
	}
	
	
}

Measured memory_bytes: 1212
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, K;
LL A[1011];

void MAIN() {
    scanf("%d%d", &N, &K);
    REP (i, N) scanf("%lld", A+i);
    vector<LL> v;
    v.reserve(N*N);
    REP (i, N) {
	LL sum = 0;
	for (int j=i; j<N; j++) {
	    sum += A[j];
	    v.push_back(sum);
	}
    }

    LL ans = 0;

    for (int t=60; t--;) {
	int cnt = 0;
	EACH (e, v) if (*e>>t&1) cnt++;

	if (cnt >= K) {
	    ans |= 1LL<<t;
	    EACH (e, v) if (~*e>>t&1) *e = 0;
	}
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 5760
#include <iostream>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;
int main(void){
    ll n,k;
    cin >> n >> k;
    ll ret = 1;
    for(ll i=0;i<n;i++)ret=ret*k % MOD;
    cout << ret << endl;
    return 0;
}



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

using namespace std;

const int maxn = 2002;

int a[maxn];
int g[maxn][maxn];
vector<int> G[maxn];
int ind[maxn];
bool vis[maxn];
int n;

void dfs(int u) {
	for(int i = 0; i < n; ++i) if(g[u][i] > 1 && !vis[i]) {
		vis[i] = true;
		G[u].push_back(i);
		++ind[i];
		dfs(i);
	}
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
	sort(a, a + n);
	for(int i = 0; i < n; ++i) 
		for(int j = 0; j < n; ++j)
			g[i][j] = __gcd(a[i], a[j]);
	for(int i = 0; i < n; ++i)
		if(!vis[i]) vis[i] = true, dfs(i);
	priority_queue<int, vector<int>, less<int> > q;
	for(int i = 0; i < n; ++i) if(ind[i] == 0) q.push(i);
	while(!q.empty()) {
		int x = q.top(); q.pop();
		printf("%d ", a[x]);
		for(auto i: G[x]) if(--ind[i]==0) q.push(i);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
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> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int h,n; cin >>h >>n;
  vector<int> a(n), b(n);
  rep(i, n) cin >>a.at(i) >>b.at(i);
  const int H_MAX = 10000;
  vector<int> dp(2*H_MAX+1, MOD);
  dp.at(0) = 0;
  // dp[i]...HPをiだけ減らすのに必要な魔力の最小値
  for (int i=0; i<n; i++){
    for (int j=0; j<2*H_MAX; j++){
      if (j+a.at(i) <= 2*H_MAX) chmin(dp[j+a.at(i)], dp[j] + b.at(i));
    }
  }
  int res = MOD;
  for (int i=h; i<=2*H_MAX; i++){
    chmin(res, dp[i]);
  }
  cout <<res <<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 4e2+2;
const ll INF = 1e18;

ll n,dp[nax][nax],a[nax],pr[nax];

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>n;
	for (ll i=1;i<=n;++i) cin>>a[i];
	

	for (ll i=1;i<=n;++i) pr[i]=pr[i-1]+a[i];
	
	for (ll i=0;i<nax;++i){
		for (ll j=0;j<nax;++j) dp[i][j]=INF;
	}
	
	for (ll l=n;l>=1;--l){
		for (ll r=l;r<=n;++r){
			
			if (r-l==0) dp[l][r]=0;
			else if (r-l==1) dp[l][r]=a[r]+a[l];
			
			else {
				for (ll t=l;t<=r;++t){
					dp[l][r]=min(dp[l][r],dp[l][t]+dp[t+1][r]+pr[r]-pr[l-1]);
				}
			}
			
		}
	}
	
/*	for (ll i=1;i<=n;++i){
		for (ll j=1;j<=n;++j) cout<<((dp[i][j]!=INF)? dp[i][j] : 0 )<<" ";
		cout<<"\n";
	}
	cout<<"\n";*/
	
	cout<<dp[1][n]<<"\n";
	
}

Measured memory_bytes: 4912
#include "bits/stdc++.h"
    using namespace std;
    #define dbg(var) cout<<#var<<"="<<var<<" "
    #define nl cout<<"\n"
    #define fr(i,n) for(int i=0;i<n;i++)
    #define rep(i,a,n) for(int i=a;i<=n;i++)
    #define fast ios::sync_with_stdio(false);cin.tie(0);
    #define vi vector<int>
    #define vvi vector<vi>
    #define pb push_back
    #define fa(v) for(auto &i:v)
    #define all(v) v.begin(),v.end()
    #define sz(v) (int)(v.size())
    #define int long long
    int32_t main()
    {
      int H,W; cin >> H >> W;
      int x1,y1,x2,y2;
      cin >> x1 >> y1 >> x2 >> y2;x1--;x2--;y1--;y2--;
      string s[H]; fr(_,H) cin >> s[_];
      deque<pair<int,int>> Q;
      int dist[H][W];memset(dist,0x3f,sizeof dist);
      Q.push_front({x1,y1});
      auto is_valid =[&](int x,int y){
      	return x>=0 and y >= 0 and x< H and y< W  and s[x][y] != '#';
      };
      int inf = dist[0][0];
      dist[x1][y1] = 0;
     
      while(!Q.empty()){
      	auto fr = Q.front();
      	Q.pop_front();
      	int x = fr.first;
      	int y = fr.second;
      	for(int dx = -2; dx <= 2; dx++){
      		for(int dy = -2; dy <= 2; dy++){
      			int xx = x + dx;
      			int yy = y + dy;
      			int ww = (abs(x-xx) + abs(y-yy) > 1);
      			if(!is_valid(xx,yy)) continue;
      			if(dist[x][y] + ww  < dist[xx][yy]){
      				dist[xx][yy] = dist[x][y] + ww;
      				if(ww == 1) Q.push_back({xx,yy});
      				else Q.push_front({xx,yy});
      		 }
      		}
      	}
      }
      if(dist[x2][y2] == inf)
      cout << "-1\n";
    else cout << dist[x2][y2];
    }

Measured memory_bytes: 13496
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  ll x,y;
  cin>>x>>y;
  int ans = 0;
  while(true){
    if(y<x) break;
    x *= 2;
    ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M, XX, YY = map(int, input().split())
    X = list(map(int, input().split()))
    Y = list(map(int, input().split()))
    X.append(XX)
    Y.append(YY)
    if max(X) < min(Y):
        print("No War")
    else:
        print("War")


if __name__ == '__main__':
    main()


Measured memory_bytes: 81600
#include <iostream>
#include <string>

int main()
{
	std::string S;

	std::cin >> S;

	std::string ans;

	for (size_t i = 0; i < S.size(); i++)
		if (S[i] == '0') {
			ans += '0';
		}
		else if (S[i] == '1') {
			ans += '1';
		}
		else {
			if (ans.size() > 0)
				ans.erase(ans.end() - 1);
		}

		std::cout << ans << '\n';

		return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<Long ,Integer> hm = new HashMap<Long,Integer>();
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int []a = new int [n];
		
		for(int i = 0 ;i < n ;i++) {
			a[i] = sc.nextInt();
		}
		
		long sum = 0;
		long ans = 0;
		
		hm.put(0L,1);
		
		for(int i = 0 ; i < n ;i++) {
			sum += a[i];
			sum %= m;
			
			ans += hm.getOrDefault(sum, 0);
			hm.put(sum, hm.getOrDefault(sum, 0)+1);
		}
		
		System.out.println(ans);
	}	
}

Measured memory_bytes: 52416
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            long n = Long.parseLong(sc.next());
            long m = Long.parseLong(sc.next());

            long allVote = 0;

            List<Integer> list = new ArrayList<>();
            
            for(int i = 0; i < n; i++){
                int vote = Integer.parseInt(sc.next());
                list.add(vote);
                allVote += vote;
            }

            Collections.sort(list);
            Collections.reverse(list);

            int judge = list.get((int)m - 1);

            if((double)judge < (double)allVote/(4*(double)m)) System.out.println("No");
            else System.out.println("Yes");

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 21844
#coding:utf-8
import numpy as np
from collections import deque

H, W = map(int, input().split())
maze = []
for h in range(H):
    ls = input()
    maze.append(ls)


def bfs(x,y):
    visited = np.zeros((H,W))
    dist = 0
    queue = deque()
    queue.append((x,y,0))
    while(queue):
        x,y,d = queue.popleft()
        if not visited[x][y]:
            dist = max(dist, d)
            visited[x][y] = 1
            for dx, dy in [(1,0),(-1,0),(0,1),(0,-1)]:
                if (0 <= x+dx and x+dx < H and 0 <= y+dy and y+dy < W):
                    if maze[x+dx][y+dy] == '.' and visited[x+dx][y+dy] == 0:
                        queue.append((x+dx, y+dy, d+1))
    return dist

ans = 0
for h in range(H):
    for w in range(W):
        if maze[h][w]==".":
            ans = max(ans, bfs(h,w))

print (ans)

Measured memory_bytes: 14400
#include <stdio.h>

int main(void){
	unsigned int current;
	unsigned int need;
	int n,i,j,sn;
	unsigned int bit[7];
	int data[10] = {
		        //n: gfe dcba
		0x3f,	//0: 011 1111
		0x06,   //1: 000 0110
		0x5b,   //2: 101 1011
		0x4f,   //3: 100 1111
		0x66,   //4: 110 0110
		0x6d,   //5: 110 1101
		0x7d,   //6: 111 1101
		0x27,   //7: 010 0111
		0x7f,   //8: 111 1111
		0x6f    //9: 110 1111
	};
	while(1){
		current = 0;
		scanf("%d",&n);
		if(n == -1){break;}
		for(j = 0; j < n; j++){
			scanf("%d",&sn);
			need = current ^ data[sn];
			current = data[sn];
			for(i = 0; i < 7; i++){
				bit[i] = need % 2;
				need /= 2;
			}
			for(i = 6; i >= 0; i--){
				printf("%d",bit[i]);
			}
			putchar('\n');
		}
	}

	return 0;
}

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

using namespace std;

#define X first
#define Y second
#define ll long long
#define inf (ll)1e18
const int mod = (int)1e9 + 7;
#define all(x) x.begin(), x.end()

const int N = 1000060;
const int MX = 200020;

int mx = (int)(1e5) + 10;

int c[555], s[555], f[555], res[555];

int main(){
/*
     ___     ___
    (^_^)   (^_^)
   /( | )\ /( | )\
     | |     | |
*/
    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
    	cin >> c[i] >> s[i] >> f[i];
    }


    for(int i = 0; i < n; ++i){
    	int t = s[i] + c[i];
    	for(int j = i + 1; j < n - 1; ++j){
    		if(t < s[j]){
    			t = s[j];
    		}
    		else{
    			while((t - s[j]) % f[j])t++;
    		}
    		t += c[j];
    	}
    	res[i] = t;
    	cout << res[i] << endl;
    }

   	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
ll take_p5(ll n){
	return (n*n*n*n*n);
}
int main() 
{
	string s;
	cin>>s;
	int suf=0;
	ll ans=0;
	int n=s.size();
	int power_of_ten=1;
	map<int, int>cnt_suf;
	cnt_suf[suf]++;
//	cout<<123;9
	for(int i=n-1;i>=0;i--){
		int digit=s[i]-'0';
		suf=(suf+digit*power_of_ten)%MOD;
		power_of_ten=10*power_of_ten%MOD;
		ans+=cnt_suf[suf];
		cnt_suf[suf]++;
	}
	cout<<ans;
}

Measured memory_bytes: 27120
import java.util.Scanner;
class Main{
 public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int N= Integer.parseInt(sc.next());
int M= Integer.parseInt(sc.next());
int gcd=1;
for(int n=M/N;n>=1;n--) {
   if(M%n==0) {
	if(n*N<=M) {
	gcd=n;
	break;
	 }
    }	
 }
System.out.println(gcd);
 }
  }

Measured memory_bytes: 25172
// B - RGB Balls
#include <bits/stdc++.h>

using namespace std;

#define	MOD	998244353

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	long long ans = 1;
	vector<long long> c(3);
	int p1 = 0, p2 = 0, p3 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') c[0]++;
		else if (s[i] == 'G') c[1]++;
		else if (s[i] == 'B') c[2]++;
		long long q1 = *max_element(c.begin(), c.end());
		long long q3 = *min_element(c.begin(), c.end());
		long long q2 = (i + 1) - q1 - q3;
		if (q1 != p1) ans = ans * q1 % MOD;
		else if (q2 != p2) ans = ans * (q1 - q2 + 1) % MOD;
		else ans = ans * (q2 - q3 + 1) % MOD;
		p1 = q1, p2 = q2, p3 = q3;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <math.h>
using namespace std;

int digits(int);

int main(){
  double a,b;
  cin >> a >> b;
  
  double target_d = a*pow(10, digits(b)) + b;
  int target_i = target_d;
  int x = ceil(sqrt(target_d));
  int flag = 0;
  
  for (int i = 1; i <= x; i++){
    if (i*i == target_i){
      flag = 1;
    }else{
      continue;
    }
  }
  
  if (flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

int digits(int n){
  int res = 0;
  while(1){
    n = n / 10;
    res += 1;
    if (n == 0) break;
  }
  return res;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int w,h;


int yoko[31][31];
int tate[31][31];

void bfs(){
	queue<pair<int,int> > *prv = new queue<pair<int,int> >();
	queue<pair<int,int> > *nxt = new queue<pair<int,int> >();
	
	int dy[] = {-1,0,0,1};
	int dx[] = {0,-1,1,0};

	bool passed[31][31];
	for(int i = 0; i < 31; i++)
		fill(passed[i],passed[i]+31,false);

	prv->push(make_pair(0,0));
	int cnt = 0;
	while(prv->size()){
		cnt++;
		while(prv->size()){
			pair<int,int> place = prv->front();
			prv->pop();
			if(passed[place.first][place.second])
				continue;

			passed[place.first][place.second] = true;
			if(place.second == w-1 && place.first == h-1){
				delete prv,nxt;
				cout << cnt << endl;
				return;
			}
			for(int i = 0; i < 4; i++){
				int xx = place.second + dx[i];
				int yy = place.first + dy[i];
				if(xx >= 0 && xx < w && yy >= 0 && yy < h){
					if(!passed[yy][xx]){
						if((dx[i] == -1 && !yoko[yy][xx]) || (dx[i] == 1 && !yoko[yy][xx-1]) 
							|| (dy[i] == -1 && !tate[yy][xx]) || (dy[i] == 1 && !tate[yy-1][xx])){
							nxt->push(make_pair(yy,xx));
						}
					}
				}
			}
		}
		swap(prv,nxt);
	}
	delete prv,nxt;
	cout << 0 << endl;
}

int main(){

	while(cin >> w >> h && !(w == 0 && h == 0)){
		for(int i = 0; i < 31; i++){
			fill(yoko[i],yoko[i]+31,0);
			fill(tate[i],tate[i]+31,0);
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w-1; j++){
				cin >> yoko[i][j];
			}
			if(i != h - 1){
				for(int j = 0; j < w; j++){
					cin >> tate[i][j];
				}
			}
		}
		bfs();
	}

	return 0;
}

Measured memory_bytes: 960
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <utility>
#include <functional>

using namespace std;

int m, d, A[13] = { 0,0,31,60,91,121,152,182,213,244,274,305,335 };
string s[7] = { "Wednesday", "Thursday","Friday","Saturday","Sunday","Monday","Tuesday" };
int main() {
	while (1) {
		cin >> m >> d;
		if (m == 0) break;
		cout << s[(A[m] + d) % 7] << endl;
	}
	return 0;
}


Measured memory_bytes: 3056
S = list(input())

if S.count('S')!=0 and S.count('N')== 0:
  print('No')
elif S.count('N')!=0 and S.count('S')== 0:
  print('No')
elif S.count('E')!=0 and S.count('W')== 0:
  print('No')
elif S.count('W')!=0 and S.count('E')== 0:
  print('No')
else:
  print('Yes')


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


ll X,Y,Z,K;
vector<ll> AB;
vector<ll> C;


int main() {
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    C.assign(Z,0);
    REP(i,X){
        cin >> A[i];
    }
    REP(i,Y){
        cin >> B[i];
    }
    REP(i,Z){
        cin >> C[i];
    }
    AB.assign(X*Y, 0);
    REP(i,X){
        REP(j,Y){
            AB[i*Y + j] = A[i]+B[j];
        }
    }
    sort(ALL(A), greater<ll>());
    sort(ALL(B), greater<ll>());
    sort(ALL(C), greater<ll>());


    vector<ll> vec;

    REP(i,X){
        REP(j,Y){
            REP(k,Z){
                if((i+1) * (j+1) * (k+1) <= K){
                    vec.push_back(A[i]+ B[j] + C[k]);
                }else{
                    break;
                }
            }
        }
    }

    sort(ALL(vec), greater<ll>());
    
    REP(i,K){
        cout << vec[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 12120
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int h = rint, a = rint;
	((h + a - 1) / a).writeln;
}

Measured memory_bytes: 256
def abc097_b():
    x = int(input())
    if x == 1:
        return 1

    n = int(x ** 0.5)
    ans = []
    for i in range(2, n + 1):
        tmp = i
        while tmp * i <= x:
            tmp *= i
        ans.append(tmp)

    return max(ans)


print(abc097_b())

Measured memory_bytes: 3064
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    match n {
        1...999 => println!("ABC"),
        1000...1998 => println!("ABD"),
        _ => return,
    }

}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}

	class Bit {
	public :
		// コンストラクタでサイズ数
		Bit(int length) {
			length_ = length;
			bit_ = -1; // while(bit.next()) をされるのを想定
		}

		// 一つ先の値に移動する もう次に進めないならばfalseを返す
		bool Next() {
			if (++bit_ >= (1 << length_)) return false;
			return true;
		}

		// Bit操作 指定したインデックスを変更する
		void Change(int i, int value = 1) {
			if (value == 1) bit_ |= (1 << i);
			else bit_ &= ~(1 << i);
		}

		// 指定したインデックスが1かどうか
		bool IsSelected(int i) {
			return bit_ & (1 << i);
		}

		// 1の個数を返す 引数で範囲 [l, r)
		int GetSelectedNum(int l, int r) {
			int res = 0;
			for (int i = l; i < r; ++i) {
				if (IsSelected(i)) ++res;
			}
			return res;
		}

		// ビット列をint型で返す
		int GetBit() {
			return bit_;
		}

		// ビット長を返す
		int GetLength() {
			return length_;
		}

	private:
		int bit_;
		int length_;
	};
}


int main() {

	int n, m;
	std::cin >> n >> m;
	std::vector<int> a(m), b(m);
	std::vector<std::vector<int>> c;
	rep(i, m) {
		std::cin >> a[i] >> b[i];
		std::vector<int> tmp(b[i]);
		rep(j, b[i]) std::cin >> tmp[j];
		rep(j, b[i]) --tmp[j];
		c.push_back(tmp);
	}

	// bitで宝箱が空いているかいないかを選択

	// dp[i][bit] := i番目までの鍵を任意に購入してbit状態の時の必要な最低費用
	std::vector<std::vector<int>> dp(m + 1, std::vector<int>((1 << n), inf));

	rep(i, m) {
		dp[i][0] = 0;
	}

	rep(i, m) {
		Bit bit(n);
		while (bit.Next()) {
			// 現在のbitの状態でi番目の鍵を購入するかしないか
			if (dp[i][bit.GetBit()] == inf) continue;

			// 購入する
			// 変化後のビット
			Bit new_bit = bit;
			rep(j, b[i]) {
				new_bit.Change(c[i][j], 1);
			}
			chmin(dp[i + 1][new_bit.GetBit()], dp[i][bit.GetBit()] + a[i]);

			// 購入しない
			chmin(dp[i + 1][bit.GetBit()], dp[i][bit.GetBit()]);
		}
	}

	// すべてそろった状態での最小費用
	int ans = dp[m][(1 << n) - 1];
	if (ans == inf) ans = -1;

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
long long n,ans,ans1,mod=1000000007;
long long qpow(int p,int a)
{
	if(p==0) return 1ll;
	long long k=qpow(p/2,a);
	if(p&1) return ((k*k)%mod*a)%mod;
	return (k*k)%mod;
}
int main()
{
	cin>>n;
	if(n==1||n==2)
	{
		cout<<2*n-2;
		return 0;
	}
	ans=(qpow(n,10)+qpow(n,8)+mod*3-2*qpow(n,9))%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
	long long N,x,sum = 0; cin >> N >> x;
	vector<long long> a(N);
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	if (a[0] > x){
		sum += a[0]-x;
		a[0] = x;
	}
	if (a[N-1] > x){
		sum += a[N-1]-x;
		a[N-1] = x;
	}
	for (int i = 1; i < N; i++){
		long long tmp;
		if ((a[i] + a[i-1]) > x){
			sum += (a[i]+a[i-1]-x);
			a[i] = x-a[i-1];
		}
	}
	cout << sum << endl;
}
 


Measured memory_bytes: 1024