akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
        ll x;
        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*(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;
        }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
vector<mint> a;
int N;
/* function */
void input() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        int b; cin >> b;
        a[i] = b;
    }
}
void solve1() {
    vector<mint> sum(N+1);
    sum[0] = 0;
    for (int i = 0; i < N; i++) {
        sum[i+1] += sum[i] + a[i];
    }

    mint ans = 0;
    for (int i = 0; i < N-1; i++) {
        ans += a[i] * (sum[N] - sum[i+1]);
    }
    cout << ans << '\n';
}
void solve2() {
    // ex a = {3, 1, 4}
    //   | 1 | 2 | 3
    //  1| 9 | 3 | 12
    //  2| 3 | 1 | 4
    //  3| 12| 4 | 16
    // ans = (3 + 4 + 12) * 2 + (9 + 1 + 16)
    // ans = (\sigma ai) * 2 - (\sigma (ai ** 2)) * (1/2)
    mint ans = 0;
    mint sum1 = 0;
    mint sum2 = 0;
    for (int i = 0; i < N; i++) {
        sum1 += a[i];
        sum2 += a[i] * a[i];
    }
    ans += sum1 * sum1 - sum2;
    ans /= 2;
    cout << ans << '\n';
}
/* main */
int main(){
    input();
    // solve1();
    solve2();
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<char> d(k);
    for (auto& e : d) cin >> e;

    for (int i = n; i < 1e5; i++) {
        string ns = to_string(i);
        sort(begin(ns), end(ns));
        string tmp;
        set_intersection(begin(ns), end(ns), begin(d), end(d), back_inserter(tmp));
        if ((int) tmp.size() == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;
 
tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderset;
 
const int N=2e5+5;
 
 
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long double x,y,a,b;
    cin>>x>>y>>a>>b;
    long double de=(a*30+b/2)-b*6;
    if(de<0)de=-de;
    long double val=cos(de*3.14159265359/180.0);
    long double res=sqrt(x*x+y*y-2*x*y*val);
    cout<<fixed<<setprecision(10)<<res;
}

Measured memory_bytes: 4192
import java.util.Scanner;

class Stack {

	int top;
	int[] stack;
	int size;

	public Stack(int size) {
		top = -1;
		stack = new int[size];
		this.size = size;
	}


	public void push(int value) {
		stack[++top] = value;
	}

	public int pop() {
		System.out.println(stack[top]);
		return stack[top--];
	}

}

public class Main {


	public static void main(String args[]) {
		int number;

		Stack st = new Stack(10);

		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()) {

			number = sc.nextInt();

			if(number != 0) {
				st.push(number);
			}

			else {
				st.pop();
			}

		}

	}

}

Measured memory_bytes: 26008
#include <stdio.h>
#include <math.h>

int main(void){
  double x1, x2, y1, y2;
  double x_def, y_def;
  double len;
  
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

  x_def = (x1 >= x2) ? (x1 - x2) : (x2 - x1);
  y_def = (y1 >= y2) ? (y1 - y2) : (y2 - y1);
  
  len = x_def * x_def + y_def * y_def;

  printf("%f\n", sqrt(len));
  
  return 0;
}


Measured memory_bytes: 2104
input = readlines()
n = input.shift.chomp.to_i
s = input.shift.chomp

cnt = 0
list = s.split('')
list.each_with_index do |c, i|
  if c == 'C' && i >= 2
    cnt += 1 if s[i - 1] == 'B' && s[i - 2] == 'A'
  end
end

puts cnt

Measured memory_bytes: 14380
from collections import deque
n, m = map(int, input().split())

adjacent_list = [[] for _ in range(n + 1)]

for i in range(m):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)

signs = [-1 for _ in range(n + 1)]

que = deque()
que.append(1)

while que:
    node = que.popleft()
    for i in adjacent_list[node]:
        if signs[i] == -1:
            que.append(i)
            signs[i] = node


print('Yes')
for i in range(2, n + 1):
    print(signs[i])

Measured memory_bytes: 33988
import math
a , b , x = map(int,input().split())
if x >= a*a*b/2:
  t = 2*b - (2*x/(a*a))
  print(math.degrees(math.atan(t/a)))
else:
  t = 2*x/(a*b)
  print(math.degrees(math.atan(b/t)))

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

using namespace std;

const int MAX_N = 200010;
int N, M;
vector <int> adj[MAX_N];
int visited[MAX_N];

int dfs(int v) {
	visited[v] = true;
	int ans = 1;
	for (int i = 0; i < (int)adj[v].size(); i++) {
		if (!visited[adj[v][i]]) {
			ans += dfs(adj[v][i]);
		}
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> M;
	
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (visited[i]) continue;
		ans = max(ans, dfs(i));
	}
	
	cout << ans << "\n";
	
	return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int H, N;
	cin >> H >> N;
	ll sum = 0;
	fx(N) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum>=H) {
		cey
	}
	else {
		cen
	}
    return 0;
}



Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = [True if int(input())%2==0 else False for _ in range(N)]

if all(As):
    print('second')
else:
    print('first')


Measured memory_bytes: 77620
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int a;
  cin >> a;
  if (a%2 == 0) cout << (a/2)*(a/2) << endl;
  else cout << (a/2)*(a/2 + 1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
bool f[300001];
int main(){
    vector<int>ms;
    fill_n(f,300001,true);
    f[0]=f[1]=false;
    for(int i=2;i<300001;i++){
        if(!f[i])continue;
        if(i%7!=1&&i%7!=6){
            f[i]=false;
            continue;
        }
        for(int j=i+i;j<300001;j+=i)f[j]=false;
        ms.push_back(i);
    }

    int n;
    while(cin>>n,n!=1){
        cout<<n<<":";
        for(int i=0;i<ms.size();i++){
            if(n%ms[i])continue;
            cout<<" "<<ms[i];
        }
        cout<<endl;
    }

    return 0;
}

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

using namespace std;

int otsuri(int yen){
    int tmp=yen,res=0,t;
    t=tmp/500;tmp-=t*500;res+=t;
    t=tmp/100;tmp-=t*100;res+=t;
    t=tmp/50;tmp-=t*50;res+=t;
    res+=tmp/10;
    return res;
}

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

  int sum;
  bool flag=false;
  while(true){
      cin>>sum;
      if(sum==0) break;
      if(flag) cout<<endl;
      flag=true;
      int coin[4]={};
      for(int i=0;i<4;i++){
          int k;cin>>k;
          coin[i]=k;
      }
      int mi=1e8,name[4]={10,50,100,500},ma[4]={};
      for(int i=0;i<=coin[0];i++){
          for(int j=0;j<=coin[1];j++){
              for(int k=0;k<=coin[2];k++){
                  for(int l=0;l<=coin[3];l++){
                      if(i*10+j*50+k*100+l*500>=sum){
                          if(otsuri(-sum+i*10+j*50+k*100+l*500)+(coin[0]-i+coin[1]-j+coin[2]-k+coin[3]-l)<mi){
                              mi=otsuri(-sum+i*10+j*50+k*100+l*500)+(coin[0]-i+coin[1]-j+coin[2]-k+coin[3]-l);
                              ma[0]=i;ma[1]=j;ma[2]=k;ma[3]=l;
                          }
                      }
                  }
              }
          }
      }
      for(int i=0;i<4;i++){
          if(ma[i]){
              cout<<name[i]<<" "<<ma[i]<<endl;
          }
      }
  }
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
/**
(k, i) * (i, j) => n (k, j)
(i, j) * (j, k) => n (i, k)

**/
const int mod = 1000000007;
const int maxn = 3030;
int p[maxn][maxn], a[maxn];
int mul(long long a, long long b){
	return a * b % mod;
}
int add(int a, int b){
	a += b; if(a >= mod) a -= mod;
	return a;
}
int xp(int a, int b){
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
int inv(int x){
	return xp(x, mod - 2);
}
int main(){
	int n, q; cin >> n >> q;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) p[i][j] = a[i] > a[j];
	int p2q = xp(2, q);
	int iq = inv(p2q);
	for(int i = 0; i < q; i++){
		int x, y; cin >> x >> y; x--; y--;
		for(int j = 0; j < n; j++){
			if(j == x || j == y) continue;
			int tmp;
			tmp = mul(add(p[j][x], p[j][y]), (mod + 1)/2);
			p[j][x] = p[j][y] = tmp;
			tmp = mul(add(p[x][j], p[y][j]), (mod + 1)/2);
			p[x][j] = p[y][j] = tmp;
		}
		int pxy = p[x][y], pyx = p[y][x];
		p[x][y] = mul(add(pxy, pyx), (mod + 1)/2);
		p[y][x] = mul(add(pyx, pxy), (mod + 1)/2);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) ans = add(ans, p[i][j]);
	cout << mul(ans, p2q) << endl;
	return 0;
}


Measured memory_bytes: 35840
#include <iostream>
using namespace std;
const int N = 1e9 + 10;
int main(){
	int n;
	while(cin >> n){
		long long m = 0;
		for(int i = 1; i <= n - 1; i++){
			m += i;
		}
		cout << m << endl;
		
	}
	return 0;
}

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


#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define mp  make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a; i<=b;i++)
#define F first 
#define S second
#define ccM 1000000007

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int32_t main()
{
	fastio;
    ios::sync_with_stdio(0);
 #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
 #endif

  int n;
  cin >> n;
  int ans=n/500*1000;
  ans+=n%500/5*5;
  cout << ans << endl;
  return 0;
}


    


Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>
#include <vector>
#define ll long long
#define NUM 200010

using namespace std;

int main(void){
    vector<long long> v;
    ll N;
    scanf("%lld", &N);

    ll sum = 0;
    for(ll i = 0; i < N; i++){
        ll A;
        scanf("%lld", &A);
        sum += A;
        v.push_back(A - (i + 1) + N);
    }

    sort(v.begin(), v.end());

    ll sum1 = 0;
    ll sum2 = 0;

    ll middle1 = N / 2 - 1;
    ll middle2 = N / 2;

    for(int i = 0; i < N; i++){
        sum1 += abs(v[i] - v[middle1]);
        sum2 += abs(v[i] - v[middle2]);
    }

    printf("%lld\n", min(sum1, sum2));

}


Measured memory_bytes: 2420
#include<iostream>
#include<iomanip>
#include<vector>
#include<complex>
#include<map>
#include<stack>

#define EQ(a,b) abs((a)-(b))<EPS
using namespace std;
typedef long double D;

const D EPS = 1e-10;
const int MAX_N = 1e5 + 10;

int n;
D t,s[MAX_N],p[MAX_N],q[MAX_N],th[MAX_N];

D calc(D x){
  D res = t*x;

  for(int i=0;i<n;i++){
    D rem = (th[i]-s[i]*x);
    if(rem>0)res += (th[i]-s[i]*x)/q[i]*p[i];
  }
  return res;
}

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

  while(cin >> n){
    if(n==0)return 0;
    cin >> t;
    for(int i=0;i<n;i++)cin >> s[i] >> p[i] >> q[i] >> th[i];

    D l = 0, r = 10000;
    for(int azu=0;azu<500;azu++){
      D m1 = (2*l+r)/3, m2 = (l+2*r)/3;
      if(calc(m1) < calc(m2))r = m2;
      else l = m1;
    }
    cout << fixed << setprecision(10) << calc(l) << endl;
  }
}

Measured memory_bytes: 7544
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

// 解説を読んだ
const lint mo=998244353;
const int N=1000000;
lint fact[N],invfact[N];
lint powmod(lint x,lint y){
  lint ans=1;
  for(int i=63;i>=0;--i){
    ans=ans*ans%mo;
    if(y&1LL<<i)ans=ans*x%mo;
  }
  return ans;
}

lint comb(int x,int y){
  if(y<0||y>x)return 0;
  return fact[x]*(invfact[y]*invfact[x-y]%mo)%mo;
}

lint catalan(int r,int b,int lim){
  if(b-r>lim)return 0;
  if(lim<0)return 0;
  return (comb(r+b,b)-comb(r+b,r+lim+1)+mo)%mo;
}

int main(){
  fact[0]=1;
  for(int i=1;i<N;++i)fact[i]=fact[i-1]*i%mo;
  invfact[N-1]=powmod(fact[N-1],mo-2);
  for(int i=N-2;i>=0;--i)invfact[i]=invfact[i+1]*(i+1)%mo;
  int n,k;
  cin>>n>>k;
  lint ans=0;
  for(int b=0;b<=k;++b){
    int r=k-b;
    if(r<b)continue;
    if(r==b)ans+=catalan(r,b-1,r-n);
    if(r>b)ans+=catalan(r,b,r-n);
    ans%=mo;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 15872
N, M = map(int, input().split())
arr = [input().split() for i in range(M)]
s = [[0,0] for i in range(N)]
p = 0
a = 0
for i, j in arr:
    if j == 'AC':
        s[int(i)-1][0] = 1
    elif j == 'WA':
        if s[int(i)-1][0] == 1: # if done
            pass
        else:
            s[int(i)-1][1] += 1
for i, j in s:
    if i == 1:
        p += j
        a += 1
print(a, p)


Measured memory_bytes: 42368
/**
 *    created by : PawPaw       
**/

#include<bits/stdc++.h>
using namespace std;

#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)

int solve(){
  int r;
  cin >> r;
  cout << r*r << '\n';
  return 0;
}

void fun(){
  int t = 1;
  // cin >> t;
  while(t--) solve();
} 

int main(){
  ios::sync_with_stdio(false); 
  cin.tie(0);
  // #ifndef ONLINE_JUDGE
  //   freopen("fi", "r", stdin);
  //   freopen("fo", "w", stdout);
  //   clock_t startClock, endClock;
  //   startClock = clock();
  // #endif

  fun();

  // #ifndef ONLINE_JUDGE
  //   endClock = clock(); 
  //   cout << "Time taken by program is : " << fixed <<  double(endClock - startClock) / double(CLOCKS_PER_SEC) << setprecision(5) << " sec " << endl; 
  // #endif
  
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ARainySeason {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;
        if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
            out << 3 << endl;
        }else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R')){
            out << 2 << endl;
        }else if(s[0]=='R'||s[1]=='R'||s[2]=='R'){
            out << 1 << endl;
        }else{
            out << 0 << endl;
        }
	}
};


int main() {
	ARainySeason solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import java.math.*;
import java.io.BufferedInputStream;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    String s = sc.next();
    int n = s.length();
    int[][] dp = new int[n][2];
    dp[0][0] = s.charAt(n - 1) - '0';
    int plus = 0;
    if(dp[0][0] == 0) {
      dp[0][1] = 0;
    } else {
      dp[0][1] = 10 - dp[0][0];
      plus = 1;
    }
    for(int i = 1; i < n; ++i) {
      int now = s.charAt(n - 1 - i) - '0';
      dp[i][0] = Math.min(dp[i - 1][0], dp[i - 1][1] + 1) + now;
      if(now == 0) {
        dp[i][1] = Math.min(dp[i - 1][0], dp[i - 1][1] + plus);
        plus = 0;
      } else {
        dp[i][1] = Math.min(dp[i - 1][0] + 10 - now, dp[i - 1][1] + 10 - now - plus);
        plus = 1;
      }
    }        
    System.out.println(Math.min(dp[n - 1][0], dp[n - 1][1] + 1));
  }
}
    


Measured memory_bytes: 73536
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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


    const ll MOD = 1e9 + 7;
    int N;  cin >> N;

    auto dp = vector<map<string, ll>>(N + 1);
    char C[4] = { 'A','G', 'C', 'T' };
    for(char c1 : C) {
        for(char c2 : C) {
            for(char c3 : C) {
                string last3 = { c1,c2,c3 };
                if (last3=="AGC" || last3=="GAC" || last3=="ACG") {
                    dp[3][last3] = 0;
                } else {
                    dp[3][last3] += 1;
                }
            }
        }
    }

    FOR(i, 3, N) {
        for (auto p : dp[i]) {
            string s = p.first;

            for(char c : C) {
                string ns = s.substr(1, 2) + c;
                if (ns == "AGC" || ns == "GAC" || ns == "ACG" 
                    || (s[0]=='A' && s[2]=='G' && c=='C')
                    || (s[0]=='A' && s[1]=='G' && c=='C')) {
                    continue;
                }

                dp[i + 1][ns] += dp[i][s];
                dp[i + 1][ns] %= MOD;
            }
        }
    }

    ll ans = 0;
    for(auto p : dp[N]) {
        ans += p.second;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b = sc.nextInt();
        int count = 1;
        int ans = 0;
        while(count<b){
            ans ++;
            count += (a-1);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
# Problem https://atcoder.jp/contests/abc086/tasks/abc086_a
# Python 2nd try
yes = "Odd"
no = "Even"
if __name__ == "__main__":
    a,b =  map(int,input().split(' '))
    answer = ""
    check = (a*b)%2
    if check == 1:
        answer = yes
    else:
        answer = no
    print(answer)

Measured memory_bytes: 2940
#include <iostream>
#include <set>

int main()
{	
	std::set<int> S;
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int op, x;
		std::cin >> op >> x;
		if (op==0) {
			S.insert(x);
			std::cout << S.size() << std::endl;
		}
		else {
			if (S.find(x) != S.end()) std::cout << 1 << std::endl;
			else std::cout << 0 << std::endl;
		}
	}
	
	return 0;
}



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

const int MOD = (int)1e9+7;

int main(){
	double N;
	cin >> N;
	double a=0;
	for(int i=1;i<=N;i++)	if(i%2==1)	a++;
	printf("%.8lf\n",a/N);

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(all(p));
  int ans = 0;
  rep(i, n) {
    int f = p[i].first;
    int s = p[i].second;
    if (m - s > 0) {
      ans += f * s;
      m -= s;
    } else {
      ans += m * f;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	int n; cin >> n;
	vint a(n);
	int b=0;
	rep(i, n) {
		cin >> a[i];
		b ^= a[i];
	}

	rep(i, n) {
		cout << (b^a[i]) << endl;
	}
	return 0;
}


Measured memory_bytes: 3992
import sys

def gcd(x, y, *val):
    val = sorted([x, y], reverse=True) + list(val)
    count = len(val)

    if count == 2:
        if val[1] == 0:
            return val[0]

        mod = val[0] % val[1]
        if mod == 0:
            return val[1]
        elif mod == 1:
            return 1
        else:
            return gcd(val[1], mod)
    else:
        if count % 2 == 1:
            val.append(val[-1])

        return gcd(*[gcd(val[i], val[i + 1]) for i in range(0, count, 2)])
        

def main():
    sinputl = sys.stdin.readline

    num = int(sinputl().strip())
    input = [int(x) for x in sinputl().split()]

    gcd_max = 1
    input_mem = []

    if num == 2:
        print(max(input))
        return

    gcd_left = [0]
    gcd_right = [0]

    for i in range(num - 1):
        gcd_left.append(gcd(input[i], gcd_left[i]))
        gcd_right.append(gcd(input[-1 - i], gcd_right[i]))

    gcd_right.reverse()
    gcd_list = []

    for i in range(num):
        gcd_list.append(gcd(gcd_left[i], gcd_right[i]))

    print(max(gcd_list))



if __name__ == "__main__":
    main()

Measured memory_bytes: 14136
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

#ifdef _WIN32
#define scanfll(x) scanf("%I64d", x)
#define printfll(x) printf("%I64d", x)
#else
#define scanfll(x) scanf("%lld", x)
#define printfll(x) printf("%lld", x)
#endif
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
void printbits(ll mask, ll n) { rep(i, n) { cout << !!(mask & (1ll << i)); } cout << endl; }
#define ldout fixed << setprecision(40) 

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n = 3;
    vll a(n); rep(i, a.size()) cin >> a[i];
    sort(all(a));
    if (a[2] % 2 == 1) 
        cout << a[0] * a[1] << endl;
    else 
        cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	var s1 int
	var s2 int
	min := math.Inf(1)
	for t := 1; t <= n; t++ {
		s1 = 0
		s2 = 0
		for i, w := range slice {
			if i <= t {
				s1 += w
			}
			if t < i {
				s2 += w
			}
		}
		abs := math.Abs(float64(s1) - float64(s2))
		if min > abs {
			min = abs
		}
	}

	fmt.Println(int64(min))
}


Measured memory_bytes: 640
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
vpll vc;
int main(){
	int X,Y,A,B,C;
	scan(X>>Y>>A>>B>>C);
	rep(i,A){
		ll v;
		scan(v);
		vc.push_back({v,0});
	}
	rep(i,B){
		ll v;
		scan(v);
		vc.push_back({v,1});
	}
	rep(i,C){
		ll v;
		scan(v);
		vc.push_back({v,2});
	}
	ll sum=0;
	sort(rALL(vc));
	int cnt[3]={};
	rep(i,vc.size()){
		if((vc[i].second==0&&cnt[0]==X)||(vc[i].second==1&&cnt[1]==Y)) continue;
		sum+=vc[i].first;
		cnt[vc[i].second]++;
		if(cnt[0]+cnt[1]+cnt[2]==X+Y){
			prin(sum);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 11608
#include <stdio.h>
int main(){
 
  int d1[6],d2[6],i,j,blank;
 
  for(i = 0; i < 6; i++){
 
    scanf("%d",&d1[i]);
     
  }
   
  for(i = 0; i < 6; i++){
     
    scanf("%d",&d2[i]);
     
  }
 
  for(i = 0; d1[1] != d2[1] && i < 3; i++){
     
    //3S
    blank=d2[0];
    d2[0]=d2[4];
    d2[4]=d2[5];
    d2[5]=d2[1];
    d2[1]=blank;
     
  }
   
  if(d1[1] != d2[1]){
     
    //1E
    blank=d2[0];
    d2[0]=d2[3];
    d2[3]=d2[5];
    d2[5]=d2[2];
    d2[2]=blank;
 
    for(i = 0; d1[1] != d2[1] && i < 3; i++){
 
      //3S
      blank=d2[0];
      d2[0]=d2[4];
      d2[4]=d2[5];
      d2[5]=d2[1];
      d2[1]=blank;
 
    }
 
  }
 
  if(d1[1] != d2[1]){
 
    printf("No\n");
 
    return 0;
 
  }
   
  for(i = 0; d1[0] != d2[0]; i++){
     
    //3E
    blank=d2[0];
    d2[0]=d2[3];
    d2[3]=d2[5];
    d2[5]=d2[2];
    d2[2]=blank;
 
  }
 
  if(d1[0] != d2[0]){
     
    printf("No\n");
     
    return 0;
     
  }
 
  if(d1[2] == d2[2] && d1[3] == d2[3] && d1[4] == d2[4] && d1[5] == d2[5]){
 
    printf("Yes\n");
 
  } else {
 
    printf("No\n");
 
  }
 
  return 0;
 
}


Measured memory_bytes: 2148
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] A = new int[M];
        int sum = 0;
        int sumr = 0;
        for(int i = 0; i < M; i++){
            A[i] = sc.nextInt();
            sum++;
            if(A[i] < X)
                sumr++;
        }
        sc.close();
        System.out.println(Math.min(sum-sumr, sumr));
   }
}

Measured memory_bytes: 21588
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int h,w,n;
int f[1111][1111];
int m[1111][1111];
int dx[] = {0,1};
int dy[] = {1,0};
int main(void){
  while(cin >> h >> w >> n && h){
    memset(m,0,sizeof(m));
    m[0][0] = n-1;
    for(int y = 0; y < h; y++){
      for(int x = 0; x < w; x++){
	cin >> f[x][y];
	for(int k = 0; k < 2; k++){
	  int nx = x + dx[k];
	  int ny = y + dy[k];
	  m[nx][ny] += (m[x][y] + ((f[x][y] == k)?1:0) )/2;
	}
	if(m[x][y] % 2) f[x][y] = (f[x][y]+1)%2;
      }
    }

    int x = 0,y = 0;
    while(x != w && y != h){
      int nx = x + dx[f[x][y]];
      int ny = y + dy[f[x][y]];
      x = nx;
      y = ny;
    }
    cout << y+1 << " " << x+1 << endl;
  }
}

Measured memory_bytes: 10340
class LazySegmentTree
	def initialize(n, l = 0, r = n-1)
		@range_min = l
		@range_max = r
		@start = 0
		@between = 0
		@end = 0
		if l == r
		else
			c = (l + r) / 2
			@left_child = self.class.new(n, l, c)
			@right_child = self.class.new(n, c+1, r)
		end
	end

	attr_reader :range_min, :range_max

	def add_start(x, bits)
		if @range_min == @range_max
			@start |= bits
		else
			force
			if x <= @left_child.range_max
				@left_child.add_start(x, bits)
			else
				@right_child.add_start(x, bits)
			end
		end
	end

	def add_end(x, bits)
		if @range_min == @range_max
			@end |= bits
		else
			force
			if x <= @left_child.range_max
				@left_child.add_end(x, bits)
			else
				@right_child.add_end(x, bits)
			end
		end
	end

	def add_between(x, y, bits)
		return if x > y

		if x == @range_min && y == @range_max
			@between |= bits
		else
			force
			lr = @left_child.range_max
			@left_child.add_between(x, lr < y ? lr : y, bits)
			rl = @right_child.range_min
			@right_child.add_between(rl > x ? rl : x, y, bits)
		end
	end

	def force
		if @range_min != @range_max
			@left_child.take(@start, @between, @end)
			@right_child.take(@start, @between, @end)
		end
		@star = @between = @end = 0
	end

	def take(start, between, finish)
		@start |= start
		@between |= between
		@end |= finish
	end

	def net_start_count(x)
		if @range_min == @range_max
			bits = @start
			bits -= bits & @end
			bits -= bits & @between
			bits.to_s(2).count("1")
		else
			force
			if x <= @left_child.range_max
				@left_child.net_start_count(x)
			else
				@right_child.net_start_count(x)
			end
		end
	end

	def net_end_count(x)
		if @range_min == @range_max
			bits = @end
			bits -= bits & @start
			bits -= bits & @between
			bits.to_s(2).count("1")
		else force
			if x <= @left_child.range_max
				@left_child.net_end_count(x)
			else
				@right_child.net_end_count(x)
			end
		end
	end
end


ones = [0]
10000.times{
	ones << ((ones[-1] << 1) | 1)
}

t = Time.new

loop {
	n, r = gets.split.map(&:to_i)
	break if n == 0

	v_st = LazySegmentTree.new(10001)
	h_st = LazySegmentTree.new(10001)

	n.times {
		x1, y1, x2, y2 = gets.split.map(&:to_i)
		bits = ones[y2-y1] << y1
		v_st.add_start(x1, bits)
		v_st.add_between(x1+1, x2-1, bits) if x1+1 < x2
		v_st.add_end(x2, bits)
		bits = ones[x2-x1] << x1
		h_st.add_start(y1, bits)
		h_st.add_between(y1+1, y2-1, bits) if y1+1 < y2
		h_st.add_end(y2, bits)
	}

	area = 0
	for i in 0..10000
		area += v_st.net_start_count(i) * (10000-i)
		area -= v_st.net_end_count(i) * (10000-i)
	end
	p area

	if r == 2
		len = 0
		for i in 0..10000
			len += v_st.net_start_count(i)
			len += v_st.net_end_count(i)
			len += h_st.net_start_count(i)
			len += h_st.net_end_count(i)
		end
		p len
	end
}

Measured memory_bytes: 88584
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string X;
  cin >> X;
  int s = 0, rem = X.size();
  for (char c : X) {
    if (c == 'S') {
      ++s;
    } else {
      if (s > 0) {
        rem -= 2;
        --s;
      }
    }
  }
  cout << rem << endl;
  return 0;
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    int ans = 0;
    for (int i = 1, v; i <= n; ++i)
    {
        cin >> v;
        if (v %2 == 1&& i%2 == 1)
            ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
  int x, y, t;
  while(1)
    {
      scanf("%d %d", &x, &y); 
      if( x == 0 && y == 0 ) break;
      if( x < y )
        {printf("%d %d\n", x, y);}
      else
	{printf("%d %d\n", y, x);}
    }    
  return 0;
}

Measured memory_bytes: 600
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
from itertools import combinations_with_replacement as cwr
#======================================================#
def main():
    n = II()
    # (x+y+z)^2 - n = xy + yz + zx
    lst = [1]
    ans = {i:0 for i in range(1,n+1)}
    for x,y,z in cwr(range(1,100),3):
        p = (x+y+z)**2 - (x*y + y*z + z*x)
        if p <= n:
            if x == y == z:
                ans[p] += 1
            elif x != y and y != z:
                ans[p] += 6
            else:
                ans[p] += 3
    for k,v in ans.items():
        print(v)




if __name__ == '__main__':
    main()

Measured memory_bytes: 9544
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

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

      if(A<10&&B<10){
        System.out.println(A*B);
      }else{
        System.out.println(-1);
      }

                   }
}


Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		if (n / 1000 == 0) {
			System.out.println("ABC");
		} else {
			System.out.println("ABD");
		}
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 40000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

string S;
int X, Y;
vector <int> fx, fy;
bool flag[4096][MAX];


void solve(void){
    cin >> S >> X >> Y;
    int j = 0, tcnt = 0, xsum = 0, ysum = 0;
    rep(S.size(), i) {
        if (S[i] == 'F') tcnt++;
        else {
            if (j%2==0) {
                fx.push_back(tcnt);
                xsum += tcnt;
            }
            else {
                fy.push_back(tcnt);
                ysum += tcnt;
            }
            j++; tcnt = 0;
        }
    }
    if (j%2==0) {
        fx.push_back(tcnt);
        xsum += tcnt;
    }
    else {
        fy.push_back(tcnt);
        ysum += tcnt;
    }
    //init
    X -= fx[0];
    fx[0] = 0;

    //check
    memset(flag, false, sizeof(flag));
    flag[0][MAX/2] = true;
    rep(fx.size(), x) {
        rep(MAX, b) {
            if (flag[x][b]) {
                flag[x+1][b-fx[x]] = flag[x+1][b+fx[x]] = true;
            }
        }
    }
    bool can = flag[fx.size()][MAX/2+X];
    if (j > 0) {
        memset(flag, false, sizeof(flag));
        flag[0][MAX/2] = true;
        rep(fy.size(), y) {
            rep(MAX, b) {
                if (flag[y][b]) {
                    flag[y+1][b-fy[y]] = flag[y+1][b+fy[y]] = true;
                }
            }
        }
        can = can and flag[fy.size()][MAX/2+Y];
    }
    else can = can and Y == 0;
    cout << (can?"Yes":"No") << '\n';
}

int main(void){
  solve();
  return 0;
}


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

string udlr(char ch, int n) {
    string s;
    for (int i = 0; i < n; ++i) {
        s += ch;
    }
    return s;
}

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

    int x, y, X, Y;
    cin >> x >> y >> X >> Y;

    int w = X - x;
    int h = Y - y;
    string s;
    s += udlr('U', h);
    s += udlr('R', w);
    s += udlr('D', h);
    s += udlr('L', w + 1);
    s += udlr('U', h + 1);
    s += udlr('R', w + 1);
    s += "DR";
    s += udlr('D', h + 1);
    s += udlr('L', w + 1);
    s += "U";

    cout << s << endl;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;++i){
        int ai;cin>>ai;
        v[i] = {ai,i+1};
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    
    multiset<int> st;
    st.insert(0);
    st.insert(0);
    st.insert(n+1);
    st.insert(n+1);
    ll ret = 0ll;
    for(auto vi: v){
        ll num = vi.first;
        int id = vi.second;
        auto it = st.lower_bound(id);
        int r1 = *it;it++;
        int r2 = *it;it--;
        it--;
        int l1 = *it;
        it--;
        int l2 = *it;
        ret += num*(l1 - l2) * (r1 - id);
        ret += num*(r2 - r1) * (id - l1);
        st.insert(id);
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
#define REP(m,n) for(int i=m;i<n;++i)
#define REPj(m,n) for(int j=m;j<n;++j)
#define INF 10000000000000000
#define ll long long
#define mp make_pair

int main() {
	int c, a = 0;
	string s;
	cin >> s;
	REP((int)'a', (int)'a' + 26) {
		c = 0;
		REPj(0, s.size()) {
			if ((int)s[j] == i) {
				c++;
				break;
			}
		}
		if (c == 0) {
			cout << (char)i << endl;
			break;
		}
		else {
			a++;
		}
	}
	if (a == 26) {
		cout << "None" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

typedef unsigned long long ll;

struct Rail {
  int from, to;
  int yen, sunuke;
  ll cost;

  bool operator<(const Rail &r) const {
    return this->cost>r.cost;
  }
};

const int N = 100001;
vector<Rail> adj_list[N];

vector<ll> dijkstra(int start, bool changed) {
  vector<ll> res(N);
  bool visited[N] = { 0 };

  priority_queue<Rail> q;
  Rail s = { start, start, 0, 0, 0 };
  q.push(s);
  while (!q.empty()) {
    Rail run_rail = q.top();
    q.pop();

    int c = run_rail.to;
    if (visited[c])
      continue;
    visited[c] = true;
    res[c] = run_rail.cost;

    for (auto r : adj_list[c]) {
      if (!visited[r.to]) {
        r.cost = run_rail.cost + (changed ? r.sunuke : r.yen);
        q.push(r);
      }
    }
  }

  return res;
}

int main() {
  int n, m, start, goal;
  cin >> n >> m >> start >> goal;
  start--, goal--;
  for (int i=0; i<m; i++) {
    int u, v, yen, sunuke;
    scanf("%d %d %d %d", &u, &v, &yen, &sunuke);
    u--, v--;

    Rail r = { u, v, yen, sunuke, 0 };
    adj_list[u].push_back(r);
    Rail r2 = { v, u, yen, sunuke, 0 };
    adj_list[v].push_back(r2);
  }
  vector<ll> yen_min = dijkstra(start, false);
  vector<ll> sunuke_min = dijkstra(goal, true);

  vector<ll> res(n);
  ll max_sunuke = 0;
  for (int i=n-1; i>=0; i--) {
    ll s = 1000000000000000 - yen_min[i] - sunuke_min[i];
    max_sunuke = max(max_sunuke, s);
    res[i] = max_sunuke;
  }
  for (auto r : res) {
    cout << r << endl;
  }
  return 0;
}



Measured memory_bytes: 18504
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a,b = readInts()
ab = b-a
if ab%2:
    print('Borys')
else:
    print('Alice')


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


using namespace std;

#define endl '\n'
#define PB push_back
#define MP make_pair
#define LL long long
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

typedef long long ll;

bool file=0,rt=1;
clock_t tStart ;
void FAST_IO();
////////////////////////

int main() {

    //FAST_IO();
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout << setprecision(5);
    cout << fixed;

    int n;
    cin >> n;

    vector<int> dp(3);
    for(int day = 0; day < n; day++) {

        vector<int> n_dp(3, 0);
        vector<int> c(3);

        for(int i = 0; i < 3; i++) {

            cin >> c[i];
        }

        for(int i = 0; i < 3; i++) {

            for(int j = 0; j < 3; j++) {

                if(i != j) {

                    n_dp[j] = max(n_dp[j], dp[i] + c[j]);
                }
            }
        }

        dp = n_dp;

    }

     cout << max(max(dp[0], dp[1]),  dp[2]) << endl;


    return 0;
}

void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);
    if(rt && file){ tStart = clock(); }
    if(file){
    #ifndef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    }
}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
ll const INF = 1LL << 60;

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    int B[M];
    rep(i, M) cin >> B[i];

    int A[N][M];
    rep(i, N) rep(j, M) cin >> A[i][j];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0;

        for (int j = 0; j < M; j++) {
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum > 0)
            ans++;

    }
    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define setA0(a) for(ull i =0;i<n;i++){a[i] = 0;}
#define aout(a) for(auto x : a){cout<<x<<' ';} 
#define ain(a) for(ull i =0;i<n;i++){cin>>a[i];}
#define NofSetBits(x) __builtin_popcount(x);
#define InpGrph(g,e) while(e--){ll x;ll y;cin>>x>>y ;g[x].pub(y);g[y].pub(x);}
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);








int main(){
  FastIO;
  string s;
  cin>>s;
  if(s[s.length()-1]!='s'){
  	cout<<s+"s";
  }else{
  	cout<<s+"es";
  }
  return 0;
}


Measured memory_bytes: 3612