akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n,m;cin>>n>>m;
  vector<pair<ll,ll>> X;
  rep(i,n){
    ll l,r;
    cin>>l>>r;
    X.push_back({l,-r});
  }
  sort(all(X));
  rep(i,n){
    X[i].second *= -1;
  }
  queue<ll> q;
  vector<ll> taka;
  int xi = 0;
  while(xi < X.size() && X[xi].first == 0){
    taka.push_back(X[xi].second);
    xi++;
  }
  reps(t,m){
    q.push(t);
    while(xi < X.size() && X[xi].first == t){
      //cerr<<xi<<" "<<q.size()<<endl;
      if(q.size() > 0){
        q.pop();
      }else{
        taka.push_back(X[xi].second);
      }
      xi++;
    }
  }
  /*while(xi < X.size()){
    taka.push_back(X[xi].second);
    xi++;
  }*/

  cerr<<q.size()<<endl;
  ll ans = 0;
  vector<ll> mass;
  while(q.size()>0){
    mass.push_back(q.front());
    q.pop();
  }
  sort(all(mass));
  reverse(all(mass));
  rep(i,mass.size()){
    //cout<<"m"<<i<<" "<<mass[i]<<endl;
  }
  cerr<<taka.size()<<endl;
  sort(all(taka));
  REP(i,taka.size()){
    //cout<<"ta"<<i<<" "<<taka[i]<<endl;
  }

  int mi = 0;
  REP(i,taka.size()){
    //cerr<<taka[i]<<endl;
    if(mi < mass.size() && taka[i] <= mass[mi]){
      mi++;
    }else{
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;

}


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

#define ll long long

using namespace std;

int pmod(int x, int y, int p){ int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1)  res = (res*x) % p;  y = y>>1; x = (x*x) % p; } return res; }  
ll pmod(ll x, ll y, ll p){ ll res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1)  res = (res*x) % p;  y = y>>1; x = (x*x) % p; } return res; } 

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

	int n,k;
	cin >> n >> k;
	vector <bool> hs(n,false);
	for(int i = 0; i < k; ++i){
		int d;
		cin >> d;
		for(int j = 0; j < d; ++j){
			int x;
			cin >> x;
			hs[x - 1] = true;
		}
	}
	int res = 0;
	for(auto i : hs)
		if(i == false)
			res++;
	cout << res;
	return 0;
}

Measured memory_bytes: 3616
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long 
#define w(t) int t; cin>>t; while(t--)
#define mk(arr,n,type) type *arr = new type [n];
#define rep(i,n) for(i=0;i<n;++i)
#define REP(i,k,n) for(i=k;i<=n;++i)
#define REPR(i,k,n) for(i=k;i>=n;--i)
#define inpc(x)   scanf("%d",&x)
#define printc(x) printf("%d",x)
void input(){
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){

   //input();
    int32_t k,x;
    cin>>k>>x;
    if(k*500>=x){
cout<<"Yes\n";

    }
    else cout<<"No\n";
     
   return 0;    
    }



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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;


int main(){
    ll n;
    cin>>n;

    vector<ll>a(n+2);
    rep2(i,1,n)cin>>a[i];

    vector<ll>l(n+2),r(n+2);
    l[1]=a[1];
    rep(i,n-1){
        l[i+2]=__gcd(l[i+1],a[i+2]);
    }

    r[n]=a[n];
    repr(i,n-1,0){
        r[i]=__gcd(r[i+1],a[i]);
    }

    ll ans=0;
    rep2(i,1,n){
        ans=max(ans,__gcd(l[i-1],r[i+1]));
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int ans;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int d[10001];
    for(int i=1;i<=a;++i)
    {
        cin>>d[i];
        if(d[i]<b||d[i]>=c)
        {
            ans++;  
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	final int MAX = Integer.MAX_VALUE;
	Scanner sc = new Scanner(System.in);
	void doIt() {
		new Cliff_Climbing().Main();
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

	class Cliff_Climbing{

		void Main() {
			while(true) {
				int w = sc.nextInt();
				int h = sc.nextInt();
				if(w == 0 && h == 0) return;
				int dx[] = {1, 1, 1, 1, 1, 2, 2, 2, 3};
				int dy[] = {2, 1, 0, -1, -2, 1, 0, -1, 0};
				int d[][][] = new int[h][w][2];
				int c[][][] = new int[h][w][2];
				List<Point> t = new ArrayList<>(); 
				PriorityQueue<Node> next = new PriorityQueue<>();
				for(int i = 0; i < h; i++) {
					for(int j = 0; j < w; j++) {
						String s = sc.next();
						if (s.equals("X")) {
							d[i][j][0] = -1;
							c[i][j][0] = -1;
							d[i][j][1] = -1;
							c[i][j][1] = -1;
						}
						else if(s.equals("S")) {
							d[i][j][0] = 0;
							c[i][j][0] = 0;
							next.add(new Node(0, i, j, 0));
							d[i][j][1] = 0;
							c[i][j][1] = 0;
							next.add(new Node(0, i, j, 1));
						}
						else if(s.equals("T")) {
							t.add(new Point(i, j));
							d[i][j][0] = MAX;
							c[i][j][0] = 0;
							d[i][j][1] = MAX;
							c[i][j][1] = 0;
						}
						else {
							d[i][j][0] = MAX;
							c[i][j][0] = Integer.parseInt(s);
							d[i][j][1] = MAX;
							c[i][j][1] = Integer.parseInt(s);
						}

					}
				}
				while(!next.isEmpty()) {
					Node v = next.poll();
					if(d[v.y][v.x][v.z] < v.d)continue;
					for(int i = 0; i < 9; i++) {
						int mx = 1;
						if(v.z == 1) mx = -1;
						int x = v.x + dx[i] * mx; 
						int y = v.y + dy[i];
						int z = v.z ^ 1;
						if(x >= 0 && x < w 
								&& y >= 0 && y < h) {
							if(c[y][x][z] < 0)continue;
							//System.out.println(d[y][x][z] + " "  +(c[y][x][z] + v.d));
							if(d[y][x][z] > c[y][x][z] + v.d) {
								d[y][x][z] = c[y][x][z] + v.d;
								next.add(new Node(d[y][x][z], y, x, z));
							}
						}
					}
				}

				//System.out.println("!");
				int min = MAX;
				for(Point p: t) {
					if(min > d[p.y][p.x][0]) {
						min = d[p.y][p.x][0];
					}
					if(min > d[p.y][p.x][1]) {
						min = d[p.y][p.x][1];
					}
				}
				System.out.println((min < MAX)?min:-1);

			}
		}
		class Point{
			int x, y; Point (int y, int x){this.x = x; this.y = y;}
		}
		class Node implements Comparable<Node>{
			int d, x, y, z;
			//d => 最短距離
			@Override
			public int compareTo(Node arg0) {
				if(this.d < arg0.d){
					return -1;
				}
				else if(this.d > arg0.d){
					return 1;
				}
				return 0;
			}

			Node(int d, int y, int x, int z){
				this.d = d; this.x = x; this.y = y; this.z = z;
			}

		}

	}
}



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

int main(void)
{
    int N;
    cin >> N;
    int A[210];
    int i;
    int count = 0;

    for (int i = 0; i < N; ++i) cin >> A[i];

    while(true){
        for(i=0; i<N; ++i){
            if( (A[i] % 2) != 0 ){
                cout << count << endl;
                return 0;
            }
        }
        for(i=0; i<N; i++) A[i] /=  2;
        count++;
        
    }
}

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

int main(){
   string s; int q; cin >> s >> q;
   string mae=""; string ato=""; 
   int switc=0;
   rep(i,q){
       int com; cin >> com;
       if(com==1){
           if(switc) switc=0;
           else switc=1;
       }
       else{
           int num; char c; cin >> num >> c;
           if(switc){
               if(num==1) ato=ato+c;
               else mae=c+mae;;
           }else{
               if(num==1) mae=c+mae;
               else ato=ato+c;
           }
       }
   }
   if(switc){
       reverse(mae.begin(),mae.end());
       reverse(s.begin(),s.end());
       reverse(ato.begin(),ato.end());
        cout << ato << s << mae;
   }
   else cout << mae << s << ato << endl;
return 0;
}


Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(int argc, char* argv[])
{
	int N,M,i;
	cin>>N>>M;
	if (N>=M){
		cout<<0<<endl;
		return 0;
	}
	vector<int> X(M);
	for (i=0;i<M;i++){
		cin>>X[i];
	}
	sort(X.begin(),X.end());
	vector<int> L(M-1);
	for (i=0;i<M-1;i++){
		L[i]=X[i+1]-X[i];
	}
	sort(L.begin(),L.end(),greater<int>());
	int MaxL=X[M-1]-X[0];
	for (i=0;i<N-1;i++){
		MaxL-=L[i];
	}
	cout<<MaxL<<endl;
	return 0;
}

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

int main() {
  int N;
  int ans = 1;
  string S;
  cin >> N >> S;
  
  if( N % 2 == 1) ans = 0;
  else{
    N /= 2;
    for(int i=0; i<N; i++){
      if(S.at(i) != S.at(i+N)) ans = 0;
    }
  }
  if(ans == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));

$s = $n % 60;

$h = intval($n / 60 / 60);
$m = intval($n / 60) % 60;
$s = intval($n % 60 % 60);

echo $h . ":" . $m . ":" . $s . PHP_EOL;


Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int N,X;
    int res =1;
    int sum =0;

    cin  >> N >> X;

    int L[N];

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

    for(int i=0;i<N;i++){
        sum += L[i];
        if(sum<=X)res++;
    }

    cout << res << endl;

    return 0;
}

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

int main () {
    int a[6];
    for (int i = 1; i <= 5; i++) cin >> a[i];
    for (int i = 1; i <= 5; i++) {
        if (a[i] == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
  double a,b,c,d;
  cin>>a>>b>>c>>d;
  int x = ceil(c/b);
  int y = ceil(a/d);
  if (x>y){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3696
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 素因数分解の練習

func main() {
	N, P := nextInt(), nextInt()
	pf := primeFuctorize(P)
	ans := 1
	// fmt.Println(pf)
	if N == 1 {
		ans = P
	} else {
		for k, v := range pf {
			// fmt.Println(k, v)
			// ans *= int(math.Pow(float64(k), float64(v/N)))
			ans *= pow(k, v/N)
			// for i := 0; i < v/N; i++ {
			// 	ans *= k
			// 	// fmt.Println("ans", ans, v/N)
			// }
		}
	}
	fmt.Println(ans)
}

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

// https://qiita.com/drken/items/a14e9af0ca2d857dad23#4-%E7%B4%A0%E5%9B%A0%E6%95%B0%E5%88%86%E8%A7%A3
// https://atcoder.jp/contests/caddi2018/submissions/3842181

func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}


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

int main()
{
  int x1, x2, y1, y2;
  cin >> x1;
  cin >> y1;
  cin >> x2;
  cin >> y2;
  int dx, dy;
  dx = x2 - x1;
  dy = y2 - y1;
  int x3, x4, y3, y4;
  x3 = x2 - dy;
  y3 = y2 + dx;
  x4 = x3 - dx;
  y4 = y3 - dy;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << " " << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N;
  scanln(N);
  long[] as = readln.split.to!(long[]);

  if (as.sort!"a<b".group.any!"a[1]>1") {
    "NO".writeln;
  } else {
    "YES".writeln;
  }
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 10744
#include<stdio.h>
int main(){
  int a, b, d, r;
  double f;
  
  scanf("%d%d",&a, &b);
  d=a/b;
  r=a%b;
  f=(double)a /(double)b;

  
  printf("%d %d %.5f\n",d, r, f);
  return 0;
}
  

Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem159b(s))
}

fun problem159b(s: String): String {
    val s = s.toCharArray()
    val sRight = s.take(s.size / 2)
    val sLeft = s.takeLast(s.size / 2)
    return if (s.toList() == s.reversed() && sRight == sRight.reversed() && sLeft == sLeft.reversed())"Yes" else "No"
}

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


int main(){
    long int a, b, n;
    long int max=0;
    cin >> a >> b >> n;

    if(b-1 < n){
        cout << floor(a*(b-1)/b) -  a*floor((b-1)/b) << endl;
    }else{
        cout << floor(a*n/b) - a*floor(n/b) << endl;
    }
    return 0;
}

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

int H, W;
string alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin >> H >> W;
    string s;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> s;
            if(s == "snuke")
                cout << alph[j] << i+1 << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 384
#include<map>
#include<cstdio>
#include<cstring>
#define lg2(x)(63-__builtin_clzll(x))
using namespace std;
typedef unsigned __int128 u128;
typedef unsigned long long uLL;
const int md=998244353;
map<u128,int>f;
char s[128];
int n;
inline int lg(const u128&x){return(x>>64?lg2((uLL)(x>>64))+64:lg2((uLL)x));}
int dfs(const u128&b){
	if(f.count(b))return f[b];
	int&F=f[b],L=lg(b);
	F=(1+(uLL)(b&1))*dfs(b>>1)%md;
	for(int l=1;l<<1<=L;++l){
		u128 t=b&(((u128)1<<l)-1),s=b>>l;
		for(int i=2;i*l<=L;++i){
			t&=s&(((u128)1<<l)-1),s>>=l;
			F=(F+(uLL)dfs(t|((u128)1<<l))*dfs(s))%md;
		}
	}
	return F;
}
int main(){
	scanf("%s",s);
	int L=strlen(s);
	u128 n=1;
	for(int i=0;i<L;++i)n=n<<1|(s[i]&15);
	f[1]=1;
	printf("%d\n",dfs(n));
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b;
  c=max(a,b);
  d=min(a,b);
  if(c==2&&d==1){
    cout<<3<<endl;
  }
  else if(c==3&&d==1){
    cout<<2<<endl;
  }
  else if(c==3&&d==2){
    cout<<1<<endl;
  }
}

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

const int mod = 2019;

int main() {
    string S; cin >> S;
    reverse(S.begin(), S.end());
    int N = S.size();
    int total = 0;
    vector<int> cnt(mod);
    int x = 1;
    int ans = 0;
    rep(i, N){
        cnt[total]++;
        int a = S[i] - '0';
        a *= x;
        a %= mod;
        total += a;
        total %= mod;
        ans += cnt[total];

        x *= 10;
        x %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3724
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


li = LI()
k = II()
print(li[0] + li[1] + li[2] + max(li)*((2**k)-1))


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

#define int long long
#define pb push_back
#define mp make_pair
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a,b;
    cin>>a>>b;
    if(a>8||b>8)
        cout<<":(";
    else
        cout<<"Yay!";
    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#define rg32 register int
#define rg8 register char
typedef long long ll;
const double eps=1e-6;
int n,k;
int a[200005];
inline int read() {
	rg32 x=0,f=1;rg8 s=getchar();
	while(s>'9'||s<'0') {if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9') {x=x*10+s-'0';s=getchar();}
	return x*f;
}
inline bool check(double x) {
	ll sum=0;
	for(rg32 i=1;i<=n;++i) {
		ll val=a[i]/x;
		if(fabs(a[i]-x*val)>eps) ++val;
		sum+=val-1;
	}
	return sum<=k;
}
int main() {
	n=read(),k=read();
	for(rg32 i=1;i<=n;++i) a[i]=read();
	double l=0,r=1e9;
	while(r-l>eps) {//精度限制为eps 
		double mid=l+(r-l)/2;
		if(check(mid)) {r=mid;}
		else {l=mid;}
	} 
	printf("%lld\n",(ll)(r+1-eps));
	return 0;
}

Measured memory_bytes: 2372
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m;
    scan(n, m);
    auto drink = new long[][](n, 2);
    foreach (ref e; drink)
    {
        e = aryread();
    }
    drink.sort();
    long count, maney, tmp;
    foreach (i, e; drink)
    {
        if (count + e[1] <= m)
        {
            count += e[1];
            maney += e[0] * e[1];
        }
        else
        {
            tmp = i;
            break;
        }
    }
    // writeln(maney);
    writeln(maney + (m - count) * drink[tmp][0]);
}

Measured memory_bytes: 22396
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define pii pair<int,int>
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
int inf_i = 1001001000;
ll inf_l = 1001001001001000;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

void solve()
{
	int n, k; cin >> n >> k;
	vd p(n);
	rep(i, n)cin >> p[i];
	vd ex(n);
	rep(i, n)ex[i] = (p[i] + 1) / 2;
	double ans = 0, tmp = 0;
	rep(i, n)
	{
		if (i + k - 1 == n)break;
		if (i == 0)rep(j, k)tmp += ex[j];
		else
		{
			tmp -= ex[i - 1];
			tmp += ex[i + k - 1];
		}
		chmax(ans, tmp);
	}
	co(ans);
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    int n;
    cin >> n;
    vector<double> B(n + 1);
    B[0] = 1;
    for(int i = 0; i < n; i++) {
        double x;
        cin >> x;
        for(int j = n; j > 0; j--)
            B[j] = (B[j - 1] * x + B[j] * (1 - x));
        B[0] *= (1 - x);
    }
    double result = 0;
    for(int i = n / 2 + 1; i <= n; i++)
        result += B[i];
    printf("%.10f\n", result);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()

int main(){
    int n;
    cin >> n;
    int a[n-1];
    rep(i,n-1){
        cin >> a[i];
    }
    int b[n];
    rep(i,n){
        b[i] = 0;
    }
    rep(i,n-1){
        b[a[i]-1]++;
    }
    rep(i,n){
        cout << b[i] << endl;
    }


}

Measured memory_bytes: 4752
from _bisect import bisect_right
N=int(input())
A=[int(input()) for _ in range(N)][::-1]

DP=[A[0]]
for i in range(1,N):
    num=A[i]
    if num>=DP[-1]:
        DP.append(num)
    else:
        index=bisect_right(DP,num)
        DP[index]=num
print(len(DP))

Measured memory_bytes: 13856
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    string ans;
    ll n,a,b,c,m,k,q,l;
    a=0;
    cin >> n;
    string s;
    cin >> s;
    for(ll i=0;i<n;i++)if(s[i]=='B')a++;
    if(n>(2*a))ans="Yes";
    else ans="No";
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7),n;
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = a+b+c-Math.max(a, Math.max(c, b));
		out.print(ans);
		out.close();
	}
	
	
}

Measured memory_bytes: 21332
#include <iostream>
#include <cstdio> 
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
int a[100005];
int main()
{
	string s;
	cin>>s;
	int flag=-1;
	while(true)
	{
		int f=0;
		flag*=(-1);
		for(int i=1;i<s.size()-1;i++)
		{
			if(s[i-1]==s[i+1])
			{
				continue;
			}
			else
			{
				f=1;
				string a=s.substr(0,i)+s.substr(i+1,s.size()-i-1);
				s=a;
				break;
			}
			
		}
		if(f==0)
		{
			break;
		}
		if(s.size()<=2)
		{
			flag*=(-1);
			break;
		}
	}
	if(flag==1)
	{
		cout<<"Second"<<endl;
	}
	else
	{
		cout<<"First"<<endl;
	}
	return 0;
}

Measured memory_bytes: 568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int n,m; cin >> n >> m;
    vector<int> memo(n+1);
    vector<int> ans(n+1);
    rep(i,m){
        int a; cin >> a;
        memo.at(a) = 1;
    }
    rep(i,n+1){
        if(i==0){
            ans.at(i) = 1;
        } else if(i == 1){
            if(memo.at(i) != 1){
                ans.at(i) = 1;
            }
        } else {
            if(memo.at(i) != 1){
                ans.at(i) = (ans.at(i - 1) + ans.at(i - 2)) % mod;
            }
        }
    }
    cout << ans.at(n) << endl;

    return 0;
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, N;
	cin >> H >> W >> N;
	int c[N];
	int A[H][W]{};
	rep(i,N) cin >> c[i];
	int num{}, cnt{};
	rep(i,H){
		rep(j,W){
			if(i % 2 == 0){
				A[i][j] = num+1;
				++cnt;
				if(cnt == c[num]){
					++num;
					cnt = 0;
				}
			}
			else{
				A[i][W-1-j] = num+1;
				++cnt;
				if(cnt == c[num]){
					++num;
					cnt = 0;
				}
			}
		}
	}
	rep(i,H){
		rep(j,W){
			cout << A[i][j] << ' ';
		}
		cout << endl;
	}
}

Measured memory_bytes: 512
N = int(input())
S = input()

es = [0] * N # 東を向かないといけない人の累積人数
ws = [0] * N # 西を向かないといけない人の累積人数

for i in range(1, N):
    es[i] = es[i-1]
    if S[i-1] == 'W':
        es[i] += 1
    ws[N-i-1] = ws[N-i]
    if S[N-i] == 'E':
        ws[N-i-1] += 1

print(min(es[i] + ws[i] for i in range(N)))


Measured memory_bytes: 19596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int N, M;
    cin >> N >> M;
    vint L(M), R(M);
    rep(i, M)
    {
        cin >> L[i] >> R[i];
    }
    int lmax = *max_element(all(L));
    int rmin = *min_element(all(R));
    cout << max(rmin - lmax+1,0);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                  \
  ifstream in("atcoder-problems/cf17_final_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string s;
  cin >> s;

  int a = 0, b = 0, c = 0;
  rep(i, s.size()) {
    if (s[i] == 'a') a++;
    if (s[i] == 'b') b++;
    if (s[i] == 'c') c++;
  }

  int minimum = min(min(a, b), c);
  a -= minimum;
  b -= minimum;
  c -= minimum;
  vector<int> d({a, b, c});
  sort(d.begin(), d.end(), greater<int>());

  int mod = s.size() % 3;
  if (a + b + c != mod || (mod == 0 && a + b + c == 3)) {
    cout << "NO" << endl;
    return 0;
  }

  bool ok = false;
  if (mod == 0) {
    if (d[0] != 3) ok = true;
  } else if (mod == 2) {
    if (d[0] == d[1]) ok = true;
  } else {
    ok = true;
  }

  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int f[100][10] = {};
int p[100][11] = {};

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 5; j++) {
			cin >> f[i][j*2+0];
			cin >> f[i][j*2+1];
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	int ans = -(1<<30);
	for(int bits = 1; bits < (1<<10); bits++) {
		int temp_score = 0;
		for(int j = 0; j < n; j++) {
			int temp_open = 0;
			for(int i = 0; i < 10; i++) {
				if(((1<<i)&bits)!=0 && f[j][i]>0) {
					temp_open++;
				}
			}
			temp_score += p[j][temp_open];
		}
		ans = max(ans,temp_score);
	}
	cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  int sum;
  int count=0;
  for (int i =0;i<n;i++) cin >> a[i];
  for (int i =n-1;i>=0;i--){
    sum=0;
    for (int j=2;;j++){
      if ((i+1)*j>n) break;
      sum+=a[(i+1)*j-1];
    }
    if (sum%2==a[i]){
      a[i]=0;
    }else {
      a[i]=1;
      count++;
    }
  }
  int j=0;
  int b[count];
  for (int i=0;i<n;i++){
    if(a[i]==1){
      b[j]=i+1;
      j++;
    }
  }
  cout << count << endl;
  for (int i =0;i<count;i++){
    cout << b[i] << " ";
  }
}


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

using namespace std;

int gcd(int a, int b) {
  return !b ? a : gcd(b, a % b);
}

int main() {
  int a, b;
  while (scanf("%d%d", &a, &b) == 2) {
    if (a > b) swap(a, b);
    int g = gcd(a, b);
    printf("%d %d\n", g, b / g * a);
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,k,s;
    cin >> n >> k >> s;
    for(int i = 0;i < k;i++)
    {
        if(i)
        {
            cout << " ";
        }
        cout << s;
    }
    if(s != 1000000000)
    {
        for(int i = k;i < n;i++)
        {
            cout << " " << s + 1;
        }
    }
    else
    {
        for(int i = k;i < n;i++)
        {
            cout << " 1";
        }
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int N; cin >>N;

  unsigned long Ans = 0;

  rep_eq( i, 1, N ) {
    if ( i%3 && i%5 ) Ans += i;
  }
  cout <<Ans <<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

string s[N];
map<string,int>m;

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
   // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int ma=0;
        for(int i=1;i<=n;++i){
            //string s;
            cin>>s[i];
            m[s[i]]++;
            ma=max(ma,m[s[i]]);
        }
        set<string>ss;
        for(int i=1;i<=n;++i){
            if(m[s[i]]==ma){
                ss.insert(s[i]);
            }
        }

        for(auto it: ss){
            cout<<(it)<<endl;
        }


        //printf("Case %d: ",++te);
    }
    return 0;
}




Measured memory_bytes: 41088
n=int(input())
s=input()
r=len([i for i in range(1,n) if s[i]=='E'])
l=0
i=1
x=r+l
while i<=n-1:
    if s[i]=='E' and s[i-1]=='E':
        r=r-1
        l=l
    elif s[i]=='W' and s[i-1]=='W':
        r=r
        l=l+1
    elif s[i]=='W' and s[i-1]=='E':
        r=r
        l=l
    elif s[i]=='E' and s[i-1]=='W':
        r=r-1
        l=l+1
    x=min(l+r,x)
    i+=1
print(x)

Measured memory_bytes: 15520
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int N,f; 
int main(){

    cin>>N;
    vector<int> a(N);
    f=0;
    for(int i;i<N;i++){
        cin>>a.at(i);
    }
    

    for(int i;i<N;i++){
        f=f+a.at(i)-1;
    }

    cout<<f<<endl;
    
    return 0;

}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = [i for i in range(N)]
C = []
for i in range(N):
    C.append([A[i],B[i]])
C = sorted(C,reverse=True)
dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    dp[i][0] = dp[i-1][0] + C[i-1][0]*(-C[i-1][1]+N-i)
    dp[0][i] = dp[0][i-1] + C[i-1][0]*(C[i-1][1]-i+1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i+j <= N:
            c = C[i+j-1][0]
            d = C[i+j-1][1]
            dp[i][j] = max(dp[i-1][j]+c*abs(N-i-d),dp[i][j-1]+c*abs(j-d-1))
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
print(dp[N][N])

Measured memory_bytes: 106428
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int len, dp[maxn];
char s[maxn], a[5][10];

int lpl(int t){
	if(dp[t] != -1) return dp[t];
	if(t >= 5){
		for(int i = 1; i <= 5; ++i){
			if(s[t - i + 1] != a[1][5 - i + 1]) break;
			if(i == 5 && lpl(t - 5) == 1) return dp[t] = 1;
		}
		for(int i = 1; i <= 5; ++i){
			if(s[t - i + 1] != a[3][5 - i + 1]) break;
			if(i == 5 && lpl(t - 5) == 1) return dp[t] = 1;
		}
	}
	if(t >= 6){
		for(int i = 1; i <= 6; ++i){
			if(s[t - i + 1] != a[4][6 - i + 1]) break;
			if(i == 6 && lpl(t - 6) == 1) return dp[t] = 1;
		}
	}
	if(t >= 7){
		for(int i = 1; i <= 7; ++i){
			if(s[t - i + 1] != a[2][7 - i + 1]) break;
			if(i == 7 && lpl(t - 7) == 1) return dp[t] = 1;
		}
	}
	return dp[t] = 0;
}

int main()
{
	memset(dp, -1, sizeof(dp)); dp[0] = 1;
	a[1][1] = 'd'; a[1][2] = 'r'; a[1][3] = 'e'; a[1][4] = 'a'; a[1][5] = 'm';
	a[2][1] = 'd'; a[2][2] = 'r'; a[2][3] = 'e'; a[2][4] = 'a'; a[2][5] = 'm'; a[2][6] = 'e'; a[2][7] = 'r';
	a[3][1] = 'e'; a[3][2] = 'r'; a[3][3] = 'a'; a[3][4] = 's'; a[3][5] = 'e';
	a[4][1] = 'e'; a[4][2] = 'r'; a[4][3] = 'a'; a[4][4] = 's'; a[4][5] = 'e'; a[4][6] = 'r';
	scanf("%s", s + 1); len = strlen(s + 1);
	if(lpl(len)) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	int N;
	cin >> N >> S;
	for(int i = 0; i < S.length(); i++)
		printf("%c", (S.at(i)-'A'+N)%26+'A');
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
	string s;
	cin >> s;
	string array[] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
	int n;
	if(s=="SUN"){
		cout << 7;
		return 0;
	}
	rep(i,7){
		if(array[i]==s){
			cout<<6-i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<ll,ll> P;
#define fi first
#define se second
map<ll,ll> mp;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int x,y,z;
cin>>x>>y>>z;
vector<vector<bool>> a(x,vector<bool>(y,true));
for(int i=0;i<z;i++){
    int s,b,c;
    cin>>s>>b>>c;
    if(c==1){
        for(int i=0;i<s;i++)for(int j=0;j<y;j++)a.at(i).at(j)=false;
    }
    else if(c==2){
        for(int i=s;i<x;i++)for(int j=0;j<y;j++)a.at(i).at(j)=false;
    }
    else if(c==3){
         for(int i=0;i<b;i++)for(int j=0;j<x;j++)a.at(j).at(i)=false;
    }
    else{
         for(int i=b;i<y;i++)for(int j=0;j<x;j++)a.at(j).at(i)=false;
    }
}
int ans=0;
for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
        if(a.at(i).at(j))ans++;
    }
}
cout<<ans<<endl;
}


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

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

int a[100005],l[100005],r[100005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    REP(i,1,n+1)cin>>a[i];
    l[0]=0;
    REP(i,1,n+1) l[i]=gcd(l[i-1],a[i]);
    r[n+1]=0;
    for(int i=n;i>0;i--)r[i]=gcd(r[i+1],a[i]);
    REP(i,1,n+1)a[i]=gcd(l[i-1],r[i+1]);
    int maxi=0;
    REP(i,1,n+1)if(a[i]>maxi)maxi=a[i];
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 1408
import math

n = int(input())
ans = 0
for i in range(105, n+1, 2):
    cnt = 0
    for j in range(2, int(math.sqrt(i-1))+1):
        # print(i, j)
        if i % j == 0:
            cnt += 1
    if cnt == 3:
        ans += 1
print(ans)


Measured memory_bytes: 2940
N,A,B=map(int,input().split())
if A>B:
  tem=A
  A=B
  B=tem
if (B-A)%2==0:
  print((B-A)//2)
else:
  print(min(A+(B-A-1)//2,N-B+1+(B-A-1)//2))

Measured memory_bytes: 3060
def solve():
    a1 = raw_input()
    a2 = raw_input()
    a = len(a1)
    b = len(a2)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = a1[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == a2[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i2 in range(n):
    print solve()

Measured memory_bytes: 6516
import java.io.*;
 
class Main {
    public static void main(String[] arg)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] div = str.split(" ");
        int s =  Integer.parseInt(div[0]);
        int l =  Integer.parseInt(div[1]);
        System.out.println(s*l + " "+ 2*(s+l));
    }   
}

Measured memory_bytes: 24304
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

//解説1行読みAC

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	ll A, B;
	cin >> A >> B;
	vll V(N);
	V[0] = 0;
	int pre;
	cin >> pre;
	REP(i, N - 1) {
		int cur;
		cin >> cur;
		V[i + 1] = cur - pre;
		pre = cur;
	}
	ll ans = 0;
	FOR(i, 1, N) {
		ans += min(V[i] * A, B);
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 1272
import java.util.*;
    public class Main {
      public static void main(String...args) {
      	final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= N; i++) {
          int sum = 0;
          for(int j = i; j > 0; j /= 10)
            sum += j % 10;
          if(A <= sum && sum <= B)
            ans += i;
        }
        System.out.println(ans);
      }
    }

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

int main()
{
    int i, j;
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    int a[n][m];
    int count[n];
    int hantei = 0;
    for (i = 0; i < m; i++)
        cin >> b[i];
    for (i = 0; i < n; i++)
        for(j = 0; j < m; j++)
            cin >> a[i][j];
    for (i = 0; i < n; i++) {
        count[i] = c;
        for (j = 0; j < m; j++)
            count[i] += a[i][j] * b[j];
        if (count[i] > 0)
            hantei++;
    }
    cout << hantei << endl;
    return (0);
}

Measured memory_bytes: 256