akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
 
 
class MaxFlow:
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev
 
    def __init__(self, node_size, inf):
        self._node = node_size
        self._inf = inf
        self._level = [-1]*self._node
        self._iter = [0]*self._node
        self._graph = [[] for _ in range(self._node)]
 
    def add_edge(self, from_, to, cap):
        self._graph[from_].append(self.Edge(to, cap, len(self._graph[to])))
        self._graph[to].append(self.Edge(from_, 0, len(self._graph[from_])-1))
 
    def bfs(self, start):
        self._level = [-1]*self._node
        que = deque()
        self._level[start] = 0
        que.append(start)
        while que:
            cur_vertex = que.popleft()
            for e in self._graph[cur_vertex]:
                if self._level[e.to] < 0 < e.cap:
                    self._level[e.to] = self._level[cur_vertex] + 1
                    que.append(e.to)
 
    def dfs(self, cur_vertex, end_vertex, flow):
        if cur_vertex == end_vertex:
            return flow
        while self._iter[cur_vertex] < len(self._graph[cur_vertex]):
            e = self._graph[cur_vertex][self._iter[cur_vertex]]
            if e.cap > 0 and self._level[cur_vertex] < self._level[e.to]:
                flowed = self.dfs(e.to, end_vertex, min(flow, e.cap))
                if flowed > 0:
                    e.cap -= flowed
                    self._graph[e.to][e.rev].cap += flowed
                    return flowed
            self._iter[cur_vertex] += 1
        return 0
 
    def solve(self, source, sink):
        flow = 0
        while True:
            self.bfs(source)
            if self._level[sink] < 0:
                return flow
            self._iter = [0]*self._node
            while True:
                f = self.dfs(source, sink, self._inf)
                if f == 0:
                    break
                flow += f
 
 
class BipartiteMatching:
    def __init__(self, size1, size2):
        self._u_size, self. _v_size = size1, size2
        self.mf = MaxFlow(self._u_size+self. _v_size+2, min(self._u_size, self._v_size))
        for i in range(self._u_size):
            self.mf.add_edge(0, i+1, 1)
        for i in range(self._v_size):
            self.mf.add_edge(self._u_size+i+1, self._u_size+self._v_size+1, 1)
 
    def add_edge(self, from_, to):
        self.mf.add_edge(from_+1, to+self._u_size+1, 1)
 
    def solve(self):
        return self.mf.solve(0, self._u_size+self._v_size+1)
 
if __name__=='__main__':
    x, y, m = map(int, sys.stdin.readline().split())
    bm = BipartiteMatching(x, y)
    for _ in range(m):
        u, v = map(int, sys.stdin.readline().split())
        bm.add_edge(u, v)
    print(bm.solve())


Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int H, W, N; cin >> H >> W >> N;
    int sr, sc; cin >> sr >> sc;

    string s, t; cin >> s >> t;

    int north = sr, south = H+1-sr, left = sc, right = W+1-sc;

    vector<int> tol(N+1, 0), tor(N+1, 0), ton(N+1, 0), tos(N+1, 0);

    if(s[0] == 'L') tol[0] = 1;
    if(s[0] == 'R') tor[0] = 1;
    if(s[0] == 'U') ton[0] = 1;
    if(s[0] == 'D') tos[0] = 1;


    for(int i=1; i<N; i++){
        if(s[i] == 'L'){
            tol[i] = tol[i-1]+1;
            tor[i] = tor[i-1];
            ton[i] = ton[i-1];
            tos[i] = tos[i-1];
        }
        else if(s[i] == 'R'){
            tol[i] = tol[i-1];
            tor[i] = tor[i-1]+1;
            ton[i] = ton[i-1];
            tos[i] = tos[i-1];
        }
        else if(s[i] == 'U'){
            tol[i] = tol[i-1];
            tor[i] = tor[i-1];
            ton[i] = ton[i-1]+1;
            tos[i] = tos[i-1];
        }
        else if(s[i] == 'D'){
            tol[i] = tol[i-1];
            tor[i] = tor[i-1];
            ton[i] = ton[i-1];
            tos[i] = tos[i-1]+1;
        }

        if(t[i-1] == 'L'){
            if(sc+tor[i-1] > 1)tor[i]--;
        }
        else if(t[i-1] == 'R'){
            if(sc-tol[i-1] < W )tol[i]--;
        }
        else if(t[i-1] == 'U'){
            if(sr+tos[i-1] > 1) tos[i]--;
        }
        else if(t[i-1] == 'D'){
            if(sr-ton[i-1] < H) ton[i]--;
        }
    }


    for(int i=0; i<N; i++){
        if(tol[i] >= left || tor[i] >= right || tos[i] >= south || ton[i] >= north){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n;
    cin >> n;
    
    vector<ll> a(n);
    
    rep(i, n){
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    
    string res = "YES";
    rep(i, n-1){
        if(a[i] == a[i+1]){
            res = "NO";
            break;
        }
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
int LCS(const char* a,const char* b)
{
    int m=strlen(a); int n=strlen(b); //i???????¬????a????????????j???????¬????b?????????
    int c[m+1][n+1]; //c??°???????????¨?????°???????¬????a??????i??????????¬????b??????j????????´???LCS
    for(int i=0;i<=m;i++) c[i][0]=0;
    for(int i=0;i<=n;i++) c[0][i]=0;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
        {
            if(a[i]==b[j]) c[i+1][j+1]=c[i][j]+1;
            else
            {
                c[i+1][j+1]=max(c[i][j+1],c[i+1][j]);
            }
        }
    return c[m][n];

}
int main()
{
    char *a=new char[1001];
    char *b=new char[1001];
    int q;
    while(cin>>q)
    {
        for(int i=0;i<q;i++)
        {
            cin>>a>>b;
            cout<<LCS(a,b)<<endl;
        }
    }
}

Measured memory_bytes: 7004
#include<stdio.h>
int main(void){
   int a,b;
   scanf("%d %d",&a,&b);
   if(a<b){
      printf("a < b\n");
   }
   else if(a>b){
      printf("a > b\n");
   }
   else if(a==b){
      printf("a == b\n");
   }
   return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int num[N];
    for(int i=0;i<N;i++){
    cin>>num[i];
}
int min=1000000;
int sum;
    for(int i=-100;i<=100;i++){sum=0;
       for(int j=0;j<N;j++){
           sum+=(i-num[j])*(i-num[j]);
       }
       if(min>sum) min=sum;
    }
    cout<<min;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int X=scan.nextInt();
        int max=1;
        int i,j;
        for(i=2;i<=Math.sqrt(X);i++){
            j=i;
            while(j*i<=X){
                j*=i;
            }
            if(max<j){
                max=j;
            }
        }
        System.out.println(max);

    }
}

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

using namespace std;

#define PI 3.14159265358979

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    cout.precision(10);
    int elapsed = 60*h + m;
    double hh = 0.5*elapsed;
    double mm = (6*elapsed)%360;
    double alpha = abs(hh-mm);
    //if(alpha > 180)
    //    alpha -= 180;
    double c = sqrt(a*a + b*b - 2*a*b*(cos(alpha*PI/180.0)));
    // printf("%.10f", c);
    cout << fixed << c;
    
}

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

using namespace std;

int main()
{
 int n;
  cin >> n;
  int arr[n+1];
  memset(arr,0,sizeof(arr));
  for(int i = 0 ; i < n-1 ; i++)
  {
   	int x;
    cin >> x;
    arr[x]++;
  }
  
  for(int i = 1 ; i <=n ; i++)
    cout << arr[i] << " ";
  return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    long long A,B,C,X,Y;
    
    cin >> A >> B >> C >> X >> Y;
    if(A+B <= 2*C){
        cout << A*X + B*Y << endl;
    }else{
        int m = min(X,Y);
        //if(m % 2 == 1){
        //    m--;
        //}
        cout << min(m*C*2 + (X-m)*A + (Y-m)*B,2*C*max(X,Y)) << endl;
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

signed main(){
	int k,x;
	cin>>k>>x;
	vint ans;
	rep(i,2*k-1){
		if(i)cout<<" ";
		cout<<x-(k-1)+i;
	}cout<<endl;
	return 0;
}

Measured memory_bytes: 256
S = int(input())
mod = 10**9 + 7
N = 10**6
ans = 0
n = S // 3

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]


def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod


for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


for i in range(1, n + 1):
    si = S - i * 3
    ans += cmb(si + i - 1, i - 1)
    ans %= mod

print(ans)




Measured memory_bytes: 212956
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
LL n,K;
LL doit(LL x,LL y)//一边为x一边为y的四边形 
{
	LL ret=0;
	if(!(y%x))return y*2-x;
	else
	{
		ret+=x*(y/x)*2;
		return ret+doit(y%x,x);
	}
}
int main()
{
	n=read();K=read();
	LL ans=n;
	ans+=doit(min(K,n-K),max(K,n-K));
	pr2(ans);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int* w = new int[n];
    int s1=0,s2=0;
    for(int i=0;i<n;i++){
        cin >> w[i];
        s2+=w[i];
    }
    int minsub = 100000000;
    for(int i=0;i<n;i++){
        s1+=w[i];s2-=w[i];
        minsub = min(minsub,abs(s2-s1));
    }
    cout << minsub;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#include <queue>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
#define int long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl


#define MAX 55

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

    int n;
    int num;
    int s1 = 0, s2 = 0;
    priority_queue<pair<int,int>> a, b;
    static int ans[MAX][MAX];

    cin>>n;

    for(int i = 0, sum = 0; i <= n; i++){
        cin>>num;
        s1 += num;
        for(int j = 0; j < num; j++){
           
            a.push(make_pair(i,sum++));
            
        }
    }

    for(int j = 0, sum = 0; j <= n; j++){
        cin>>num;
        s2 += num;
        for(int k = 0; k < num; k++){
           
            b.push(make_pair(j,sum++));
            
        }
    }

    if(s1 =! s2 || s1 != n){
        cout<<"NO"<<endl;
        return 0;
    }
    while(!a.empty()){
        pair<int,int> A = a.top(); a.pop();
        vector<pair<int,int>> temp;
        
        if(A.first == 0) break;
        
        for(int i = 0; i < A.first; i++){

            if(b.size() == 0){
                cout<<"NO"<<endl;
                return 0;
            }
            pair<int,int> B = b.top(); b.pop();
            
            if(B.first == 0){
                cout<<"NO"<<endl;
                return 0;
            }
            
            if(B.first-1 > 0)temp.push_back(make_pair(B.first-1,B.second));
           
            ans[B.second][A.second]++;
        }

        for(int j = 0; j < temp.size(); j++){
            b.push(temp[j]);
        }
    }

    cout<<"YES"<<endl;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j) cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
    
    return 0;
}




Measured memory_bytes: 3216
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxN = 1e5;
const ll mod = 1e9+7;
 
ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
 
const int sz = 5e5+20;
ll fact[sz], inv[sz];
void pre(){
	fact[0] = 1;
	inv[0] = pow(fact[0], mod-2);
	for(int i=1;i<sz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}
 
int spf[10];
void sieve(){
    spf[1]=1;
    for(int i=2;i<mxN;i++) spf[i]=i;
    for(int i=4;i<mxN;i+=2) spf[i]=2;
    for(int i=3;i*i<mxN;i++){
        if(spf[i]==i){
            for(int j=i*i;j<mxN;j+=i){
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}

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

    bool a;
    cin>>a;

    cout<<(a^1)<<endl;
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := intScanner()
	op := Scanner()
	b := intScanner()
	if op == "+" {
		fmt.Println(a + b)
	} else {
		fmt.Println(a - b)
	}
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define forn(i,n) for(int i=0; i<(int)n; i++)
ll power(ll x,ll n);
bool isprime(ll n);
ll mod=1e9+7;

void test_case()
{
    int x;
    int ans;
    for(int i=1;i<=5;i++) {
        cin>>x;
        if(x==0)
            ans=i;
    }
    cout<<ans;
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}
ll power(ll x,ll n)
{
    ll ans=1;
    while(n>0) {
        if(n&1)
            ans*=x;
        n>>=1;
        x*=x;
    }
    return ans;
}

bool isprime(ll n)
{
    if(n==2 || n==3)
        return true;
    if(n<=1 || n%2==0 || (n%6!=1 && n%6!=5))
        return false;
    for(int i=3;i*i<=n;i+=2) {
        if(n%i==0)
            return false;
    }
    return true;
}


Measured memory_bytes: 3640
from collections import Counter
_ = input()
D = map(int, input().split())
_ = input()
T = Counter(map(int, input().split()))
for d in D:
  if d in T and T[d] > 0:
    T[d] -= 1
print('YES' if all(v==0 for v in T.values()) else 'NO')

Measured memory_bytes: 62684
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    int n;
    cin >> n;
    int zero = 0;
    map<pair<ll, ll>, P> mp;
    for(int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        if(x == 0 && y == 0) {
            zero++;
            continue;
        }
        ll g = GCD(x, y);
        x /= g;
        y /= g;
        // yが負の時⇒円の下側に存在するとき
        if(y < 0) x = -x, y = -y;
        if(y == 0 && x < 0) x = -x, y = -y;
        // xが負なら時計回りに90度回転
        bool rot90 = {x <= 0};
        if(rot90) {
            ll tmp = x;
            x = y; y = -tmp;
        }
        if(rot90) mp[{x, y}].first++;
        else mp[{x, y}].second++;
    }

    mint ans = 1;
    for(auto p : mp) {
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1;
        now += mint(2).pow(s) - 1;
        now += mint(2).pow(t) - 1;
        ans *= now;
    }

    ans -= 1;
    ans += zero;
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    const ll MOD = 1e9 + 7;
    vector<ll> x(n);
    vector<ll> y(m);
    for(i = 0;i < n;++i){
        cin >> x.at(i);
    }
    for(i = 0;i < m;++i){
        cin >> y.at(i);
    }
    vector<ll> tx(n-1);
    for(i = 1;i <= n-1;++i){
        tx.at(i-1) = i*(n-i)%MOD*(x.at(i) - x.at(i-1))%MOD;
    }
    vector<ll> ty(m-1);
    for(i = 1;i <= m-1;++i){
        ty.at(i-1) = i*(m-i)%MOD*(y.at(i) - y.at(i-1))%MOD;
    }
    ll sumx = 0;
    for(i = 0;i < n-1;++i){
        sumx += tx.at(i);
        sumx %= MOD;
    }
    ll ans = 0;
    for(i = 1;i <= m-1;++i){
        ans += ty.at(i-1)*sumx;
        ans %= MOD;
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
  string a, r;
  cin >> a;
  r = "No";
  
  if (a[0] == 'a' && a[1] == 'b' && a[2] == 'c') r = "Yes";
  else if (a[0] == 'a' && a[1] == 'c' && a[2] == 'b') r = "Yes";
  else if (a[0] == 'b' && a[1] == 'a' && a[2] == 'c') r = "Yes";
  else if (a[0] == 'b' && a[1] == 'c' && a[2] == 'a') r = "Yes";
  else if (a[0] == 'c' && a[1] == 'b' && a[2] == 'a') r = "Yes";
  else if (a[0] == 'c' && a[1] == 'a' && a[2] == 'b') r = "Yes";
  
  cout << r << endl;
}

Measured memory_bytes: 256
s=list(input())
n=len(s)
mod=10**9+7
dp=[[0]*13 for j in range(100005)]
dp[0][0]=1
for i in range(n):
    if s[i]=="?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(k*10+j)%13]+=dp[i][k]
        for j in range(13):
            dp[i+1][j]%=mod
    else:
        for k in range(13):
            dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]
        for j in range(13):
            dp[i+1][j]%=mod
print(dp[n][5])


Measured memory_bytes: 64888
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    sx,sy,tx,ty=MI()
    w=tx-sx
    h=ty-sy
    ans="D"
    ans+="R"*(w+1)
    ans+="U"*(h+1)
    ans+="L"
    ans+="D"*h
    ans+="L"*(w+1)
    ans+="U"*(h+1)
    ans+="R"*(w+1)
    ans+="D"
    ans+="L"*w
    ans+="D"*h
    print(ans)

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, k;
  cin >> n >> k;
  int digit = 0, left = n;
  while (left) {
    left /= k;
    ++digit;
  }
  cout << digit << endl;
  return 0;
}

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

int main()
{
    int K, sum,temp;
    cin >> K;
    sum = 0;
    for(int i = 0 ; i < K; i++)
        for(int j = 0 ; j < K; j++)
            for(int k = 0 ; k < K; k++)
            {
                temp = __gcd(i+1,j+1);
                sum = sum+__gcd(temp,k+1);
            }
    cout << sum;
    return 0;
}

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

int main()
{
  int n,i,j,a=0;
  scanf("%d",&n);
  int s[n];
  for(i=0;i<n;i++)
    scanf("%d",&s[i]);
    j=0;
  for(i=0;i<n;i++)
  {
      if(s[i]<=s[j])
        j=i;
      else
        a++;
  }
  printf("%d",n-a);
    return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 3608
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1e9 + 7;


ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

int n;

ll h[1200];

vector<ll> vv;
pair<ll, ll> ans[1200];
int en[1200];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> h[i], vv.push_back(h[i]);
	sort(vv.begin(), vv.end());
	vv.resize(unique(vv.begin(), vv.end()) - vv.begin());
	reverse(vv.begin(), vv.end());
	vv.push_back(0);
	for (int i = 0; i < n; ++i)
		en[i] = 0;
	h[n] = 0;
	for (int it = 0; it < vv.size() - 1; ++it) {
		ll hh = vv[it];
		int st = -1;
		int cnt = 0;
		vector<pair<ll, ll>> cur;
		ll len = vv[it] - vv[it + 1];
		ll gd = 1;
		ll all = 1;
		for (int i = 0; i <= n; ++i) {
			if (en[i] == 1) {
				if (st == -1)
					st = i;
				gd = (gd * ans[i].first) % MOD;
				all = (all * (ans[i].first * 2 + ans[i].second)) % MOD;
			}
			else if (h[i] == hh) {
				if (st == -1)
					st = i;
				++cnt;
			}
			else if (en[i] == 0) {
				if (st != -1) {
					for (int j = st; j < i; ++j)
						en[j] = 2;
					en[st] = 1;
					ans[st].first = gd * pw(2, len) % MOD;
					ans[st].second = (all * pw(2, cnt) % MOD - gd * 2 % MOD + MOD) % MOD;
				}
				gd = all = 1;
				st = -1;
				cnt = 0;
			}
		}
	}
	cout << (ans[0].first + ans[0].second) % MOD;
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i, a, cnt = 0;

	scanf("%d", &a);

	for (i = 1; i <= a; i++) {
		if (i % 2 == 1) {
			cnt++;
		}
	}

	printf("%lf\n", (float)cnt / a);

	return 0;
}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  string s;
  cin >> s;

  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main()
{
	int K, A, B;
	cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i%K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}

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

int const MAXL=3000;

char s1[MAXL+1], s2[MAXL+1];

int dp[MAXL+1][MAXL+1];
char ans[MAXL+1];

int main() {
  std::cin >> s1 >> s2;
  int l1 = std::strlen(s1), l2 = std::strlen(s2);

  for(int i = 0; i <= l1; ++i) dp[i][0] = 0;
  for(int i = 0; i <= l2; ++i) dp[0][i] = 0;

  for(int i = 1; i <= l1; ++i) {
    for(int j=1; j <= l2; ++j) {
      if(s1[i-1]==s2[j-1]) dp[i][j] = dp[i-1][j-1]+1;
      else dp[i][j] = std::max(dp[i-1][j], dp[i][j-1]);
    }
  }

  ans[dp[l1][l2]] = 0;
  while(l1 > 0 && l2 > 0) {
    if(dp[l1][l2] == dp[l1][l2-1]) --l2;
    else if(dp[l1][l2] == dp[l1-1][l2]) --l1;
    else {
      --l1; --l2;
      ans[dp[l1][l2]] = s1[l1];
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 35456
input()
a = list(map(int, input().split()))
dp = [float('inf')]*len(a)
dp[0] = 0
for i in range(len(a)-1):
    dp[i+1] = min(dp[i+1], dp[i] + abs(a[i+1] - a[i]))
    if i < len(a)-2:
        dp[i+2] = dp[i] + abs(a[i+2] - a[i])
print(dp[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    map<string, ll> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll res = 0;
    for (auto v : mp) {
        if (v.second!= 1) res += v.second*(v.second-1) / 2;
    }

    cout << res << endl;
    
    return 0;
}         

Measured memory_bytes: 11264
#include<stdio.h>
#define INF 1e9
int min(int a,int b){
  if(a<b)return a;
  else return b;
}
int main(){
  int i,j,k,n;
  int t[100],u[100];
  int dp[100][100];
  for(i=0;i<100;i++)
    for(j=0;j<100;j++)
      dp[i][j]=(i==j?0:INF);
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d %d",&t[i],&u[i]);
  for(k=1;k<n;k++)
    for(i=0;i+k<n;i++)
      for(j=i;j<i+k;j++)
	dp[i][i+k]=min(dp[i][i+k],dp[i][j]+dp[j+1][i+k]+t[i]*u[j]*u[i+k]);
  printf("%d\n",dp[0][n-1]);
  return 0;
}

Measured memory_bytes: 636
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = 1
    for n in range(1, N + 1):
        ret *= n
        ret %= MOD
    print(ret)


if __name__ == '__main__':
    main()


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

int main()
{
    int h, w; cin>>h>>w;
    for(int i=1; i<=h; ++i) {
        for(int j=0; j<w; ++j) {
            string s; cin>>s;
            if (s=="snuke") cout<<char('A'+j)<<i<<endl;
        }
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ss = []
for i in range(M):
  ws = [int(w) for w in input().split()]
  ws.pop(0)
  s = 0
  for w in ws:
    s |= 1 << (w-1)
  ss.append(s)
#print(ss)
ps = [int(w) for w in input().split()]

def countbit(o):
  c = 0
  for n in range(N):
    if o & (1 << n) != 0:
      c += 1
  return c
r = 0
for i in range(1 << N):
  ok = True
  for m in range(M):
    s, p = ss[m], ps[m]
    o = i & s
    c = countbit(o)
    #print(o, c)
    if c % 2 != p:
      ok = False
      break
  if ok:
    r += 1
print(r)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int N, i, j;
	scanf("%lld", &N);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	vector<int> c(3, 0);
	int ans = 1;
	for(i = 0; i < N; i++){
		int count = 0, lastj = -1;
		for(j = 0; j < 3; j++){
			if(A[i] == c[j]){
				count++;
				lastj = j;
			}
		}
		if(count == 0){
			printf("0\n");
			return 0;
		}
		ans = MOD(ans * count);
		c[lastj]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define PER(i,a,b) for( int i = (int) a; i >= (int) b; i-- )
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
#define all(s) s.begin(), s.end()
 
using namespace std;
 
typedef long long int ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
 
const int MAX = 2e3+3;
const int mod = 1e9+7;


ll pd[707][2020];
int S;

ll solve(int i, int s){
	if(s>S)	return 0;
	if(s==S) return 1;
	
	ll &ret = pd[i][s];
	if(ret!=-1) return ret;
	
	ll v = 0;
	rep(j, 3, S-s+1)
		v = v + solve(i+1, s+j);
	
	return ret = v%mod;
}

int main(){
	
	cin >> S;
	memset(pd, -1, sizeof pd);
	cout << solve(0, 0) << '\n';
	
    return 0;
}

Measured memory_bytes: 14800
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int x; cin >> x;
  x = 10 - x/200;
  cout << x << '\n';
}

signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b,
  c = (a * b) % 2;
  if ( c == 1 ) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int n,m;
const int nax = 2e5+10;
vvi adj;
vi vis;
int cursz, mxsz;


void dfs(int x){
    cursz++;
    vis[x] = 1;
    for(auto ad: adj[x]){
        if(!vis[ad])
            dfs(ad);
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    while(cin>>n>>m){
        mxsz = 0;
        vis.assign(nax,0);
        adj.assign(nax,{});
        
        forn(i,m){
            int x, y; cin>>x>>y;
            adj[x].pb(y), adj[y].pb(x);
        }

        forn(i,n){
            if(!vis[i]){
                cursz = 0;
                dfs(i);
                max_self(mxsz, cursz);
            }
        }
        cout<<mxsz<<"\n";
    }

    return 0;
}

Measured memory_bytes: 21156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int H = cin.nextInt();
		int W = cin.nextInt();
		char[,] c1 = new char[H, W];
		char[,] c = new char[W, H];
		long ans = 0;
		for (int i = 0; i < H; i++)
		{
			string str = cin.next();
			for (int j = 0; j < W; j++)
			{
				c1[i, j] = str[j];
			}
		}
		for (int i = 0; i < W; i++)
		{
			for (int j = 0; j < H; j++)
			{
				c[i, j] = c1[H - 1 - j, i];
			}
		}

		//if (W > 3) return;

		int[,] cost = new int[H + 1, H + 1];
		for (int i = 0; i < W - 1; i++)
		{
			// 列i, i+1の間に発生するコスト

			for (int j = 0; j <= H; j++)
			{
				cost[H, j] = 0;
				for (int k = 0; k < j; k++)
				{
					if (c[i, k] == c[i + 1, k + H - j]) cost[H, j]++;
				}
			}
			for (int j = 0; j <= H; j++)
			{
				cost[j, H] = 0;
				for (int k = 0; k < j; k++)
				{
					if (c[i, k + H - j] == c[i + 1, k]) cost[j, H]++;
				}
			}
			for (int j = H - 1; j >= 0; j--)
			{
				for (int k = H - 1; k >= 0; k--)
				{
					cost[j, k] = cost[j + 1, k + 1] - (c[i, H - j - 1] == c[i + 1, H - k - 1] ? 1 : 0);
				}
			}

			for (int j = 1; j <= H; j++)
			{
				for (int k = 1; k <= H; k++)
				{
					cost[j, k] += Math.Min(cost[j - 1, k], cost[j, k - 1]);
				}
			}
			ans += cost[H, H];
		}
		Console.WriteLine(ans);
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 4056
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  
  for(int i = n-1; i >= 0; i -= 2) {
    cout << a[i] << " ";
  }
  if(n % 2 == 0) {
    for(int i = 0; i <= n-1; i += 2) {
      cout << a[i] << " ";
    }
  } else {
    for(int i = 1; i <= n-1; i += 2) {
      cout << a[i] << " ";
    }
  }
  cout << endl;

  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

map<vector<int>, int> mp;

void init(vector<int> v) {
   queue<vector<int>> que;
   que.push(v);
   while (que.size()) {
      vector<int> cur = que.front(); que.pop();

      int idx = -1;
      rep (i, 8) {
         if (cur[i] == 0) {
            idx = i;
            break;
         }
      }

      rep (k, 4) {
         int nx = (idx / 4) + dx[k];
         int ny = (idx % 4) + dy[k];
         if (nx < 0 || nx >= 2 || ny < 0 || ny >= 4) continue;
         int nc = nx * 4 + ny;
         vector<int> tmp = cur;
         swap(tmp[nc], tmp[idx]);
         if (mp.count(tmp)) continue;
         mp[tmp] = mp[cur] + 1;
         que.push(tmp);
      }
   }
}

int main() {
   vector<int> v(8);
   iota(all(v), 0);
   mp[v] = 0;
   init(v);

   string s;
   while (getline(cin, s)) {
      stringstream ss(s);
      vector<int> vs;
      int val;
      while (ss >> val) vs.push_back(val);
      cout << mp[vs] << endl;
   }

   return 0;
}


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

using namespace std;

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int k = min(x, y);
    long long ans = 0;
    ans += 1LL * k * min(a+b, 2*c);
    if(x < y) {
        int remy = y - x;
        ans += 1LL * remy * min(b, 2*c);
    }
    else {
        int remx = x - y;
        ans += 1LL * remx * min(a, 2*c);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
	int z;
	while( cin >> z , z ){
		long long int ans = -1;
		for(long long int x = 1 ; x*x*x < z*z*z ; x++ ){
			for(long long int y=1 ; x*x*x + y*y*y < z*z*z ; y++ ){
				long long int s = z*z*z - x*x*x - y*y*y;
				ans = ( ans == -1 )? s : min( ans , s );
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

INF = 10**9
dst = [[INF]*W for _ in range(H)]
dst[sh][sw] = 0

from collections import deque
dq = deque([(sh, sw)])
while dq:
    h, w = dq.popleft()

    for dh, dw in dhw[:4]:
        nh = h + dh; nw = w + dw
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] < dst[nh][nw]:
            dst[nh][nw] = dst[h][w]
            dq.appendleft((nh, nw))

    for dh, dw in dhw[4:]:
        nh = h + dh; nw = w + dw
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] + 1 < dst[nh][nw]:
            dst[nh][nw] = dst[h][w] + 1
            dq.append((nh, nw))

print(-1 if dst[eh][ew]==INF else dst[eh][ew])


Measured memory_bytes: 90748
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
#define mod 1000000007
data_type  bigmod(data_type n,data_type p,data_type m)
{
    if(p==0)
        return 1;
    data_type x=bigmod(n,p>>1,m);
    x=(x*x)%m;
    if(p&1)
        x=(x*n)%m;
    return x;
}
data_type mod_inverse(data_type b)
{
    return bigmod(b,mod-2,mod);
}

vector<data_type> fact;
vector<data_type> inverse_fact;
inline void factorial()
{
    fact.emplace_back(1);
    inverse_fact.emplace_back(mod_inverse(fact.back()));
    for(data_type i=1; i<=200010; i++)
        {
            fact.emplace_back((fact.back()%mod*i%mod)%mod);
            inverse_fact.emplace_back(mod_inverse(fact.back()));;
        }

}
data_type ncr(data_type n, data_type r) {
  if (r == 0 || n == r) return 1;
  return (((fact[n] * inverse_fact[n-r]) % mod) * inverse_fact[r]) % mod;
}


int  main()
{
    factorial();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    data_type h, w, a, b;
    cin >> h >> w >> a >> b;
    data_type res=0;
    for (int i = b; i < w; i++)
        {
            data_type y1 = h - a - 1, x1 = i;
            data_type y2 = a - 1, x2 = w - i - 1;
            res= (res+(ncr(x1 + y1, x1) * ncr(x2 + y2, x2)) % mod)%mod;
        }
    cout << res << endl;

    return 0;
}




Measured memory_bytes: 3564
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val k = sc.nextInt()
    val s = (0 until h).map { sc.next() }
    println(problemSumitomoMitsuiD(h, w, k, s))
}

fun problemSumitomoMitsuiD(h: Int, w: Int, k: Int, s: List<String>): String {
    val array = Array(h) { IntArray(w) }
    val hasBerryCheck = Array(h) { false }
    var current = 0
    for (i in 0 until h) {
        var hasBerry = false
        current++
        for (j in 0 until w) {
            val sij = s[i][j]
            if (sij == '#') {
                if (hasBerry) {
                    current++
                }
                hasBerry = true
            }
            array[i][j] = current
            hasBerryCheck[i] = hasBerry
        }
        if (hasBerryCheck.all { !it } || !hasBerry) {
            current--
        }
    }
    if (h != 1) {
        for (i in 0 until h) {
            if (!hasBerryCheck[i]) {
                var count = 0
                while (i + count < h - 1 && !hasBerryCheck[i + count]) count++
                for (j in 0 until w) {
                    array[i][j] = array[i + count][j]
                }
            }
        }
        for (i in h - 1 downTo 0) {
            if (!hasBerryCheck[i]) {
                var count = 0
                while (i - count > 0 && !hasBerryCheck[i - count]) count++
                for (j in 0 until w) {
                    array[i][j] = array[i - count][j]
                }
            }
        }
    }
    return array.map { it.joinToString(" ") }.joinToString("\n")
}

Measured memory_bytes: 52892
n,l = map(int,input().split())
tastes = [0]*n
ans = 0

for i in range(n):
    tastes[i] = l+i

tmp = 10**12
for taste in tastes:
    s = sum([x for x in tastes if x != taste])
    if abs(sum(tastes)-s) <= tmp:
        tmp = abs(sum(tastes)-s)
        ans = s

print(ans)

Measured memory_bytes: 3064