akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int n; cin >>n;
  vector<double> p(n);
  rep(i, n) cin >>p.at(i);
  vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
  dp.at(0).at(0) = 1.0;

  for (int i=0; i<n; i++){
    for (int j=0; j<=i; j++){
      dp.at(i+1).at(j) += dp.at(i).at(j) * (1.0 - p.at(i));
      dp.at(i+1).at(j+1) += dp.at(i).at(j) * p.at(i);
    }
  }

  double res = 0.0;
  for (int i=n/2+1; i<=n; i++) res += dp.at(n).at(i);
  cout <<fixed <<setprecision(10) <<res <<endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[20];
int f(int l,int r,int cl,int cr){
	int ans=1e18;
	if(l+1>=r) return 0;
	for(int i=l+1;i<=r-1;++i)
		ans=min(ans,f(l,i,cl,cl+cr)+f(i,r,cl+cr,cr)+a[i]*(cl+cr));
	return ans;
}
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	cout<<f(1,n,1,1)+a[1]+a[n];
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>

int main() {
 
  int x_animal, y_leg;
  std::cin >> x_animal >> y_leg;
  
  int exact = 0;
  
  for(int i=0; i<x_animal+1; i++) {
    int turu, kame;
    turu = i;
    kame = x_animal - i;
    
    int leg = i*2 + (x_animal - i)*4;
    if(leg == y_leg) exact ++;
  }
  
  if(exact > 0) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

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

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 1000000007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext
#define minus mminus

using namespace std;

int N,M; lld ans;
lld x[100002],y[100002];
lld sumx[100002],sumy[100002];

int main(){
	scanf("%d %d",&N,&M);
	for(int i=1; i<=N; i++){
		scanf("%lld",&x[i]);
		sumx[i] = sumx[i-1]+x[i];
		sumx[i] %= MOD;
	}
	for(int i=1; i<=M; i++){
		scanf("%lld",&y[i]);
		sumy[i] = sumy[i-1]+y[i];
		sumy[i] %= MOD;
	}
	lld tmp = 0;
	for(int i=2; i<=M; i++){
		tmp += (y[i]*(i-1)-sumy[i-1]);
		tmp %= MOD;
	}
	for(int i=2; i<=N; i++){
		ans += (x[i]*(i-1)-sumx[i-1]);
		ans %= MOD;
	}
	ans *= tmp; ans %= MOD;
	if(ans < 0) ans += MOD;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3328
package main
import (
   "fmt"
   "os"
   "bufio"
   "strings"
   "strconv"
)

func StrStdin() (stringInput string) {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Scan()
  stringInput = scanner.Text()
  // stringInput = strings.TrimSpace(stringInput)
  return
}

func IntStdin() (int, error) {
  stringInput := StrStdin()
  return strconv.Atoi(strings.TrimSpace(stringInput))
}

func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
  stringSplited := strings.Split(stringTargeted, delim)

  for _, str := range stringSplited {
    if str != "" {
      stringReturned = append(stringReturned, str)
    }
  }
  return
}

func SplitStrStdin(delim string) (stringReturned []string){
  // 文字列で1行取得
  stringInput := StrStdin()

  // 空白で分割
  // stringSplited := strings.Split(stringInput, delim)
  stringReturned = SplitWithoutEmpty(stringInput, delim)

  return
}

// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // 文字列スライスを取得
    stringSplited := SplitStrStdin(" ")

    // 整数スライスに保存
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func calculate(i []int) (fee int) {
    train_fee := i[0]*i[1]
    taxi_fee := i[2]
    if train_fee <= taxi_fee {
      fmt.Println(train_fee)
    } else {
      fmt.Println(taxi_fee)
    }
    return
}


func main() {
    i, err := SplitIntStdin(" ")
    if err != nil {
        fmt.Println(err)
    } else {
        //fmt.Println(i)
        //fmt.Println(len(i))
        calculate(i)
    }
}


Measured memory_bytes: 640
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
A=[]
for i in range(n):
  for j in range(a[i]):
    A.append(i+1)
ans=[[0]*w for i in range(h)]
for i in range(h):
  ans[i]=A[i*w:(i+1)*w]
for i in range(1,h,2):
  ans[i]=ans[i][::-1]
for i in range(h):
  for j in range(w):
    print(ans[i][j],end=" ")
    if j==w-1:
      print()

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll H, W;
    cin >> H >> W;
    VS S(H);
    rep(i, 0, H) cin >> S[i];

    VVL L(H+2, VL(W+2, 0)), R(H+2, VL(W+2, 0)), U(H+2, VL(W+2, 0)), B(H+2, VL(W+2, 0));
    
    rep(h, 1, H+1){
        rep(w, 1, W+1){
            if(S[h-1][w-1] == '#') L[h][w] = 0;
            else L[h][w] = L[h][w-1] + 1;
        }
        for(ll w = W; w > 0; w--){
            if(S[h-1][w-1] == '#') R[h][w] = 0;
            else R[h][w] = R[h][w+1] + 1;
        }
    }

    rep(w, 1, W+1){
        rep(h, 1, H+1){
            if(S[h-1][w-1] == '#') U[h][w] = 0;
            else U[h][w] = U[h-1][w] + 1;
        }
        for(ll h = H; h > 0; h--){
            if(S[h-1][w-1] == '#') B[h][w] = 0;
            else B[h][w] = B[h+1][w] + 1;
        }
    }
    
    
    ll ans = 0;
    rep(h, 1, H+1){
        rep(w, 1, W+1){
            if(S[h-1][w-1] == '#') continue;
            ans = max(ans, L[h][w] + R[h][w] + U[h][w] + B[h][w] - 3);
        }
    }
    cout << ans << endl;
    return 0;
}

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


int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}




int main(){

	int n,X,a,ans,flg;
	cin>>n>>X;

	vector<int>x(n);
	for(int i=0;i<n;i++){
		cin>>a;
		x[i]=abs(a-X);
	}
	sort(x.begin(),x.end());
	ans=gcd(x[1],x[0]);

	for(int i =1;i<n-1;i++){
		ans=gcd(x[i+1],ans);
	}

	cout<<ans;

}



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

int main(){
    int n;
    while(cin >> n, n){
        int dp[26][26] = {};
        string b;
        cin >> b;
        bool ng = false;
        for(int i = 1; i < n; i++){
            string s;   cin >> s;
            int j;
            for(j = 0; j < min(b.length(), s.length()); j++){
                if(b[j] != s[j])    break;
            }
            if(j < min(b.length(), s.length())){
                dp[b[j]-'a'][s[j]-'a'] = -1;
            }else if(j == s.length() && j < b.length()){
                ng = true;
            }
            b = s;
        }
        for(int k = 0; k < 26; k++){
            for(int i = 0; i < 26; i++){
                for(int j = 0; j < 26; j++){
                    if(dp[i][k] == 0 || dp[k][j] == 0)  continue;
                    dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
                }
            }
        }
        for(int i = 0; i < 26; i++){
            ng |= (dp[i][i] < 0);
        }
        cout << (ng ? "no" : "yes") << endl;
    }
    return 0;
}


Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

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

using namespace std;

int main()
{
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    int hantei;
    if (w == x * 2 && h == y * 2)
    {
        hantei = 1;
    }
    else
    {
        hantei = 0;
    }

    double menseki;
    double div = 2;
    menseki = w * h / div;
    
    cout << setprecision(10) << menseki;
    cout << " " << hantei << endl;
    


}

Measured memory_bytes: 256
spade = [True for i in range(13)]
heart = [True for i in range(13)]
club = [True for i in range(13)]
dia = [True for i in range(13)]

n = int(input())
for i in range(n):
  suit, num = map(str,input().split())
  if suit == "S":
    spade[int(num)-1] = False
  elif suit =="H":
    heart[int(num)-1] = False
  elif suit == "C":
    club[int(num)-1] = False
  elif suit == "D":
    dia[int(num)-1] = False

for i in range(13):
  if spade[i]:
    print("S {0}".format(i+1))

for i in range(13):
  if heart[i]:
    print("H {0}".format(i+1))

for i in range(13):
  if club[i]:
    print("C {0}".format(i+1))

for i in range(13):
  if dia[i]:
    print("D {0}".format(i+1))


Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N, K, C;
string S;
vector<int> vl, vr;

const int INF = 100000000;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K >> C;
    cin >> S;
    vl.push_back(-INF);
    for(int i = 0; i < N; i++){
        if(S[i] == 'o'){
            int s = vl.size();
            if(vl[s-1]+C < i) vl.push_back(i);
        }
    }
    // for(int i = 0; i < vl.size(); i++) cout << vl[i] << ' ';
    // cout << endl;
    vr.push_back(INF);
    for(int i = N-1; i >= 0; i--){
        if(S[i] == 'o'){
            int s = vr.size();
            if(i+C < vr[s-1]) vr.push_back(i);
        }
    }
    sort(vr.begin(), vr.end());
    // for(int i = 0; i < vr.size(); i++) cout << vr[i] << ' ';
    // cout << endl;
    vector<int> ans;
    for(int i = 0; i < N; i++){
        if(S[i] == 'x') continue;
        auto pl = lower_bound(vl.begin(), vl.end(), i);
        pl--;
        auto pr = upper_bound(vr.begin(), vr.end(), i);
        int cnt = (pl-vl.begin()+1) + (vr.end()-pr);
        if(*pr - *pl <= C) cnt--;
        cnt -= 2;
        // cout << *pr << ' ' << *pl << ' ' << cnt << endl;
        if(cnt < K) cout << i+1 << endl;
    }
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}
	
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ld a, b; cin>>a>>b;
	ld tmp = a*b;
	cout<<ll(floor(tmp+ld(1e-9)))<<'\n';
}


Measured memory_bytes: 3748
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	a = list(map(int,input().split()))
	if(a.count(5)==2 and a.count(7)==1):
		print('YES')
	else:
		print('NO')
	

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 65516
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/

int main() {
	ll x,a,b;cin >> x>>a>>b;
	if (abs(b - x) < abs(a - x))cout << "B" << endl;
	else cout << "A" << endl;
}

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

bool solve(string& s) {
    int N = s.size();

    int even = (N % 2 == 0);
    int same = (s[0] == s[N-1]);
    // same -> odd; even -> odd : First (true)
    // !same -> even; even -> even : Second (false)

    return even == same;
}

int main() {
    string s; cin >> s;
    cout << (solve(s) ? "First":"Second") << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    int x = 0;
    if (s[1] == s[2] == s[3] == '0') cout << "Yes";
    else if (s[0] == s[1] && s[0] == s[2]) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x, a, b;
    cin >> x >> a >> b;
    char ans = abs(a - x) > abs(b - x) ? 'B' : 'A';
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
T = []
P = {}
for i in range(H):
    A = list(map(int, input().split()))
    T.append(A)
Q = int(input())
for i in range(H):
    for j in range(W):
        P[T[i][j]] = [i, j]

Jump = [[0] for _ in range(D+1)]
for i in range(1, D+1):
    total = 0
    for j in range(i, H*W+1-D, D):
        total += abs(P[j+D][0] - P[j][0]) + abs(P[j+D][1] - P[j][1])
        Jump[i].append(total)
Ans = []
for i in range(Q):
    L, R = map(int, input().split())
    k = L % D
    start = L//D
    end = R//D
    if k == 0:
        k += D
        start -= 1
        end -= 1
    Ans.append(Jump[k][end] - Jump[k][start])

for i in range(Q):
    print(Ans[i])

Measured memory_bytes: 107596
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int>c(n);
  int ans = 10000000000;
  vector<vector<int>> a(n, vector<int>(m));//int型の2次元配列(3×4要素の)の宣言
  rep(i,n){
    cin >> c.at(i);
    for(int j=0;j<m;j++){
      cin >> a.at(i).at(j);
    }
  }
  //入力できているかテスト
/*  rep(i,n){
    cout << c.at(i) << " ";
    for(int j=0;j<m;j++){
      cout << a.at(i).at(j) << " ";
    }
    cout << endl;
  }
}
*/
  int flag = 0;
  int count = 0;
  int okane = 0;
  vector<int>check(m);
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
     vector<int>check(m);  
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }

//        cout << bit << ": {";

      okane = 0;//shokika
      for (int i = 0; i < (int)S.size(); ++i) {
          okane += c.at(S.at(i));
        for(int j=0;j<m;j++){
          check.at(j) += a.at(S.at(i)).at(j);
        }
      }
      count = 0;
      
      rep(i,m){
        if(check.at(i) >= x)count++;
      }
      if(count==m){
        ans = min(ans,okane);
        flag = 1;
      }
      
//        cout << "}" << endl;
//      cout << check.at(0) << " " << check.at(1) <<" "<< check.at(2) << endl;
    }
  
  
  if(flag==0){
    cout << -1 << endl;
  }
  else{
    cout << ans <<endl;
  }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e3+10;
const int maxh=1e4+10;
const int inf=0x3f3f3f3f;
int dp[maxh<<1]={};
int a[maxn],b[maxn];
main(){
    int h,n;
    cin>>h>>n;
    int mx=0;
    for(int i=1;i<=n;++i){
        cin>>a[i]>>b[i];
        mx=max(mx,a[i]);
    }
    for(int i=1;i<h+mx;++i)dp[i]=inf;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=h;++j){
            dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
        }
    }
    int ans=inf;
    for(int i=h;i<h+mx;++i)
        ans=min(ans,dp[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 384
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

for i in range(0, 3):
    for j in range(i, 3):
        if a[i] + b[j] != a[j] + b[i] or a[i] + c[j] != a[j] + c[i] or b[i] + c[j] != b[j] + c[i]:
            print("No")
            quit(0)

print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int n;
cin >> n;
  set<string> s;
  string g;
  for(int i = 0; i < n; i++){
  	cin >> g;
    s.insert(g);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 19220
#include<iostream>
#include<stdio.h>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
    int n;
    int temp;
    int count;
    while(1){
        cin>>n;
        count=0;
        temp=0;
        if(n==0){
            break;
        }else{
            int j=1;
            for(int i=1;i<n;i++){
                temp=temp+i;
                
                    for(;n<temp;j++){
                    temp=temp-j;
                     
                    
                }
                if(n==temp){
                    count++;
                    continue;
                }
            }
        }
        cout<<count<<endl;

    }
            return 0;
}

Measured memory_bytes: 3052
<?php
  fscanf(STDIN, "%d", $n);
  for ($i=0; $i<$n; $i++) {
    fscanf(STDIN, "%s %d", $s, $p);
    $states[] = $s;
    $points[] = $p;
    $stores[] = $i + 1;
  }

  # states を昇順、 points を降順でソート、 store も一緒に並べる。
  array_multisort($states, SORT_ASC, $points, SORT_DESC, $stores);

  for ($i=0; $i<$n; $i++) {
    echo $stores[$i] . "\n";
  }
?>


Measured memory_bytes: 4604
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define mp make_pair
#define ll long long
#define reg register
#define inf 0x7fffffff
#define MOD 1000000007
#define clr(a) memset(a,sizeof(a),0);
#define rep(i,l,r) for(reg int i=l;i<=r;i++)
#define dow(i,l,r) for(reg int i=l;i>=r;i--)
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
template<class T>inline T power(T a,T b){T ans=1;while(b){if(b&1){ans=ans*a%MOD;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
int main(){
	int n=read();
	if(n&1) writeln(n*2);
	else writeln(n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int x;
    cin >> x;
    for(int i=1;i<=x;i++){
        if(i*(i+1)/2>=x){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000

int N,K;
int  hoge[BUFSIZE]={0};
long long V,W,T;
int count = 0;
int main(void){
  for(int i = 0 ;i < 5;i++){
     scanf("%d",&hoge[i]);
     if(hoge[i] == 0) count = i+1;
   }
  printf("%d",count);
}


Measured memory_bytes: 1732
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        long count = 0;
        long pow = (long) (Math.pow(10, 9)+7);
        long all = n * (n+1) / 2 ;
        for (long i = k; i <= n+1; i++) {
            if (i == n + 1) {
                count++;
                break;
            }
            long t = n  - i;
            long tmp = t * (t+1) / 2;
            long max = all - tmp;
            long min = i * (i - 1) / 2 ;
            count += (max - min + 1);
        }
        System.out.println(count % pow);
    }
}

Measured memory_bytes: 35808
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;

template<typename T> struct edge
{
    int to; T cost;
    edge(int to, T cost) : to(to), cost(cost) {}
};
template<typename T>
using Gragh = vector<vector<edge<T>>>;
template<typename T>
vector<T> dijkstra(Gragh<T> &G, int s)
{
    vector<T> dist(G.size(), INF);
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.push(make_pair(dist[s], s));
    while(que.size())
    {
        P p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(auto &e : G[v])
        {
            if(dist[e.to] > p.first + e.cost)
            {
                dist[e.to] = p.first + e.cost;
                que.push(make_pair(dist[e.to], e.to));
            }
        }
    }
    return dist;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V, E, r; cin >> V >> E >> r;
    Gragh<int> G(V);
    for(int i = 0; i < E; i++)
    {
        int s, t, d; cin >> s >> t >> d;
        G[s].emplace_back(t, d);
    }
    vector<int> res = dijkstra(G, r);
    for(auto &ans : res)
    {
        if(ans == INF) cout << "INF" << endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12880
def solve(antennas, k):
    for i in range(len(antennas)):
        for j in range(i + 1, len(antennas)):
            if antennas[j] - antennas[i] > k:
                return False
    return True

antennas = [int(input()) for _ in range(5)]
k = int(input())

if solve(antennas, k):
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1;i <= n;i++){
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
def solve(N,A):
    ans = 1
    lis = []
    lis.append(A[0])
    a = A[0]
    for i in range(1,N):
        if len(lis)==1 or prev==0:
            prev = A[i]-a
        elif (A[i]-a)*prev<0:
            ans += 1
            lis = []
        lis.append(A[i])
        a = A[i]
    return ans
print(solve(N,A))

Measured memory_bytes: 14252
N, Y = map(int,input().split())
answer = -1,-1,-1
for x in range(N+1):
	for y in range(N-x+1):
		z = N-x-y
		if 10000*x+5000*y+1000*z == Y:
			answer = x,y,z
			break
		else:
			continue
		break
print(*answer)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
 
using namespace std;
 
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
 
	int64_t N, A, B;
    cin >> N >> A >> B;
	int64_t ans;
	if(A == 0){
		ans = 0;
	}
	else if(N%(A+B) < A){
		ans = A * (N/(A+B)) + (N%(A+B)); 
	}else{
		ans = A * (N/(A+B)) + A;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

const int N = 8;
const int inf = (1<<20);
char m[N][N];

inline int getval(int c,int j,int bit){
  if      (j == -1)j=0;
  else if (j ==  c)j=c-1;
  return (bit&(1<<j)) != 0;
}

inline int checkij(int r,int c,int i,int j,int bit0,int bit1,int bit2){
  int ret=0;
  int bit=0;
  //bit0
  if (i-1 < 0)bit=bit1;
  else        bit=bit0;
  REP(k,-1,2)ret+=getval(c,j+k,bit);

  //bit1
  bit=bit1;
  REP(k,-1,2)ret+=getval(c,j+k,bit);

  //bit2
  if (i+1 == r)bit=bit1;
  else         bit=bit2;
  REP(k,-1,2)ret+=getval(c,j+k,bit);
  return ret;
}

inline bool isvalid(int r,int c,int now,int bit0,int bit1,int bit2){
  rep(j,c){
    int cnt=checkij(r,c,now-1,j,bit0,bit1,bit2);
    if ((m[now-1][j] == '#'&&cnt>=5) ||
	(m[now-1][j] == '.'&&cnt<5 ));
    else return false;
  }
  return true;
}

int dp[1<<N][1<<N][N];
int dp2[1<<N][1<<N][N];
int bitcount[1<<N];

void solve(int r,int c,int bit0,int bit1,int now){
  if (now == r){
    if (isvalid(r,c,now,bit0,bit1,0)){
      dp[ bit0][bit1][now-1]=bitcount[bit1];
      dp2[bit0][bit1][now-1]=bitcount[bit1];
    }else {
      dp[ bit0][bit1][now-1] =-inf;
      dp2[bit0][bit1][now-1]= inf;
    }
    return;
  }
  int &ret= dp[ bit0][bit1][now-1];
  int &ret2=dp2[bit0][bit1][now-1];
  if (ret == -2*inf ){
    ret=-inf;
    ret2=inf;
    rep(i,(1<<c)){
      if (isvalid(r,c,now,bit0,bit1,i)){
	solve(r,c,bit1,i,now+1);
	if (dp[bit1][i][now] != -inf){
	  ret =max(ret, dp[bit1][i][now]+bitcount[bit1]);
	  ret2=min(ret2,dp2[bit1][i][now]+bitcount[bit1]);
	}
      }
    }
  }
  return;
}

main(){
  rep(i,(1<<N))bitcount[i]=__builtin_popcount(i);
  int c,r,tc=1;
  while(cin>>c>>r && r){
    cout <<"Case " << tc++ << ": ";
    rep(i,r)cin>>m[i];
    rep(i,(1<<c)){
      rep(j,(1<<c)){
	rep(k,r){
	  dp[i][j][k]=-2*inf;
	  //dp2[i][j][k]=2*inf;
	}
      }
    }
    int maxi=-2*inf,mini=inf;
    rep(i,(1<<c)){
      solve(r,c,0,i,1);
      if (dp[0][i][0] >= 0){
	maxi=max(maxi,dp[0][i][0]);
	mini=min(mini,dp2[0][i][0]);
      }
    }

    if (maxi < 0){
      cout <<"Impossible" << endl;
      continue;
    }else  cout << maxi-mini << endl;
  }
  return false;
}



/*
void test(){
  int bit0=17,bit1=14,bit2=24;
  int r=3,c=5;
  rep(j,c)cout << checkij(r,c,0,j,0,bit0,bit1)<<" ";cout << endl;
  rep(j,c)cout << checkij(r,c,1,j,bit0,bit1,bit2)<<" ";cout << endl;
  rep(j,c)cout << checkij(r,c,2,j,bit1,bit2,0)<<" ";cout << endl;
}

void output(int c,int bit){
  rep(j,c){
    if ((1<<j)&bit) cout <<"#";
    else cout << ".";
  }
  cout << endl;
}

*/

Measured memory_bytes: 4972
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL long long
#define MAXN 100001
using namespace std;
int n,a[MAXN];
int main()
{
	int x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		a[x]=i;
	}
	for(int i=1;i<=n;i++) printf("%d ",a[i]);
	return 0;
}

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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;


LL check(vector<LL> A) {

    LL ans = 0;
    int N = A.size();
    while (true) {
        sort(RALL(A));
        if (A[0] >= N) {
            A[0] -= N;
            FOR(i, 1, N) {
                A[i] += 1;
            }
        }
        else {
            break;
        }
        ans++;
    }
    return ans;
}



int solve(LL K) {
    vector<LL> v(50);
    iota(ALL(v), 0);

    LL num = K / 50;
    FOR(i, 0, v.size()) {
        v[i] += num;
    }

    LL rest = K % 50;
    FOR(i, 0, rest) {
        v[i] += 50;
        FOR(j, 0, 50) {
            if (i != j) {
                v[j] -= 1;
            }
        }
    }

    cout << 50 << endl;
    FOE(x, v) {
        cout << x << endl;
    }
}


int main() {
    LL K;
    cin >> K;
    solve(K);

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Collection;
class Main
{
  public static void main(String args[])  throws java.lang.Exception
  {
    BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    HashSet<String> hs=new HashSet<String>();
    for(int i=0;i<n;i++)
     {
       String s=br.readLine();
       hs.add(s);
     } 
    System.out.println(hs.size());
   
   }
}  


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = 1e9 + 5;

bool solve(void){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    if(X >= Y){
        return false;
    }
    vector<int> x(n), y(m);
    rep(i, n){
        cin >> x[i];
    }
    rep(i, m){
        cin >> y[i];
    }
    SORT(x);
    SORT(y);
    return x[n-1] < Y && x[n-1] < y[0] && X < y[0];
}

int main(){
    if(solve()){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
using P = std::pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvP = vector<vector<P>>;
using vP = vector<P>;
//using bint = boost::multiprecision::cpp_int;



// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};




int main(){
    
    
    int h,a;
    cin >> h >> a;
    cout << ((h+a-1)/a);
    rn 0;
}



Measured memory_bytes: 256
def gen_graph(input_list):
    graph = {}

    for item in input_list:
        if not item[0] in graph:
            graph[item[0]] = {}
        if not item[1] in graph:
            graph[item[1]] = {}
        graph[item[0]][item[1]] = item[2]
        graph[item[1]][item[0]] = item[2]

    return graph


def get_lowest_cost_vertex(costs, processed):
    lowest_cost = float("inf")
    lowest_cost_node = None
    for node in costs:
        cost = costs[node]
        if cost < lowest_cost and node not in processed:
            lowest_cost = cost
            lowest_cost_node = node
    return lowest_cost_node


def get_best_routes(graph, start):
    costs = {}
    parents = {}
    processed = []

    costs[start] = 0
    parents[start] = None
    processed.append(start)

    for item in graph[start].keys():
        costs[item] = graph[start][item]
        parents[item] = start

    for item in graph.keys():
        if not (item in costs.keys() or item == start):
            costs[item] = float("inf")
            parents[item] = None

    node = get_lowest_cost_vertex(costs, processed)

    while node is not None:
        cost = costs[node]
        neighbors = graph[node]

        for n in neighbors.keys():
            new_cost = cost + neighbors[n]
            if costs[n] > new_cost:
                costs[n] = new_cost
                parents[n] = node
        processed.append(node)
        node = get_lowest_cost_vertex(costs, processed)

    routes = []
    for item in graph.keys():
        if item != start:
            route = []
            route.append(item)
            parent = parents[item]
            while 1:
                route.append(parent)
                if parent == start:
                    break
                parent = parents[parent]
            route.reverse()
            routes.append(route)
    return routes


def main(vertex_count, input_list):
    graph = gen_graph(input_list)

    routes = []
    for start in range(1, vertex_count+1):
        for route in get_best_routes(graph, start):
            routes.append(route)

    route_sides = []
    for route in routes:
        for i, vertex in enumerate(route):
            if i == len(route)-1:
                break
            route_side = [route[i], route[i+1]]
            route_side_sorted = sorted(route_side)
            if not route_side_sorted in route_sides:
                route_sides.append(route_side_sorted)

    sides = []
    for item in input_list:
        side = [item[0], item[1]]
        side_sorted = sorted(side)
        sides.append(side_sorted)

    count = 0
    for side in sides:
        if not side in route_sides:
            count += 1

    return count


if __name__ == "__main__":
    input_1 = input()
    vertex_count, sides_count = list(map(int, input_1.split()))
    input_list = []
    for _ in range(sides_count):
        vertex_1, vertex_2, distance = list(map(int, input().split()))
        input_list.append((vertex_1, vertex_2, distance))
    print(main(vertex_count, input_list))


Measured memory_bytes: 51292
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
#include <cstring>
using namespace std;
int A[1050];
int main()
{
    int X;
    while(scanf("%d",&X)!=EOF)
    {
        int sum;
        for(int i=1; i<=X; i++)
        {
            int temp=0;
            for(int j=2; j<i; j++)
            {
                int s=i;
                while(s%j==0)
                {
                    s=s/j;
                }
                if(s==1) sum=i;
            }
        }
        if(X==1)
            printf("1\n");
        else
        printf("%d\n",sum);
    }
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(b % a == 0){
				System.out.println(a + b);
			}
			else{
				System.out.println(b - a);
			}
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;
using P = pair<ll, ll>;
using Tu = tuple<ll, ll, ll>;
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

template<typename T, const T INFT>
struct Dijkstra{
  typedef pair<int,T> pit;
  typedef pair<T,int> pti;
  vector<vector<pit>> G;
  vector<T> dist;
  int n;
  void init(int arg_n){
    n = arg_n;
    G.assign(n, vector<pit>(0));
  }
  void add_biedge(int fr, int to, T co){
    G[fr].pb(to, co);
    G[to].pb(fr, co);
  }
  void add_edge(int fr, int to, T co){
    G[fr].pb(to, co);
  }
  T dijkstra(int s, int t = -1){
    dist = vector<T>(n, INFT);
    dist[s] = 0;
    priority_queue<pti,vector<pti>,greater<pti>> que;
    que.emplace(0, s);
    while(!que.empty()){
      T d = que.top().fi;
      int p = que.top().se;
      que.pop();
      if(d > dist[p]){
        continue;
      }
      if(p == t){
        return d;
      }
      YYS(w, G[p]){
        int to = w.fi;
        T co = w.se;
        if(d + co < dist[to]){
          dist[to] = d + co;
          que.emplace(dist[to], to);
        }
      }
    }
    return INFT;
  }
};

int main(){
  ll N, M;
  cin >> N >> M;
  Dijkstra<ll, INF> g;
  g.init(3*N);
  for(int i=0;i<M;i++){
    ll u, v;
    cin >> u >> v;
    u--; v--;
    for(int k=0;k<3;k++)
      g.add_edge(3*u+k, 3*v+(k+1)%3, 1);
  }
  ll s, t;
  cin >> s >> t;
  s--; t--;
  s *= 3;
  t *= 3;
  ll ans = g.dijkstra(s, t);
  if(ans != INF)
    cout << ans/3 << endl;
  else
    cout << -1 << endl;
}


Measured memory_bytes: 18944
s = input()

good = True
for i, c in enumerate(s):
    if (i+1)&1 == 0 and c == 'R':
        good = False
        break
    if (i+1)&1 == 1 and c == 'L':
        good = False
        break

if good:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

vector<vector<int>> dis(1001,vector<int> (1001,-1));
vector<string> grid;
int n,m,x1,yy1,x2,y2;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};

void bfs(){
    cin >> n >> m >> x1 >> yy1 >> x2 >> y2;
    x1--;yy1--;x2--;y2--;
    grid = vector<string> (n);
    for(int i=0;i<n;i++) cin >> grid[i];
    dis[x1][yy1] = 0;
    deque<pair<int,int>> q;
    q.push_back({x1,yy1});
    while(!q.empty()){
        int x,y;
        tie(x,y) = q.front();q.pop_front();
        for(int i=0;i<4;i++){
            int nx = x - dx[i];
            int ny = y - dy[i];
            if(nx < 0 || nx >= n) continue;
            if(ny < 0 || ny >= m) continue;
            if(grid[nx][ny] == '#') continue;
            if(dis[nx][ny] != -1 && dis[nx][ny] <= dis[x][y]) continue;
            dis[nx][ny] = dis[x][y];
            q.push_front({nx,ny});
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int nx = x + i;
                int ny = y + j;
                if(nx < 0 || nx >= n) continue;
                if(ny < 0 || ny >= m) continue;
                if(grid[nx][ny] == '#' || dis[nx][ny] != -1) continue;
                dis[nx][ny] = dis[x][y] + 1;
                q.push_back({nx,ny});
            }
        }
    }
}

int main(){
    IOS;

    bfs();
    cout << dis[x2][y2] << endl;
    return 0;    
}

Measured memory_bytes: 8692