akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <bits/stdc++.h>
#include <cmath>
#define maxn 50010
#define maxm 1000010
#define ls x << 1
#define rs x << 1 | 1
#define inf 1000000000
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define mid ((l + r) >> 1)
//#define int long long
#define XRZ 212370440130137957
#define debug() puts("XRZ TXDY");
#define mem(i, x) memset(i, x, sizeof(i));
#define Next(i, u) for(register int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
int dx[10] = {1, -1, 0, 0};
int dy[10] = {0, 0, 1, -1};
using namespace std;
inline int read() {
    register int x = 0, f = 1; register char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
signed main() { int n = read(), x = read(), t = read();
	printf("%d", (int) ceil((double) n / x) * t);
//	cout << ceil(((double) n / x)) * t;
	return 0;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
int n;
int cnt[28];


int main(void){
	cin >> str;
	n=str.size();
	for(int i=0;i<n;i++){
		cnt[str[i]-'a']++;
	}
	int sum=0;
	for(int i=0;i<26;i++){
		if(cnt[i]%2==1){
			if(n%2==0)sum++;
			else n=0;
		}
	}
	sum-=sum/2;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3252
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S, T;
  ll r = 99999999;
  
  for (int i = 0; i <= S.length() - T.length(); i++) {
    ll nowr = 0;
    for (int j = 0;j < T.length(); j++) {
      if (T[j] != S[i + j])
        nowr++;
    }
    r = min(r, nowr);
  }


  return r;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

int main(void)
{
  
  int a,b,c,x, k;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  
  int answer = 0;
  
  for(int i = 0; i <= x/500; i++){
    for(int j = 0; j<= (x - 500 * i) / 100; j ++){

      k = x - 500 * i - 100 * j;
      
      if(k % 50 == 0 && k/50 <= c && j<= b && i <= a) {
        answer++;
        
        }
      
      }
    }
  
  

  printf("%d",answer);
  
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int len =str.length();
        sc.close();
        for(int i=1;i<=len;i++){
            int center = (len-i)/2;
            if(str.substring(0, center).equals(str.substring(center,len-i))){
                System.out.println(len-i);   
                break;
            }
        }
    }
}

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

int main(){
  int n;
  cin >> n;
  int ans=0;
  string s;
  for(int i=1;i<=n;i++){
    s=to_string(i);
    if(s.size()%2==1)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3716
H,W,N=map(int,input().split())
data=[[] for i in range(H+1)]
for i in range(N):
    X,Y=map(int,input().split())
    data[X].append(Y)
h=1
ans=H
for i in range(2,H+1):
    if not data[i]:
        h+=1
        continue
    m=min(data[i])
    if m>h+1:
        h+=1
        continue
    elif m==h+1:
        continue
    else:
        print(i-1)
        break
else:
    print(H)

Measured memory_bytes: 67148
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	N = int(input())
	W = []
	for _ in range(N):
		tmp = input()
		if tmp in W:
			print("No")
			sys.exit()
		W.append(tmp)
		
	for i, val in enumerate(W):
		if i > len(W)-2:
			print("Yes")
			sys.exit()
		
		if val[len(val)-1] != W[i+1][0]:
			print("No")
			sys.exit()
	
	print("No")
		
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3444
N,M,X=list(map(int,input().split()))
A=list(map(int,input().split()))

goal_0 = 0
goal_N = 0

for i in range(X,N+1):
    if i in A:
        goal_N += 1

for i in range(0,X):
    if i in A:
        goal_0 += 1

if goal_0 >= goal_N:
    print(goal_N)
else:
    print(goal_0)


Measured memory_bytes: 3060
def p_a():
    S = input()

    i = 0
    nx = ""
    ans = 0
    while i < len(S):
        p = nx
        nx = S[i]

        while p == nx and i + 1 < len(S):
            i += 1
            nx += S[i]

        if p == nx:
          break

        i += 1
        ans += 1

    print(ans)


if __name__ == '__main__':
    p_a()


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



int main()
{
    int64_t x;
    cin>>x;

    int64_t res_a=0,res_b=0;
    for(int64_t a=-200;a<200;a++){
        for(int64_t b=-200;b<200;b++){
            if(pow(a,5)-pow(b,5)==x){
                res_a=a;
                res_b=b;
                break;
            }
        }
    }

    cout<<res_a<<' '<<res_b<<endl;

    return 0;
}

Measured memory_bytes: 4040
#pragma GCC optimize("Ofast")  
#include<bits/stdc++.h>
using namespace std;

#define ll 				long long
#define eb 				emplace_back
const long long 		MOD = 1e9 + 7;
#define rep(i,n) 		for (int (i) = 0; (i) < (n); (i)++) 
#define REP(i,k,n)  	for (int (i) = (k); (i) <= (n); (i)++) 
#define REPR(i,k,n) 	for (int (i) = (k); (i) >= (n); (i)--)
#define watch(x) 		cout << (#x) << " = " << (x) << endl
#define t(x)			int x; cin >> x; while(x--)

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	/*---- continue Coding ;----*/

	int n;
	cin >> n;
	if(n%1000 == 0){
		cout << 0 << "\n";
	}else{
		cout << 1000 - (n%1000) << "\n";
	}
	
	
	/*---- break ;----*/

	cerr<<"Execution time: "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}

Measured memory_bytes: 3744
import math
import sys
a, b, x = map(int, input().split())
up, down = 0, b
a_dec = 2*x / (a * b)
if a_dec > a:
    up = 2 * x/(a**2) - b
    up = b - up
    c = (a**2+up**2)**(1/2)
    print(math.degrees(math.asin(up/c)))
    sys.exit(0)
c = (a_dec**2+b**2)**(1/2)
print(math.degrees(math.asin(b/c)))


Measured memory_bytes: 38548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int D;
int N = 26;
vi c;
vvi s;
vi ans;
vi las;



pii rec(int n, int dd, vi lass){
    
    if(dd >= D || n == 3) return {0,1};
    
    int los = 0;
    rep(i,N) los += c[i]*(dd-lass[i]);
    int res = -infi;
    int an = 1;
    
    rep(i,N){
        vi la = lass;
        int ddd = s[dd][i]-los+c[i]*(dd-lass[i]);
        la[i] = dd;
        int da = ddd+rec(n+1,dd+(n+1),la).fi;
        if(chmax(res,da)) an = i+1;
        
    }
    
    return {res,an};
    
}



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

    //int ti = clock();
    
    
    cin >> D;
    c.resize(N);
    s.resize(D, vi(N));
    
    in(N,c);
    rep(i,D) rep(j,N) cin >> s[i][j];
    
    ans.resize(D);
    las.assign(N,-1);
    
    
    
    
    
    rep(d,D){
        ans[d] = rec(0,d,las).se;
        las[ans[d]-1] = d;
    }









    
    
    
    rep(i,D) cout << ans[i] << endl;
    
    
    //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);

    return 0;
}


Measured memory_bytes: 3720
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max({a*c, b*d, a*d, b*c});
    cout << ans << endl; 
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.nextLine();

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

        System.out.println(Math.sqrt(ans));
    }
}

Measured memory_bytes: 35964
import java.util.*;

public class Main{
  
  public static void main (String[] args){
  
  	Scanner scanner = new Scanner (System.in);
  
   	int N = scanner.nextInt();
    int sum = 0;
    
    for (int i=0; i<N; i++){
      int l = scanner.nextInt();
      int r = scanner.nextInt();
      sum += (r-l+1);
    }
    System.out.println(sum);
  }
}

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

const int maxn = 1e5+5;
struct P
{
    int x,y,id;
}p[maxn];
struct Edge
{
    int u,v,w;
}e[maxn<<1];
int f[maxn];
int Find(int x)
{
    return f[x]==x?f[x]:f[x]=Find(f[x]);
}

int main()
{
    int n; cin>>n;
    int cnt=0;
    for(int i=1;i<=n;++i){
         scanf("%d%d",&p[i].x,&p[i].y);
         p[i].id=i;
    }
    sort(p+1,p+n+1,[](P a,P b){return a.x<b.x;});
    for(int i=1;i<n;++i){
        e[++cnt].u=p[i].id; e[cnt].v=p[i+1].id; e[cnt].w=p[i+1].x-p[i].x;
    }
    sort(p+1,p+n+1,[](P a,P b){return a.y<b.y;});
    for(int i=1;i<n;++i){
        e[++cnt].u=p[i].id; e[cnt].v=p[i+1].id; e[cnt].w=p[i+1].y-p[i].y;
    }
    ll ans=0;
    for(int i=1;i<=n;++i) f[i]=i;
    sort(e+1,e+cnt+1,[](Edge a,Edge b){return a.w<b.w;});
    for(int i=1;i<=cnt;++i){
        if(Find(e[i].u)!=Find(e[i].v)){
            f[Find(e[i].u)] = Find(e[i].v); ans+=e[i].w;
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 4224
#include<stdio.h>
 
 int main()
{

 int h,w,i,j;
 
 for(;;){
         scanf("%d%d",&h,&w);
         if(h+w==0) break;
         for(i=0;i<h;i++){
                          for(j=0;j<w;j++)
                          if(i*j==0 || i+1==h || j+1==w)
                                  printf("#");
                          else
                                  printf(".");
                          printf("\n");
                          }

           printf("\n");
          }
     return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
int cnt[105],tot;
int main(){
	int n,k,m,i,j,a;
	scanf("%d%d",&n,&k);
	for(i=1;i<=k;i++){
		scanf("%d",&m);
		for(j=1;j<=m;j++){
			scanf("%d",&a);
			cnt[a]++;
		}
	}	
	for(i=1;i<=n;i++)
		if(cnt[i])tot++;
	printf("%d\n",n-tot);
	return 0;
}

Measured memory_bytes: 3184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine().Select(c => c - 'a');
        var T = ReadLine().Select(c => c - 'a');

        var ans = "Yes";
        var STMapper = Enumerable.Repeat(-1, 26).ToArray();
        var TSMapper = Enumerable.Repeat(-1, 26).ToArray();
        foreach (var (s, t) in S.Zip(T))
        {
            if (STMapper[s] == -1)
                STMapper[s] = t;

            if (TSMapper[t] == -1)
                TSMapper[t] = s;

            if (STMapper[s] != t || TSMapper[t] != s)
            {
                ans = "No";
                break;
            }
        }

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28272
function Main(input){
	input=input.split(" ");
	let a=parseInt(input[0],10);
	let b=parseInt(input[1],10);
	let c=parseInt(input[2],10);
	if (a < b && b < c) {
		console.log("Yes");
	} else {
		console.log("No");
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 15096
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
        sum %= mod;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        sum -= a[i];
        if(sum < 0)sum += mod;
        ans += a[i] * sum;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);++i)

class Node{
public:
    int location;
    int p,l,r;
    Node(){}
};

class Point{
public:
    int id,x,y;
    Point(){}
    Point(int id,int x,int y):id(id),x(x),y(y){}
    bool operator < (const Point &p) const{
        return id < p.id;
    }

    void print(){
        printf("%d\n",id);
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){return p1.x < p2.x; }
bool lessY(const Point &p1,const Point &p2){return p1.y < p2.y; }

int makeKDTree(int l,int r,int depth){
    if(!(l<r)) return NIL;
    int mid = (l+r)/2;
    int t = np++;
    if(depth%2==0){
        sort(P+l,P+r,lessX);
    }
    else{
        sort(P+l,P+r,lessY);
    }
    T[t].location=mid;
    T[t].l=makeKDTree(l,mid,depth+1);
    T[t].r=makeKDTree(mid+1,r,depth+1);

    return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
    int x=P[T[v].location].x;
    int y=P[T[v].location].y;
    if(sx<=x && x<=tx && sy<=y && y<=ty ){
        ans.pb(P[T[v].location]);
    }
    if(depth%2==0){
        if(T[v].l != NIL){
            if(sx<=x){
                find(T[v].l,sx,tx,sy,ty,depth+1,ans);
            }
        }
        if(T[v].r != NIL){
            if(x<=tx){
                find(T[v].r,sx,tx,sy,ty,depth+1,ans);
            }
        }
    }
    else{
        if(T[v].l != NIL){
            if(sy<=y){
                find(T[v].l,sx,tx,sy,ty,depth+1,ans);
            }
        }
        if(T[v].r != NIL){
            if(y<=ty){
                find(T[v].r,sx,tx,sy,ty,depth+1,ans);
            }
        }
    }
}

int main(){
    int x,y;
    scanf("%d",&N);
    rep(i,N){
        scanf("%d %d",&x,&y);
        P[i]=Point(i,x,y);
        T[i].l=T[i].r=T[i].p=NIL;
    }
    
    np=0;

    int root =makeKDTree(0,N,0);
    int q;
    scanf("%d",&q);
    int sx,tx,sy,ty;
    vector<Point> ans;
    rep(i,q){
        scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        rep(j,ans.size()){
            ans[j].print();
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  bool answer = false;
  for(int i=0; i<3; i++){
    if(N.at(i) == '7'){
      answer = true;
    }
  }
  if(answer){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int ans = 0;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++){
        if(s.at(i) != t.at(i))ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int b[33],ans1[1000005],cnt=0,maxx=0;
const int MAXX=200005;
ll quick_m(int s)
{
    ll ans=1,p=2;
    while(s)
    {
        if(s&1)
            ans=ans*p;
        s>>=1;
        p=p*p;
    }
    return ans;
}

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

int n;
ll a[405], dp[405][405], kum[405];
const ll inf = (ll)1e15;

ll rek(int l, int r){
	if(l >= r)
		return 0;
	ll &ret = dp[l][r];
	if(ret != -1)
		return ret;
	ret = inf;
	for(int i = l ; i < r ; ++i){
		ret = min(ret, rek(l, i) + rek(i + 1, r) + kum[r] - kum[l - 1]);
	}
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1 ; i <= n ; ++i){
	cin >> a[i];
	kum[i] = kum[i - 1] + a[i];
}
memset(dp, -1, sizeof(dp));
cout << rek(1, n) << endl;

return 0;
}



Measured memory_bytes: 1536
// ABC139B2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>

using namespace std;

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

	int ans = 0;
	if (B == 1) // 必要な口数が１つだけなら、電源タップは必要なし
	{
		ans = 0;
	}
	else
	{

		if (A >= B)
		{
			ans = 1;// A>=Bなら電源タップは１個で良い
		}
		else
		{
			ans = 1 + (B - A) / (A - 1); // 最後の電源タップ１つ＋（全口数ー最後につなぐ電源タップの口数）／（電源タップの口数－１）
			if ((B - A) % (A - 1) > 0)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;

int main() {
  long long N, INF=1000000001;
  cin >> N;
  long long mx=INF, Mx=-INF, my=INF, My=-INF;
  vector<pp> V(N);
  for (int i=0; i<N; i++) {
    cin >> V[i].first >> V[i].second;
    if (mx>V[i].first) {
      mx=V[i].first;
    }
    if (Mx<V[i].first) {
      Mx=V[i].first;
    }
    if (my>V[i].second) {
      my=V[i].second;
    }
    if (My<V[i].second) {
      My=V[i].second;
    }
  }
  
  int X=(Mx+mx)/2;
  int Y=(My+my)/2;
  
  //cout << X << " " << Y << endl;
  
  int nx, ny;
  
  vector<int> A1(2,0), A2(2,0), A3(2,0), A4(2,0);
  for (int i=0; i<N; i++) {
    V[i].first=V[i].first-X;
    V[i].second=V[i].second-Y;
    nx=V[i].first;
    ny=V[i].second;
    if (nx>=0 && ny>=0 && A1[0]+A1[1]<nx+ny) {
      A1[0]=nx;
      A1[1]=ny;
    }
    else if (nx<0 && ny>=0 && -A2[0]+A2[1]<-nx+ny) {
      A2[0]=nx;
      A2[1]=ny;
    }
    else if (nx<0 && ny<0 && -A3[0]-A3[1]<-nx-ny) {
      A3[0]=nx;
      A3[1]=ny;
    }
    else if (nx>=0 && ny<0 && A4[0]-A4[1]<nx-ny) {
      A4[0]=nx;
      A4[1]=ny;
    }
  }
  int MM=max(A1[0]-A3[0]+A1[1]-A3[1], A4[0]-A2[0]+A2[1]-A4[1]);
  cout << MM << endl;
}

Measured memory_bytes: 4836
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] top={-1,-1,-1};
		for(int i=0;i<10;i++){
			int hight = Integer.parseInt(sc.nextLine());
			for(int j=0;j<3;j++){
				if(top[j]<hight){
                                    int store=top[j];
                                    top[j]=hight;
                                    if(j==0){
                                        hight=top[j+1];
                                        top[j+1]=store;
                                        top[j+2]=hight;
                                    }else if(j==1){
                                        top[j+1]=store;
                                    }
                                    break;
				}
			}
		}
		System.out.println(top[0]);
		System.out.println(top[1]);
		System.out.println(top[2]);
		
	}
}


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

bool solve()
{
    string s;
    vector<char> clist = {'a', 'b', 'c'};
    cin >> s;

    for (char c: clist) {
        if (count(s.begin(), s.end(), c) != 1) {
            return false;
        }
    }
    return true;
}

int main()
{
    if (solve()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int i = 0;
	string s;
	cin >> s;
	while (s[i]) {
		if (s[i] == ',') {
			s[i] = ' ';
		}
		i++;
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int R,a,i=1,j=0;
  	scanf("%100d",&R);
  	for(i;i<=R;i++){
      	scanf("%100d",&a);
     	if((i%2==1)&&(a%2==1))j++;
    }
  	printf("%d",j);
	return 0;
}

Measured memory_bytes: 1680
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=t.in(),n=new Array(r),i=0;i<r;i++)n[i]=t.in();for(var o=e;o<=1e6;o++){for(var s=o,u=!0;s>0;){for(var c=s%10,f=0;f<r;f++)if(n[f]==c){u=!1;break}if(!u)break;s=Math.floor(s/10)}if(u)return void console.log(o)}}}]);

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    string ss;
    cin >> ss;
    sort(ss.begin(), ss.end());
    s[i] = ss;
  }
  sort(s.begin(), s.end());
  ll ans = 0, cnt = 1;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) {
      cnt++;
      if (i == n - 2) {
        ans += cnt * (cnt - 1) / 2;
      }
    } else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6320
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
const int MAX=1000001;

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

    int fx=0;
    int i=1;
    while(i<=n){
        int a=(n%(10*i))/i;
        fx+=a;
        i*=10;
    }

    if(n%fx==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>a[i];
    }
    int ans=a[1]+a[n-1];
    for(int i=1;i<n-1;i++)ans+=min(a[i],a[i+1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k); k--;
	std::string s; cin >> s;
	
	s[k] += 'a' - 'A';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N, std::vector<std::string> S)
{
  set<string> s;
  rep(i, N) s.insert(S[i]);
  cout << s.size() << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  for (int i = 0; i < N; i++)
  {
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 25152
package main
 
import (
	"fmt"
)
 
func main() {
	var L, R, D,count int
	fmt.Scan(&L)
	fmt.Scan(&R)
	fmt.Scan(&D)
	for i := L; i <= R; i++ {
		if i % D == 0 {
			count++
		}
	}
    fmt.Println(count)
}


Measured memory_bytes: 1768
#include <algorithm>
#include <deque>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using large = long long;

struct Node {
    int v;
    int distance;

    friend bool operator<(const Node a, const Node b) { return a.distance < b.distance; }
};

static Node extract(vector<Node> &nodes) {
    int index = 0;
    int min_distance = nodes[0].distance;
    for (int i = 1; i < nodes.size(); i++) {
        if (nodes[i].distance < min_distance) {
            min_distance = nodes[i].distance;
            index = i;
        }
    }

    if (index + 1 != nodes.size()) {
        swap(nodes[index], nodes.back());
    }
    auto node = nodes.back();
    nodes.pop_back();
    return node;
}

static large distance(int start, int goal, const std::vector<vector<int>> &connected_from) {
    const auto n = connected_from.size();
    auto touched = vector<char>(n);
    auto closed = vector<char>(n);
    auto nodes = vector<Node>();

    nodes.push_back(Node{start, 0});
    touched[start] = true;

    while (!nodes.empty()) {
        // auto node = *nodes.begin();
        // nodes.erase(nodes.begin());
        auto node = extract(nodes);
        closed[node.v] = true;

        if (node.v == goal) {
            return node.distance;
        }

        for (auto u : connected_from[node.v]) {
            if (closed[u])
                continue;
            if (!touched[u]) {
                touched[u] = true;
                nodes.push_back(Node{u, node.distance + 1});
                continue;
            }
            auto itr = find_if(nodes.begin(), nodes.end(), [u](auto &n) { return n.v == u; });
            if (itr != nodes.end()) {
                if (node.distance + 1 < itr->distance) {
                    // nodes.erase(itr);
                    // nodes.insert(Node{u, node.distance + 1});
                    itr->distance = node.distance + 1;
                }
            }
        }
    }

    return -3;
}

int main() {
    int n, m;
    cin >> n >> m;

    auto connected_from = vector<vector<int>>(n * 3);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        connected_from[3 * u + 0].push_back(3 * v + 1);
        connected_from[3 * u + 1].push_back(3 * v + 2);
        connected_from[3 * u + 2].push_back(3 * v + 0);
    }
    int s, t;
    cin >> s >> t;
    s--, t--;

    cout << distance(3 * s, 3 * t, connected_from) / 3;
    return 0;
}


Measured memory_bytes: 17280
// https://atcoder.jp/contests/abc058/tasks/arc071_b
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int MOD = 1000000007;
// namespace mp = boost::multiprecision;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w, h, t;
    cin >> w >> h;
    vector<ll> vx(w), vy(h);
    REP(i, w) {
        cin >> t;
        vx[i] = t;
    }
    REP(i, h) {
        cin >> t;
        vy[i] = t;
    }
    ll x = 0, y = 0;
    // REP(i, w) FOR(j, i + 1, w) {
    //     x += vx[j] - vx[i]);
    //     x %= MOD;
    // }
    // REP(i, h) FOR(j, i + 1, h) {
    //     y += vy[j] - vy[i]);
    //     y %= MOD;
    // }
    REP(i, w) {
        // 足される回数はindex=0が0回、1が1回
        // 引かれる回数はindex=0がw-1回、2がw-2回
        x += vx[i] * i - vx[i] * (w - i - 1);
        x %= MOD;
    }
    REP(i, h) {
        y += vy[i] * i - vy[i] * (h - i - 1);
        y %= MOD;
    }
    cout << (x * y) % MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Int dp[4000][10000];

int main(void) {
    Int N, T; cin >> N >> T;
    vector<pair<Int, Int>> food(N);
    for (int i = 0; i < N; i++) {
        Int a, b; cin >> a >> b;
        food[i] = {a, b};
    }

    sort(food.begin(), food.end());
    Int ans = 0;
    for (int n = 0; n < N; n++) {
        for (int t = 0; t < 10000; t++) {
            ans = max(dp[n][t], ans);
            if (T <= t) continue;
            Int food_v = food[n].second;
            Int food_t = food[n].first;
            dp[n+1][t+food_t] = max(dp[n+1][t+food_t], dp[n][t] + food_v);
            dp[n+1][t] = max(dp[n+1][t], dp[n][t]);
        }
    }
    for (int t = 0; t < 10000; t++) {
        ans = max(dp[N][t], ans);
    }
    cout << ans << endl;
}




Measured memory_bytes: 235008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        int total = i*500 + j*100 + k*50;
        if(total == X){
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    int N, M;
    cin >> N >> M;
    bool ans_ac[N];
    int ans_penal[N];
    for (int i=0; i<N; i++){
        ans_ac[i] = false;
        ans_penal[i] = 0;
    }
    for (int i=0; i<M; i++){
        string ss;
        int p;
        cin >> p >> ss;
        if (ss=="AC"){
            ans_ac[p-1] = true;
        } else if (ss=="WA"){
            if (ans_ac[p-1] == false){
                ans_penal[p-1] = ans_penal[p-1] + 1;
            }
        } else {
            cout << "OH NO" << endl;
        }
    }
    int ans1 = 0;
    int ans2 = 0;
    for (int i=0; i<N; i++){
        if (ans_ac[i] == true){
            ans1++;
            ans2 += ans_penal[i];
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> t(1000001);
  for (int i = 0; i < n; i++) {
    t[a[i]]++;
  }
  vector<int> d(1000001);
  for (int i = 1; i <= 1000000; i++) {
    for (int j = i; j <= 1000000; j += i) {
      d[j] += t[i];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (d[a[i]] == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11920
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVVld = vector<VVld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int N, K; cin >> N >> K;
  V a(N);
  rep(i, N) cin >> a[i];
  
  V dp(K+1);

  rep(k, K) rep(i, N) if (dp[k] == 0 && k+a[i] <= K) dp[k+a[i]] = 1;
  
  string ans = (dp[K] > 0) ? "First" : "Second";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>

int main(){
    char a[]="abc",b[]="bac",c[]="bca",d[]="cab",e[]="cba",f[]="acb";
    char s[4];
    
    scanf("%s",s);
    
    if(strcmp(s,a)==0 || strcmp(s,b)==0 || strcmp(s,c)==0 || strcmp(s,d)==0 || strcmp(s,e)==0 || strcmp(s,f)==0){
        printf("Yes\n");
    }
    
    else{
        printf("No\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 128
N, P = map(int, input().split())
A = list(map(int, input().split()))
L = [i%2 for i in A]

odd_cnt = L.count(1)
eve_cnt = L.count(0)

if odd_cnt == 0:
    if P == 0:
        print(2**N)
    else:
        print(0)
else:
    print(2**(N-1))

Measured memory_bytes: 3060
import numpy as np
import sys
input = sys.stdin.readline
 
N = int(input())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = np.array(input().split(), dtype=np.int64)

A.sort()
B.sort()
C.sort()

A_cnt = np.searchsorted(A, B, side='left')
C_cnt = np.searchsorted(C, B, side='right')

ans = (A_cnt * (N-C_cnt)).sum()

print(ans)

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

typedef long long ll;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


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

    ll mod = pow(10, 9) + 7;

    ll N, K;

    cin >> N >> K;

    ll lu = N - K + 1;
    ll ru = 1;

    ll ld = 1;
    ll rd = 1;

    for(ll i = 1; i <= K; i++) {
        if(i > N - K + 1) {
            cout << 0 << endl;
        } else {
            cout << (lu * ru) % mod * modpow(ld, mod - 2, mod) % mod * modpow(rd, mod - 2, mod) % mod << endl;
        }
        ld *= (i + 1);
        ld %= mod;
        rd *= i;
        rd %= mod;
        lu *= N - K + 1 - i;
        lu %= mod;
        ru *= K - i;
        ru %= mod;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 103;
int a[N], cnt[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	int d = a[n];
	for(int i = 1; i <= n; i++)
	{
		if(a[i] < (d + 1)/2)
		{
			// cout << "1 ";
			return cout << "Impossible\n", 0;
		}
		cnt[a[i]]++;
	}
	int x = 2;
	if(d % 2 == 0)
		x--;
	if(cnt[(d + 1)/2] != x)
	{
		// cout << "2 ";
		return cout << "Impossible\n", 0;
	}
	for(int i = (d + 1)/2 + 1; i <= d; i++)
	{
		if(cnt[i] < 2)
		{
			// cout << "3 ";
			return cout << "Impossible\n", 0;
		}
	}
	cout << "Possible\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int X,Y,N,x,y,z,w;
		cin>>X>>Y>>N;
		X=2*X;
		Y=2*Y;
		long a[31][31]={};
		for(int j=2;j<31;j+=2){
			a[j][0]=1;
			a[0][j]=1;
		}
		for(int j=0;j<N;j++){
			cin>>x>>y>>z>>w;
			x=2*x;
			y=2*y;
			z=2*z;
			w=2*w;
			if(x==0&&z==0){
				if((y-w)>0){
					for(int k=y;k<31;k+=2){
						a[k][0]=0;
					}
				}
				else{
					for(int k=w;k<31;k+=2){
						a[k][0]=0;
					}
				}
			}
			else if(y==0&&w==0){
				if((x-z)>0){
					for(int k=x;k<31;k+=2){
						a[0][k]=0;
					}
				}
				else{
					for(int k=z;k<31;k+=2){
						a[0][k]=0;
					}
				}
			}
			else  {
				a[(y+w)/2][(x+z)/2]=-1;
			}
		}
		
		for(int j=2;j<31;j+=2){
			for(int k=2;k<31;k+=2){
				if(a[j-1][k]==0)a[j][k]+=a[j-2][k];
				if(a[j][k-1]==0)a[j][k]+=a[j][k-2];
			}
		}
		if(a[Y][X]!=0)cout<<a[Y][X]<<"\n";
		else cout<<"Miserable Hokusai!\n";
	}
	
	return 0;
}

Measured memory_bytes: 3096
m,d=map(int,input().split())
cnt=0
for i in range(1,m+1):
    for j in range(1,d+1):
        d10=int(("0"+str(j))[-2])
        d1=int(("0"+str(j))[-1])
        if d1>=2 and d10>=2 and d1*d10==i:
            cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
bool t;
int i,j,k,n,a[10][10],b[101],c[10][10],s,s1;
int main ()
{
	for (i=1;i<=3;i++)
	for (j=1;j<=3;j++)
	cin>>a[i][j];
	
	cin>>n;
	for (i=1;i<=n;i++)
	cin>>b[i];
	for (k=1;k<=n;k++)
	
	for (i=1;i<=3;i++)
	
		for (j=1;j<=3;j++)
		if (b[k]==a[i][j]) c[i][j]=1;
	
	if (c[1][1]+c[2][2]+c[3][3]==3 || c[1][3]+c[2][2]+c[3][1]==3)
	{
		cout<<"Yes"; return 0;
	}
	for (i=1;i<=3;i++)
	
	{ s=0; s1=0; 
		for (j=1;j<=3;j++)
		{
		if (c[i][j]==1) s++;
		if (c[j][i]==1) s1++;
		}
		if (s==3 || s1==3 ) 
		{
			t=true; break;
		}
		
	}
	if (t==true) cout<<"Yes"; else cout<<"No";

		

}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        StringBuilder strb = new StringBuilder();

        while (true) {
            String[] data = br.readLine().split(" ");
            int a = Integer.parseInt(data[0]);
            String op = data[1];
            int b = Integer.parseInt(data[2]);
            int result = 0;

            if (op.equals("?")) {
                break;
            } else if (op.equals("+")) {
                result = a + b;
            } else if (op.equals("-")) {
                result = a - b;
            } else if (op.equals("*")) {
                result = a * b;
            } else if (op.equals("/")) {
                result = a / b;
            }
            strb.append(result).append("\n");
        }
        System.out.print(strb);
    }
}

Measured memory_bytes: 24112
s=input()
l=len(s)
dp=[4*[0]for _ in range(l+1)]
dp[0][0]=1
for i in range(1,l+1):
  si=s[i-1]
  for j in range(4):dp[i][j]=dp[i-1][j]*((si=="?")*2+1)
  if si=="A":dp[i][1]+=dp[i-1][0]
  if si=="B":dp[i][2]+=dp[i-1][1]
  if si=="C":dp[i][3]+=dp[i-1][2]
  if si=="?":
    dp[i][1]+=dp[i-1][0]
    dp[i][2]+=dp[i-1][1]
    dp[i][3]+=dp[i-1][2]
  for j in range(4):dp[i][j]%=10**9+7
print(dp[-1][-1])

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

int main() {
  int a,b,c,d,e,f;
  int A,B,C,D;
  cin>>a>>b>>c>>d>>e>>f;
  A=a*b;
  B=c*d;
  C=e*f;
  D=A+B+C;
  if(D==12||D==13||D==15||D==17||D==18||D==20||D==22||D==23){
  cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int x,t;
  cin>>x>>t;
  cout<<max(0,x-t)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

	int T; cin >> T;
	rep (i, T){
		int N, D; cin >> N >> D;
		vector<int> a(N, 0);

		a[0] = D;
		for (int i = 1; i < N; ++i){
			int y = (127 ^ a[i-1]);// cerr << y << endl;
			a[i-1] = a[i-1] ^ y;
			a[i] = y;
		} // end for

		int res = accumulate(ALL(a), 0);
		cout << res << endl;
	} // end rep
					
	return 0;
}

Measured memory_bytes: 256
// Problem : E - Synchronized Subsequence
// Contest : AtCoder - AtCoder Grand Contest 026
// URL : https://atcoder.jp/contests/agc026/tasks/agc026_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Code written by IMALYD
//LK AK IOI Orz
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define it iterator
template<class IT>inline void cmx(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmn(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline bool bmx(IT &a,IT b){if(a<b){a=b;return true;}else return false;}
template<class IT>inline bool bmn(IT &a,IT b){if(b<a){a=b;return true;}else return false;}
const int N=6005;
char S[N],T[N];
inline void ac(){
	int n,i,j,c=0,a,b,k;string s,t,u;
	scanf("%d%s",&n,S+1);
	for(i=n<<1;i;i=j-1){
		for(j=i;;--j)if(!((S[j]=='a')?(++c):(--c)))break;
		//printf("j=%d i=%d\n",j,i);
		t="";
		if(S[j]=='a'){
			a=b=j;k=0;
			do{
				while(S[a]=='b'&&a<=i)++a;if(a>i)break;
				while(S[b]=='a'      )++b;
				//printf("a=%d b=%d\n",a,b);
				if(a<k){++a;++b;continue;}
				t+="ab";
				k=b;
				++a;++b;
			}while(true);
		}else{
			a=b=i;
			do{
				while(S[a]=='b'&&a>=j)--a;if(a<j)break;
				while(S[b]=='a'      )--b;
				T[a]='a';
				T[b]='b';
				u="";
				rep(k,j,i)if(T[k])u+=T[k];
				cmx(t,u);
				--a;--b;
			}while(true);
		}
		//cout<<t<<endl;
		cmx(s,t+s);
	}
	cout<<s;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	
	ac();
	return 0;
}
#undef rep
#undef per
#undef REP
#undef PER
#undef mp
#undef pb
#undef pf
#undef pob
#undef pof
#undef fi
#undef se
#undef it

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b,int c){
	return __gcd(__gcd(a,b),c);
}
main(){
	int k;
	cin>>k;
	int sum=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int m=1;m<=k;m++){
				sum+=gcd(i,j,m);	
			}
		}
	}
	cout<<sum;
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    map<string, int> m;
    string s;
    cin >> s;
    char last = s[s.size()-1];
    m[s]++;
    bool q = true;
    for(int i = 1; i < n; i++){
        cin >> s;
        m[s]++;
        if(m[s] > 1 || s[0] != last){
            q = false;
        }
        last = s[s.size()-1];
    }
    if(q) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256