akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Scanner;

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

		while(true){
			Dice dice = new Dice();
			int sum = dice.roll("None");
			String n = scan.next();

			if(Integer.parseInt(n) == 0) break;

			for(int i = 0; i < Integer.parseInt(n); i ++){
				sum += dice.roll(scan.next());
			}

			System.out.println(sum);
		}

		scan.close();
	}
}

class Dice {
	HashMap<String, Integer> dc = new HashMap<String, Integer>();

	Dice(){
		dc.put("TOP", 1);
		dc.put("E", 3);
		dc.put("N", 5);
		dc.put("W", 4);
		dc.put("S", 2);
		dc.put("BTM", 6);
	}

	public int roll(String direction) {
		switch (direction) {
			case "None":
				break;
			case "North":
				dc.put("TOP", dc.put("S", dc.put("BTM", dc.put("N", dc.get("TOP"))))); break;
			case "East":
				dc.put("TOP", dc.put("W", dc.put("BTM", dc.put("E", dc.get("TOP"))))); break;
			case "West":
				dc.put("TOP", dc.put("E", dc.put("BTM", dc.put("W", dc.get("TOP"))))); break;
			case "South":
				dc.put("TOP", dc.put("N", dc.put("BTM", dc.put("S", dc.get("TOP"))))); break;
			case "Right":
				dc.put("S", dc.put("E", dc.put("N", dc.put("W", dc.get("S"))))); break;
			case "Left":
				dc.put("S", dc.put("W", dc.put("N", dc.put("E", dc.get("S"))))); break;
			default:
				return -1;
		}
		return dc.get("TOP");
	}
}

Measured memory_bytes: 37080
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


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

int main(){
	int n, m, x, a;
	int sum1=0, sum2=0;
	cin >> n >> m >> x;
	for(int i=0; i<m; i++){
		cin >> a;
		if(a < x) sum1++;
		else sum2++;
	}
	cout << min(sum1, sum2);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t x;
  cin >> x;
 
  for (int i = -1000; i < 1000; i++) {
    for (int j = -1000; j < 1000; j++) {
      if (pow(i,5) - pow(j,5) == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
    
  }
 
}

Measured memory_bytes: 4100
import java.util.Scanner;
import java.util.Arrays;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int dataCount = Integer.parseInt(scanner.nextLine());
        String[] dataString = scanner.nextLine().split(" ");
        int[] data = new int[dataCount];
        for (int i = 0; i < dataCount; i++) {
            data[i] = Integer.parseInt(dataString[i]);
        }
        
        int changeCount = 0;
        // 1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
        // 2   for i が 0 から N-1 まで
        // 3     minj = i
        // 4     for j が i から N-1 まで
        // 5       if A[j] < A[minj]
        // 6         minj = j
        // 7     A[i] と A[minj] を交換
        for (int i = 0; i < dataCount; i++) {
            int min = i;
            for (int j = i; j < dataCount ; j++ ) {
                if (data[j] < data[min]) {
                    min = j;
                }
            }
            
            if (i != min) {
                // swap
                int tmp = data[i];
                data[i] = data[min];
                data[min] = tmp;
                changeCount++;
            }
        }

        StringJoiner joiner = new StringJoiner(" ");
        Arrays.stream(data).forEach(n -> joiner.add(Integer.toString(n)));
            
        System.out.println(joiner.toString());
        System.out.println(changeCount);
    }
}




Measured memory_bytes: 31952
#include<bits/stdc++.h>
using namespace std;
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define int long long int 
#define F first
#define S second
#define boost ios_base::sync_with_stdio(false),cin.tie(NULL);
const int MOD = 998244353;
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp>  
//using namespace __gnu_pbds; 
//stringstream ss; string temp; ss<<str(original string) ss>>temp;


int32_t main()
{	
	
  	
  	int n; cin>>n;
  	int a[n+1]={0};
  	int p[n+2]={0};
  	int s[n+2]={0};
  	for(int i=1;i<=n;i++)
  	{
  		cin>>a[i];
  	}

  	for(int i=1;i<=n;i++)
  	{
  		p[i]=max(p[i-1],a[i]);
  	}
  	for(int i=n;i>=1;i--)
  	{
  		s[i]=max(s[i+1],a[i]);
  	}
  	for(int i=1;i<=n;i++)
  	{
  		cout<<max(p[i-1],s[i+1])<<endl;
  	}
	return 0;
} 


Measured memory_bytes: 6272
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
bool desc(pii a,pii b)
{
    if(a.F==b.F)
    {
        return a.S>b.S;
    }
    else
    {
        return a.F>b.F;
    }
}
int dp[100][100001];
void oblivious()
{
    int n,w1;
    cin>>n>>w1;
    int w[n+1],v[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<100;i++)
    {
        for(int j=0;j<=100000;j++)
        {
            dp[i][j]=inf;
        }
    }
    dp[0][0]=0;
    dp[0][v[0]]=w[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=0;
        for(int j=1;j<=100000;j++)
        {
            if(j>=v[i])
            {
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    int ans=-1;
    for(int j=100000;j>=0;j--)
    {
        if(dp[n-1][j]<=w1)
        {
            ans=j;
            break;
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}
//Md Zuhair

Measured memory_bytes: 81764
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
    cout<<"a < b\n";
  }else if(a>b){
    cout<<"a > b\n";
  }else{
    cout<<"a == b\n";
  }
  return 0;
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n,k;
  cin>>n>>k;
  int ans=1;
  rep(i,n){
    if(ans>k)ans=ans+k;
    else ans=ans*2;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    ll x, y;
    cin >> x >> y;

    int ans = 0;
    while (x <= y) {
        x <<= 1;
        ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()
    c = Counter(S)
    if len(c) == 2 and list(c.items())[0][1] == 2 and list(c.items())[1][1] == 2:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
n = int(input())
p = list(map(int, input().split()))

ans = list(range(1, n + 1))

cnt = 0
for i in range(n):
    if p[i] != ans[i]:
        cnt += 1
    if cnt > 2:
        break

if cnt <= 2:
    print("YES")
else:
    print("NO")


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

int main() {
    int s,w; cin >> s >> w;
    string ans;
    ans = (w >= s) ? "unsafe" : "safe";
    cout << ans << "\n";
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include<math.h>
#include<map>
#include<vector>
#include <tuple>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  int r, D, x;
  cin >> r >> D >> x;
  F(i, 10){
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int n , y ;

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

	cin >> n >> y ;

	y /= 1000 ;

	for (int i = 0 ; i * 10 <= y ; i ++) {
		for (int j = 0 ; i * 10 + j * 5 <= y ; j ++) {
			int k = y - i * 10 - j * 5 ;

			if (i + j + k == n) return cout << i << ' ' << j << ' ' << k << '\n' , 0 ;
		}
	}

	cout << "-1 -1 -1\n" ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int h = sc.nextInt();
            int w = sc.nextInt();
            String line[] = new String[h];
            for(int i=0;i<h;i++){
              line[i] = sc.next();
            }

            int x[] = {1,1,1,-1,-1,-1,0,0};
            int y[] = {1,0,-1,1,0,-1,1,-1};
            
            for(int i=0;i<h;i++){
              for(int j=0;j<w;j++){
                if(line[i].charAt(j)=='#'){
                  System.out.print("#");
                  continue;
                }
                int count = 0; 
                for(int k=0;k<8;k++){
                   int dx = i+x[k];
                   int dy = j+y[k];
                   if(dx<0||dx>=h||dy<0||dy>=w) continue;
                   if(line[dx].charAt(dy)=='#') count++;
                }
                System.out.print(count);
              }
              System.out.print("\n");
            }
            
            
          }
        }

Measured memory_bytes: 21972
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


ll gcd(ll x, ll y){
	if(y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y){
	return x*y / gcd(x,y);
}

ll n, m;
string s,t;

int main(){
	cin >> n >> m;
	cin >> s >> t;
	
	if(s[0] != t[0]){
		cout << -1 << endl;
	}
	else if(n % m == 0){
		int c = n/m;
		for(int i = 0; i*c < n; i++){
			if(s[c*i] != t[i]){
				cout << -1 << endl;
				return 0;
			}
		}
		cout << n << endl;
	}
	else if(m % n == 0){
		int c = m/n;
		for(int i = 0; i*c < m; i++){
			if(s[i] != t[c*i]){
				cout << -1 << endl;
				return 0;
			}
		}
		cout << m << endl;
	}
	else{
		int c = gcd(n,m);
		for(int i = 0; i < c;  i++){
			if(s[i*(n/c)] != t[i*(m/c)]){
				cout << -1 << endl;
				return 0;
			}
		}
		cout << lcm(n,m) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	a, b, h, m := nextInt(), nextInt(), nextInt(), nextInt()
	radH := math.Pi * (float64(30)*float64(h) + float64(m)/2) / 180
	radM := math.Pi * (float64(6) * float64(m)) / 180
	angle := radH - radM
	x2 := float64(a*a) + float64(b*b) - 2*float64(a)*float64(b)*math.Cos(angle)
	x := math.Sqrt(x2)
	fmt.Println(x)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a >= b) rep(i, a) cout << b;
  else rep(i, b) cout << a;
  cout << endl;
    
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = input().split()
c = 1
for i in range(a):
    if int(b[i]) == 0:
        c = 0

if c == 1:
    for i in range(a):
        c = c*int(b[i])
        if c > 1000000000000000000:
            break

if c > 1000000000000000000:
    print(-1)
else:
    print(c)

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


int main()
{
  int N;
  cin >> N;
  int a[N];
  for ( int i = 0; i < N; i++) cin >> a[i];
  
  int a_copy[N];
  copy(a, a + N, a_copy);
  bool order = false;
  
  bool reverse = false;
  for ( int k = 0; k < N-1; k++){
    if(a[k] >= a[k+1]) {
      reverse = true;
      if(reverse) break;
    }
  }
  order = !reverse;
  
  
  for ( int i = 1; i < N; i++){
    if(order) break;
    for ( int j = 0; j < i; j++){
      copy(a_copy, a_copy + N, a);

      int tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;

      bool reverse = false;
      for ( int k = 0; k < N-1; k++){
        if(a[k] >= a[k+1]) {
          reverse = true;
          if(reverse) break;
        }
      }
      order = !reverse;
      if(order) break;
    }
    
  }
  

  if(order) cout << "YES" << endl;    
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
bool prime[10001];
int main() {
  memset(prime, -1, sizeof(prime));
  prime[0] = prime[1] = false;
  for(int i = 2; i * i <= 10000; ++i) {
    if(prime[i]) {
      for(int j = i * i; j <= 10000; j += i) prime[j] = false;
    }
  }
  vector<int> psum;
  psum.push_back(0);
  for(int i = 2; i <= 10000; ++i) {
    if(prime[i]) psum.push_back(i + psum.back());
  }
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    set<int> s;
    s.insert(0);
    int ans = 0;
    for(int i = 1; i < (int)psum.size(); ++i) {
      if(s.count(psum[i] - N)) ans++;
      s.insert(psum[i]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1296
#include<iostream>
#define ll long long int
using namespace std;
#include<math.h>
#include<bits/stdc++.h>
ll max(ll a,ll b)
{
  return a > b ? (a) : (b);
}
int main()
{
    ll n,wt;
    cin >> n >> wt;
    ll w[n],v[n];
    for(int i = 0;i < n;i++)
        cin >> w[i] >> v[i];
    ll dp[n+1][wt+1];
    for(int i = 0; i <= n;i++)
        dp[i][0] = 0;
    for(int i = 0; i <= wt;i++)
        dp[0][i] = 0;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= wt;j++)
        {
            if(w[i-1] <= j)
                dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j - w[i-1]]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][wt];
 	return 0;
}


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

int main(){
    string s;
    cin>>s;
    bool fln=false;
    bool flw=false;
    bool fls=false;
    bool fle=false;
    rep(i,s.size()){
        if(s[i]=='N') fln=true;
        if(s[i]=='W') flw=true;
        if(s[i]=='S') fls=true;
        if(s[i]=='E') fle=true;
    }

    if(fln && fls){
        if(flw == fle) cout<<"Yes"<<"\n";
        else cout<<"No"<<"\n";
    }
    else if(flw && fle){
        if(fln == fls) cout<<"Yes"<<"\n";
        else cout<<"No"<<"\n";
    }
    else cout<<"No"<<"\n";
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, n) for(ll i=0;i<n;i++)
#define r(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
ll gcd(ll a,ll b){
    while(b){
        ll temp=a;
        a=b;
        b=temp%b;
    }
    return a;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/gcd(a,b); 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int MAX = 100000;
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
	IsPrime[0] = false; IsPrime[1] = false; 
	for (int i = 2; i < n; ++i) IsPrime[i] = true;
	for (int i = 2; i < n; ++i) {
		if (IsPrime[i]) {
            res.push_back(i);
			for (int j = i*2; j < n; j += i) IsPrime[j] = false;
		}
	}
    return res;
}


int n;

int main() {
    vint prime = Era();
    while (cin >> n) {
        if (n == 0) break;
        int res = 0;
        for (int i = 0; i < prime.size(); ++i) {
            if (n - prime[i] < prime[i]) break;
            int m = n - prime[i];
            if (IsPrime[m]) ++res;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1416
#include<iostream>
#include<cstring>
using namespace std;
char mas[101][101];
int main(){
  int h,w,x,y;
  while(1){
    x=0,y=0;
    cin >> h >> w;
    if(h==0&&w==0){break;}
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mas[i][j];
      }
    }
    while(1){
	if(mas[x][y]=='>'){
	  mas[x][y]='1';
	  y++;
	}else if(mas[x][y]=='<'){
	  mas[x][y]='1';
	  y--;
	}else if(mas[x][y]=='v'){
	  mas[x][y]='1';
	  x++;
	}else if(mas[x][y]=='^'){
	  mas[x][y]='1';
	  x--;
	}else if(mas[x][y]=='.'){
	  break;
	}else if(mas[x][y]=='1'){
	  x=-1;
	  break;
      }
    }
    if(x!=-1){
      cout <<y<<" "<<x<<endl;
    }else if(x==-1){
      cout<<"LOOP"<<endl;
    }
  }
  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;

    if((a+b) % 2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;

}


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

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i : a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class CWalkingTakahashi {
public:
  static void solve(istream &cin, ostream &cout) {
    int X, K, D;
    cin>>X>>K>>D;
    X = abs(X);
    int a = X/D;
    if (K < a){
      cout<<X - D*K<<endl;
      return;
    }
    if ((K-a)%2 == 0){
      cout<<X - a*D<<endl;
    }else{
      cout<<abs(X - a*D - D)<<endl;
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  CWalkingTakahashi solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int N, i;
  long long int ans = 0;
  scanf("%d", &N);

  for(i=1; i<=N; i++){
    if(i % 15 != 0 && i % 5 != 0 && i % 3 != 0){
      ans += (long long int)i;
    }
  }

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

  return 0;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[3][3];
int b[100];
int main()
{
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		for(int i1=0;i1<n;i1++)
		{
			for(int i2=0;i2<n;i2++)
			{
				if(b[i]==a[i1][i2]) a[i1][i2]=0;
			}
		}
	}
	int flag=0;
	int cnt3=0,cnt4=0;
	for(int i=0;i<3;i++)
	{
		int cnt1=0,cnt2=0;
		for(int j=0;j<3;j++)
		{
			if(a[i][j]==0) cnt1++;
			if(a[j][i]==0) cnt2++;
		}
		if(cnt1==3||cnt2==3) flag=1; 
		if(a[i][i]==0) cnt3++;
		if(a[2-i][i]==0) cnt4++;
	}
	if(cnt3==3||cnt4==3) flag=1;
	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

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

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int n, q;
	
	cin >> n;
	
	map<int ,int > m;
	
	int sm = 0;
	
	for(int i = 0; i < n; ++i) {
		int x;
		
		cin >> x;
		
		m[x]++;
		
		sm += x;
	}
	
	cin >> q;
	
	int x , y;
	
	while(q--) {
		cin >> x >> y;
		
		if(x == y) {
			continue;
		}
		
		sm = sm - m[x]*x + m[x]*y;
		
		int rem = m[x];
		
		m.erase(x);
		
		m[y] += rem;
		
		cout << sm  << endl;
	}
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 7532
#include<bits/stdc++.h>
using namespace std; 
int main(){
  int n;cin>> n;
  int arr[n];
  float sum=0;
  for(int i=0;i<n;i++)
  {
  cin>> arr[i];sum+=arr[i];
  }
  float ans = (float)sum/(n);
  int final = round(ans);
  int result =0;
  for(int i=0;i<n;i++)
  {
  	result += (final-arr[i])*(final-arr[i]);
  }
  cout<< result<< endl;
  
}

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

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; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    ll a,b,x;
    cin>>a>>b>>x;
    int p = 0;
    if(a==0) {
        a=1;
        p=1;
    }
    cout<<(b/x)-((a-1)/x)+p<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    double cnt = 100;
    double X;
    cin >> X;
    int ans = 0;
    while (cnt < X) {
        cnt = floor(cnt * 1.01);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3700
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
A = read_ints()

# 最初にすべてのマイナスが外せないか試して、
# abs最小の数に-をつけて合計すればいいんだ！

# 問題はどうやってすべてのマイナスがはずせるか判別するか
# +-+,---っていうパターンがあったらアウト
# flg = False
minuscount = 0
for a in A:
    if a < 0:
        minuscount += 1


anstmp = sum([abs(a) for a in A])
if minuscount % 2 == 0:
    print(anstmp)
    exit()

# else
mi = 10 ** 9
for a in A:
    mi = min(mi, abs(a))

print(anstmp-2*mi)


Measured memory_bytes: 15180
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long a,b,v,w,t;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>v>>b>>w>>t;
	t=max((v-w)*t,0LL);
	if(abs(a-b)<=t){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll N; cin >> N;
  map <ll, int> mp;
  
  if(N == 1){
    cout << 0 << endl;
    return 0;
  }
  
  ll cnt = 0;
  vector<ll> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
    mp[A.at(i)]++;
  }
  
  sort(A.begin(), A.end());
  
  for(int i = N-1; i > 0; --i){
    if(mp[A.at(i)]==0) continue;
    ll x = 1;
    while(x <= A.at(i)) x*=2;
    ll d = x - A.at(i);
    
    if(d!=A.at(i) && mp[d]>0){
      cnt++;
      mp[A.at(i)]--;
      mp[d]--;
    }
    else if(d==A.at(i) && mp[d]>1){
      cnt++;
      mp[d] -= 2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 26752
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#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,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A; cin >> A;
    cout << N * N - A << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e9;

int main(){
  int n = 5;
  vector<int> a(5);
  REP(i,5) cin >> a[i];

  VSORT(a);

  int mi = 11;
  int idx = -1;
  int p;
  REP(i,n){
    p = a[i]%10;
    if (p == 0) p = 10;
    if (p<mi){
      mi = p;
      idx = i;
    }
  }

  int res = 0;

  REP(i,n){
    if (i != idx){
      res += a[i];
      p = res%10;
      if (p != 0) p = 10 - p;
      res += p;

    }
  }

  cout << res+a[idx] << endl;

}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if(w>=v){
    	cout<<"NO"<<endl;
    	return 0;
    }
    int diff=abs(a-b);
    int gg=v-w;
    diff+=gg-1;
    diff/=gg;
    if(diff<=t){
    	cout<<"YES"<<endl;
    }
    else{
    	cout<<"NO"<<endl;
    }
    return 0;   
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main()
{
   int n;
   cin>>n;
  
   string str;
  
   cin>>str;
  
   for(int i=0;i<str.length();i++)
   {
      // ascii value ranges from 65 to 91
      
       if((int)str[i] + n >=91)
       str[i] = 65 + ((int)str[i] + n)%91;
       else
         str[i] = ((int)str[i] + n)%91;
     
   }
    cout<<str;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    cin >> x;
    x ^= 1;
    cout << x << endl;

}


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

int main(){
        int x,a,b;
        int absa,absb;
        scanf("%d %d %d", &x, &a, &b);
        absa = abs(x-a);
        absb = abs(x-b);
        if(absa<absb){
                printf("A\n");
        }else{
                printf("B\n");
        }
        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d, x, y[10]; cin >> r >> d >> x;
  for(int i=0;i<10;i++) {
    y[i]=r*x-d;
    cout << y[i] << endl;
    x=y[i];
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int now=0;
  int cnt=0;
  vector<int> x,y;
  rep(i,s.size() ){
    if(s[i]=='F'){
      now++;
    }else{
      if(cnt%2==0){
	x.push_back(now);
	now=0;
      }else{
	y.push_back(now);
	now=0;
      }
      cnt++;
    }
  }
  if(cnt%2==0){
    x.push_back(now);
    now=0;
  }else{
    y.push_back(now);
    now=0;
  }
  rep(i,x.size() ){
    //   cout<<x[i]<<" ";
  }
  // cout<<endl;
  int X,Y;
  cin>>X>>Y;
  set<int> a,b;
  a.insert(x[0]);
  repi(i,1,x.size() ){
    for(auto itr=a.begin();itr!=a.end();itr++){
      b.insert( *itr + x[i]);
      b.insert( *itr - x[i]);
    }
    //for(auto itr=b.begin();itr!=b.end();itr++){
      // cout<<*itr<<" ";
    // }
    //cout<<endl;
    a=b;
    b.clear();
  }
  //for(auto itr=a.begin();itr!=a.end();itr++){
    // cout<<*itr<<" ";
  // }
  // cout<<endl;
    
  if(a.count(X)==0){cout<<"No"<<endl;return 0;}

  a.clear();
  a.insert(0);
  rep(i,y.size() ){
    for(auto itr=a.begin();itr!=a.end();itr++){
      b.insert( *itr + y[i]);
      b.insert( *itr - y[i]);
    }
    a=b;
    b.clear();
  }
  if(a.count(Y)==0){cout<<"No"<<endl;return 0;}
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3980
def f():
 for x in a:
  if x%2==0:
   continue
  else:
   return False
 return True

n,p=map(int,raw_input().split())
a=map(int,raw_input().split())

if f()==True and p==0:
 print 2**n
elif f()==True and p==1:
 print 0
else:
 print 2**(n-1)


Measured memory_bytes: 2568
#include <iostream>
#include <cmath>

int main(void){
    long long N, A, B, quo, rem, ans=0;
    std::cin >> N >> A >> B;

    quo = N / (A + B);
    rem = N % (A + B);

    if (rem > A) rem = A;
    ans += quo * A + rem;

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

    return 0;
}


Measured memory_bytes: 3624
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {



        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet t = new HashSet();
        String s;
        int ans = 0;
        for(int i=0;i<N;i++){
            s = sc.next();
            if(!t.contains(s)){
                t.add(s);
                ans ++;
            }
        }

        System.out.println(ans);

        }


    }

Measured memory_bytes: 76980
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 200005

ll dp[MAXN];

int main()
{
    _io
    int n, m; cin >> n >> m;
    string s; cin >> s;
    if(s[0] == 1 || s[n] == 1)
        return cout << -1, 0;
    deque <int> Q;
    fill(dp, dp+1+n, INT_MAX);
    dp[n] = 0;
    Q.pb(n);
    FORs(i, n-1, 0)
    {
        if(!Q.empty() && Q.front()-i > m)
            Q.pop_front();
        if(s[i] == '1') continue;
        if(Q.empty())   continue;
        dp[i] = dp[Q.front()]+1;
        while(!Q.empty() && dp[i] <= dp[Q.back()])
            Q.pop_back();
        Q.pb(i);
    }
    if(dp[0] == INT_MAX)
        return cout << -1, 0;
    //cout << dp[1] << '\n';
    vector <int> res;
    int pos = 0;
    FOR(i, 1, n)
    {
        if(dp[i] == dp[pos] - 1)
        {
            res.pb(i-pos);
            pos = i;
        }
    }
    for(int u : res)
        cout << u << ' ';
}


Measured memory_bytes: 1868
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();

    int max = 0;
    int[][] dp = new int[N + 1][N + 1];
    for (int j = N - 1; j > 0; j--) {
      for (int i = j - 1; i >= 0; i--) {
        dp[i][j] = s[i] == s[j] ? dp[i + 1][j + 1] + 1 : 0;
        max = Math.max(max, Math.min(dp[i][j], j - i));
      }
    }
    System.out.println(max);
  }
}


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

int main(){
	int n;
	cin>>n;
	int a[n+1];
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i] ;
	}
	
	sort(a+1,a+n+1);
	int s=0;
	a[0]=0;

	
	for(int i=1;i<=n-2;i++)
	{
		for(int j=i+1;j<=n-1;j++)
			{
				for(int k=j+1;k<=n;k++)
				{
					if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k]) continue;
					if(a[i]+a[j]>a[k])
						{
							s++;
				  		}
						
				} 
			}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3624
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n;

	cin >> n;

	int num = n % 10;

	switch (num)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 6:
	case 1:
	case 0:
	case 8:
		cout << "pon" << endl;
		break;
	default:
		cout << "bon" << endl;
		break;
	}


	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long h,w,z=1L<<30,a,b,c,d,e,i;
long f(long h,long w){for(i=0;i<=h/2;i++)a=w*i,b=w/2*(h-i),c=(h-i)/2*w,d=h*w-a-b,e=h*w-a-c,z=min({z,max({a,b,d})-min({a,b,d}),max({a,c,e})-min({a,c,e})});}
main(){cin>>h>>w;f(h,w);f(w,h);cout<<z;}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T,class U>
ostream& operator<<(ostream& os,const map<T, U> & mp){
	os << "{";
	int i = 0;
	for(auto it : mp){
		if(i) os<<", ";
		os << it;
		i++;
	}
	os << "}";	
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	int n; sd(n);
	for(int i = 1; i < n; i++){
		for(int j = i + 1; j <= n; j++){
			for(int k = 0; k < 100; k++) if((i >> k & 1) ^ (j >> k & 1)){
				printf("%d ", k + 1); break;
			}
		}
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b == c+d){
    cout << "Balanced" << endl;
  }
  else if(a+b > c+d){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256