akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<ctime>
#include<iomanip>
#include<map>
#define F first
#define S second

using namespace std;
int n,ans;

int main(){
  while(cin >> n && n){
    //clock_t st,ed;
    //st = clock();
    int dp[n+1][31];
    vector<int> day[31];
    vector<int> person[n+1];
    int daymax =0;
    for(int i=0;i<=n;i++)for(int j=0;j<=30;j++)dp[i][j] = false;
    for(int i=1;i<=n;i++){
      int re;
      cin >> re;
      for(int j=0;j<re;j++){
	int in;
	cin >> in;
	daymax = max(daymax,in);
	day[in].push_back(i);
	dp[i][in] = true;
      }
    }

    for(int i=1;i<=30;i++){
      map<int,bool> today;
      for(int j=1;j<=n;j++){
	if(!dp[j][i])continue;
	for(int k=0;k<day[i].size();k++)person[j].push_back(day[i][k]);
	sort(person[j].begin(),person[j].end());
	person[j].erase(unique(person[j].begin(),person[j].end()),person[j].end());
	for(int k=0;k<person[j].size();k++)today[person[j][k]] = true;
      }

      map<int,bool>::iterator it = today.begin();
      while(it != today.end()){
	for(int j=1;j<=n;j++){
	  if(!dp[j][i])continue;
	  person[j].push_back((*it).F); 
	}
	for(int j=1;j<=n;j++){
	  if(!dp[j][i])continue;
	sort(person[j].begin(),person[j].end());
	person[j].erase(unique(person[j].begin(),person[j].end()),person[j].end());
	}
	it++;
      }
      bool fin = false;
      for(int j=1;j<=n;j++){   
	if(!dp[j][i])continue;
	int sum = 0;
	for(int k=0;k<person[j].size();k++){ 
	  sum += person[j][k];
	}
	if(sum == (n*(n+1))/2){
	  fin = true;	
	  cout << i << endl;
	  break;
	}
      }
      if(fin)break;
      if(i >= daymax && !fin){
	cout << -1 << endl;
	break;
      }

    }

    //ed = clock();
    //cout << setiosflags(ios::fixed) << setprecision(10) <<  (double)(ed-st)/CLOCKS_PER_SEC << endl;

  }
  return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;

	int cnt = 0;
	bool h = false;
	for(int i = 0;i < n;i++){
		int d_1, d_2;
		cin >> d_1 >> d_2;
		if (d_1 == d_2)
			cnt++;
		else
			cnt = 0;

		if (cnt == 3)
			h = true;
	}

	if (h)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
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 a
from collections import Counter
n=int(input())
p=Counter()
for i in range(1,n+1):
    p.update(Counter(prime_factorize(i)))
#print(p)
ans=1
for i in p.values():
    ans*=i+1
    ans%=10**9+7
print(ans)


Measured memory_bytes: 42480
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main()
{
    int n;
    long long d = 0;
    int c = 0;
    cin >> n >> d;
    d = d * d;
    for (int i = 0; i < n; i++)
    {
        long long x, y;
        cin >> x >> y;
        if (x * x + y * y <= d) c++;
    }
    cout << c << '\n';
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;


int main() {

	int x, n;
	int min = 1000;
	int ans = 0;
	cin >> x >> n;

	vector<int> p(n);
	bool f = true;

	rep(i, n) {
		cin >> p[i];
		if (p[i] == x) {
			f = false;
		}
	}

	if (f == true) {
		cout << x << endl;
		return 0;
	}

	rep(xx, 102) {
		int a = 1;
		rep(i, n) {

			if (p[i] == xx) {
				a = 0;
			}

		}
		if (a == 1) {
			int z = fabs(x - xx);
			if (min > z) {
				ans = xx;
				min = z;
			}
		}

	}

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

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, N; cin >> D >> N;
    int x = 0;
    for(int i = 1;; i++){
        int cnt = 0;
        int val = i;
        while(val % 100 == 0){
            val/=100;
            cnt++;
        }
        if(cnt == D) x++;
        if(x == N){
            cout << i << endl;
            break;
        } 
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    double l; cin >> l;
    double a = (l / 3.0) * (l / 3.0) * (l / 3.0);
    printf("%.10lf\n", a);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(T: "List[int]", A: "List[int]", B: "List[int]"):

    if A[0] < B[0]:
        A, B = B, A

    if A[1] > B[1]:
        print(0)
        return
    elif A[0]*T[0]+A[1]*T[1] > B[0]*T[0]+B[1]*T[1]:
        print(0)
        return
    elif A[0]*T[0]+A[1]*T[1] == B[0]*T[0]+B[1]*T[1]:
        print("infinity")
        return

    K = (B[0]*T[0]+B[1]*T[1])-(A[0]*T[0]+A[1]*T[1])
    L = (A[0]-B[0])*T[0] // K
    if (B[0]-A[0])*T[0] % K == 0:
        print(2*L)
    else:
        print(2*L+1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = [int(next(tokens)) for _ in range(2)]  # type: "List[int]"
    A = [int(next(tokens)) for _ in range(2)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(2)]  # type: "List[int]"
    solve(T, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

    int ans = 0;
    for (int i=0; i<n; ++i) {
        for (int j=i+1; j<n; ++j) {
            for (int k=j+1; k<n; ++k) {
                if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
                    if(l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]) {
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  
  vector<int> v(N);
  for(int i=0;i<N;++i){
    cin>>v[i];
  }
  
  // バケット法
  int b_odd[100000]={0};
  int b_even[100000]={0};
  
  for(int i=0;i<N;i=i+2){
    ++b_odd[v[i]];
  }
  
  for(int i=1;i<N;i=i+2){
    ++b_even[v[i]];
  }
  
  // 奇数列の最大と２番目を探索
  int odd1=0, odd2=0;  // インデックス
  int odd_max=0, odd_second=0;  // 個数
  
  for(int i=1;i<=100000;++i){
    if(odd_second<b_odd[i]){
      if(odd_max<b_odd[i]){
        odd2=odd1;
        odd1=i;
        odd_second=odd_max;
        odd_max=b_odd[i];
      }
      else{
        odd2=i;
        odd_second=b_odd[i];
      }
    }
  }
  
  // 偶数列の最大と２番目を探索
  int even1=0, even2=0;
  int even_max=0, even_second=0;
  
  for(int i=1;i<=100000;++i){
    if(even_second<b_even[i]){
      if(even_max<b_even[i]){
        even2=even1;
        even1=i;
        even_second=even_max;
        even_max=b_even[i];
      }
      else{
        even2=i;
        even_second=b_even[i];
      }
    }
  }
   
  if(odd1!=even1){
    cout<<N-odd_max-even_max;
  }
  else if(odd1==even1){
    
    if(odd_second==0 && even_second==0)
      cout<<even_max<<endl;
    
    else if(odd_second==0)
      cout<<N/2-even_second<<endl;
    
    else if(even_second==0)
      cout<<N/2-odd_second<<endl;
    
    else if(odd_max==odd_second || even_max==even_second)
      cout<<N-odd_max-even_max<<endl;
    
    else if(odd_second>=even_second)
      cout<<N-odd_second-even_max<<endl;
    
    else if(odd_second<even_second)
      cout<<N-odd_max-even_second<<endl;
      
  }
  
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>

using namespace std;

const int MAX_N = 1e5 + 10;

int N, fl, ans;

int col[MAX_N];

int cap;
int head[MAX_N], to[MAX_N], nxt[MAX_N];

queue<int> que;

inline int Abs(int x) { return x < 0 ? -x : x; }

void BFS(int x) {
	memset(col, 0, sizeof col);
	col[x] = 1;
	
	que.push(x);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		ans = max(ans, col[u]);
		for (int i = head[u]; i; i = nxt[i]) {
			if (!col[to[i]]) {
				col[to[i]] = col[u] + 1;
				que.push(to[i]);
			} else if (Abs(col[to[i]] - col[u]) != 1) fl = 1;
		}
		if (fl)  break;
	}
}

inline void add(int x, int y) { to[++cap] = y, nxt[cap] = head[x], head[x] = cap; }

int main() {
	
	scanf("%d", &N);
	
	int x;
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) {
			scanf("%1d", &x);
			if (x)  add(i, j), add(j, i);	
		}
	}
	
	for (int i = 1; i <= N; ++i) {
		BFS(i);	
		if (fl)  return puts("-1"), 0;
	}
	
	printf("%d\n", ans);
	
	return 0;	
}

Measured memory_bytes: 1280
//11-A

/*
 * AOL??????????????¬???????????????????????????????????°??????1-6???0-5??????????????????
 * ????????§????????????????????????????????????
 * 
 * ?????????????????????????????????????????????????????????????????????????????????????¢?????????????
 * 
 * ??????????????????????????\?????§?????£????????????????????¨?????????????????????
 * 
 */

import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	
    	Scanner sc = new Scanner(System.in);
    	
    	int Answer = 0;
    	String strnum = sc.nextLine();
    	String houkou = sc.nextLine();
    	
    	Dice dice = new Dice(strnum);
    	
    	for( int i = 0 ; i < houkou.length() ; i++ ){
    		
    		if( houkou.charAt(i) == 'E'){
    			Answer = dice.getE();
    		}
    		if( houkou.charAt(i) == 'N'){
    			Answer = dice.getN();
    		}
    		if( houkou.charAt(i) == 'S'){
    			Answer = dice.getS();
    		}
    		if( houkou.charAt(i) == 'W'){
    			Answer = dice.getW();
    		}
    	}
    	
    	System.out.println(Answer);
    	
    }
}

class Dice{
	
	int[] dice = new int[6];
	String[] me;
	int kari = 0;
	
	
	
	
	
	public Dice(String strnum){
		
		me = strnum.split(" ");
		
		for(int i = 0 ; i < me.length ; i++ ){
			dice[i] = Integer.parseInt(me[i]);
		}
		
	}
	
	
	
	
	
	public int getE(){
		kari = dice[0];
        dice[0] = dice[3] ;
        dice[3] = dice[5] ;
        dice[5] = dice[2];
        dice[2] = kari;
        return dice[0];
	}
	
	public int getN(){
		kari = dice[0];
        dice[0] = dice[1] ;
        dice[1] = dice[5] ;
        dice[5] = dice[4];
        dice[4] = kari;
        return dice[0];
	}
	public int getS(){
		 kari = dice[0];
	     dice[0] = dice[4] ;
	     dice[4] = dice[5] ;
	     dice[5] = dice[1];
	     dice[1] = kari;
	     return dice[0];
	}
	public int getW(){
		 kari = dice[0];
	     dice[0] = dice[2] ;
	     dice[2] = dice[5] ;
	     dice[5] = dice[3];
	     dice[3] = kari;
	     return dice[0];
	}
	
}

Measured memory_bytes: 26280
#include <iostream>
#include <queue>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	int N, M;
	cin >> N >> M;
	
	priority_queue<ull> A;
	ull a;
	
	for(uint i=0; i<N; i++) {
		cin >> a;
		A.push(a);
	}
	
	for(uint i=0; i<M; i++) {
		ull na = A.top() / 2;
		A.pop();
		A.push(na);
	}
	
	ull ans = 0;
	for(uint i=0; i<N; i++) {
		ans += A.top();
		A.pop();
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 1400
library = """
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "atcoder":
    cdef cppclass fenwick_tree[T]:
        fenwick_tree()
        fenwick_tree(int n)
        void add(int p, T x)
        T sum(int l, int r)
cdef class DSU:
    cdef dsu *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new dsu(n)
    def __dealloc__(self):
        del self._thisptr
    cpdef int merge(self, int a, int b):
        return self._thisptr.merge(a, b)
    cpdef bool same(self, int a, int b):
        return self._thisptr.same(a, b)
    cpdef int leader(self, int a):
        return self._thisptr.leader(a)
    cpdef int size(self, int a):
        return self._thisptr.size(a)
cdef class BIT:
    cdef fenwick_tree[long] *_thisptr
    def __cinit__(self, int n = 0):
        if n == 0:
            self._thisptr = new fenwick_tree[long]()
        else:
            self._thisptr = new fenwick_tree[long](n)  
    def __dealloc__(self):
        del self._thisptr
    cpdef void add(self, int p, long x):
        self._thisptr.add(p, x)
    cpdef long sum(self, int l, int r):
        return self._thisptr.sum(l, r)
"""
import os,sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('atcoder.pyx','w').write(library)
    os.system('cythonize -i -3 -b atcoder.pyx')
 
# ↑ここまでライブラリ↓ここから解法
 
import sys
import atcoder
input = sys.stdin.buffer.readline
n, q = map(int, input().split())
dummy = atcoder.BIT()
bit = atcoder.BIT(n)
*map(bit.add, range(n), map(int, input().split())),
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t: res.append(bit.sum(u, v))
    else: bit.add(u, v)
print('\n'.join(map(str, res)))

Measured memory_bytes: 49868
S = input()
N = len(S)

if S == S[::-1]:
  Sfor = S[:int((N-1)/2)]
  if Sfor == Sfor[::-1]:
    Slat = S[int((N+1)/2):]
    if Slat == Slat[::-1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")   
else:
  print("No")

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

#define pb push_back
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

int const N = 1e5 + 7;
int dp[N][3] = {};
int ar[N][3];

int main()
{
	fastio;

	int n;
	cin >> n;

	for (int i = 1; i <= n; ++i)
		cin >> ar[i][0] >> ar[i][1] >> ar[i][2];

	dp[1][0] = ar[1][0];
	dp[1][1] = ar[1][1];
	dp[1][2] = ar[1][2];

	for (int i = 2; i <= n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
			{
				if (j != k)
					dp[i][j] = max(dp[i][j], dp[i-1][k] + ar[i][j]);
			}
		}
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';
	return 0;
}


Measured memory_bytes: 5904
package main

import (
	"fmt"
)

func main() {
	var H, N int64
	fmt.Scan(&H, &N)
	var i int64
	for i = 0; i < N; i++ {
		var a int64
		fmt.Scan(&a)
		H -= a
	}
	if H <= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 6304
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string s1, s2;
    cin >> N;
    if(N == 1) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n,r;
	while(scanf("%d %d",&n,&r),n) {
		vector<int> v;
		for(int i=0;i<n;i++) {
			v.push_back(n-i);
		}
		for(int i=0;i<r;i++) {
			int p,c;
			scanf("%d %d",&p,&c);
			vector<int> a,b;
			for(int j=0;j+1<p;j++) {
				int e=v.front();v.erase(v.begin());
				a.push_back(e);
			}
			for(int j=0;j<c;j++) {
				int e=v.front();v.erase(v.begin());
				b.push_back(e);
			}
			for(int j=p-2;j>=0;j--) {
				v.insert(v.begin(),a[j]);
			}
			for(int j=c-1;j>=0;j--) {
				v.insert(v.begin(),b[j]);
			}
		}
		printf("%d\n",v[0]);
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

i64 dp[51][51][2501];

void solve() {
  dp[0][0][0] = 1;
  int N, A; cin >> N >> A;
  vi32 x(N); cin >> x;
  rep(i, N) rep(j, N) rep(k, 2501) {
    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
    dp[i + 1][j][k] += dp[i][j][k];
  }
  i64 ans = 0;
  reps(j, N) rep(k, 2501) {
    if (j * A == k) ans += dp[N][j][k];
  }
  cout << ans << '\n';
}


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

int main(){
    //the thing is to never rush and play it patience
    int a[2];
    cin>>a[0]>>a[1];
    sort(a,a+2);
    if(a[1]==3){
        if(a[0]%2==0)cout<<"No";
        else cout<<"Yes";
    }else if(a[1]==1)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#061-D
#v,Eは、頂点(vertex),辺(edge)の数
v,E=map(int,input().split())
e=[]
for i in range(E): #eの各要素は[始点,終点,コスト]
    f,t,c=map(int,input().split())
    e.append([f-1,t-1,c])
d=[None for i in range(v)]
for i in range(v):
    d[i]=-float('INF')
d[0]=0
for i in range(v-1):
    update=False
    for i in range(E):
        if d[e[i][0]]!=-float('INF') and d[e[i][1]]<d[e[i][0]]+e[i][2]:
            d[e[i][1]]=d[e[i][0]]+e[i][2]
            update=True
    if not update:
        break
ans=d[v-1]
for i in range(E):
    if d[e[i][0]]!=-float('INF') and d[e[i][1]]<d[e[i][0]]+e[i][2]:
        d[e[i][1]]=d[e[i][0]]+e[i][2]
print(ans if ans==d[v-1] else 'inf')

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <array>
using namespace std;

int main() {
	long N,K;
	cin >> N >> K;
	long cnt1=0,cnt2=0;
	for (long i=1; i<=N; i++) {
		if (K%2==0){
			if (i%K==0) cnt1++;
			else if (i%K==K/2) cnt2++;
		} else {
			if (i%K==0) cnt1++;
		}
	}
	cout << cnt1*cnt1*cnt1+cnt2*cnt2*cnt2 << endl;
	return 0;
}


Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing1.cpp
time :Sun Jan 19 14:54:36 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	if(N==M)cout<<"Yes \n";
	else cout<<"No \n";

	return 0;
}


Measured memory_bytes: 256
# 初期入力 2020-0730-2150
from bisect import bisect_left
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())
x = list(map(int, input().split()))
x_shift =[i +abs(x[0]) for i in x]
bis_0 =bisect_left(x,0)
 
d_end =[0]*(N-K+1)
d_left =0
d_right =0
dist =[]
for i in range(N-K+1):
    d_end =x_shift[i+K-1] -x_shift[i] #ローソクK本の内、端と端の距離
    d_left =abs(x[i])
    d_right =abs(x[i+K-1])
    dist.append(d_end +min(d_left,d_right))
print(min(dist))

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,a[100000],cnt=0,ans=0,b=1000000000;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(a[i]<0) {
      a[i]=abs(a[i]);
      cnt++;
    }
    b=min(b,a[i]);
    ans+=a[i];
  }
  if(cnt%2==1) {
    ans-=b*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

// えびちゃんの make_vector (ここから)
template <typename Tp, size_t N>
std::vector<Tp> make_vector_detail(std::vector<size_t>& sizes, typename std::enable_if<(N == 1), const Tp&>::type x) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector_detail(std::vector<size_t>& sizes, typename std::enable_if<(N > 1), const Tp&>::type x) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector_detail<Tp, N-1>(sizes, x))>(size, make_vector_detail<Tp, N-1>(sizes, x));
}

template <typename Tp, size_t N>
auto make_vector(const size_t(&sizes)[N], const Tp& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return make_vector_detail<Tp, N>(s, x);
}
// えびちゃんの make_vector (ここまで)

signed main(){
    
    int a, b; cin >> a >> b;
    cout << (3 * a + b) / 2 << endl;    
    return 0;
}


Measured memory_bytes: 256
/*
Owner: dxxrk
Problem: Simple Calculator
Date: 22/11/2019
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	long long x, y; cin >> x >> y;
	
	long long ans = INF;
	if(y - x >= 0){
		ans = min(ans, y - x);
	}
	if(y + x >= 0){
		ans = min(ans, y + x + 1);
	}
	if(-y - x >= 0){
		ans = min(ans, -y - x + 1);
	}
	if(-y + x >= 0){
		ans = min(ans, -y + x + 2);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[100010];
int cnt, ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		if (a[i - 1] >= a[i])cnt++;
		else {
			ans = max(cnt, ans);
			cnt = 0;
		}
	}
	cout << max(ans, cnt) << endl;
}

Measured memory_bytes: 1024
//To include everything you need
#include <bits/stdc++.h>
using namespace std;
typedef std::vector<int>  vi;
typedef std::vector<std::pair<int,int> > vpi;
typedef std::vector<string>  vs;
typedef std::vector<char>  vc;


int main(){

     string x;
    cin>>x;
    
    int counter = 0;
    int removed = 0;
    for(int i =0;i<x.length();i++){
        if(x[i] == 'S')
            counter++;
        else if(x[i] == 'T'){
            if(counter>0)
            {
                counter--;
                removed+=2;
            }
        }    
    }
    cout<<x.length()-removed;
        
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int N;
inline void g(int &x) 
{ 
    char ch=getchar(); bool mark=false; 
    for(;!isdigit(ch);ch=getchar())if(ch=='-')mark=true; 
    for(x=0;isdigit(ch);ch=getchar())x=x*10+ch-'0'; 
    if(mark)x=-x; 
} 
int main()
{
	g(N);
	printf("ABC");
	printf("%d",N);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	cin >> h;
	ll p = log2(h);
	ll ptr = 1;
	rep(i, p) {
		ptr *= 2;
	}
	ll res = ptr * 2;
	res--;
	cout << res << endl;
}



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

using namespace std;
int main() {
  string s;
  cin >> s;
  map<char, int> use;

  for (int i = 0; i < 4; i++) {
    if (use.count(s[i])) {
      use[s[i]] += 1;
    } else {
      use[s[i]] = 1;
    }
  }

  bool check = true;
  for (auto i = use.begin(); i != use.end(); ++i) {
    if (i->second != 2) check = false;
  }
  cout << (check ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
import math

H,W = map(int, input().split()) 

def func(h,w,ans):
    for i in range(1,h+1):

        if((h-i) % 2 == 0): 
            a = i*w
            b = ( (h-i)//2 )*w
            s = abs(a-b)
            ans = min(s,ans)
    
        else:
            a = i * w 
            w1 = w//2 
            b = (h-i)*w1
            c = (h-i)*(w-w1)
            M = max(a,b,c)
            m = min(a,b,c)
            s = M-m
            ans = min(s,ans)
    return ans

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

ans = float('inf')

ans = func(H,W,ans)
ans = func(W,H,ans)

print(ans)

Measured memory_bytes: 3064
n=int(input())
# m=[list(map(int,input().split()))for _ in[0]*n]
m = [[-1 for i in range(n)] for j in range(n)]
for i in range(n): #隣接の辺のコストを入力
  nums = list(map(int, input().split()))
  for j in range(n):
    m[i][j] = nums[j]

d=[0]+[10**9]*n
b=[1]*n
a=0
while 1:
  u=-1
  for i in range(n):
    if b[i] and (u<0 or d[i]<d[u]):
      u=i
  if u<0:
    break
  b[u]=0
  a+=d[u]
  for v in range(n):
    t=m[u][v]
    if t+1 and d[v]>t:
      d[v]=t
print(a)




Measured memory_bytes: 5772
def find(n, N, E, visited):
    visited = visited | {n}
    if len(visited) == N:
        return 1
    cnt = 0
    for e in E[n]:
        if e not in visited:
            cnt += find(e, N, E, visited)
    return cnt

N, M = [int(x) for x in input().split()]
E = {}

for i in range(M):
    x, y = [int(x) for x in input().split()]
    E[x] = E.get(x, set()) | {y}
    E[y] = E.get(y, set()) | {x}

print(find(1, N, E, {1}))




Measured memory_bytes: 3064
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;


int main()
{
	migmig ;
  int n , m ; 
  cin>>n>>m ; 
  if(m == n) cout<<"Yes" ; 
  else cout<<"No" ; 

}
//////
////////
///////////




Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn permutation(pos: usize, n: usize, used: &mut [bool], perm: &mut [usize], dp: &[Vec<usize>], rs: &[usize]) -> usize {
    if pos == n {
        let mut cost = 0;
        for i in 0..n-1 {
            let a = perm[i];
            let b = perm[i+1];
            cost += dp[rs[a]][rs[b]];
        }
        return cost;
    }

    let mut cost = 1 << 32;
    for i in 0..n as usize {
        if used[i] == false {
            used[i] = true;
            perm[pos as usize] = i as usize;
            cost = min(cost, permutation(pos + 1, n, used, perm, dp, rs));
            used[i] = false;
        }
    }
    cost
}

fn main() {
    input!{
      n: usize,
      m: usize,
      r: usize,
      rs: [usize; r],
      abcs: [(usize, usize, usize); m],
    }
    const INF: usize = 1 << 32;

    let mut dp = vec![vec![INF; n+1]; n+1];
    for &(a, b, c) in &abcs {
        dp[a][b] = c;
        dp[b][a] = c;
    }
    for k in 0..n+1 {
        for i in 0..n+1 {
            for j in 0..n+1 {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    // debug!(dp);

    let mut used = vec![false; r];
    let mut perm = vec![0; r];
    let ans = permutation(0, r, &mut used, &mut perm, &dp, &rs);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll N,X,A[MAXN],dp[202][MAXN];
const ll MOD = 1e9+7;
int main()
{
	FAST
	cin>>N>>X;
	for(ll i=1;i<=N;i++) cin>>A[i];
	sort(A+1,A+N+1,greater<ll>());
	dp[0][X]=1;
	for(ll i=1;i<=N;i++){
		for(ll j=0;j<=1e5;j++) {
			dp[i][j%A[i]]  += dp[i-1][j]; dp[i][j%A[i]] %= MOD;
			dp[i][j] += (dp[i-1][j] * (N - i))%MOD;
			dp[i][j] %= MOD;
		}
	}
	ll ans = 0;
	for(ll i = 1; i <= 1e5; i++) { ans += (dp[N][i] * i)%MOD; ans %= MOD; }
	cout<<ans<<'\n';
}


Measured memory_bytes: 471296
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	string s=to_string(a);
	string d=to_string(b);
	string e=s+d;
	int q=stoi(e);
	int c=sqrt(q);
	if(c*c==q){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
template<class T>
void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>
void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vi a(n),b(n),c(n);
	rep(i,n)cin>>a[i]>>b[i]>>c[i];
	vvi dp(n+1,vi(3,0));
	rep(i,n){
		dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
		dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
		dp[i+1][2]=max(dp[i][0]+c[i],dp[i][1]+c[i]);
	}
	cout<<*max_element(all(dp[n]))<<endl;
	return 0;
}

Measured memory_bytes: 6912
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		out.println(instr().replace("2017", "2018"));

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <functional>
#include <map>
#include <string>
using namespace std;
#define INF 1000000000;
#define MOD 1000000007;
typedef long long int ll;
int main(void){
    int x,a;
    cin>>x>>a;
    if(x<a){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
// typedef vector vec;

ll mod = 1e9 + 7;

#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
// cout<<endl;


int main()
{
	fastio();
	int n;
	cin>>n;
	int mi = n+5, a, ans=0;
	rep(i, n)
	{
		cin>>a;
		if(mi > a) ans++, mi = a;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
   int n,i,j,a[100001],tmp=0;
   scanf("%d",&n);
   a[0]=0;
   a[n+1]=0;
   for(i=1;i<=n;i++) {
      scanf("%d",&a[i]);
      tmp+=abs(a[i]-a[i-1]);
   }
   tmp+=abs(a[n]-a[n+1]);
   for(i=1;i<=n;i++){
      printf("%d\n",tmp-(abs(a[i-1]-a[i])+(abs(a[i]-a[i+1])))+abs(a[i-1]-a[i+1]));
   }
   return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,w;
	ll ans[102][102];
	cin>>h>>w;
	char a[100][100];
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>a[i][j];
			ans[i][j]=INF;
		}
	}
	if(a[0][0]=='#'){
		ans[0][0]=1;
	}
	else{
		ans[0][0]=0;
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(a[i][j]=='.'&&a[i][j+1]=='#'){
				ans[i][j+1]=min(ans[i][j+1],ans[i][j]+1);
			}
			else{
				ans[i][j+1]=min(ans[i][j+1],ans[i][j]);
			}
			if(a[i][j]=='.'&&a[i+1][j]=='#'){
				ans[i+1][j]=min(ans[i+1][j],ans[i][j]+1);
			}
			else{
				ans[i+1][j]=min(ans[i+1][j],ans[i][j]);
			}			
		}
	}
	cout <<ans[h-1][w-1];
	// your code goes here
	return 0;
}

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

using namespace std;

int main(){
  int h,w;cin>>h>>w;
  vector<string> board(h);
  for(int i=0;i<h;i++){
    cin>>board[i];
  }
  const int x[8] = {-1,0,1,-1,1,-1,0,1};
  const int y[8] = {1,1,1,0,0,-1,-1,-1};

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j]=='#') continue;
      int cnt=0;
      for(int k=0;k<8;++k){
        const int iy = i + y[k];
        const int jx = j + x[k];
        if(iy<0 || h<=iy) continue;
        if(jx<0 || w<=jx) continue;
        if(board[iy][jx]=='#') cnt++;
      }
      board[i][j] = char(cnt+'0');
    }
  }
  for(int i=0;i<h;i++) cout<<board[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    vector<set<int>> d(w+1);
    for(int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        d[b].insert(a);
    }
    int ans = h;

    int now = 2;
    for(int i = 1; i <= w; i++)
    {
        auto titr = d[i].lower_bound(now);
        if(titr != d[i].end())
        {
            ans = min(ans, *titr-1);
        }
        if(i == w) break;
        while(true)
        {
            if(now == h)
            {
                cout << ans << endl;
                return 0;
            }
            auto itr = d[i+1].find(now);
            if(itr != d[i+1].end())
            {
                now++;
                continue;
            }
            else
            {
                now++;
                break;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
	int i,ans;
	string s;
	cin >> s;
	
	ans=s.size()/2;
	for(i=0; i<s.size(); i++){
		if(s[i]=='p'){
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>

int main(void)
{
	int a,b,c,i,M,d;
	scanf("%d %d %d",&a,&b,&c);
	M=a;
	if(M<b){
		M=b;
	}
	if(M<c){
		M=c;
	}
	if(M==a){
		if((a-b)%2==(a-c)%2){
			d=0;
		}else{
			d=1;
		}
	}else if(M==b){
		if((b-a)%2==(b-c)%2){
			d=0;
		}else{
			d=1;
		}
	}else{
		if((c-a)%2==(c-b)%2){
			d=0;
		}else{
			d=1;
		}
	}
	if(d==0){
		printf("%d",(3*M-(a+b+c))/2);
	}else{
		printf("%d",(3*M-(a+b+c))/2+2);
	}
//	printf("%d",M);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int main(void){
    //入力
    int n,max1=0,max2=0,cnt=0;
    cin >> n;
    int A[n];  
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        max1=max(A[i],max1);
    }
    for (int i = 0; i < n; ++i) {
        if(A[i]<max1){
            max2=max(A[i],max2);
        }else{
            cnt++;
        }
    }
    if(cnt>1){
        max2=max1;
    }
    for (int i = 0; i < n; ++i) {
        if(A[i]==max1){
            cout << max2 << endl;
        }else{
            cout << max1 << endl;
        }
    }    
    
    return 0;
    
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<int> A(N); rep(i,N)cin>>A[i];
    int minus = 1e7, plus = -1e7;
    vector<pint> res;
    rep(i,N)minus = min(minus,A[i]), plus = max(plus,A[i]);
    // cout<<minus<<" "<<plus<<endl;
    if(plus>=fabs(minus)){
        int ind = -1;
        rep(i,N)if(A[i]==plus)ind = i;
        rep(i,N){
            if(i!=ind)res.push_back({ind+1,i+1});
        }
        rep(i,N-1){
            res.push_back({i+1,i+2});
        }
    }else{
        int ind = -1;
        rep(i,N)if(A[i]==minus)ind = i;
        rep(i,N){
            if(i!=ind)res.push_back({ind+1,i+1});
        }
        rep(i,N-1){
            res.push_back({N-i,N-i-1});
        }
    }
    int s = res.size();
    cout<<s<<endl;
    rep(i,s)cout<<res[i].first<<" "<<res[i].second<<endl;
}


Measured memory_bytes: 3592
from operator import add
N, M, X = map(int, input().split())

price = []
effect = []
for _ in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    effect.append(A)

ans = 10**10
flg = False
for bit in range(2**N):
    tmp_price = 0
    tmp = [0 for _ in range(M)]
    for i in range(N):
        if (1 << i) & bit:
            tmp = map(add, tmp, effect[i]) #理解度の管理
            tmp_price += price[i]

    if min(tmp) >= X:
        flg = True
        ans = min(ans, tmp_price)

if flg:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 9304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int H, N;
    cin >> H >> N;
    int A[N], B[N];
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];

    int dp[30000], ans = inf;
    fill(dp, dp + 30000, -1);
    dp[0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 10010; j++) {
            if(dp[j] == -1) continue;
            if(j + A[i] >= H)
                ans = min(ans, dp[j] + B[i]);
            else {
                if(dp[j + A[i]] == -1)
                    dp[j + A[i]] = dp[j] + B[i];
                else
                    dp[j + A[i]] = min(dp[j + A[i]], dp[j] + B[i]);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384