akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static long[][] d;
	static long min=Long.MAX_VALUE;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    int M=gi();
	    int R=gi();
	    int[] rs=new int[R];
	    d=new long[N][N];
	    for (int i=0; i<N;i++) {
	    	for (int j=0; j<N;j++) {
	    		if(i==j) {
	    			d[i][j]=0;
	    		} else {
		    	    d[i][j]=Long.MAX_VALUE;
	    		}
		    }
	    }
	    for (int i=0; i<R;i++) {
	    	rs[i]=gi()-1;
	    }
	    for (int i=0; i<M;i++) {
	    	int a=gi()-1;
	    	int b=gi()-1;
	    	long c=gl();
	    	d[a][b]=c;
	    	d[b][a]=c;
	    }

	    for (int i=0; i<N; i++) {
	    	for (int j=0; j<N; j++) {
	    		for (int k=0; k<N; k++) {
	    			if (d[j][i]!=Long.MAX_VALUE && d[i][k]!=Long.MAX_VALUE) {
	    	    	    d[j][k]=Math.min(d[j][k], d[j][i]+d[i][k]);
	    			}
	    	    }
		    }
	    }

	    List l=new ArrayList<Integer>();
	    f(l,rs);
	    System.out.println(min);


        //System.out.println(ns);
	}

	public static void f(List<Integer> l, int[] rs) {
		if(l.size()==rs.length) {
			long k=0;
			for (int i=1; i<l.size();i++) {
				k+=d[l.get(i-1)][l.get(i)];
			}
			min=Math.min(min, k);
			return;
		}

		for (int i=0; i<rs.length;i++) {
			if(!l.contains(rs[i])) {
				List nl=new ArrayList<Integer>();
				nl.addAll(l);
				nl.add(rs[i]);
				f(nl,rs);
			}
		}
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 59916
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n = I()
G = [[] for _ in range(n)]
for k in range(n - 1):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]


def bfs(root):
    que = deque([root])
    dist = [INF] * n
    dist[root] = 0
    while que:
        u = que.popleft()
        for v in G[u]:
            if dist[u] + 1 < dist[v]:
                dist[v] = dist[u] + 1
                que += [v]
    return dist



def double_sweep():
    dist = bfs(0)
    ret = -1
    for u in range(n):
        if dist[u] > ret:
            ret = dist[u]
            v = u
    return max(bfs(v))



if (double_sweep() + 1) % 3 == 2:
    print('Second')
else:
    print('First')

Measured memory_bytes: 86092
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  ll max_v = 0;
  bool fail_flag = false;
  for (int i = 0; i < N - 1; i++) {
    if (H[i] - 1 <= H[i + 1] && max_v <= H[i + 1]) {
      max_v = max(max_v, H[i] - 1);
      continue;
    } else {
      fail_flag = true;
    }
  }

  string ans = "Yes";
  if (fail_flag) {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  
  if(a % 2 == 1 && b % 2 == 1){
    cout << "Odd" << endl;
  }
    
  else{
    cout << "Even" << endl;
  }
}


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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;
typedef pair<string, int> psi;

void print(vector<vector<psi>> &sl, int fst = 0, int depth = 0) {
    REP (i, 0, sl[fst].size()) {
        REP (j, 0, depth) cout << '.';
        cout << sl[fst][i].first << endl;
        print(sl, sl[fst][i].second, depth + 1);
    }
}

int main () {
    int n;
    cin >> n;
    vector<vector<psi>> slist(n + 1);
    REP (i, 0, n) {
        int k;
        string s;
        cin >> k >> s;
        slist[k].push_back({s, i + 1});
    }
    print(slist);
    return 0;
}

Measured memory_bytes: 3436
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s,w = map(int,input().split())
print("unsafe" if s <= w else "safe")

Measured memory_bytes: 9540
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int INF = 1000000000;
const int MOD = 1000000007;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

int D, G;
int c[MAXN], p[MAXN];

int main()
{
	
	cin >> D >> G;
	for (int i = 0; i < D; ++ i)
		cin >> p[i] >> c[i];
	int ans = INF;
	for (int s = 0; s < 1<<D; ++ s)
	{
		int sum = 0, cnt = 0;
		for (int i = 0; i < D; ++ i)
			if (s>>i&1)
			{
				sum += p[i]*100*(i+1)+c[i];
				cnt += p[i];
			}
		for (int i = D-1; i >= 0; -- i)
		{
			if (s>>i&1) continue;
			for (int j = 1; j <= p[i]; ++ j)
			{
				if (sum >= G) continue;
				sum += 100*(i+1);
				cnt ++;
			}
		}
		if (sum >= G) ans = min(ans, cnt);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main() {
	int n;
	scanf("%d",&n);
	int mid=n/100;
	int ans1=mid*111;
	int ans2=ans1+111;
	if(ans1>=n) cout<<ans1<<endl;
	else cout<<ans2<<endl;
	return 0; 
		
	}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		long[] dp = new long[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[0] - h[1]);
		for (int i = 2; i < n; i++) {
			dp[i] = dp[i - 1] + Math.abs(h[i - 1] - h[i]);
			for (int j = 2; j <= k; j++) {
				if (i - j < 0) break;
				dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i - j] - h[i]));
			}
		}
		
		System.out.println(dp[n - 1]);
		
		sc.close();
	}
}



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

int main() {
  long N, X, M;
  cin >> N >> X >> M;
  
  long ans = 0;
  vector<pair<long, long>> pre(M);

  for (long i = 0; i < N; i++) {
    auto [p_i, p_ans] = pre.at(X);
    if (!p_i) {
      pre.at(X) = {i, ans};
    } else {
      long len = i - p_i;
      long cnt = (N - i - 1) / len;
      i += len * cnt;
      ans += (ans - p_ans) * cnt;
    }
    ans += X;
    X = X * X % M;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define mx 1005
using namespace std;
typedef long long ll;
 vector<ll>prime;
 void sieve()
 {
     bool flag[mx];
     memset(flag,0,sizeof(flag));
     flag[1]=1;
     for(int i=4;i<=mx;i+=2)
    {
        flag[i]=1;
    }
     for(int i=3;i<=sqrt(mx);i+=2)
     {
         if(flag[i]==0)
         {
             for(int j=2*i;j<=mx;j+=i)
                flag[j]=1;
         }
     }
     for(int i=2;i<mx;i++)
     {
         if(flag[i]==0)
         {
             prime.push_back(i);
         }
     }
     //for(int i=0;i<10;++i)
        //cout<<prime[i]<<endl;
 }
ll NumOfDivisors(ll n)
 {
     ll sqrtn=sqrt(n);
     ll c=0,ans=1;
     for(int i=0;i<prime.size()&& prime[i]<=sqrtn;i++)
     {
         if(n%prime[i]==0)
         {c=0;
             while(n%prime[i]==0)
             {
                 n/=prime[i];
                 c++;
             }
             sqrtn=sqrt(n);
             ans*=(c+1);
         }
     }

     if(n!=1 )
     {
         ans*=2;
     }
     return ans;
 }
 int main()
{
    ll n;
    cin>>n;
    ll c,ans=0;
    sieve();
    ll x;
    for(int i=1; i<n; i++)
    {
        x=NumOfDivisors(n-i);
        ans+=x;
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3680
#include<iostream>

using namespace std;

int main() {
	int h1, m1, h2, m2, k, t;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	t = (60 * h2 + m2) - (60 * h1 + m1) - k;
	
	if (t <= 0) {
		t = 0;
		cout << t;
	}
	else {
		cout << t;
	}
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    while(K--){
        vec<l_l> v;
        rep(i,N){
            ll l = max(0LL, i - A[i]);
            ll r = min(N-1, i + A[i]);
            v.emplace_back(l,r);
        }
        vec<ll> I(N+1, 0);
        rep(i,N){
            I[v[i].first]++;
            I[v[i].second+1]--;
        }
        rep(i,N){
            I[i+1]+=I[i];
        }
        I.pop_back();
        //print(A);
        //print(I);
        bool fin = true;
        rep(i,N){
            if(I[i] != N)fin = false;
        }
        if(fin){
            rep(i,N){
                cout << I[i] << " ";
            }
            cout << endl;
            return 0;
        }
        swap(A, I);
    }
    rep(i,N){
        cout << A[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 12544
N=int(input())
a=list(map(int,input().split()))
odd = False
cnt=0
while True:
    for i in range(0,N):
        if a[i] % 2 != 0:
            odd=True
    if odd :
        break

    for i in range(0,N):
        a[i]/=2
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,m,iter[100005],dist[1100005],vis[100005];
vector<pair<int,int> > og[100005];
vector<int> st[1000005],g[1100005];
queue<int> q;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v,c;
		cin>>u>>v>>c;
		--u;
		--v;
		og[u].push_back(make_pair(c,v));
		og[v].push_back(make_pair(c,u));
		st[c].push_back(u);
		st[c].push_back(v);
	}
	for(int i=0;i<n;i++){
		sort(og[i].begin(),og[i].end());
	}
	int newn=n;
	for(int col=1;col<=1000000;col++){
		if(st[col].empty())continue;
		for(int i=0;i<st[col].size();i++){
			int u=st[col][i];
			if(vis[u]==col)continue;
			vector<int> cur;
			q.push(u);
			vis[u]=col;
			while(!q.empty()){
				int v=q.front();
				q.pop();
				cur.push_back(v);
				while(iter[v]<og[v].size()){
					int x=og[v][iter[v]].first;
					if(x!=col)break;
					int u=og[v][iter[v]].second;
					if(vis[u]!=col){
						vis[u]=col;
						q.push(og[v][iter[v]].second);
					}
					iter[v]++;
				}
			}
			for(int i=0;i<cur.size();i++){
				g[newn].push_back(cur[i]);
				g[cur[i]].push_back(newn);
			}
			newn++;
		}
	}
	setINF(dist);
	dist[0]=0;
	q.push(0);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=0;i<g[u].size();i++){
			int v=g[u][i];
			if(dist[v]<INF)continue;
			dist[v]=dist[u]+1;
			q.push(v);
		}
	}
	if(dist[n-1]==INF)cout<<"-1\n";
	else cout<<dist[n-1]/2<<endl;
	return 0;
}

Measured memory_bytes: 78464
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <string>
#include <climits>

using std::cin;
using std::cout;
using std::endl;
using std::max;
using std::min;
using std::sort;
using std::string;
using std::vector;

using ll = long long int;

#define rep(i,s,t)for(ll i = s;i <= t;i++)
#define rrep(i,s,t)for(ll i = s;i >= t;i--)

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

	ll res = 0;
	ll pmin = LLONG_MAX;
	rep(i, 0, n-1){
		ll p;
		cin >> p;
		if(pmin >= p){
			pmin = p;
			res++;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, m;
char a[50][51], b[50][51];

int is(int i, int j)
{
    for (int k = 0; k < m; ++k) {
        for (int l = 0; l < m; ++l) {
            if(a[i+k][j+l] != b[k][l]) {
                return 0;
            }
        }
    }
    return 1;
}

int main(int argc, char **argv)
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", a[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%s", b[i]);
    }

    for (int i = 0; i < n-m+1; ++i) {
        for (int j = 0; j < n-m+1; ++j) {
            if (is(i, j)) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<vector>

#define INF 1000000000

struct matrix {
	int row;
	int column;

};

using namespace std;

//leftはindexの添え字
int partprob_matchain(vector<vector<int>>& table, matrix* mat, int left, int right) {
	if (left == right) return 0;
	if (table.at(left).at(right) != 0) return table.at(left).at(right);
	int temp, min = INF;
	for (int i = left, j = left + 1; j <= right; i++, j++) {
		temp = partprob_matchain(table, mat, left, i);
		temp += partprob_matchain(table, mat, j, right);
		temp += mat[left].row * mat[i].column * mat[right].column;
		if (temp < min) min = temp;
	}
	table.at(left).at(right) = min;
	return min;
}


int matrix_chain(vector<vector<int>>& table, matrix* mat) {
	return partprob_matchain(table, mat, 0, table.at(0).size() - 1);
}


int main(void) {
	int size;
	cin >> size;
	matrix* mat = new matrix[size];
	vector<vector<int>> table(size, vector<int>(size));

	for (int i = 0; i < size; i++) cin >> mat[i].row >> mat[i].column;

	cout << matrix_chain(table, mat) << endl;
	delete[] mat;
	return 0;

}



Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <string>
#define ll long long; int
using namespace std;


int main(void) {
   int n, m, c;
   cin >> n >> m >> c;
   vector<vector<int>> a(n,vector<int> (m));
   vector<int> b(m);
   for(int i = 0; i < m; i++) {
       cin >> b.at(i);
   }
   for(int i = 0; i < n; i++) {
        for(int j = 0; j < m;  j++) {
            cin >> a.at(i).at(j);
        }
    }
int count = 0;
   int k = 0;
   for(int i = 0; i < n; i++) {
       for(int j = 0; j < m; j++) {
            k +=a.at(i).at(j) * b.at(j);
       }
       if(k + c > 0) {
           count++;
       }
       k = 0;
   }
   cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,d,i,j,cc=0;
    cin>>n>>d;
    vector<ll>ara[n];
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            ll x;cin>>x;
            ara[i].pb(x);
        }
    }
    for(i=0;i<n-1;i++){
        for(ll k=i+1;k<n;k++){
            ll x=0;
            for(j=0;j<d;j++){
                 x+=abs(ara[i][j]-ara[k][j])*abs(ara[i][j]-ara[k][j]);
            }
            ll y=sqrt(x);
            if(y*y==x)cc++;
        }

    }
    cout<<cc<<endl;
return 0;
}


Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> check(n+1, false);

    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        int x = -1;

        if(a == 1)
            x = b;
        else if(b == n)
            x = a;

        if(x != -1){
            if(check[x]){
                cout << "POSSIBLE" << endl;
                return 0;
            }
            check[x] = true;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int a[3];
    int k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a, a + 3);
    cout << a[0] + a[1] + a[2] * (1 << k) << endl;

    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
def main():
  n,m = map(int, input().split())
  
  uf = UnionFind(n)
  for i in range(m):
    tmp1, tmp2 = map(int,input().split())
    a = tmp1-1
    b = tmp2-1
    uf.union(a, b)
    
  print(uf.group_count() -1)
  
main()

Measured memory_bytes: 74272
def rot(xa,ya,xb,yb,xc,yc):
    r=(xb-xa)*(yc-ya)-(xc-xa)*(yb-ya)
    if r>0:return 1
    if r==0:return 0
    if r<0:return -1
while 1:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split(" "))
        if rot(x1,y1,x2,y2,xp,yp)==rot(x2,y2,x3,y3,xp,yp)==rot(x3,y3,x1,y1,xp,yp):
            print("YES")
        else:
            print("NO")
    except:break



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int N, K;
  cin >> N >> K;
  vector<int> okasi(N);
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int A;
      cin >> A;
      okasi[A-1]++;
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    if(okasi[i] == 0){
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	char A, B;
	cin >> A >> B;

	if (A == B) co("H");
	else co("D");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n)   FOR(i,0,n)
typedef pair< ll,ll > cp2;
typedef pair<ll,cp2 > cp3;
#define fi first
#define se second
#define sec se.fi
#define thr se.se
const ll mod = 1000000007;
//              123456789

int main(){
	int n;
	
	cin >> n;
	
	REP(i,n){
		int k, p;
		
		cin >> k >> p;
		
		int ans = k%p;
		
		if (ans == 0) ans = p;
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 1;
		while(ans * 2 <= n) {
			ans *= 2;
		}
		System.out.println(ans);
	}
}

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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string s; getline(cin, s);
    REP(i, s.length())
    {
        if('A' <= s[i] && s[i] <= 'Z') cout << (char)(s[i]-'A'+'a');
        else if('a' <= s[i] && s[i] <= 'z') cout << (char)(s[i]-'a'+'A');
        else cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 
 
 
 
int main() {
    int N;
    string S;
    cin >> N;
    if (N%2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    cin >> S;
    int cnt = 0;
    rep (i, N/2) {
        if (S[i]==S[N/2+i]) {
            cnt++;
            continue;
        } else {
            break;
        }
    }
    if (cnt == N/2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(){cout << -1 << '\n';}
const int INF = 1e18;

int f(int x){
    int p = 1;
    while(p <= x) p *= 2;
    return p - x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    V<> a(n);
    map<int,int> mp;
    REP(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(rall(a));
    int ans = 0;
    REP(i,n){
        if(!mp[a[i]]) continue;
        mp[a[i]]--;
        if(mp[f(a[i])]){
            ans++;
            mp[f(a[i])]--;
        }
    }
    cout << ans << '\n';
}

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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    int N, M;
    cin>>N>>M;

    cout<<((N-M)*100+M*1900) * (int)pow(2, M)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {

  int n, old, older, inp, ans = 0;
  cin >> n >> older >> old;
  for(int i = 2;i < n;i++){
    cin >> inp;
    if(older <= old && old <= inp){
      ans++;
    }else if(older >= old && old >= inp){
      ans++;
    }
    older = old;
    old = inp;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <vector>
#include <algorithm>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<unsigned long long int>;

// 基本的な演算
namespace BasicMath {
    // 分数の Ceil を求める関数
    static UInt Ceil(const UInt a, const UInt b);
    // 分数の Floor を求める関数
    static UInt Floor(const UInt a, const UInt b);

    // 分数の Ceil を求める関数
    UInt Ceil(const UInt a, const UInt b) {
        if (a % b == 0) {
            return a / b;
        } else {
            return a / b + 1;
        }
    }
    // 分数の Floor を求める関数
    UInt Floor(const UInt a, const UInt b) {
        return a / b;
    }
}
using namespace BasicMath;

int main(void) {
    int n;
    cin >> n;
    if (n == 0) {
        cout << '0' << endl;
    } else {
        vector<int> v;
        while (1) {
            //cout << "N = " << n << endl;
            if (n > 0) {
                v.push_back(n % 2);
                n = Floor(n, 2);
                n *= (-1);
                if (n == -1) {
                    break;
                }
            } else if (n < 0) {
                n *= (-1);
                v.push_back(n % 2);
                n = Ceil(n, 2);
                if (n == 1) {
                    break;
                }
            }
        }
        if (n == 1) {
            v.push_back(1);
        } else if (n == -1) {
            v.push_back(11);
        }
        for (Int i = v.size() - 1; i >= 0; --i) {
            cout << v[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import math

D = int(input())
c = list(map(int, input().split()))
S = []
for i in range(D):
    S.append(list(map(int, input().split())))

nocontest = [1 for i in range(26)]
count_nocontest = [3 for i in range(26)]
for i in range(D):
    s = S[i]
    contest = [0 for j in range(26)]
    for j in range(26):
        contest[j] = c[j] * nocontest[j] * s[j]
    #print(contest)
    max_contest = max(contest)
    ans = contest.index(max_contest)
    print(ans + 1)
    
    for j in range(26):
        if j == ans:
            nocontest[j] = 1
            count_nocontest[j] = 2
        else:
            nocontest[j] += count_nocontest[j]
            count_nocontest[j] += 1
    #print(nocontest)

Measured memory_bytes: 9472
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		while(H!=0&&W!=0){
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						System.out.print(".");
					}else{
						System.out.print("#");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
}

Measured memory_bytes: 25732
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var (h, w, _, xs) = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToArray();
            decimal ans;

            if ((h == 1) || (w == 1)) {
                ans = 1;
            }
            else if ((h % 2 == 0) || (w % 2 == 0)) {
                // 偶数
                ans = w * h / 2;
            }
            else {
                // 奇数
                ans = Math.Floor(w * h / 2) + 1;
            }

            Console.WriteLine(ans);
        }
    }
    public static class ArrayDeconstruct {
        public static void Deconstruct<T>(this T[] source, out T d1, out T d2, out T d3, out T[] rest) {
            const int maxLen = 3;
            var len = source.Length;

            d1 = default;
            d2 = default;
            d3 = default;

            if (len > 0) d1 = source[0];
            if (len > 1) d2 = source[1];
            if (len > 2) d3 = source[2];

            rest = source.Skip(maxLen).ToArray();
        }
    }
}


Measured memory_bytes: 28288
#include<bits/stdc++.h>
using namespace std;
/*
c++ の / はデフォルトで切り捨て
*/

int main(){
    int a, b, x;
    cin >> a >> b;
    x = ((a+b) + (2-1))/2 ;//(i + (j-1)) / j ってかくと，切り上げ
    cout << x << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, R: int, S: int, P: int, T: str):

    T = [int(t_) for t_ in T.replace("r","0").replace("s","1").replace("p","2")]
    # win = (h-1) % 3
    r = 0
    s = 1
    p = 2 
    PS = (R,S,P)
    pt = 0
    for k in range(K):
        pre_ = 3
        for c_ind in range(k, len(T), K):
            c_ = T[c_ind]
            if c_ != pre_:
                pt +=  PS[(c_-1)%3]
                pre_ = c_
            else:
                pre_ = 3
    print(pt)



    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    T = next(tokens)  # type: str
    solve(N, K, R, S, P, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4376
// package arc.arc085;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int m = in.nextInt();
        long time = m * 1900 + (n - m) * 100;

        out.println(time * (1<<m));
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

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

        private int next() {
            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 char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

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

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

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

Measured memory_bytes: 21844
w, h, n = gets.chomp.split.map(&:to_i)
data = n.times.map { gets.chomp.split.map(&:to_i) }

cell = Array.new(w).map { Array.new(h, 0) }

data.each do |el|
    # binding.pry
  case el[2]
  when 1
    (0...el[0]).each do |x|
        (0...h).each do |y|
            cell[x][y] = 1
        end
    end
  when 2
    (el[0]...w).each do |x|
        (0...h).each do |y|
            cell[x][y] = 1
        end
    end
  when 3
    (0...w).each do |x|
        (0...el[1]).each do |y|
            cell[x][y] = 1
        end
    end
  when 4
    (0...w).each do |x|
        (el[1]...h).each do |y|
            cell[x][y] = 1
        end
    end
  end
end

puts cell.flatten.count{|el| el == 0}


Measured memory_bytes: 1916
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 2 "d.cpp"

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  vl cnt(n+1);
  vl b(n+1);

  rep(i, n) {
    cnt[a[i]]++;
  }

  ll sum = 0;
  rep(i, n+1) {
    if (cnt[i] >= 2) {
      b[i] = cnt[i] * (cnt[i]-1) / 2;
    }
    sum += b[i];
  }

  rep(i, n) {
    ll t = sum - b[a[i]];
    cout << t + (cnt[a[i]]-1) * (cnt[a[i]]-2) / 2 << el;
  }

  cout << flush;
}


Measured memory_bytes: 7296
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

ll d_s(ll x){
    ll res=0;
    while(x){
        res+=x%10;
        x/=10;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll K;
    cin >> K;
    ll t=1,ans=0;
    rep(i,K){
        while((ans+t*10)*d_s(ans+t)<(ans+t)*d_s(ans+t*10))t*=10;
        ans+=t;
        cout << ans << endl;
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 3480
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 200005
#include <bits/stdc++.h>
using namespace std;

vector<string> s;
string t;
int dp[105][105];

int main() {
    int n, m;
    cin >> n >> m;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            dp[i][j] = 1e8;
        }
    }
    for(int i=1;i<=n;i++){
        cin >> t;
        t+= '?';
        s.pb(t);
    }
    t = "";
    for(int i=0;i<=m;i++)  t+= '?';
    s.pb(t);
    if(s[0][0] == '.') dp[0][0] = 0;
    else dp[0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            //cout << i << " "<< j << endl;
            if(s[i][j] == '.' && s[i][j+1] == '#'){
                dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1);
            }
            else{
                dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
            }
            if(s[i][j] == '.' && s[i+1][j] == '#'){
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1);
            }
            else{
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            }
        }
    }
    cout << dp[n-1][m-1] << endl;

    return 0;
}


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

using namespace std;

#define ll long long
stack<ll> sta[1005];

int main() {
    int n, q, a, t, x;
    cin >> n >> q;
    while (q--) {
        cin >> a;
        if (a == 0) {
            cin >> t >> x;
            sta[t].push(x);
        } else if (a == 1) {
            cin >> t;
            if (!sta[t].empty())
                cout << sta[t].top() << endl;
        } else if (a == 2) {
            cin >> t;
            if (!sta[t].empty())
                sta[t].pop();
        }
    }

    return 0;
}


Measured memory_bytes: 4956
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b+1>=c) {
        cout<<b+c<<endl;
    }else{
        cout<<a+2*b+1<<endl;
    }
    return 0;
}

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

int main() {
  int N,l,r,a;
  cin >> N;
  a = 0;
  // ここにプログラムを追記
  rep(i,N) {
    cin >> l >> r;
      a += r - l + 1;
  }
  
    cout << a << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=2000010,mod=1e9+7;
int n,A,B,C,ans,fac[N],inv[N];

int ksm(int a,int b){
	int res=1;
	for (; b; a=1ll*a*a%mod,b>>=1)
		if (b & 1) res=1ll*res*a%mod;
	return res;
}

int cc(int n,int m){ return n<m ? 0 : 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod; }

int main(){
	scanf("%d%d%d%d",&n,&A,&B,&C); int ii=ksm(100,mod-2);
	A=1ll*A*ii%mod; B=1ll*B*ii%mod; C=1ll*C*ii%mod;
	int a=1ll*ksm(A+B,mod-2)*A%mod,b=1ll*ksm(A+B,mod-2)*B%mod;
	fac[0]=1; rep(i,1,n+n) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n+n]=ksm(fac[n+n],mod-2); for (int i=n+n; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	rep(i,0,n-1){
		ans=(ans+1ll*ksm(b,i)*ksm(a,n)%mod*cc(n-1+i,i)%mod*ksm(1-C+mod,mod-2)%mod*(n+i))%mod;
		ans=(ans+1ll*ksm(a,i)*ksm(b,n)%mod*cc(n-1+i,i)%mod*ksm(1-C+mod,mod-2)%mod*(n+i))%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}

void Main()
{
	ll N;
	ll result=0;
	string S;
	cin>>N;
	VI A(N);
	REP(i, N) cin >> A[i];

	result= GCD(A);
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 1792
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


m1, d1 = LI()
m2, d2 = LI()

if m1 == m2:
    ans = 0
    print(ans)
else:
    ans = 1
    print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int n;
    int ans=0;
    int a[20],b[20],c[20];

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

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	const xmas = 25
	d := readInt()
	
	fmt.Println("Christmas" + strings.Repeat(" Eve", xmas - d))
}

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

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
type Vect = (Double, Double)
line :: Vect -> Vect -> Vect
line (x,y) (a,b) = (x-a, y-b)

threshold :: Double
threshold = 0.0000001

isParallel :: Vect -> Vect -> Bool
isParallel (0,_) (u1,_) = u1 == 0
isParallel (u0,_) (0,_) = u0 == 0
isParallel (u0,v0) (u1,v1) = let
    d0 = v0/u0
    d1 = v1/u1
    in
        abs (d0 - d1) < threshold

main = getContents >>=
        mapM_ (putStrLn . (\b -> if b then "YES" else "NO")
                    . uncurry isParallel
                    . (\[ax,ay,bx,by,cx,cy,dx,dy] ->
                            (line (ax,ay) (bx,by), line (cx,cy) (dx,dy)))
                    . map read . words) . tail . lines

Measured memory_bytes: 4316