akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    get!(usize);
    let aa = util::gets::<u64>();

    if aa.len() == 1 || aa.iter().filter(|&x| x % 2 == 1).count() % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 6396
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

# a,b,c = map(int, input().split())
n = int(input())
# a = list(map(int,input().split()))
dic = {}
for i in range(n):
    s = input()
    if s in dic: dic[s] += 1
    else: dic[s] = 1

max = 0
for i in dic:
    max = dic[i] if dic[i] > max else max
#
# dic = sorted(dic.items(), key=lambda x:x[0])
# print(dic)
#
ans = []
for k,v in dic.items():
    if v == max: ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 32096
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, ans;
	scanf("%d%d", &a, &b);
	if (a > b) swap(a, b);
	ans = a * 2, b -= a;
	if (b) ans += b * 2;
	if (ans <= 16) printf("Yay!\n");
	else printf(":(\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string N;
    cin >> N;
    cout << (N[0] == '9' || N[1] == '9' ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 200005
#define ll long long
#define mod 1000000007
#define inf 0x3f3f3f3f
int fac[N], inv[N];
int n, c[N], w[N], x, y;
int mn[N], cnt[N];
int Pow(int a, int k)
{
	int ret = 1;
	while (k)
	{
		if (k & 1)
			ret = (ll)ret * a % mod;
		a = (ll)a * a % mod;
		k >>= 1;
	}
	return ret;
}
int C(int n, int m)
{
	if (n < m || m < 0)
		return 0;
	return (ll)fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main()
{
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 1; i <= n; i++)
		mn[i] = inf;
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[n] = Pow(fac[n], mod - 2);
	for (int i = n; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", &c[i], &w[i]);
		mn[c[i]] = min(mn[c[i]], w[i]);
		cnt[c[i]]++;
	}
	int u = 0;
	for (int i = 1; i <= n; i++)
		if (mn[i] != inf)
			if (u == 0 || mn[i] < mn[u])
				u = i;
	int v = inf;
	for (int i = 1; i <= n; i++)
		if (mn[i] != inf && i != u)
			v = min(v, mn[i]);
	for (int i = 1; i <= n; i++)
	{
		if (w[i] != mn[c[i]] && w[i] + mn[c[i]] <= x)
			continue;
		if (c[i] != u && w[i] + mn[u] <= y)
			continue;
		if (c[i] == u && w[i] + v <= y)
			continue;
		cnt[c[i]]--;
	}
	int num = cnt[u];
	for (int i = 1; i <= n; i++)
		if (mn[i] != inf && i != u)
			if (mn[i] + mn[u] <= y)
				num += cnt[i];
	int ans = 1;
	for (int i = 1; i <= n; i++)
		if (mn[i] != inf && (i == u || mn[i] + mn[u] <= y))
		{
			ans = (ll)ans * C(num, cnt[i]) % mod;
			num -= cnt[i];
		}
	printf("%d\n", ans);
}


Measured memory_bytes: 4992
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
ll A,B,N;
int main()
{
	cin>>N>>A>>B;
	if(A>B)puts("0");
	else if(N==1&&A!=B)puts("0");
	else if(N<=2)puts("1");
	else cout<<B*(N-2)-A*(N-2)+1<<endl; 
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<long long> v(n);
    vector<string> s(n);

    for(int i=0; i<n; i++){
        cin>>s[i];
        cin>>v[i];
        //cout<<v[i]<<endl;
    }

    string pat;
    cin>>pat;

    int indx = -1;
    for(int i=0; i<n; i++){
        if(s[i] == pat){
            indx = i;
            //cout<<indx<<endl;
            break;
        }
    }

    if(indx == n-1){
        cout<<0<<endl;
        return 0;
    }

    long long result = 0;
    for(int i = indx+1; i<n; i++){
        result += v[i];
    }

    cout<<result<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,ans;
    double p;
    while(scanf("%d",&ans)==1)
    {
        p=1;
        for(a=2;a<=ans;a++)
            p = p*a;
        printf("%0.lf\n",p);
    }
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = r / d - (l - 1) / d;
    cout << ans << "\n";
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	if(a<=8 && b<=8) cout<<"Yay!\n";
	else cout<<":(\n";
	return 0;
}





























Measured memory_bytes: 256
cards_a = list(input())
cards_b = list(input())
cards_c = list(input())
P = "a"

while True:
    if P == "a":
        if len(cards_a) == 0:
            ans = "A"
            break
        P =  cards_a[0]
        cards_a.pop(0)
    elif P == "b":
        if len(cards_b) == 0:
            ans = "B"
            break
        P = cards_b[0]
        cards_b.pop(0)
    elif P == "c":
        if len(cards_c) == 0:
            ans = "C"
            break
        P = cards_c[0]
        cards_c.pop(0)
print(ans)

Measured memory_bytes: 3064
n,a,b,c,d = map(int,input().split())
#v = list(map(int,input().split()))
s = input()
flag = True
flag2 = False
if d>c:
    tmpflag = False
    for i in range(b-1,d):
        if tmpflag:
            if s[i] == '#':
                flag = False
                break
            else:
                tmpflag = False
        elif s[i] == '#':
            tmpflag = True
    
    for i in range(a-1,c):
        if tmpflag:
            if s[i] == '#':
                flag = False
                break
            else:
                tmpflag = False
        elif s[i] == '#':
            tmpflag = True
    if flag:
        print('Yes')
    else:
        print('No')
else:
    tmpflag = False
    for i in range(a-1,c):
        if tmpflag:
            if s[i] == '#':
                flag = False
                break
            else:
                tmpflag = False
        elif s[i] == '#':
            tmpflag = True
    counter = 0
    for i in range(b-2,d+1):
        if s[i] == '.':
            counter += 1
            if counter == 3:
                flag2 = True
        if s[i] == '#':
            counter = 0
    if flag and flag2:
        print('Yes')
    else:
        print('No')




Measured memory_bytes: 3700
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (H, W) = Slice2<long>();
            var ban = new char[H][];
            for (var i = 0; i < H; ++i)
                ban[i] = ReadLine().ToCharArray();
            var dh = new long[] { -1, 0, 0, 1 };
            var dw = new long[] { 0, -1, 1, 0 };
            for (var h = 0; h < H; ++h)
                for (var w = 0; w < W; ++w)
                {
                    if (ban[h][w] == '.') continue;
                    var cnt = 1;
                    for (var k = 0; k < 4; ++k)
                    {
                        var ch = h + dh[k];
                        var cw = w + dw[k];
                        if (ch < 0 || H <= ch || cw < 0 || W <= cw) continue;
                        if (ban[ch][cw] == '#') ++cnt;
                    }
                    if (1 == cnt)
                    {
                        WriteLine("No");
                        return;
                    }
                }
            WriteLine("Yes");
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27564
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int r;
  cin >> r;
  if(r < 1200) cout << "ABC" << endl;
  else if(1200 <= r && r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int N; cin >> N;
    VL A(N), B(N); REP(i,N) cin >> A[i] >> B[i];
    ll sum = 0; REP(i,N) sum += A[i];

    bool flag = true;
    REP(i,N){
        if(A[i] != B[i]){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << 0 << en;
        return;
    }

    ll b = LINF;
    REP(i,N) if(A[i] > B[i]) chmin(b, B[i]);

    ll ans = sum - b;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 310, M = 1010;

int n, m, d, k;
int g[N][N];
PII p[N * N];
vector<vector<LL>> h;

int main()
{
	scanf("%d%d%d", &n, &m, &d);
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
		{
			int x;
			scanf("%d", &x);
			g[i][j] = x;
			p[x] = {i, j};
		}
	p[0] = p[d];
	
	h.resize(d + 10);
	for (int i = 0; i < d; i ++ )
	{
		h[i].resize((n * m + d - 1) / d + 10);
		h[i][0] = 0;
		for (int j = 0; i + (j + 1) * d <= n * m; j ++ )
		{
			PII st = p[i + j * d], ed = p[i + (j + 1) * d];
			LL sum = abs(st.F - ed.F) + abs(st.S - ed.S);
			h[i][j + 1] = h[i][j] + sum;
		}
	}
	
	scanf("%d", &k);
	while (k -- )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		if (l == r) puts("0");
		else
		{
			int t = l % d;
			l /= d, r /= d;
			printf("%lld\n", h[t][r] - h[t][l]);
		}
	}
	return 0;
}

Measured memory_bytes: 12032
#--Count ABC

N = int(input())
S = list(input())

A_list = [i for i, x in enumerate(S) if x == 'A']
A_num = len(A_list)

k = 0
for j in range(A_num):
  if(A_list[j] < N-2):
    pp = A_list[j]
    if(S[pp+1]=="B" and S[pp+2]=="C"):
      k = k + 1
    else:
      pass
  else:
    pass

print(k)


Measured memory_bytes: 3060
s = input()
small = list("abcdefghijklmnopqrstuvwxyz")


if s[0] == "A" and s[2:-1].count("C") == 1:
	i = s.index("C")
	for j in range(1, len(s)):
		if j == i:
			continue
		else:
			if s[j] not in small:
				print("WA")
				break
	else:
		print("AC")
else:
	print("WA")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}
#define ll long long

using namespace std;

using pii = pair<int, int>;

ll M = 1000000007;
const ll facts_n = 200000;
ll facts[facts_n];

ll powmod(ll a, ll b){
  if(!b) return 1;
  if(b%2){
    ll d = powmod(a, b - 1);
    return (d * a) % M;
  }else{
    ll d = powmod(a, b / 2);
    return (d * d) % M;
  }
}

ll c(ll a, ll b){
  if(a == b || !a || !b) return 1;
  return facts[a] * powmod((facts[b] * facts[a - b] %M), M - 2) % M;
}

int main(){
  ll results = 1;
  FOR(i, 1, facts_n){
    results *= i;
    if(results >= M) results %= M;
    facts[i] = results;
  }

  int input(h);
  int input(w);
  int input(a);
  int input(b);

  int ha1 = h - a - 1;
  ll result = 0;
  rep(i, w - b){
    // p("%d %d %d", ha1, (w - 1) - i, ha1 + (w - 1) - i);
    // cout << c(ha1 + (w - 1) - i, ha1) << endl;
    // cout << c(a - 1 + i, a - 1) << endl;
    result += c(ha1 + (w - 1) - i, ha1) * c(a - 1 + i, a - 1) % M;
  }
  cout << result %M << endl;
}


Measured memory_bytes: 1792
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let w: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = vec![vec![0i64; w + 1]; n + 1];
    for i in 1..n + 1 {
        let wi: usize = read(&mut stdin_lock, &mut buf, b' ');
        let vi: i64 = read(&mut stdin_lock, &mut buf, b'\n');
        for j in 1..w + 1 {
            ans[i][j] = max(
                ans[i - 1][j],
                if j < wi { 0i64 } else { ans[i - 1][j - wi] + vi },
            );
        }
    }
    println!("{}", ans[n][w]);
}


Measured memory_bytes: 106748
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll MOD=998244353;

int main(){
  ll n,s;
  cin >> n >> s;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  vector<ll> dp(s+1,0);
  dp[0]=1;
  for(int i=1;i<=n;i++){
    for(int j=s;j>=0;j--){
      dp[j]=2*dp[j];
      if(j-a[i-1]>=0) dp[j]+=dp[j-a[i-1]];
      dp[j]%=MOD;
    }
  }
  cout << dp[s] << endl; 
}


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

using namespace std;

#define ll long long

ll dp[(int)1e5 + 1][26];

signed main() {
	string s, t;
	cin >> s >> t;

	// 答えが-1か判定する.
	// sにない文字がtに含まれているかをみればよい.
	bool alps[26];
	bool alpt[26];
	for (int i = 0; i < 26; ++i) {
		alps[i] = false;
		alpt[i] = false;
	}
	for (int i = 0; i < s.length(); ++i)
		alps[s[i] - 'a'] = true;
	for (int i = 0; i < t.length(); ++i)
		alpt[t[i] - 'a'] = true;
	for (int i = 0; i < 26; ++i) {
		if (alpt[i] && (!alps[i])) {
			cout << "-1\n";
			return 0;
		}
	}

	// st[i] : アルファベットiのインデックス
	set<int> st[26];
	for (int i = 0; i < s.length(); ++i) {
		st[s[i] - 'a'].insert(i);
	}
	for (int i = 0; i < 26; ++i)
		st[i].insert((int)1e8);

	//   dp[i][j] = 今sのインデックスiにいて、次に
	// アルファベットjが現れるのは何個後か
	for (int i = 0; i < s.length(); ++i) {
		for (int j = 0; j < 26; ++j) {
			int nind = *(st[j].lower_bound(i + 1));
			if (nind == (int)1e8)
				nind = *(st[j].begin()) + s.length();
			dp[i][j] = (ll)nind - i;
		}
	}

	ll ans = *(st[t[0] - 'a'].begin());
	int ind = ans;
	for (int i = 1; i < t.length(); ++i) {
		int nex = dp[ind][t[i] - 'a'];
		ans += nex;
		ind = (ind + nex) % s.length();
	}

	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 25600
#include<stdio.h>
int main()
{
    long long a,b,k,i,d,p,m[100000],j,temp=0,min;
    scanf("%lld %lld %lld",&a,&b,&k);
    d=b-a;
    p=0;
    if(k<d){
    while(k--)
    {
        // printf("%lld\n",a);
        //a++;
        m[p]=a++;
        //printf("%lld\n",b);
        //  b--;
        m[p+1]=b--;
        p=p+2;
    }
    min=m[0];
    for(i=0; i<p; i++)
    {
        // printf("%lld\n",m[i]);
        for(j=i+1; j<p; j++)
        {
            if(m[j]<m[i])
            {
                temp=m[i];
                m[i]=m[j];
                m[j]=temp;
            }
            if(m[j]==m[i])
            {
                   // printf("%lld\n",m[i]);
                    m[j]--;
                   p=p-1;
            }
        }
        printf("%lld\n",m[i]);

    }
    }
    else
    {
            for(i=a;i<=b;i++)
            {
                    printf("%lld\n",i);
            }
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long w = sc.nextLong();
		long h = sc.nextLong();
		long x = sc.nextLong();
		long y = sc.nextLong();
		
		double area = w * h / 2.0;
		int mlt = x * 2 == w && y * 2 == h ? 1 : 0;
		System.out.printf("%f %d\n", area, mlt);
		
		sc.close();
	}
}




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

#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

using namespace std;

void clear(int ar[]){
	for(int i=0;i<10;i++){
		ar[i]=0;
	}
}

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

	int h;
	int w;
	cin >> h >> w;
	char tu[h+1][w+1];
	char tiz[h][w];
	for(int i=0;i<h;i++){
		cin >> tiz[i];
	}
	for(int i=0;i<h+1;i++){
		for(int j=0;j<w+1;j++){
			if(i==0 || j==0)
				tu[i][j]='.';
			else{
				tu[i][j]=tiz[i-1][j-1];
			}
		}
	}
	/*for(int i=0;i<h+1;i++){
		for(int j=0;j<w+1;j++){
			cout << tu[i][j];
		}
		cout <<endl;
	}*/
	
	int dp[h+1][w+1];

	for(int i=0;i<h+1;i++){
		for(int j=0;j<w+1;j++){
			int up=10000;
			int left=10000;
			if(i>1)
				up=dp[i-1][j];
			if(j>1)
				left=dp[i][j-1];
			if(tu[i][j]=='#'){
				dp[i][j]=min(up+(tu[i-1][j]=='.')
					,left+(tu[i][j-1]=='.'));
			}
			else{
				dp[i][j]=min(up,left);
			}
			if(i<1||j<1||(i==1&&j==1))
				dp[i][j]=(tu[i][j]=='#');
		}
	}
	/*for(int i=0;i<h+1;i++){
		for(int j=0;j<w+1;j++){
			cout << dp[i][j];
		}
		cout <<endl;
	}*/
	cout << dp[h][w] << endl;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<String[]> list = new ArrayList<>();
		for (int i = 1; i <= n; i++) {
			String st = sc.next();
			String score = sc.next();
			String[] array = new String[3];
			array[0] = st;
			array[1] = score;
			array[2] = String.valueOf(i);
			list.add(array);
		}

		Collections.sort(
				list,
				new Comparator<String[]>() {
					@Override
					public int compare(String[] obj1, String[] obj2) {
						if(obj1[0].compareTo(obj2[0]) != 0) {
							return obj1[0].compareTo(obj2[0]);
						}else {
							return Integer.parseInt(obj2[1])-(Integer.parseInt(obj1[1]));
						}
					}
				});

		for(String[] st : list) {
			System.out.println(st[2]);
		}

	}

}


Measured memory_bytes: 21588
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
      P[b[j]-1] = 1 
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

Measured memory_bytes: 9148
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

#define equals(a, b) (fabs((a)-(b)) < EPS)
const double EPS = (1e-10);

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (double a) {
        return Point(x*a, y*a);
    }
    Point operator / (double a) {
        return Point(x/a, y/a);
    }

    double abs() {
        return sqrt(norm());
    }
    double norm() {
        return x*x + y*y;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;
// 内積
double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}
// 外積
double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

class Segment {
public:
    Point p1, p2;

    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};
typedef Segment Line;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;

    if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if (cross(a, b) < -EPS) return CLOCKWISE;
    if (dot(a, b) < -EPS) return ONLINE_BACK;
    if (a.norm() < b.norm()) return ONLINE_FRONT;

    return ON_SEGMENT;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
    return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 &&
            ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

int main(void) {
    int q; cin >> q;

    double x0, y0, x1, y1, x2, y2, x3, y3;
    for (int i = 0; i < q; i++) {
        cin >> x0 >> y0 >> x1 >> y1
            >> x2 >> y2 >> x3 >> y3;
        Segment s1(Point(x0, y0), Point(x1, y1));
        Segment s2(Point(x2, y2), Point(x3, y3));

        if (intersect(s1, s2)) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

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

int main() {
  int N;
  bool yorn = false;
  
  cin >> N;
  
  for(int i=0; i<=20; i++) {
    for(int j=0; j<=14; j++) {
      if(i*4+j*7 == N) {
        yorn = true;
        break;
      }
    }
  }
  
  if(yorn == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  ll ans=n*(n-1)/2+m*(m-1)/2;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
// #include <iomanip>
// #include <iterator> // inserter . setのintersection するとき．
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N; cin >> N;
vector<int64_t> a(N), b(N);
rep(i, 0, N) cin >> a[i];
rep(i, 0, N) cin >> b[i];
// 操作回数
int64_t diff = accumulate(ALL(b), 0LL) - accumulate(ALL(a), 0LL);
if (diff < 0){
    cout << "No\n";
    return 0;
}

int64_t cnt = 0;
rep(i, 0, N){
    if (a[i] > b[i]) cnt -= a[i] - b[i];
    else cnt += (b[i] - a[i]) / 2;
}

if (cnt >= 0) cout << "Yes\n";
else cout << "No\n";


}

// 境界，出力文字列 チェック



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

//#define DEBUG

#define INF ll_MAX
#define BEAMMAX 10

typedef long long ll;

using namespace std;

int main(void){
	int n,t;
	cin >> n >> t;
	int ans = 0;
	int finishtime = 0;
	int lasttt = 0;
	for(int i = 0;i < n;i++){
		int tt;
		cin >> tt;
		if(finishtime <= tt){
			finishtime = tt + t;
			ans += t;
		}else{
			finishtime = tt + t;
			ans += tt - lasttt;
		}
		lasttt = tt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

n = int(input())

c_ac = 0
c_wa = 0
c_tle = 0
c_re = 0

for i in range(n):
    x = input()
    if x == 'AC':
        c_ac += 1
    elif x == 'WA':
        c_wa += 1
    elif x == 'TLE':
        c_tle += 1
    else:
        c_re += 1

print('AC x ' + str(c_ac))
print('WA x ' + str(c_wa))
print('TLE x ' + str(c_tle))
print('RE x ' + str(c_re))



Measured memory_bytes: 9204
X, K, D = map(int, input().split())

now = abs(X)
rest = K

step1 = min(now//D, K)
rest -= step1
now -= step1 * D

if rest <= 0:
    print(abs(now))
else:
    if rest % 2 == 1:
        now = abs(now - D)
        print(now)
    else:
        print(now)

Measured memory_bytes: 61764
from collections import deque
S = input()
L = deque()
L.append(S)
Q = int(input())
is_lookforward = True
for i in range(Q):
    query = input()
    if query[0] == '1':
        is_lookforward = not is_lookforward
    else:
        F = int(query[2])
        C = query[4]
        if (F == 1 and is_lookforward) or (F == 2 and not is_lookforward):
            L.appendleft(C)

        else:
            L.append(C)
ans = ''.join(L)
print(ans if is_lookforward else ans[::-1])


Measured memory_bytes: 7028
N,K = map(int,raw_input().split())

ab_list=[]

count = 0
for i in range(N):
    a,b = map(int,raw_input().split())
    ab_list.append([a,b])
    
ab_list = sorted(ab_list,key=lambda ab:ab[0])

for i in range(N):
    count+=ab_list[i][1]
    if count>=K:
        print ab_list[i][0]
        break



Measured memory_bytes: 25076
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N; cin >> N;
	vector<int> A(N), B(N), AB(N);
	ll X = 0;
	rep(i, N) {
		cin >> A[i] >> B[i];
		X -= B[i];
		AB[i] = A[i] + B[i];
	}
	sort(AB.rbegin(), AB.rend());
	rep(i, N) if (i % 2 == 0)X += AB[i];
	cout << X << endl;
	cin >> N;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, 0, h) cin >> s[i];
    vector<vector<int>> dist(h, vector<int> (w, INF));
    queue<P> q;
    int count = 0;
    int cnt = 0;
    rep(i, 0, h) rep(j, 0, w){
        if(s[i][j] == '#'){
            cnt++;
        }
    }
    auto update = [&](int i, int j, int x){
        if(dist[i][j] != INF) return;
        dist[i][j] = x;
        q.push(P(i, j));
    };
    update(0, 0, 0);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second; q.pop();
        rep(dir, 0, 4){
            int ni = i + di[dir], nj = j + dj[dir];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            update(ni, nj, dist[i][j]+1);
        }
    }
    count = dist[h-1][w-1];
    if(count == INF){
        cout << -1 << endl;
        return 0;
    }
    cout << h*w - cnt - count - 1 << endl;
    return 0;
}


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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 21;

ll n, a[N][N], dp[N][1 << N];

ll solve(int i, int mask) {
    if (i == n)
        return 1;
    ll& ret = dp[i][mask];
    if (~ret)
        return ret;
    ret = 0;
    for (int j = 0; j < n; ++j) 
        if (!(mask & (1 << j)) && a[i][j])
            (ret += solve(i + 1, mask | (1 << j))) %= MOD;
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];

    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;
}

Measured memory_bytes: 344320
/*
    Mbak Sana Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<int> vi;
int sana[1000010];
int main()
{
    int n,m,i,j,k,x,y,ans,curr,temp;
    cin >> n;
    for(i=100;i<=105;i++) vi.push_back(i);
    sana[0] = 1;
    for(auto x : vi)
    {
        for(i=x;i<=n;i++)
        {
            sana[i] |= sana[i-x];
        }
    }
    if(sana[n]) cout << "1";
    else cout << "0";
    cout << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n,k;
string s;

ll cul(ll a){
    if(a==0){return 0;}
    a--;
    ll ret=1;
    if(s[0]){ret++;}
    if(a==0){return ret;}
    ret+=a;
    for(ll i=1;i<n && i<=a;i++){
        if(s[i]^(i&1)){ret++;}
    }
    if(a>=n && n&1){ret+=a-n+1;}
    return ret;
}


int main(){
    cin>>n>>k;
    cin>>s;
    for(auto &I:s){I=(I=='A'?1:0);}
    ll l=0,r=MOD;
    while(r-l>3){
        ll m=l+(r-l)/2;
        if(cul(m)<=k){l=m;}
        else{r=m;}
    }
    ll cnt=-1;
    ll w=-1;
    for(ll i=r;i>=l;i--){
        if((w=cul(i))<=k){cnt=i; break;}
    }
    string ans=s;
    for(ll i=n-1;i>=0;i--){
        if(cnt!=0){
            if(cnt>=n-i){ans[i]=(n-i)&1;}
            else{ans[i]=s[i+cnt]^(cnt&1);}
        }
    }
    //cout<<cnt<<" "<<w<<endl;
    k-=w;
    if(k){ans[0]=0;}
    for(auto &I:ans){I=(I==0?'B':'A');}
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  for(int i = 0; i < S.size(); i++){
    char tmpC = S[i];
    int tmpI = (int)(unsigned char)tmpC;
    tmpI += N;
    if(tmpI > 90) tmpI = tmpI % 90 + 64;
    cout << (char)tmpI;
  }
  cout << endl;
}


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

int main() {
  int X, N; cin >> X >> N;
  map<int, int> list;

  for (int i = 0; i < N; i++) {
    int p; cin >> p;
    list[p]++;
  }

  int j = 0;
  while (true) {
    if (list[X - j] == 0) {
      cout << X - j << endl;
      return 0;
    } else if (list[X + j] == 0) {
      cout << X + j << endl;
      return 0;
    }

    j++;
  }
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200010


int main() {
	char a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	n = strlen(a);

	f(i, n) {
		if (a[i] == '?')a[i] = 'D';


	}
	printf("%s\n", a);


	return 0;
}

Measured memory_bytes: 1844
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int result = 0;
  for (int i = 1; i <= N; ++i) {
    int c = 0;
    for (int j = i; j > 0; j /= 10) {
      ++c;
    }
    result += (c & 1);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val ans = Iterator.continually(io.StdIn.readLine.split(" "))
    .take(n)
    .foldLeft((0,0,0,true))((pre,cur) => {
      val t = cur(0).toInt
      val x = cur(1).toInt
      val y = cur(2).toInt
      val dt = t - pre._1.toInt
      val dist = (x - pre._2.toInt).abs +
                (y - pre._3.toInt).abs
      (t,x,y,pre._4 && dt >= dist && (dist&1) == (dt&1))
      })

  println(if(ans._4) "Yes" else "No")
}

Measured memory_bytes: 43720
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string c;

int main() {
	cin >> c;
	c += c[0] + 1;
	cout << c[1] << endl;
	return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

class Point{
private:
    double x;
    double y;
public:
    void setPoint(double inX, double inY){x = inX; y = inY;};
    void disp(){printf("%.12f %.12f\n", x,y);}
    double length(){return x*x + y*y;};
    double cross(Point Q){return x*Q.y - Q.x*y;};
    double dot(Point Q){return x*Q.x + y*Q.y;};
};


//??????????????????2????????????????????¨????????±???
//P = P2-P1, Q = P - P1
void judge(Point P, Point Q){
    double Cval = P.cross(Q);
    if(Cval > 0) cout << "COUNTER_CLOCKWISE" << endl;
    else{
        if(Cval < 0) cout << "CLOCKWISE" << endl;
        else{
            double Dval = P.dot(Q);
            if(Dval < 0) cout << "ONLINE_BACK" << endl;
            else{
                if(P.length() >= Q.length()) cout << "ON_SEGMENT" << endl;
                else cout << "ONLINE_FRONT" << endl;
            }
        }
    }
}




int main(){
    int n;
    double a,b,c,d;
    Point P, Q;
    cin >> a >> b >> c >> d;
    P.setPoint(c-a, d-b);
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> c >> d;
        Q.setPoint(c-a, d-b);
        judge(P,Q);
    }
    return 0;
}

Measured memory_bytes: 1220
import itertools
s = input()

ans = [0]
si = itertools.groupby(s)
for key, value in si:
    l = len(list(value))

    if key == "<":
        for i in range(1, l+1):
            ans.append(i)
    else:
        if ans[-1] < l:
            ans.pop()
            for i in range(1, l+1):
                ans.append(i)
        else:
            for i in range(1, l):
                ans.append(i)

print(sum(ans))


Measured memory_bytes: 27076
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

struct TWO {
	long long int a, b;
};

bool cmp(TWO x, TWO y) {
	return x.a < y.a;
}

//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
	long long int tmp;
	long long int r = 1;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0) {


		a = b;
		b = r;
		r = a % b;

	}
	return b;
}


int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007,INF=100000000000000;
	map<long long int, long long int>mp;
	string str,str2;
	cout << fixed << setprecision(10);
	long long int n, m, h, w, res = 0, num[200] = {};
	TWO two[200001];
	cin >>str;
	num[str[0]]++;
	num[str[1]]++;
	num[str[2]]++;
	num[str[3]]++;
	if (num[str[0]] == 2 && num[str[1]] == 2 && num[str[2]] == 2 && num[str[3]] == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
} 


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

int main(){
  string S;
  cin >> S;
  vector<bool> ans(4,false);
  for (int i = 0; i < S.size(); i++){
    if (S.at(i) == 'N'){
      ans.at(0) = true;
    }
    if (S.at(i) == 'W'){
      ans.at(1) = true;
    }
    if (S.at(i) == 'S'){
      ans.at(2) = true;
    }
    if (S.at(i) == 'E'){
      ans.at(3) = true;
    }
  }
  if (ans.at(0) && ans.at(2) && !(ans.at(1)) && !(ans.at(3))){
    cout << "Yes" << endl;
  }
  else if (ans.at(1) && ans.at(3) && !(ans.at(0)) && !(ans.at(2))){
    cout << "Yes" << endl;
  }
  else if (ans.at(0) && ans.at(1) && ans.at(2) && ans.at(3)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define s scanf
#define p printf

using namespace std;

ll getSumofDigit(ll num)
{
    if(num==0)
        return 0;
    return num%10+getSumofDigit(num/10);
}

int main()
{
    ll N,A,B,sum=0;
    s("%lld%lld%lld",&N,&A,&B);
    for(ll i=1; i<=N; i++)
    {
        ll k=getSumofDigit(i);
        //p("%lld\t",k);
        if(k>=A && k<=B)
            sum=sum+i;
            //p("%lld\t",sum);
    }
    p("%lld\n",sum);

}


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

int main(){
    int A,B,H,M;
    cin >> A>>B>>H>>M;

    long double argm = 6*M;
    long double argh = 30*H+0.5*M;
    long double arg = abs(argm-argh);
    long double X = A*A+B*B-2*A*B*cos(arg/180*pi);
    X = sqrt(X);
    cout << fixed << setprecision(9)<< X<<endl;
}

Measured memory_bytes: 4160
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<b){
		if(b<c){
			cout<<"Yes"<<endl;
		}
	else{
		cout<<"No"<<endl;
	}
	}else{
		cout<<"No"<<endl;
	}
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int A, B, C;
    A = 1;
    B = 1;
    C = 1;
    
    int sum = 0;

    for(int a = 1; a <= N; a++){
        for(int b = 1; b <= N; b++){
            for(int c = 1; c <= N; c++){
                int min = std::min(std::min(a, b), c);
                for(int i = min; i >= 1; i--){
                    if(a % i == 0 && b % i == 0 && c % i == 0) {
                        sum += i;
                        break;
                    }
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
s = input()
l = 0
r = len(s)-1
ans = 0
while l < r:
    while (s[l] == 'x' or s[r] == 'x') and l < r:
        if s[l] != s[r]:
            ans += 1
        if s[l] == 'x':
            l += 1
        if s[r] == 'x':
            r -= 1
    if s[l] != s[r]:
        break
    l += 1
    r -= 1
else:
    print(ans)
    exit()
print(-1)


Measured memory_bytes: 40944
s=list(input())
for i in range(4):
  s[i]=int(s[i])
op=['+','-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      cnt=s[0]
      if i==0:
        cnt+=s[1]
      else:
        cnt-=s[1]
      if j==0:
        cnt+=s[2]
      else:
        cnt-=s[2]
      if k==0:
        cnt+=s[3]
      else:
        cnt-=s[3]
      if cnt==7:
        print(str(s[0])+op[i]+str(s[1])+op[j]+str(s[2])+op[k]+str(s[3])+'=7')
        exit()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    REP(i,s.length())cout << "x";
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
A= 'a'
n = int(input())
# 二つのリストを独立に動かす.
# max('ab') は文字列のアルファベット順での最大値
for _ in range(n - 1):
    # max(a)の次のアルファベットを追加してsorted　で辞書順に
    A = [a + s for a in A for s in sorted(set(a + chr(ord(max(a))+1))) ]
print(*A, sep = '\n')

Measured memory_bytes: 14776