akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	ll N; cin>>N;
	int len = 0;
	for(; pow(26,len) <= N; ++len){
		N -= pow(26,len);
	}
	vector<int> v(len,0);
	int cnt = 0;
	while(N>0){
		int x = N%26;
		// if(x == 0)x = 25;
		N /= 26;
		v[cnt++] = x;
	}
	reverse(all(v));
	rep(i,len){cout<<(char)('a'+v[i]);}
	cout<<endl;
	return 0;
}

// int main(){
// 	ll N; cin>>N;
// 	string ans;
// 	while(N>0){
// 		int x = N%26;
// 		if(x == 0)x = 26;
// 		char t = 'a' + (x-1);
// 		N /= 26;
// 		printf("[%lld... %d]\n", N, x);
// 	}
// 	reverse(all(ans));
// 	cout<<ans<<endl;
// 	return 0;
// }

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

using namespace std;

int a[100001];

int main()
{
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	int flag = 0;
	int res = 0;
	int start = 1;
	for(int i=1;i<=n;i++)
	{
		start = a[start];
		res++;
		if(start == 2)
		{
			flag = 1;
			break;
		}
	}
	if(flag)
		cout << res << endl;
	else
		cout << -1 << endl;
}

Measured memory_bytes: 640
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const weights = arg[1].split(" ").map(n=>parseInt(n));
    
    let   right  = weights.reduce((m,n)=>m+n);
    let   left   = 0;
    let   answer = right;
    
    for(let i in weights) {
        left  += weights[i];
        right -= weights[i];
        answer = Math.min(answer, Math.abs(left - right));
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
/* Just_Do_It ___________ICARUS__________________*/
                     
    #include <bits/stdc++.h>
    using namespace std;
           
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(int i=a;i<n;i++)
    #define per(i,n,a) for (int i=n;i>a;i--)
    #define te int t; std::cin >> t; while(t--)
    #define SZ 200010
    //# define M_PIl  3.141592653589793238462643383279502884L 
    /*   Proceed with CAUTION   */

    int main(){
        fastio;
        string a,b;
        cin>>a>>b;
        ll n = a.length(),ans=0;
        map<ll,ll> ma,mb;
        rep(i,0,n) ma[a[i]-'0']++ , mb[b[i]-'0']++ ;
        rep(i,0,n) a[i]!=b[i] && ma[a[i]-'0']!=mb[b[i]-'0'] ? ans = 1 : 0;
        cout<<(ans ? "No":"Yes")<<endl;
    }	

Measured memory_bytes: 916
#include"bits/stdc++.h"
 

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

#define ll long long int

//const int mod=1000000007;
using namespace std;
 
/*int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
*/

const int mod=1e9+7;

char c[1100][1100];
int dp[1100][1100];


int main()
{

    int x,y;
    cin>>x>>y;
    
    for(int i=0;i<x;i++)
    {
        for(int j=0;j<y;j++)
            cin>>c[i][j];
    }
    
    dp[0][0]=1;
    
    for(int i=0;i<x;i++)
    {
        for(int j=0;j<y;j++)
        {
            if(c[i][j]=='#')continue;
            
            if(i>=1)dp[i][j]= (dp[i][j] + dp[i-1][j])%mod;
            if(j>=1) dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
            
        }
    }
    
    
    cout<<dp[x-1][y-1]<<endl;
}


Measured memory_bytes: 8912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int h1,h2,m1,m2;
  int k;
  
  cin>>h1>>m1>>h2>>m2;
  cin>>k;
  
  int now=0;
  now=(h2-h1)*60+m2-m1;
  now-=k;
  
  cout<<now<<endl;
}

Measured memory_bytes: 3636
if __name__ == "__main__":
    N = int(input())
    hist = list(map(lambda x: int(x), input().split()))

    stack = [(0, -1)]  # (height, x_position)
    ans = 0
    for i in range(N):
        height = hist[i]
        pos = i
        while stack and height <= stack[-1][0]:
            h, j = stack.pop()
            ans = max(ans, (i - j) * h)
            pos = j
        stack.append((height, pos))
    while stack:
        h, j = stack.pop()
        ans = max(ans, (N - j) * h)

    print(ans)



Measured memory_bytes: 19604
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

int main() {
    int num,ans=10000;
    string s;
    cin >> s;
    for(int i=0;i<s.size()-2;i++){
        num=atoi(s.substr(i,3).c_str());
        ans=min(ans,abs(753-num));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MAXN 111111
#define ll long long
using namespace std;

bool Poss(int a,int b) {
    if (a+b==1)
        return true;
    if (a==0 || b==0)
        return true;
    printf("%d %d\n",a,b);
    bool can=true;
    if (a>=2)
        can |= Poss(a-1,b);
    if (b>=2)
        can |= Poss(a+1,b-2);
    
    return can;
        
    
    
    
}

int main() {
    int N;
    cin>>N;
    int a=0;
    int b=0;
    for(int i=1;i<=N;i++) {
        int x;
        cin>>x;
        if (x&1)
            a++;
        else
            b++;
    }
    

    
    if (a==0 || b==0) {
        cout << "YES" << endl;
        return 0;
    }
    

    if (a%2==0) {
        cout << "YES" << endl;
        return 0;
    }
    

    
    cout << "NO" << endl;
    
    
    
    
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll x;
  cin >> x;

  for (ll a = -150; a <= 150; a++) {
    for (ll b = -150; b <= 150; b++) {
      ll aa = a * a * a * a * a;
      ll bb = b * b * b * b * b;
      if (aa - bb == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<int> a(101, 0);
	int n, max = 0;
	
	while (cin >> n, n != 4)
	{
		a[n]++;
		if (a[n] > max) max = a[n];
	}

	for (int i = 1; i < a.size(); ++i)
		if (a[i] == max) cout << i << endl;

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>();
	cout<<360/__gcd(360LL, n)<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3648
s = list(str(input()))


s_tmp = s[:]
s_str = ""
ans = 0

if len(s)==1:
    print(int(s[0]))
else:
    for i in range(pow(2,len(s_tmp)-1)):
        s_str = s.pop(0)
        j = 0
        while len(s) > 0:
            i_bin = list(format(i,"010b"))
            #print(*i_bin)
            if i_bin[len(i_bin)-j-1] == "1":
                s_str += "+"
            s_str += s.pop(0)
            j += 1
        #print(i,s_str)
        ans += eval(s_str)
        s = s_tmp[:]
        s_str = ""
    print(ans)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inclass in = new inclass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AF solver = new AF();
        solver.solve(1, in, out);
        out.close();
    }

    static class AF {
        public void solve(int testNumber, inclass in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();
            if (a + b == 15) {
                out.println("+");
                return;
            } else if (a * b == 15) {
                out.println("*");
            } else {
                out.println("x");
            }
        }

    }

    static class inclass {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private inclass.SpaceCharFilter filter;

        public inclass(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22612
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
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	as := stringSliceScanner(n)
	ans := 0
	for i := 0; i < n; i++ {
		if judge(n, append(as[i:], as[:i]...)) {
			ans += n
		}
	}
	fmt.Println(ans)
}
func judge(n int, x []string) bool {
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if x[i][j] != x[j][i] {
				return false
			}
		}
	}
	return true
}


Measured memory_bytes: 3776
#include<iostream>
#include<cstdio>
#include<queue>
#include<functional>
#include<vector>
#include<string>
using namespace std;
typedef pair<int,pair<int,int> > P;
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};
int R,C;
string board[100];
pair<int,int> S,RR;
priority_queue<P,vector<P>,greater<P> >que;
int SS[100][100];
int main()
{
	scanf("%d%d",&R,&C);
	for(int i=0;i<R;i++)cin >> board[i];
	for(int i=0;i<R;i++)for(int j=0;j<C;j++){if(board[i][j]=='S'){S.second=j;S.first=i;}else if(board[i][j]=='G'){RR.second=j;RR.first=i;}}
	board[S.first][S.second]='.';board[RR.first][RR.second]='.';
	for(int i=0;i<R;i++)for(int j=0;j<C;j++)SS[i][j]=100001;
	que.push(P(0,S));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(SS[p.second.first][p.second.second]<=p.first)continue;
		SS[p.second.first][p.second.second]=p.first;
		//printf("x:%d y:%d %d\n",p.second.second,p.second.first,p.first);
		for(int k=0;k<4;k++){
		
			if(p.second.second+dx[k]>=0&&p.second.second+dx[k]<C&&p.second.first+dy[k]>=0&&p.second.first+dy[k]<R){
				int XX=p.second.second+dx[k];int YY=p.second.first+dy[k];
				pair<int,int> next;next.second=XX;next.first=YY;
				if(board[YY][XX]=='o')que.push(P(p.first+1,next));
				else if(board[YY][XX]=='#')continue;
				else{
					if(board[YY][XX]=='.')que.push(P(p.first+2,next));
					else que.push(P(p.first+3,next));
					XX+=dx[k];YY+=dy[k];
					next.second=XX;next.first=YY;
					if(XX>=0&&XX<C&&YY>=0&&YY<R){
						if(board[YY][XX]=='#')continue;
						if(board[YY-dy[k]][XX-dx[k]]=='.'&&board[YY][XX]=='o')que.push(P(p.first+3,next));
						else que.push(P(p.first+4,next));
						XX+=dx[k];YY+=dy[k];
						next.second=XX;next.first=YY;
						if(XX>=0&&XX<C&&YY>=0&&YY<R){
							if(board[YY][XX]=='#')continue;
							if(board[YY-2*dy[k]][XX-2*dx[k]]=='.'&&board[YY][XX]=='o'&&board[YY-dy[k]][XX-dx[k]]=='o')que.push(P(p.first+4,next));
							else que.push(P(p.first+5,next));
							
						}
					}
				}
			}
		}
	}
	printf("%d\n",SS[RR.first][RR.second]);
	return 0;
}

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

long long gcd(long long x, long long y){
    if(x < y){
        swap(x,y);
    }
    while(x % y != 0){
        x = x % y;
        // cerr << "x=" << x << "y="<<y << endl;
        if(x < y){
            swap(x,y);
        }
    }
    cerr << y << endl;
    return y;
}

void solve(long long A, long long B){
    long long ans =  A * B /gcd(A,B);
    cout << ans << endl;


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int m, f, r;
    
    while(-1)
    {
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1)
        {
            return 0;
        }
        
        if(m==-1 || f==-1)
        {
            printf("F\n");
        }
        
        else if(m+f>=80)
        {
            printf("A\n");
        }
        
        else if(m+f>=65)
        {
            printf("B\n");
        }
        
                else if(m+f>=50)
        {
            printf("C\n");
        }
        else if(m+f>=30)
        {
            if(r>=50)
            {
                printf("C\n");
            }
            
            else
            {
                printf("D\n");
            }
        }
        else
        {
            printf("F\n");
        }

    }
    return 0;

}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    string a, b;
    cin >> n >> a >> b;
    forn(i, n) {
        if (a == b) return cout << (n+i) << '\n', 0;
        a = a.substr(1);
        b.pop_back();
    }
    cout << (2*n) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 1e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    int n, W;
    cin >> n >> W;
    vector<ll> dp(N, INF);
    dp[0] = 0;
    for(int j = 0; j < n; j++){
        ll w, v;
        cin >> w >> v;
        vector<ll> cur(N, INF);
        for(int k = 0; k < N; k++){
            cur[k] = dp[k];
            if(k >= v) cur[k] = min(cur[k], dp[k-v]+w);
        }
        dp = cur;
    }
    for(int j = N-1; j >= 0; j--) 
        if(dp[j] <= W){
            cout << j;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 1792
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
elif l % 2019 > r % 2019:
    print(0)
else:
    ans = 2019
    for i in range(l % 2019, r % 2019):
        for j in range(i + 1, r % 2019 + 1):
            ans = min(ans, i * j % 2019)
    print(ans)


Measured memory_bytes: 3060
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int A, B;
  ci(A, B);
  if(A % 2 == 1 && B % 2 == 1){
    co("Yes");
  }
  else{
    co("No");
  }
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    sort(A, A + N, [](ll a, ll b) { return a > b; });
    ll max = 0;
    ll l = 0;
    REP(i, N - 1)
    {
        if (A[i] != A[i + 1])
            continue;
        max = std::max(max, l * A[i]);
        l = A[i++];
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (b - a == c - b ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
let n = read_int ()
let ss = Array.init n @@ fun _ -> read_line ()
let cs = Array.make 128 0
let f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n
let _ = Array.(Char.(for i = code 'a' to code 'z' do let m = ref 50 in iter (fun s -> m := min !m @@ f s @@ chr i) ss; cs.(i) <- !m done;
  iteri (fun i c -> print_string @@ String.make c @@ chr i) cs)); print_newline ()

Measured memory_bytes: 512
move = [[0, 1], [0, -1], [1, 0], [-1, 0]]
from collections import deque
def main(w, h):
    field = [list(input()) for i in range(h)]
    check = [[True] * w for i in range(h)]
    q = deque()
    for i in range(h):
        for k in range(w):
            if field[i][k] == "@":
                q.append((k, i))
                check[i][k] = False
    ans = 1
    while q:
        x, y = q.popleft()
        for mx, my in move:
            xm = mx + x
            ym = my + y
            if 0 <= xm < w and 0 <= ym < h:
                if field[ym][xm] == "." and check[ym][xm]:
                    check[ym][xm] = False
                    q.append((xm, ym))
                    ans += 1
    print(ans)
while 1:
    w, h = map(int, input().split())
    if w == h == 0:
        break
    main(w,h)


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int dis[21][21];
string a[21];

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

int bfs(int x, int y){
	queue<ii> q;
	q.push(ii(x,y));
	int i,j;
	int maks = 0;
	dis[x][y] = 0;
	// printf("x: %d y: %d\n",x,y);
	while(!q.empty()){
		ii pas = q.front(); q.pop();
		int x = pas.first, y = pas.second;

		for(i=0;i<4;i++){
			int xbaru = x + dx[i], ybaru = y + dy[i];
			if(xbaru >= 0 && xbaru < n && ybaru >= 0 && ybaru < m){
				if(dis[xbaru][ybaru] == -1 && a[xbaru][ybaru] == '.'){
					dis[xbaru][ybaru] = dis[x][y] + 1;
					maks = max(maks, dis[xbaru][ybaru]);
					q.push(ii(xbaru, ybaru));
				}
			}
		}	
	}
	// printf("maks: %d\n",maks);
	return maks;	
}

int main(){
	int i,j;
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){cin>>a[i];}
	int ans = 0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(a[i][j] == '.'){
				memset(dis, -1, sizeof dis);
				ans = max(ans, bfs(i,j));
			}
		}
	}
	printf("%d\n",ans);
	return 0;
};

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

#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

int n,m;

int f(int x) {
    return (x * (x - 1)) / 2;
}

int main () {
    cin >> n >> m;
    int ans = 0;
    ans += f(n);
    ans += f(m);

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int n=in(),k=in(),i,j,ans=10000,t;
	rep(i,n){
		t=1;
		rep(j,i+1){
			t*=2;
		}
		for(;j<n;j++){
			t+=k;
		}
		ans=min(ans,t);
	}
	print(ans);
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int x, y;
    cin >> x >> y;
    int b = (y - 2 * x) / 2;
    int a = x - b;
    if(2*a + 4 * b == y && a >= 0&& b >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    ll c = 0;
    for (ll i = 0, j = s.size() - 1; i <= j; i++, j--)
        if (s[i] != s[j])
            c++;
    cout << c;
    return 0;
}

Measured memory_bytes: 256
/**********
Author: WLBKR5
Problem: ABC176 D
Date: 2020/08/22
**********/
#include<bits/stdc++.h>
using namespace std;
inline int getint(){
    int ans=0,f=1;
    char c=getchar();
    while(c>'9'||c<'0'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        ans=ans*10+c-'0';
        c=getchar();
    }
    return ans*f;
}
const int N=1e6+10,M=1e7+10;
struct bian{
    int l,e,n;
};
bian b[M];
int s[N],tot=0;
void add(int x,int y,int z){
    //cerr<<"> "<<x<<" "<<y<<" "<<z<<endl;
    tot++;
    b[tot].l=z;
    b[tot].e=y;
    b[tot].n=s[x];
    s[x]=tot;
}

char a[1010][1010];
int n,m;
int id(int x,int y){
    return (x-1)*m+y;
}
int dis[N];
int main(){
    n=getint(),m=getint();
    int x1=getint(),y1=getint(),st=id(x1,y1);
    int x2=getint(),y2=getint(),ed=id(x2,y2);
    //cerr<<st<<" -> "<<ed<<endl;
    for(int i=1;i<=n;i++){
        scanf("%s",a[i]+1);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#')continue;
            if(i-1>0&&a[i-1][j]=='.')add(id(i,j),id(i-1,j),0);
            if(i+1<=n&&a[i+1][j]=='.')add(id(i,j),id(i+1,j),0);
            if(j-1>0&&a[i][j-1]=='.')add(id(i,j),id(i,j-1),0);
            if(j+1<=m&&a[i][j+1]=='.')add(id(i,j),id(i,j+1),0);
        }
    }
    deque<int>q;
    memset(dis,0x3f,sizeof(dis));
    dis[st]=0;
    q.push_back(st);
    while(q.size()){
        int t=q.front();
        q.pop_front();
        for(int i=s[t];i;i=b[i].n){
            int v=b[i].e;
            if(dis[v]>dis[t]+b[i].l){
                if(b[i].l)q.push_back(v);
                else q.push_front(v);
                dis[v]=dis[t]+b[i].l;
            }
        }
        int i=(t-1)/m+1,j=(t-1)%m+1;
        for(int ii=-2;ii<=2;ii++){
            for(int jj=-2;jj<=2;jj++){
                int v=id(i+ii,j+jj);
                if(i+ii>0&&i+ii<=n&&j+jj>0&&j+jj<=m
                    &&a[i+ii][j+jj]=='.'&&dis[v]>dis[t]+1){
                        q.push_back(v);
                        dis[v]=dis[t]+1;
                    }
            }
        }
    }
    if(dis[ed]==0x3f3f3f3f)cout<<"-1";
    else cout<<dis[ed];
    return 0;
}


Measured memory_bytes: 24068
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

template<int Mod> struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll sig) { int sigt = sig % Mod; if(sigt < 0) sigt += Mod; x = sigt; }
    int get() const { return (int)x; }

    ModInt &operator+=(ModInt that) { if((x += that.x) >= Mod) x -= Mod; return *this; }
    ModInt &operator-=(ModInt that) { if((x += Mod - that.x) >= Mod) x -= Mod; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % Mod; return *this; }

    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<MOD> mint;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    mint m(1);
    vector<int> c(3);
    REP(i, N){
        ll cnt = 0;
        if(c[0] == A[i]) cnt++; 
        if(c[1] == A[i]) cnt++; 
        if(c[2] == A[i]) cnt++;

        m *= cnt;
        REP(j, 3){
            if(c[j]==A[i]){
                c[j]++;
                break;
            }
        }
    }
    pr(m.x);
}

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

using namespace std;
const int maxN=3e2+100;
int n,m,st,fn;
int cap[maxN][maxN],excess[maxN],height[maxN];
vector<int> g[maxN];
set<pair<int,int> > candidates;

void input()
{
  cin>>n>>m;
  //cin>>st>>fn;
  st=1; fn=n;
  for(int i=1;i<=m;i++)
    {
      int k1,k2,val;
      cin>>k1>>k2>>val;
      k1++;k2++;
      if(cap[k1][k2]==0 && cap[k1][k2]==0){
	g[k1].push_back(k2);
	g[k2].push_back(k1);
      }
      cap[k1][k2]+=val;
    }
}
int findExcessedVertex()
{
    while(candidates.size()>0)
      {
	auto item=*candidates.begin();
	if(item.second==st || item.second==fn)
	  candidates.erase(item);
	else
	  return item.second;
      }
    return 0;
}
bool push(int v)//change to multi push
{
  bool done=false;
  for(auto u :g[v])
    if(cap[v][u]>0 && height[v]>=height[u]+1)//h[v]==h[u]+1
	{
	int delta=min(excess[v],cap[v][u]);
	cap[v][u]-=delta;
	cap[u][v]+=delta;
	excess[v]-=delta;
	if(excess[v]==0)
	  candidates.erase({height[v],v});
	if(excess[u]==0)
	  candidates.insert({height[u],u});
	excess[u]+=delta;
	done=true;
	if(excess[v]==0)
	  break;
	//return done;
      }
  return done;
}
void relabel(int v)
{
  height[v]++;
  if(candidates.find({height[v]-1,v})!=candidates.end()){
    candidates.erase({height[v]-1,v});
    candidates.insert({height[v],v});}
}
void GT_init()
{
  height[st]=n;
  height[fn]=0;//not done
  for(auto u:g[st])
    if(cap[st][u]>0)
      {
      int delta=cap[st][u];
      cap[st][u]-=delta;
      cap[u][st]+=delta;
      excess[st]-=delta;
      if(excess[st]==0)
	candidates.erase({height[st],st});
      if(excess[u]==0)
	candidates.insert({height[u],u});
      excess[u]+=delta;
    }
}
int Goldberg_Tarjan()
{
  GT_init();
  while(int v=findExcessedVertex())
    {
      
      // cout<<"gt "<<v<<" "<<excess[v]<<" "<<height[v]<<endl;
      if(!push(v))
	relabel(v);
    }
  return excess[fn];
}
int main()
{
  input();
  int Maxflow=Goldberg_Tarjan();
  cout<<Maxflow<<endl;
  
  return 0;
}

Measured memory_bytes: 3356
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <utility>
using namespace std;
int inf = 1e9;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    vector<vector<char>> grid(h+2, vector<char>(w+2, '@'));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> grid[i][j];
        }
    }
    vector<vector<int>> mincost(h+2, vector<int>(w+2, inf));
    mincost[sx][sy] = 0;
    queue<pair<pair<int, int>, int>> wait;
    wait.push({{sx, sy}, 0});
    while(!wait.empty()){
        int x = wait.front().first.first;
        int y = wait.front().first.second;
        int cost = wait.front().second;
        wait.pop();
        if(cost > mincost[x][y]) continue;
        for(int d=0; d<4; d++){
            for(int i=1; i<=k; i++){
                int nx = x +i*dx[d];
                int ny = y +i*dy[d];
                if(grid[nx][ny] == '@') break;
                if(mincost[nx][ny] < cost+1) break;
                if(mincost[nx][ny] > cost+1){
                    mincost[nx][ny] = cost+1;
                    wait.push({{nx, ny}, cost+1});
                }
            }
        }
    }
    if(mincost[gx][gy] == inf){
        cout << -1 << endl;
    }else{
        cout << mincost[gx][gy] << endl;
    }
    return 0;
}


Measured memory_bytes: 21860
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
typedef long long int ll;
const double pi = 3.14159265358979323846;

int main() {
    fast
    //test
    {
        double i,j,a,b,h,m;
        cin >> a>>b>>h>>m;
      	double min;
      min=60*h+m;
      double angle=360*abs(min/720-m/60);
      if(angle>180)
        angle=360-angle;
      angle=(angle/180)*pi;
      printf("%.20lf",sqrt(a*a+b*b-2*a*b*cos(angle)));
    }
	return 0;
}


Measured memory_bytes: 4248
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N = ri()
print(N ** 3)

Measured memory_bytes: 63724
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

sum = A.inject(&:+)

left_len = 0
i = 0
while (left_len * 2 < sum) 
  left_len += A[i]
  i += 1
end

right_len = sum - left_len
# Now, left_len > right_len. the diff is ans

can1 = left_len - right_len
can2 = (right_len + A[i-1]) - (left_len - A[i-1])
# p "can1: #{can1}"
# p "can2: #{can2}"
ans = [can1, can2].min

p ans

  

Measured memory_bytes: 18308
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

char str[200010];

int main()
{
    int n;
    cin>>n;
    cin>>str;
    int l=0;
    int r=strlen(str)-1;
    int tot=0;
    while(str[l]=='R'&&l<strlen(str))
        l++;
    while(str[r]=='W'&&r>=0)
        r--;
    while(l<r)
    {
        tot++;
        l++;
        r--;
        while(str[l]=='R'&&l<strlen(str))
            l++;
        while(str[r]=='W'&&r>=0)
            r--;
    }
    cout<<tot;
    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
 
    vector<vector<int>> t(n + 1, vector<int>(n + 1, 100000001));
    REP1(i, n) t[i][i] = 0;

  	vector<tuple<int, int, int>> u;
    int a, b, c;
    REP(i, m) {
        cin >> a >> b >> c;
        t[a][b] = c;
        t[b][a] = c;
        u.emplace_back(a, b, c);
    }
 
    REP1(k, n) {
        REP1(i, n) {
            REP1(j, n) {
                t[i][j] = min(t[i][j] ,t[i][k] + t[k][j]);
            }
        }
    }
  
    int total = 0;
    for (auto s : u) {
        if (get<2>(s) > t[get<0>(s)][get<1>(s)]) {
            total++;
        }
    }

    cout << total << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
vector<vector<int>>G(200200,vector<int>());
vector<bool>used(200200,false);
const int MX=100000;
ll xx,yy,e;
void dfs(int v){
  if(v<MX){xx++;}
  else{yy++;}
  e+=G[v].size();
  for(int nx:G[v]){
    if(used[nx])continue;
    used[nx]=true;
    dfs(nx);
  }
}
int main()
{
  int N;
  cin >> N;
  rep(i,N){
    int x,y;
    cin >> x >> y;
    x--;y--;y+=MX;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  ll ans=0;
  rep(i,200200){
    if(!used[i]){
      used[i]=true;
      xx=yy=e=0;
      dfs(i);
      e/=2;
      ans+=xx*yy-e;
    }
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 9984
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h){
    cin >> s[i];
  }

  int ans = 1001001;
  rep(div, 1<<h){
    vi idx;
    int g = 0;
    rep(i, h){
      idx.push_back(g);
      if (div>>i & 1) g++;
    }
    g++;

    vector<vi> g_sum(g, vi(w));
    rep(i, h) rep(j, w) if (s[i][j] == '1') g_sum[idx[i]][j] += 1;
    bool ok = true;
    rep(i, g) rep(j, w) if (g_sum[i][j] > k) ok = false;
    if (!ok) continue;

    int tmp_ans = g - 1;
    vi now(g);
    rep(i, w){
      bool can_add = true;
      rep(j, g){
        now[j] += g_sum[j][i];
        if (now[j] > k) {
          can_add = false;
          break;
        }
      }
      if (!can_add){
        tmp_ans++;
        rep(j, g) now[j] = g_sum[j][i];
      }
    }
    ans = min(ans, tmp_ans);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    L = max(K, max(A), 1).bit_length()
    k = [0 for i in range(L)]
    i = 0
    while K:
        k[i] += K & 1
        i += 1
        K >>= 1
    b = [0 for i in range(L)]
    for a in A:
        i = 0
        x = a
        while x:
            b[i] += x & 1
            i += 1
            x >>= 1
    k = k[::-1]
    b = b[::-1]
    # dp[i][1]: 上位iビットがKと等しいときの最大値
    # dp[i][0]: 上位iビットがKより小さいときの最大値
    dp = [[-1, -1] for i in range(L+1)]
    dp[0][1] = 0
    for i in range(L):
        if dp[i][0] >= 0:
            dp[i+1][0] = (dp[i][0] << 1) + max(b[i], N-b[i])
        #if dp[i][1] >= 0:
        if k[i] == 1:
            dp[i+1][0] = max(dp[i+1][0], (dp[i][1] << 1) + b[i])
            dp[i+1][1] = (dp[i][1] << 1) + (N-b[i])
        else:
            dp[i+1][1] = (dp[i][1] << 1) + (b[i])
    return max(dp[L][1], dp[L][0])


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    vector<ll> a;
    NREP() {
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    ll brk = 0;
    ll count = 1;
    NREP() {
        if (a[i] == count) {
            count++;
            brk++;
        }
    }

    if (count != 1) {
        cout << n - brk << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3444
#include<stdio.h>

int a[1010],m,n,i,b,c;

int main(){
    scanf("%d%d",&n,&m);
    while(n!=0 && m!=0){
        for(i=1;i<=n;i++)a[i]=1;
        b=i=n;
        while(b>1){
            c=0;
            while(c<m){
                i++;if(i>n)i=1;
                c+=a[i];
            }
            a[i]=0;b--;
        }
        for(i=1;i<=n;i++)if(a[i]==1)printf("%d\n",i);
        scanf("%d%d",&n,&m);
    }
    
    return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}

		sc.close();

		//
		long result = 0;
		for (int i = 1; i < N; i++) {
			if (A[i - 1] <= A[i]) {
				// result = result;
			} else {
				result = result + (A[i - 1] - A[i]);
				A[i] = A[i - 1];
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 61264
#include <cstdio>
#include <algorithm>
using namespace std;
pair<pair<int, int>, int> p[1010];
long long dp[20010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int w, s, v;
		scanf("%d%d%d", &w, &s, &v);
		p[i] = make_pair(make_pair(s + w, w), v);
	}
	sort(p, p + n);
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int s = p[i].first.first, w = p[i].first.second, v = p[i].second;
		s -= w;
		for (int j = s; j >= 0; j--) {
			dp[j+w] = max(dp[j+w], dp[j] + v);
		}
		for (int j = 20000; j >= 0; j--) {
			ans = max(ans, dp[j]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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



int main() {
	int a,b;
	cin >> a >> b;
	int n[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	cout << (n[a]==n[b]?"Yes":"No") << endl;
}


Measured memory_bytes: 256
N, H, W = map(int, input().split(" "))
x, y = list(), list()
for i in range(N) :
    _x, _y = input().split(" ")
    x.append(int(_x))
    y.append(int(_y))
    
cnt = 0
for _x, _y in zip(x, y) :
    if _x >= H and _y >= W : cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
#include <map>
#include <stack>
using namespace std;
 
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,-1,1,-1,1};
 
 
int main() {
int m;
while(cin>>m && m){
int a[110][110]={0};
int b[110]={0};
int n,l;
for(int i=1;i<m+1;i++){
cin>>n;
for(int j=0;j<n;j++){
cin>>l;
a[i][l]=1;
}
}
cin>>n;
for(int j=0;j<n;j++){
cin>>l;
b[l]=1;
}
int ans=0,ans1=0;
for(int i=1;i<m+1;i++){
int y=0;
for(int j=1;j<m+1;j++){
y=y+a[i][j]*b[j];
}
//cout<<y<<endl;
if(y==n) {
ans++;
ans1=i;
}
}
if(ans==1) cout<<ans1<<endl;
else cout<<"-1"<<endl;



}

	return 0;
 
   }

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    long long int sum;
    string s;
    cin>>s;
    sum=0;
    rep(i,s.size()){
        sum=sum+(long long int)s.at(i)-48;
        //cout<<sum<<endl;
    }
    
    //n=(int)s.at(3);
    if(sum%9==0)cout<<"Yes"<<endl;
    else {cout<<"No"<<endl;}
    //cout<<sum<<endl;
    
}


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

int main(int argc, char const *argv[])
{
	int d, n; cin >> d >> n;
	int k = pow(100, d);
	if (n < 100) printf("%d\n", k * n);
	else printf("%d\n", k * 101);
	return 0;
}

Measured memory_bytes: 256
import itertools 

line1 = input().split()
rei = input().split()
rei =list(map(int,rei))
den =input().split()
den =list(map(int,den))
cupon =[list(map(int,input().split())) for i in range(int(line1[2]))]

rei_mi = min(rei)
den_mi =min(den)

no_total =rei_mi +den_mi

for s in range(int(line1[2])):
  yes_total =int(rei[cupon[s][0]-1]) +int(den[cupon[s][1]-1]) - cupon[s][2]
  if no_total > yes_total:
    no_total =yes_total
print(no_total)


Measured memory_bytes: 38564
from sys import stdin 
import math 

def main():

	h, w = map(int, input().split())

	grid = []

	for ind in range(h):
		grid.append(input())


	L = [ [0 for _ in range(w)] for _ in range(h) ]

	L[0][0] = 1

	for h_ind in range(h):
		for w_ind in range(w):
			if grid[h_ind][w_ind] == '.':
				if h_ind - 1 >= 0:
					L[h_ind][w_ind] += L[h_ind - 1][w_ind]
				if w_ind - 1 >= 0:
					L[h_ind][w_ind] +=  L[h_ind][w_ind - 1]


	modulo = int (pow(10, 9) + 7)
	print(L[h - 1][w - 1] % modulo)











if __name__ == '__main__':
	main()





















Measured memory_bytes: 168164
import sys
n = int(input())
s = str(input())
tmp = []
if n%2:
    print('No')
    sys.exit()

for i in range(n):
    if i+1 <= n//2:
        tmp.append(s[i])
    else:
        if tmp[i-n//2] != s[i]:
            print('No')
            sys.exit()
        else:
            continue
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  string s,t;
  int n,i;
  cin>>s;
  i = s.size()/2;
  n = s.size();
  t = s.substr(0,i);
  
  
  
  if(s.substr(0,i) == s.substr(n-i,i)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256