akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/dp/tasks/dp_n
//長さを固定しiとし、位置をjとしずらしていく
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N;
LL a[400];

LL ans = 0;

void solve(){
	//dp[j][j+i]:a[j]~a[j+i]についての最小値
	LL dp[402][402] = {0};
	LL tmp;
	LL sum;

	auto draw_dp_table = [&](int i,int j){
		printf("\nj=%d j+i=%d\n",j,j+i);
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}
	};

	for (int i=1;i<N;i++){
		//i（区間の長さ）を固定して
		//j（開始インデックス）を0~N-i-1まで動かしていく
	    for (int j=0;j<N-i;j++){
	    	//いま求めたいのはdp[j][j+i]
	        tmp = INF;
	        //j~j+iの区間の全部の和がsum
	        //これからj~k間とk+1~j+i間を統合するが、そのときのコストがsumなため
	        sum = 0;
	        for (int k=j;k<j+i;k++){
	        	//dp[j][k]+dp[k+1][j+i]
	        	//j~k間のコストの最小値 ＋ k+1~j+i間のコストの最小値
	        	//のうち、最も小さいものをtmpとする
	            tmp = min(tmp,dp[j][k]+dp[k+1][j+i]);
	            sum += a[k];
	        }
	        sum += a[j+i];//j~j+iの区間の全部の和
	        dp[j][j+i] = tmp+sum;//j~k間とk+1~j+i間を統合
	        //draw_dp_table(i,j);
	    }
	}
	ans = dp[0][N-1];
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> a[i];
 
	solve();

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

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

int main() {
  int n;
  cin >> n;
  
  int a;
  map<int,int> b;
  for(int i=0; i<n; i++) {
    cin >> a;
    b[a]++;
  }
  
  int ans = 0;
  for(auto p : b) if(p.second%2!=0) ans++;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8236
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e10
)

var sc = bufio.NewScanner(os.Stdin)

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

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

func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)

	for i := 1; i < 6; i++ {
		if nextInt() == 0 {
			fmt.Println(i)
			return
		}
	}
}

func intSlicePrint(el ...int) {
	first := true
	for _, v := range el {
		if v < 0 {
			continue
		}
		if !first {
			fmt.Printf(" ")
		}
		fmt.Printf("%v", v)
		first = false
	}
	fmt.Println("")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1756
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>

using namespace std;
typedef long long ll;
void yes(){
cout<<"Yes"<<endl;
}
void no(){
cout<<"No"<<endl;
}
int main(){
ll n,m,X,Y;
cin>>n>>m>>X>>Y;
ll x[n],y[m];
for(ll i=0;i<n;i++){
cin>>x[i];
}
for(ll i=0;i<m;i++){
cin>>y[i];
}
sort(x,x+n);
sort(y,y+m);
ll xn=x[n-1];
ll yn=y[0];
int flag=0;
if(xn>=yn)
flag=1;
else{
int flag2=0;
for(ll i=xn+1;i<=yn;i++){
if(X<i&&i<=Y)
flag2=1;
}
if(flag2==0)
flag=1;
}
if(flag==1)
cout<<"War";
else
cout<<"No War";
  return 0;
}



Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

dp = [1e9] * n
dp[0] = 0

for i in range(n):
    for j in [i + 1, i + 2]:
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))

print(dp[n - 1])

Measured memory_bytes: 13980
#include <stdio.h>

int main()
{
	int n, i, c[8] = { 0 };
	int a[100], wild = 0;
	int max, min;
	max = min = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
		if (a[i] >= 3200)
			wild++;
		else if (a[i] >= 2800)
			c[7] = 1;
		else if (a[i] >= 2400)
			c[6] = 1;
		else if (a[i] >= 2000)
			c[5] = 1;
		else if (a[i] >= 1600)
			c[4] = 1;
		else if (a[i] >= 1200)
			c[3] = 1;
		else if (a[i] >= 800)
			c[2] = 1;
		else if (a[i] >= 400)
			c[1] = 1;
		else
			c[0] = 1;
	}

	for (i = 0; i < 8; i++){
		if (c[i] == 1)
			min++;
	}
	max = min + wild;
	if (min == 0)
		min = 1;
	printf("%d %d", min, max);

	return 0;
}

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

int main() {
    int A, B, C;
    int X;
    
    cin >> A >> B >> C >> X;
    
    int res = 0;
    for(int a = 0; a <= A; ++a){
        for(int b = 0; b <= B; ++b){
            for(int c = 0; c <= C; ++c){
                int total = 500 * a + 100 * b + 50 * c;
                if(total == X) ++res;
            }
        }
    }
    
    cout << res << endl;
    
}

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

using namespace std;
typedef long long ll;






int main()
{
    int D,N;
    cin >> D >> N;
    if(D==0){
        if(N!=100) cout << N << endl;
        else cout << 101 << endl;
        
    }
    else if(D == 1){
        if(N*100!=10000) cout << N*100 << endl;
        else cout << 10100 << endl;
        
    }
    else if(D == 2){
        if(N*10000!=1000000) cout << N*10000 << endl;
        else cout << 1010000 << endl;
        
        
    }
        
    
    
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
L_max,R_min = 0,10000000
for i in range(M):
  L,R = map(int,input().split())
  L_max = max(L_max,L)
  R_min = min(R_min,R)
if R_min < L_max:
  print(0)
else:
  print(R_min - L_max + 1)

Measured memory_bytes: 9156
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int[][] map = new int[11][11];

		String line = "";
		for (int i = 0; i < 11; i++) {
			if ((i != 0) && (i != 10)) line = sc.nextLine();

			for (int j = 0; j < 11; j++) {
				if ((i == 0) || (j == 0) || (i == 10) || (j == 10)) {
					map[i][j] = 0;
					continue;
				}
				if ((j % 2) != (i % 2)) map[i][j] = line.charAt((j - 1) / 2) - '0';
				else map[i][j] = 0;
			}
		}
		
		int x = 2;
		int y = 0;
		int v = 1;
		
		while (true) {
			switch (v) {
			case 0:
				if (map[y][x + 1] == 1) {
					if (map[y - 1][x] == 0) {
						System.out.print("U");
						y = y - 2;
					} else {
						if (map[y][x - 1] == 0) {
							System.out.print("U");
							v = 3;
						} else {
							System.out.print("UL");
							v = 2;
						}
					}
				} else {
					v++;
					x = x + 2;
				}
				break;
				
			case 1:
				if (map[y + 1][x] == 1) {
					if (map[y][x + 1] == 0) {
						System.out.print("R");
						x = x + 2;
					} else {
						if (map[y - 1][x] == 0) {
							System.out.print("R");
							v = 0;
						} else {
							System.out.print("RU");
							v = 3;
						}
					}
				} else {
					v++;
					y = y + 2;
				}
				break;
				
			case 2:
				if (map[y][x - 1] == 1) {
					if (map[y + 1][x] == 0) {
						System.out.print("D");
						y = y + 2;
					} else {
						if (map[y][x + 1] == 0) {
							System.out.print("D");
							v = 1;
						} else {
							System.out.print("DR");
							v = 0;
						}
					}
				} else {
					v++;
					x = x - 2;
				}
				break;
				
			case 3:
				if (map[y - 1][x] == 1) {
					if (map[y][x - 1] == 0) {
						System.out.print("L");
						x = x - 2;
					} else {
						if (map[y + 1][x] == 0) {
							System.out.print("L");
							v = 2;
						} else {
							System.out.print("LD");
							v = 1;
						}
					}
				} else {
					v = 0;
					y = y - 2;
				}
				break;
			}
			if ((x == 2) && (y == 0)) break;
		}
		System.out.println();
	}
}

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

int c[100];

int main()
{
	int a, b;
	while( std::cin >> a >> b )
	{
		memset( c, 0, sizeof( c ) );
		++c[a-1], ++c[b-1];

		while( std::cin >> a >> b, a | b )
			++c[a-1], ++c[b-1];

		bool f = true;

		if( c[0] % 2 && c[1] % 2 )
		{
			for( int i = 2; i != 100; ++i )
			{
				if( c[i] % 2 )
				{
					f = false;
					break;
				}
			}
		}
		else 
			f = false;

		if( f )
			std::cout << "OK" << std::endl;
		else
			std::cout << "NG" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#ここまでテンプレ
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

import math

ans = a[0]
sosu = a[0]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)

an = prime_factorize(a[0])
flag = True

for i in range(1, n):
    ans = math.gcd(ans, a[i])
    pri = prime_factorize(a[i])
    for j in pri:
        if j in an:
            flag = False
        else:
            an.add(j)
    
if ans == 1 and flag == True:
    print("pairwise coprime")
elif ans == 1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 182536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null && !line.isEmpty()) {
            int d = Integer.parseInt(line);
            int s = 0;
            for (int x = 0; x < 600; x += d) {
                s += x * x * d;
            }
            out.println(s);
        }
    }
}

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int c = 0;
	const int n = s.size();
	vector<int> v(n + 1, -1);
	for (int i = 0; i < n + 1; ++i) {
		if (i == 0 && s[i] == '<') v[i] = 0;
		if (i == n && s[i - 1] == '>') v[i] = 0;
		if (i != 0 && i != n && s[i] == '<' && s[i - 1] == '>') v[i] = 0;
	}
	for (int i = 0; i < n + 1; ++i) {
		if (i != 0 && v[i - 1] != -1 && s[i - 1] == '<') v[i] = max(v[i], v[i - 1] + 1);
	}
	for (int i = n; i >= 0; --i) {
		if (i != n && v[i + 1] != -1 && s[i] == '>') v[i] = max(v[i], v[i + 1] + 1);
	}
	
	/*
	
	for (int i = 0; i <= n; ++i) {
		cout << v[i] << " ";
		if (i != n) cout << s[i] << " ";
	}
	cout << "\n";
	
	*/
	
	long long r = 0;
	for (int i = 0; i < n + 1; ++i) r += v[i];
	cout << r << "\n";
}


Measured memory_bytes: 2820
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]

x = 0
for i in range(n - 2):
    if d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1] and d[i + 2][0] == d[i + 2][1]:
        print("Yes")
        exit(0)

print("No")


Measured memory_bytes: 9124
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, m;
vector<int> g[maxN], path[2];
bool visited[maxN];

void DFS(int u, vector<int> &path) {
    path.pb(u);
    visited[u] = true;
    forit(it, g[u]) {
        int v = *it;
        if (!visited[v]) {
            DFS(v, path);
            break;
        }
    }
}

int main () {
    scanf("%d%d", &n, &m);
    fto(i, 1, m) {
        int u, v;
        scanf("%d%d" , &u, &v);
        g[u].pb(v); g[v].pb(u);
    }

    fto(u, 1, n) {
        if (sz(g[u]) > 0) {
            visited[u] = true;

            int cnt = 0;
            forit(it, g[u]) {
                if (!visited[*it]) DFS(*it, path[cnt++]);
                if (cnt > 1) break;
            }
            reverse(path[0].begin(), path[0].end());
            printf("%d\n", sz(path[0])+sz(path[1])+1);
            forit(it, path[0]) printf("%d ", *it);
            printf("%d", u);
            forit(it, path[1]) printf(" %d", *it);
            break;
        }
    }


    return 0;
}


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

int main (){ 
    string S, T;
    int S_len;

    cin >> S >> T;
    S_len = S.size();

    if (S.compare(0, S_len, T, 0, S_len) == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;
	ll ans=0;
	cin >>n>>k;
	ll a=n/k;
	ll b=0;
	if(k%2==0){
		b=n/(k/2)-a;
	}
	ans=a*a*a+b*b*b;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
//TDPC E-数 https://tdpc.contest.atcoder.jp/tasks/tdpc_number
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;
ll N;
vector<ll> v;
int a[100010];
int main(void)
{
    string s;
    cin >> s;
    if(s.size()==2) cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    char n[3];
    cin >> n;
    for (int i = 0; i < 3; i++)
    {
        if (n[i] == '1')
        {
            n[i] = '9';
        }
        else if (n[i] == '9')
        {
            n[i] = '1';
        }
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    dp=[0 for _ in range(N+1)]
    dp[1]=0
    x=A[0]
    for i,a in enumerate(A[1:],2):
        if i%2!=0:
            dp[i]=max(a+dp[i-2],dp[i-1])
            x+=a
            continue
        dp[i]=max(a+dp[i-2],x)
    print(dp[-1])





if __name__ == "__main__":
    main()

Measured memory_bytes: 116744
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

const int MAX_N = 402;

ll dp[MAX_N][MAX_N]; //dp[i][j] : 区間[i, j)のコストの最小値

int main() {
    int N; cin >> N;
    ll a[N]; rep(i, N) cin >> a[i];
    ll sum[N + 1]; //sum[i] : [0, i)の累積和
    sum[0] = 0;
    rep(i, N) sum[i + 1] = sum[i] + a[i];
    rep(i, N + 1)
        rep(j, N + 1)
            dp[i][j] = ((i == j) ? 0 : LLINF);
    for(int len = 1; len <= N; ++len) {
        for(int i = 0; i + len <= N; ++i) {
            ll k = sum[i + len] - sum[i];
            if(i + 1 == i + len) dp[i][i + len] = 0;//dp[i][i + 1]を0に，ここでやる意味はなし
            for(int j = i + 1; j < i + len; ++j) {
                dp[i][i + len] = min<ll>(dp[i][j] + dp[j][i + len] + k, dp[i][i + len]);
            }
        }
    }

    cout << dp[0][N] << endl;
}


Measured memory_bytes: 1664
#C
MOD = 2019
L ,R = map(int, input().split())
k = L % MOD
t = R % MOD
if L + 2019 - k <= R:
    print(0)
else:
    ans = float('inf')
    for i in range(k, t+1):
        for j in range(i+1, t+1):
            ans = min(ans, (i*j) % MOD)
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
	vector<int> a(9);
	for (int i=0;i<9;i++){
		cin >> a[i];
	}
	int N;
	cin >> N;
	for (int i=0;i<N;i++){
		int b;
		cin >> b;
		for (int i=0;i<9;i++){
			if (a[i]==b){
				a[i] = -1;
			}
		}
	}
	int b[8][3] = {
		{a[0],a[1],a[2]},
		{a[3],a[4],a[5]},
		{a[6],a[7],a[8]},
		{a[0],a[3],a[6]},
		{a[1],a[4],a[7]},
		{a[2],a[5],a[8]},
		{a[0],a[4],a[8]},
		{a[6],a[4],a[2]},
	};
	bool ans = false;
	for (int i=0;i<8;i++){
		if (b[i][0]==-1 && b[i][1]==-1 && b[i][2]==-1){
			ans = true;
		}
	}
	if (ans){
		cout <<  "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def sumCifre(n):
	sum = 0
	while n > 0:
		sum = sum + n % 10
		n //= 10
	return sum
	
def main():
	linie = input()
	vector = [int(x) for x in linie.split()]	
	x = vector[0]
	y = vector[1]
	imp = y // x
	nr = 0
	while imp > 1:
		imp //= 2
		nr += 1
	print(nr + 1)
 
if __name__ == "__main__":
	main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int K,A,B;
    cin>>K>>A>>B;
    FOR(i,A,B+1){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}   
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	map<int,int> m;
	m.insert(mp(0,0));
	m.insert(mp(1e18,1e18));
	int ans=0;
	for(int i=0;i<n;i++){
		auto it=m.lower_bound(a[i]); it--;
		int res=b[i]+it->ss; it++;
		while(1){
			if(it->ss<res){
				int x=it->ff;
				m.erase(m.find(x));
				it=m.lower_bound(x);
			}
			else break;
		}
		ans=max(ans,res);		
		m.insert(mp(a[i],res));
	}   
	cout<<ans<<endl;
}

Measured memory_bytes: 15872
# AOJ 0009 Prime Number
# Python3 2018.6.9 bal4u

MAX = 1000000
SQRT = 1000     # sqrt(MAX)

prime = [0] * MAX

def sieve():
	for i in range(3, MAX, 2):
		prime[i] = 1
	for i in range(3, SQRT, 2):
		if prime[i] == 1:
			for j in range(i*i, MAX, i):
				prime[j] = 0

sieve()
cnt = [0] * (MAX+1)
cnt[2] = f = 1
for i in range(3, MAX, 2):
	if prime[i]:
		f += 1;
	cnt[i] = cnt[i+1] = f
	
while True:
    try:
        print(cnt[int(input())])
    except EOFError:
        break



Measured memory_bytes: 23440
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
typedef struct Eachtop {
  double x;
  double y;
  struct Eachtop *next;
} Top;
 
Top *tenode, *lnode, *tnode;
 
void makenewpoint(Top* a, Top* b){
  Top *fnode, *snode, *thnode;
  fnode = (Top*)malloc(sizeof(Top));
  fnode->x = (b->x - a->x)/ 3.0+a->x;
  fnode->y = (b->y - a->y)/ 3.0+a->y;
  snode = (Top*)malloc(sizeof(Top));
  snode->x = (b->x - a->x)/ 3.0*2+a->x;
  snode->y = (b->y - a->y)/ 3.0*2+a->y;
  thnode = (Top*)malloc(sizeof(Top));
  thnode->x =1/sqrt(3.0)* ((b->x - a->x) * cos(M_PI/6.0) - (b->y - a->y)*sin(M_PI/6.0)) + a->x;
  thnode->y =1/sqrt(3.0)* ((b->x - a->x) * sin(M_PI/6.0) + (b->y - a->y)*cos(M_PI/6.0)) + a->y;
  a->next = fnode;
  fnode->next = thnode;
  thnode->next = snode;
  snode->next = b;
  tnode = b;
}
int main(void){
  int n, i;
  scanf("%d", &n);
  tenode = NULL;
  lnode = NULL;
  tenode = (Top*)malloc(sizeof(Top));
  tenode->x = 0;
  tenode->y = 0;
  lnode = (Top*)malloc(sizeof(Top));
  lnode->x = 100;
  lnode->y = 0;
  tnode = tenode;
  tenode->next = lnode;
  lnode->next = NULL;
  for(i=0; i<n ;i++){
    tnode = tenode;
    while(tnode != lnode)
      makenewpoint(tnode, tnode->next);
  }
  tnode = tenode;
  while(tnode != NULL){  
    printf("%f %f\n", tnode->x, tnode->y);
    tnode = tnode->next;
  }
  return 0;
}



Measured memory_bytes: 2040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            int numberA = Integer.parseInt(inputString.get(0));
            int numberB = Integer.parseInt(inputString.get(1));

            int maxAbbOrSubOrMul = getMaxAbbOrSubOrMul(numberA, numberB);
            System.out.println(maxAbbOrSubOrMul);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static int getMaxAbbOrSubOrMul(int numberA, int numberB) {

        int add = numberA + numberB;
        int sub = numberA - numberB;
        int mul = numberA * numberB;

        if (add >= sub && add >= mul) {
            return add;
        } else if (sub >= add && sub >= mul) {
            return sub;
        } else if (mul >= add && mul >= sub) {
            return mul;
        }
        return 0;
    }
}

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

int bitCount(unsigned int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); //  8bitごとに計算
    bits =
        (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16); //  32ビット分を計算
}

void func_A() {
    int A, B;
    cin >> A >> B;
    int res = A > 2 * B ? A - 2 * B : 0;
    cout << res << endl;
}
void func_B() {
    int N;
    cin >> N;
    vector<ll> d(N);
    rep(i, N) {
        cin >> d[i];
    }
    ll res = 0;
    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            res += d[i] * d[j];
        }
    }
    cout << res << endl;
}
void func_C() {
    int N;
    string S, res;
    cin >> N;
    cin >> S;
    char now = S[0];
    rep(i, N) {
        if(now != S[i]) {
            res += now;
            now = S[i];
        }
    }
    if(res[res.size() - 1] != S[N - 1]) res += S[N - 1];
    cout << res.size() << endl;
}
void func_D() {
    unsigned int N;
    cin >> N;
    ll res = 0;
    vector<ll> L(N);
    rep(i, N) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    for(int i = N - 1; i >= 0; i--) {
        auto Iter1 = upper_bound(L.begin(), L.end(), (L[i] / 2));
        if(*Iter1 != -1) {
            for(int j = i - 1; j >= (Iter1 - L.begin()); j--) {
                auto Iter2 = upper_bound(L.begin(), Iter1, L[i] - L[j]);
                if(*Iter2 != -1) {
                    res += j - (Iter2 - L.begin());
                }
            }
        }
    }
    cout << res << endl;
}
int main() {
    func_D();
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int num;
int makeFibonacci(void);
int main(){
  scanf("%d",&num);
  
  printf("%d\n",makeFibonacci());
  
  return 0;
}
int  makeFibonacci(){
  int F[num+1],i;
  F[0]=1;
  F[1]=1;
  for(i=2;i<=num;i++){
    F[i]= F[i-2]+F[i-1];
  }
  return F[i-1];
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  int N; cin >> N;
  cout << N * N << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,i,j;
  cin >> n;
  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
      }
    }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc104/tasks/abc104_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll D,G;
  cin >> D >> G;
  auto ps = make_v<pair<ll,ll>>(D);
  REP(i,D) {
    ll p, c;
    cin >> p >> c;
    ps[i] = make_pair(p, c);
  }
  auto v = make_v<int>(D);
  iota(v.begin(), v.end(), 1);
  ll ans = LONG_LONG_MAX;
  do {
    ll sum = 0, c = 0;
    for(auto x: v) {
      ll m = x * 100 * ps[x-1].first;
      if (sum + m + ps[x-1].second < G) {
        c += ps[x-1].first;
        sum += m + ps[x-1].second;
        continue;
      } else if (sum + m < G) {
        c += ps[x-1].first;
        break;
      } else {
        c += ll(ceil(double(G-sum) / double(x*100)));
        break;
      }
    }
    ans = min(ans, c);
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
a = input().split()
X = int(a[0])
N = int(a[1])
OK = []
list = []
if N ==0:
    print(X)
else:
    P = input().split()
    for i in range(102):
        OK.append(str(i))
    for i in range(len(P)):
        OK.remove(P[i])
    for i in range(len(OK)):
        list.append(abs(int(OK[i]) - X))
    Y = list.index(min(list))
    print(OK[Y])

Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++ i)

inline int read() 
{
	char cc = getchar(); int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - 48; cc = getchar();}
	return cn * flus;
}

const int MAXN = 1e5 + 10, INF = 2147483647;
const int Mod = 998244353, G = 3;

int n, d;

inline int dis(int x, int y)
{
	return ceil(sqrt(x * x + y * y));
}

signed main()
{
	int ans(0); 
	n = read(), d = read();
	rep(i, 1, n) 
	{
		int x = read(), y = read();
		if(dis(x, y) <= d) ans ++; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3804
#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;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int a; cin >> a;
  cout << 3 * a * a << endl;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m; assert(b>=0); for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// うさぎとねこを0と1にして配列とかメソッドをまとめるべきだった クソ実装

int n, u, v, m, r[505][505], c[505][505], t, rh[505], rw[505], rdl, rdr, ch[505], cw[505], cdl, cdr;
map<int,pii> rp, cp;

bool rwin() {
	int x = rp[t].fi, y = rp[t].se;
	if (x==0) return 0;
	if (n==1) return u==1;
	u -= (++rh[x]==n) + (++rw[y]==n);
	if (x==y) u -= (++rdl==n);
	if (x+y==n+1) u -= (++rdr==n);
	return u<=0;
}

bool cwin() {
	int x = cp[t].fi, y = cp[t].se;
	if (x==0) return 0;
	if (n==1) return v==1;
	v -= (++ch[x]==n) + (++cw[y]==n);
	if (x==y) v -= (++cdl==n);
	if (x+y==n+1) v -= (++cdr==n);
	return v<=0;
}

signed main() {
	cin >> n >> u >> v >> m;
	repst(i,1,n) repst(j,1,n) {
		cin >> r[i][j];
		rp[r[i][j]] = {i,j};
	}
	repst(i,1,n) repst(j,1,n) {
		cin >> c[i][j];
		cp[c[i][j]] = {i,j};
	}
	rep(i,m) {
		cin >> t;
		bool a = rwin(), b = cwin();
		if (!a && !b) continue;
		else {
			if (a && b) cout << "DRAW" << ln;
			else if (a) cout << "USAGI" << ln;
			else cout << "NEKO" << ln;
			return 0;
		}
	}
	cout << "DRAW" << ln;
}


Measured memory_bytes: 24120
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,k,m,x,cnt;
	int box[100]={0};
	int i,j;
	cin>>n>>k;
	for(i=0;i<k;i++){
		cin>>m;
		for(j=0;j<m;j++){
			cin>>x;
			box[x-1]=1;
		}
	}
	cnt=0;
	for(i=0;i<n;i++){
		if(box[i]==0)	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
	

Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long A, B, C;
    cin >> A >> B >> C;

    long long ans = B + min(A + B, C);
    if (A + B < C) ans++;

    cout << ans << endl;

}






















































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=3e2+5,M=1e7+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int f[M],st[N],top,c1,c0,e[N][N],vis[N],lk[N],n;
int isp(int x){
	if(x<=2||x%2==0)return 0;
	for(int i=2;i*i<=x;i++)if(x%i==0)return 0;
	return 1;
}
int hungry(int x){
	vis[x]=1;
	rep(i,1,top)if(e[x][i]){
		if(!lk[i]){lk[i]=x;return 1;}
		if(!vis[lk[i]]&&hungry(lk[i])){lk[i]=x;return 1;}
	}return 0;
}
int main(){
	read(n);rep(i,1,n)f[read()]=1;
	rep(i,1,1e7+1)if(f[i]^f[i-1]){st[++top]=i;if(i&1)c1++;else c0++;}
	rep(i,1,top)rep(j,i,top)if(isp(abs(st[i]-st[j])))e[i][j]=e[j][i]=1;
	int mat=0;
	rep(i,1,top)if(st[i]&1){
		clr(vis);
		mat+=hungry(i);
	}
	c1-=mat;c0-=mat;
	int res=mat+c1+c0;if(c0&1)if(c1&1)res++;
	cout<<res<<endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N), P;
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  int ans = 0;
  long long sumA = 0, sumB = 0, lack = 0;
  for (int i = 0; i < N; i++) {
    sumA += A.at(i);
    sumB += B.at(i);
    if (A.at(i) > B.at(i)) P.push_back(A.at(i) - B.at(i));
    if (A.at(i) < B.at(i)) {
      ans++;
      lack += B.at(i) - A.at(i);
    }
  }
  if (sumA < sumB) { cout << -1 << endl; return 0; }
  if (ans == 0) { cout << 0 << endl; return 0; }
  sort(P.begin(), P.end(), greater<int>());
  vector<long long> S(P.size());
  for (int i = 0; i < S.size(); i++) {
    if (i == 0) {
      S.at(0) = P.at(0);
      continue;
    }
    S.at(i) = S.at(i-1);
    S.at(i) += P.at(i);
  }
  int index = lower_bound(S.begin(), S.end(), lack) - S.begin();
  ans += index + 1;
  cout << ans << endl;
}

Measured memory_bytes: 1788
from collections import Counter

s = input()
t = input()

sc = Counter(s)
tc = Counter(t)

if len(sc) != len(tc):
    print("No")
    exit()

S,T = [],[]
for s,t in zip(sc.values(),tc.values()):
    S.append(s)
    T.append(t)

S.sort()
T.sort()

if S == T:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4016
from collections import deque

def bfs(grid, sy, sx, wall):
    queue = deque([])
    queue.append([sy, sx, 0])
    visited = {}
    visited[(sy,sx)] = 0
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while queue:
        y,x,cnt = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall or (y_,x_) in visited:
                continue
            queue.append([y_,x_,cnt+1])
            visited[(y_,x_)] = cnt+1
    return max(visited.values())

h,w = map(int, input().split())
wall = '#'
edges = [wall] * (w+2)
grid = [edges]
for i in range(h):
    s = input()
    grid.append([wall] + list(s) + [wall])
grid.append(edges)

starts = []
dxy = [(1,0), (-1,0), (0,1), (0,-1)]
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x] == wall:
            continue
        cnt = 0
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall:
                cnt += 1
        if cnt > 1:
            starts.append((y,x))

ans = 0
for y,x in starts:
    tmp = bfs(grid, y, x, wall)
    if ans < tmp:
        ans = tmp
print(ans)


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;
int main() {
	int d[55];
	int x;
	int sum = 0;
	cin >> x;
	for (int i = 0; i < x; i++) {
		cin >> d[i];
		sum += d[i];
	}
	long long int ans = 0;
	for (int i = 0; i < x; i++) {
		ans += (sum - d[i]) * d[i];
	}
	cout << ans / 2;
}

Measured memory_bytes: 256
/**
 *    AUTHOR:    __SIGSEGV__                  
 *   CREATED:   12.08.2020 21:12:35  
**/

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int w = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') ++w;
  }
  int ans = 0;
  for (int i = n - w ; i < n; i++) {
    if (s[i] == 'R') {
      ++ans;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3704
// AtCoder Regular Contest 074
// E - RGB Sequence

#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;

const int MAX_N = 300;
const int MAX_M = 300;
const ll MOD = 1e9 + 7;

int N, M;
ll dp[MAX_N + 1][MAX_N + 1][MAX_N + 1];
vector<PII> rules[MAX_N + 1];

ll f(int a, int b, int c) {
  int pos = max(max(a, b), c);
  if (dp[a][b][c] != -1) {
    return dp[a][b][c];
  }
  vector<int> w = {a, b, c};
  sort(w.begin(), w.end());
  for (PII &rule: rules[pos]) {
    for (int i = 0; i < 3; i++) {
      if (rule.first <= w[i]) {
        if (rule.second != 3 - i) {
          dp[a][b][c] = 0;
          return 0;
        }
        break;
      }
    }
  }
  if (pos == N) {
    dp[a][b][c] = 1;
    return 1;
  }
  dp[a][b][c] = (f(pos + 1, b, c) + f(a, pos + 1, c) + f(a, b, pos + 1)) % MOD;
  return dp[a][b][c];
}

int main() {

  int l, r, x;

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> l >> r >> x;
    rules[r].push_back(PII(l, x));
  }
  memset(dp, -1, sizeof(dp));

  cout << f(0, 0, 0) << endl;

  return 0;

}




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

int main(void){
  int n, k;
  int* c;
  while( cin >> n >> k, n | k ){
    c = new int[n];
    for(int i=0; i < n; i++){
      cin >> c[i];
    }
    int prdmax = 0;
    for(int i=0; i < n - (k-1); i++){
      int prd = 1;
      for(int j=i; j < i+k; j++){
        prd *= c[j];
      }
      prdmax = max(prdmax, prd);
    }

    int ans = 0;
    for(int i=0; i < n; i++){
      for(int j=i+1; j < n; j++){
        swap(c[i], c[j]);
        int prdstd = 1;
        for(int t=0; t < n-(k-1); t++){
          int prdtmp = 1;
          for(int l=t; l < t+k; l++){
            prdtmp *= c[l];
          }
          prdstd = max(prdstd, prdtmp);
        }
        ans = max(ans, prdstd);
        swap(c[i], c[j]);
      }
    }

    if(prdmax > ans) cout << "NO GAME" << endl;
    else cout << ans - prdmax << endl;

  }
  return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<bitset> 
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i=0;i<M;++i) cin >> X[i];
    vector<int> diff(M-1);
    sort(X.begin(),X.end());
    for(int i=1;i<M;++i) diff[i-1] = X[i] - X[i-1];
    sort(diff.begin(),diff.end());
    long ans = 0;
    for(int i=0;i<M-N;++i) ans += diff[i]; 

    cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    ll a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
        cout << (a + b) / 2 << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[100];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = n - 1; i >= 0; i--) {
    if (i == 0) {
      cout << a[i] << endl;
    } else {
      cout << a[i] << " ";
    }
  }

  return 0;
}


Measured memory_bytes: 3092