akhauriyash/Code-Regression huggingface dataset:
def main():
    S = [int(i) for i in input()]

    counterOne = coloringColorful(0, S)
    counterZero = coloringColorful(1, S)

    print(counterOne if counterOne <= counterZero else counterZero)


def coloringColorful(preNumber, S):
    pre = preNumber
    counter = 0
    for s in S:
        if s != pre:
            pre = 1 if pre == 0 else 0
        else:
            pre = 1 if s == 0 else 0
            counter += 1

    return counter


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
const double eps=1e-9;
struct seg{double a,b,c;};
seg calc(double x1,double y1,double x2,double y2){
	double a=y1-y2,b=x2-x1,c=x2*y1-x1*y2;
	seg ret;
	ret.a=a;
	ret.b=b;
	ret.c=c;
	return ret;
}
int main(){
	int n;
	scanf("%d",&n);
	REP0(i,n){
		double x1,y1,x2,y2,x3,y3,ox,oy;
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		seg k=calc(x1,y1,x2,y2);
		seg l=calc(x1,y1,x3,y3);
		double mx1=(x1+x2)/2,my1=(y1+y2)/2,mx2=(x1+x3)/2,my2=(y1+y3)/2;
		seg s1,s2;
		s1.a=k.b;
		s1.b=-k.a;
		s1.c=s1.a*mx1+s1.b*my1;
		s2.a=l.b;
		s2.b=-l.a;
		s2.c=s2.a*mx2+s2.b*my2;
		ox=(s1.c*s2.b-s2.c*s1.b)/(s1.a*s2.b-s2.a*s1.b);
		oy=(s1.a*s2.c-s2.a*s1.c)/(s1.a*s2.b-s2.a*s1.b);
		printf("%.3lf %.3lf %.3lf\n",ox+eps,oy+eps,sqrt((x1-ox)*(x1-ox)+(y1-oy)*(y1-oy))+eps);
	}
	return 0;
}

Measured memory_bytes: 1248
fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).unwrap();
    b.split_whitespace()
        .map(|x| x.trim().parse::<T>().unwrap())
        .collect()
}

fn can(v: &Vec<u64>, c: u64) -> bool {
    if c == 0 {
        return false;
    }
    let mut cnt = 0;
    for x in v {
        if x % c != 0 {
            cnt += 1;
            if cnt > 1 {
                return false;
            }
        }
    }
    true
}

fn main() {
    let _ = read::<u64>()[0];
    let ai = read::<u64>();
    if ai.len() == 2 {
        println!("{}", ai.iter().max().unwrap());
        return;
    }

    let mut ans = 0;

    for i in 1..100000 {
        for j in 0..3 {
            if ai[j] % i == 0 && can(&ai, ai[j] / i) {
                ans = std::cmp::max(ans, ai[j] / i);
            }
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 8444
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
R = [list(map(int, input().split())) for _ in range(M)]
for a, b in S:
    min_j = -1
    min_d = 10 ** 10
    for j, (c, d) in enumerate(R):
        distance = abs(a - c) + abs(b - d)
        if distance < min_d:
            min_j = j
            min_d = distance
    print(min_j + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n;
  cin >> n;
  vector<int> p(n);
  REP(i,n){
    cin >> p.at(i);
  }
  int t=0;
  for (int i=1;i<n-1;i++){
    int one,two,three;
    one = p.at(i-1);
    two = p.at(i);
    three = p.at(i+1);
    if ((one < two && two < three) || (three < two && two < one)){
      t++;
    }
  }
  cout << t << endl;
  return 0;
}



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

int n;
vector<int> edges[100000];

int solve(int v, int p){
    int ch = edges[v].size();
    if(p >= 0) --ch;
    if(ch == 0) return 0;
    int ret = 0;
    for(int u: edges[v]){
        if(u == p) continue;
        ret ^= solve(u, v) + 1;
    }
    return ret;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    cin >> n;
    for(int i=1;i<n;++i){
        int x, y;
        cin >> x >> y;
        --x; --y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    if(solve(0, -1) == 0) cout << "Bob" << endl;
    else cout << "Alice" << endl;
    
    return 0;
}

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

int main()
{
	int n, k, res(0);
	cin >> n >> k;
	vector<int>vec(n);
	for (int i = 0; i < n; i++) cin >> vec[i];
	sort(vec.begin(), vec.end());
	for (int i = 0; i < k; i++) res += vec[i];
	cout << res << endl;
	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> l(n);
    vector<P> t(n);
    rep(i,n){
        int X,L;
        cin >> X>>L;
        x[i] = X;
        l[i] = L;
        t[i].first = X+L;
        t[i].second = X-L;
    }

    sort(t.begin(),t.end());

    int temp = -1001001001;
    int ans = 0;
    rep(i,n){
        if(temp<=t[i].second){
            ans++;
            temp = t[i].first;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rgt register
#define rint rgt int
#define LL long long
#define rll rgt LL
#define inf 0x7f7f7f7f
#define N 10003
using namespace std;
template<class K>inline bool cmax(K&a,const K&b){return(a<b)?a=b,1:0;}
template<class K>inline bool cmin(K&a,const K&b){return(a>b)?a=b,1:0;}
inline int read() {
	rint s=0;
	rgt char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
int n,m,w,v,f[N];
int main()
{
	rint i,j;
	m=read(),n=read();
	memset(f,inf,(m+1)<<2),f[0]=0;
	for(i=1;i<=n;i++) {
		w=read(),v=read();
		for(j=0;j<=m;j++)
			cmin(f[min(j+w,m)],f[j]+v);
	}printf("%d",f[m]);
	return 0;
}

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

using namespace std;

string data[9] = {"\',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ"};

main(){
  char c;
  while(scanf("%c", &c)!=EOF){
    string out;
    bool f = true;
    char num = c;
    int cnt = 1;
    for(int i=1;;i++){
      scanf("%c", &c)!=EOF;
      if(c == '\n') break;
      if(c == '0'){
        if(num == '0') cnt++;
        else{
          out += data[num-'1'][cnt-1];
          num = c;
          cnt = 0;
        }
      }else if(num != c){
        if(num == '0') while(cnt--) out += ' ';
        else out += data[num-'1'][cnt-1];
        num = c;
        cnt = 1;
      }else cnt++;
    }
    if(num == '0') while(cnt--) out += ' ';
    else out += data[num-'1'][cnt-1];
    cout << out << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <bits/stdc++.h>
#define mst(a) memset(a,0,sizeof(a))
#define rev(a) reverse(a,a+strlen(a))
using namespace std;
typedef long long ll;
bool cmp(int i,int j)
{
    return i>j;
}
int main()
{
   int n,b[101],sum;
   cin>>n;
   for(int i=0;i<n-1;i++)cin>>b[i];
   sum=b[0];
   for(int i=1;i<n-1;i++)sum+=min(b[i-1],b[i]);
   sum+=b[n-2];
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        printf("a > b");
    }
    if(a<b){
        printf("a < b");
    }
    if(a==b){
        printf("a == b");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <map>
using namespace std;
int main() {
    int A[100001]={0};
    int n,k,q,index;

    cin>>n>>k>>q;
    for(int i=1;i<=n;i++)
        A[i] = -1 * q + k;
    for(int i=0;i<q;i++){
        cin>>index;
        A[index]++;
    }
    for(int i=1;i<=n;i++){
        if(A[i]>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 7) {
		if (b == c && b + c == 10) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else if (b == 7) {
		if (a == c && a + c == 10) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else if (c == 7) {
		if (b == a && b + a == 10) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var a = l[0]; var b = l[1];
        if (a % 2 != b % 2)
        {
            Console.WriteLine("IMPOSSIBLE");
        }
        else
        {
            Console.WriteLine((a + b) / 2);
        }
    }
}

Measured memory_bytes: 13396
N = int(input())
h = list(map(int,input().split()))

dp = [0]*2
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
  dp.append(min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i])))

print(dp[N-1])

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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;}

int N,K;
int P[5005];
int C[5005];
int v[5005];
bool visited[5005];
bool loop[5005];
PI loopCost[5005];
int ans=-INF;

void init(){
    for(int i=0;i<5005;++i){
        loop[i]=false;
        loopCost[i]=PI(-INF,-INF);
    }
}

void cal(int n){
    if(visited[n]){
        loop[n]=true;
        return;
    }
    visited[n]=true;
    cal(P[n]);
}

signed main(){
    init();
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>P[i];
        P[i]--;
    }
    for(int i=0;i<N;++i)cin>>C[i];
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j)visited[j]=false;
        cal(i);
    }
    for(int i=0;i<N;++i){
        if(!loop[i])continue;
        int p=i;
        int cost=0;
        int cnt=0;
        while(true){
            cost+=C[p];
            p=P[p];
            cnt++;
            if(p==i)break;
        }
        loopCost[i]=PI(cost,cnt);
    }
    for(int i=0;i<N;++i){
        int res=0;
        int cnt=0;
        int p=i;
        bool skip=false;
        while(cnt<K){
            int remain=K-cnt;
            if(loop[p]&&loopCost[p].second<remain&&!skip){
                if(loopCost[p].first>0){
                    res+=(remain/loopCost[p].second-1)*loopCost[p].first;
                    cnt+=(remain/loopCost[p].second-1)*loopCost[p].second;
                    chmax(ans,res);
                }
                else {
                    cnt=K-loopCost[p].second;
                }
                skip=true;
            }
            else {
                res+=C[p];
                p=P[p];
                cnt++;
                chmax(ans,res);
            }
        }
        chmax(ans,res);
    }
    cout<<ans<<endl;
}

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

long long L[N], P[N];

long long f(long long n){
	if(L[n] == -1){
		if(n == 0){
			P[n] = L[n] = 1;
		} else {
			L[n] = 1 + f(n-1) + 1 + f(n-1) + 1; 
			P[n] = P[n-1]*2 + 1;
		}
	}
	return L[n];
}

long long g(int n, long long x){
	long long total = 0;
	if(n >= 0 && x > 0){
		if(L[n] <= x)
			return P[n];
		else if(x > 0){
			x--;
			if(x >= L[n-1]){
				x -= L[n-1];
			
				total += P[n-1];
				if(x >= 1) {
					x--;
					total++;
					if(x >= L[n-1]){
						x-= L[n-1];
						total += P[n-1];
					} else {
						total += g(n-1, x);
					}
				}
			} else {
				total += g(n-1, x);
			}
			x--;
		}
	}
	return total;
}

int main(){
	for(int i = 0 ; i < N ; i++){
		P[i] = L[i] = -1;
	}

	long long n, x;
	cin >> n >> x;
	f(n);
	// cout << f(n) << endl;
	// cout << P[n] << endl;
	cout << g(n, x) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 10000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	
	ll ans = 1;
	rep(i, n){
		ll t;
		cin >> t;
		ans = lcm(t, ans);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
 
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
 
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
 
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
 
double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
 
const int N=200005;

int h[N+1];int bit[N+1];

int getparent(int i)
{
    return i-(i& -i);
}
int getnext(int i)
{
    return i+(i& -i);
}
int getmax(int i)
{
    int ans=0;
    while(i>0)
    {
        ans=max(ans,bit[i]);
        i=getparent(i);
    }
    return ans;
}
void update(int i,int x)
{
    while(i<=N)
    {
        bit[i]=max(bit[i],x);
        i=getnext(i);
    }
}

    
void solve()
{
int n;
cin>>n;
int h[n];
int a[n];
for(int i=0;i<n;i++)
cin>>h[i];
for(int i=0;i<n;i++)
cin>>a[i];
int ans=0;
for(int i=0;i<n;i++)
{
    int mx=getmax(h[i]-1);
    ans=max(ans,mx+a[i]);
    update(h[i],mx+a[i]);
}
cout<<ans<<endl;




}

int32_t main()
{
    //IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}

Measured memory_bytes: 8264
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

N, Q = map(int, input().split())

nodes = [[] for _ in range(N)]
values = [0 for _ in range(N)]

for _ in range(N-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  nodes[a].append(b)
  nodes[b].append(a)

for _ in range(Q):
  p, x = map(int, input().split())
  p = p-1
  values[p] += x

def dfs(i, p):
  for c in nodes[i]:
    if c != p:
      values[c] += values[i]
      dfs(c, i)

dfs(0, None)
print(*values)


Measured memory_bytes: 230960
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/11/ALDS1_11_D

from collections import defaultdict
import sys
sys.setrecursionlimit(1 << 25)  # 再起上限引き上げ

G = defaultdict(lambda: [])

# load data
N, M = list(map(int, input().split()))
color = {key: None for key in range(N)}  # 色というかグループ #intで表す #Noneは未訪問を示す
# graphをdefault dictで保持することにする。
for _ in range(M):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)

# 離接リストをもとに、たどり着ける友達関係をグループ化する #(union findが使える気もするけどここではDFSで領域を探索していく)


def dfs(node: int, co: int):
    # 終了条件 #すでに訪問済みなら訪問しない
    if color[node] is not None:
        return
    # 処理
    color[node] = co
    # 探索
    for n in G[node]:
        dfs(n, co)
    return


# すべてのnodeを開始点としてdfsで領域わけしてみる
c = 1
for node in G.keys():
    dfs(node, c)  # 訪問済みだったら色を塗り替えないというないようはdfs関数内の処理で吸収できる
    c += 1


# 問題に回答していく
Q = int(input())
for _ in range(Q):
    s, t = list(map(int, input().split()))
    if ((color[s] is not None) or (color[t] is not None)) and (color[s] == color[t]):
        # s,tも友達がいて、かつ同じグループだったら
        print('yes')
    else:
        print('no')



Measured memory_bytes: 143920
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

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

	for(int x, h; scanf("%d %d", &x, &h), x | h;) {
		const double o = hypot(x / 2.0, h);
		const double s = o * x * 2.0 + x * x;
		printf("%.10lf\n", hypot(x / 2.0, h) * x * 2.0 + x * x);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1256
//https://ideone.com/x8zpRc
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=100000,M=100000;


 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
//priority_queue<ll,vector<ll>,greater<ll>>y;
input;

string s;
cin>>s;

if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])cout<<"Bad";
else cout<<"Good";







return 0;
}


Measured memory_bytes: 256
def main():
    A, B = (int(i) for i in input().split())

    def f(X):
        X += 1
        bi = []
        d = 2
        for i in range(40):
            v = (X//d) * (d//2) + max((X % d) - (d//2), 0)
            bi.append(v)
            d *= 2
        return bi

    ans = 0
    d = 0
    fA = f(A-1)
    fB = f(B)
    # print(fA, fB, sep="\n")
    for a, b in zip(fA, fB):
        v = max(b - a, 0)
        if v % 2 == 1:
            ans += 2**d
        d += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int a,b;
	cin >> a >> b ;
	if(b%a == 0) cout << a+b << endl;
	else cout << b-a << endl;
}


Measured memory_bytes: 384
def solve_uresisa(cash,uresisalist):
    coins = uresisalist.keys()
    uresisa = 0
    for coin in coins:
        uresisa += cash//coin * uresisalist[coin]
        cash = cash % coin
    return uresisa

uresisalist = {500:1000,5:5}
cash = int(input())
print(solve_uresisa(cash,uresisalist))

Measured memory_bytes: 2940
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_101_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 S      PIC X(4).
    01 len    PIC 9(1)   VALUE 1.

    01 i      PIC 9(1).

    01 ans    PIC X(2).
    01 SS     PIC S9(1).
    01 ZS     PIC -(2)9.
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT S.

    MOVE 0 TO ZS.

    PERFORM VARYING i FROM 1 BY 1 UNTIL 4 < i
        IF S(i:len) = '+' THEN
            ADD 1 TO SS
        ELSE
            SUBTRACT 1 FROM SS
        END-IF
    END-PERFORM.

    MOVE SS TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).

    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int[] ia = readNums();
		Arrays.sort(ia);
		int a = 0;
		int b = 0;
		boolean bAlice = true;
		for (int i = n - 1; i >= 0; i--) {
			if (bAlice) {
				a += ia[i];
			} else {
				b += ia[i];
			}
			bAlice = !bAlice;
		}
		pln(a - b);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string s; cin >> s;
  int l = s.length();
  string result = "No";
  rep(i,l) for (int j=i+1; j<l; j++) {
    if (s[i]=='C'&&s[j]=='F') result = "Yes";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused)]
use std::cmp::{max, min};

#[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")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        p: [i64; n],
    }

    let mut count = 0;
    for i in 1..n - 1 {
        if (p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i - 1] < p[i] && p[i] < p[i + 1]) {
            count += 1;
        }
    }
    println!("{}", count);
}

Measured memory_bytes: 4352
#include <stdio.h>

#define MAX 2000000
#define AN 10000

/*
 * Runtime Error
 */

void counting_sort(int B[], int Bn)
{
    int A[AN];
    int C[MAX];
    for (int i = 0; i < AN; i++) {
        A[i] = 0;
    }

    for (int i = 0; i < Bn; i++) {
        A[B[i]]++;
    }

    int q = 0;
    for (int i = 0; i < AN; i++) {
        for (int j = 0; j < A[i]; j++) {
            C[q++] = i;
        }
    }
    for (int i = 0; i < Bn; i++) {
        if (i) printf(" ");
        printf("%d", C[i]);
    }
    printf("\n");
}

int main(int argc, char const *argv[])
{
    int B[MAX];

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &B[i]);
    }

    counting_sort(B, n);

    return 0;
}



Measured memory_bytes: 17404
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

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


int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  int g = a[0];
  rrep(i, n-1) {
    g = gcd(g, a[i]);
  }
  sort(ALL(a));
  if (k%g == 0 && a[n-1] >= k) cout << "POSSIBLE\n";
  else cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 3676
N = int(input())
h = list(map(int, input().split()))

h_inf = 10 ** 10
dp = [h_inf] * N
dp[0] = 0

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

print(dp[N-1])


Measured memory_bytes: 13924
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  int count1[MAX], count2[MAX];
  fill(count1, count1 + MAX, 0);
  fill(count2, count2 + MAX, 0);
  for(int i = 0; i < n; i += 2){
    ++count1[a[i]];
    ++count2[a[i + 1]];
  }

  int m1_1 = 0, m1_2 = 0, m2_1 = 0, m2_2 = 0;
  for(int i = 1; i < MAX; i++){
    if(count1[i] > count1[m1_1]){
      m1_2 = m1_1; m1_1 = i;
    }
    else if(count1[i] > count1[m1_2]){
      m1_2 = i;
    }
    if(count2[i] > count2[m2_1]){
      m2_2 = m2_1; m2_1 = i;
    }
    else if(count2[i] > count2[m2_2]){
      m2_2 = i;
    }
  }

  int count = 0;
  if(m1_1 != m2_1){
    for(int i = 0; i < n; i += 2){
      if(a[i] != m1_1) ++count;
      if(a[i + 1] != m2_1) ++count;
    }
  }
  else{
    int c1 = 0, c2 = 0;
    for(int i = 0; i < n; i += 2){
      if(a[i] != m1_1) ++c1;
      if(a[i + 1] != m2_2) ++c1;
    }
    for(int i = 0; i < n; i += 2){
      if(a[i] != m1_2) ++c2;
      if(a[i + 1] != m2_1) ++c2;
    }
    count = min(c1, c2);
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1408
import sys
import math



H,W,K=map(int,input().split())
a=[[0 for j in range(W)] for i in range(H)]
for i in range(H):
    s=input()
    for j in range(W):
        if s[j]=="#": a[i][j]=1

sig=[sum(a[i]) for i in range(H)]
for i in range(H):
    if sig[i]>0:
        p=i
        break



tmp=0
b=[[0 for j in range(W)] for i in range(H)]
for i in range(p,H):
    if sig[i]>0:
        tmp+=1
        tmp2=sig[i]
        for j in range(W):
            b[i][j]=tmp
            if a[i][j]==1 and tmp2>1:
                tmp+=1
                tmp2-=1
    else:
        for j in range(W):
            b[i][j]=b[i-1][j]

for i in range(p-1,-1,-1):

    for j in range(W):
        b[i][j]=b[i+1][j]


for i in range(H):
    for j in range(W-1):
        print(b[i][j],end=" ")
    print(b[i][W-1])


Measured memory_bytes: 8272
#include <stdio.h>
#include <iostream>

using namespace std;

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a > b) {
        if (a > c) {
            cout << b + c << endl; // maximum = a
        } else {
            cout << b + a << endl; // maximum = c
        }
    } else {
        if (b > c) {
            cout << a + c << endl; // maximum = b
        } else {
            cout << a + b << endl; // maximum = c
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {
    int N,K;
    cin >> N >> K;

    int count = 1;
    while(N>=K){
        N /= K;
        count ++;
    }

    cout << count << endl;

    return 0;
}

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

#define SIZE 200001

using namespace std;

int main() {
    long long int A,B,C,D,i,j,k,M,K,Q;
    long long int X,N,Y,Z,N0,N1,N2,N3;
  //  long long int A[100][100];

    cin >> N;
    string S;

    N0 = 0;
    N1 = 0;
    N2 = 0;
    N3 = 0;
    for (i=0;i<N;i++) {
      cin >> S;
      if (S=="AC")
        N0++;
      else if (S=="WA")
        N1++;
      else if (S=="TLE")
        N2++;
      else if (S=="RE")
          N3++;
    }
    cout << "AC x " << N0 << endl;
    cout << "WA x " << N1 << endl;
    cout << "TLE x " << N2 << endl;
    cout << "RE x " << N3 << endl;

  return 0;

}


Measured memory_bytes: 3624
a, b, c, x, y = map(int, input().split())
if a + b <= 2 * c:
    print(a * x + b * y)
else:
    if x >= y:
        if a <= 2 * c:
            print((x - y) * a + y * 2 * c)
        else:
            print(2 * x * c)
    else:
        if b <= 2 * c:
            print((y - x) * b + x * 2 * c)
        else:
            print(2 * y * c)

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

int main(){
    int h,n;
    cin>>h>>n;
    vector<int> cost(n), damage(n);
    for(int i=0; i<n; i++){
        cin>>damage[i]>>cost[i];
    }
    vector<int> dp(10001,1000000000);
    dp[h]=0;
    for(int i =0; i<n;i++){
        for(int j=h; j>=1; j-- ){
            int k=max(0, j-damage[i]);
            dp[k] = min(dp[k], dp[j]+cost[i] );
        }
    }
    cout<<dp[0]<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std; 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()  
{ 
    FAST_INP;
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ok=0;
    while(k--){
    	if(b<=a) b*=2;
    	else c*=2;
	}
	if(b>a&&c>b) cout << "Yes\n";
	else cout <<"No\n";
    return 0;
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int N;
int loc[105];
int main() {
    cin >> N;
    for (int i=0; i<N; i++) scanf("%d", &loc[i]);
    int ans = INT_MAX;
    for (int i = -100; i<= 100; i++){
        int temp = 0;
        for (int j=0; j<N; j++) temp += (loc[j]-i)*(loc[j]-i);
        ans = min(temp, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    // ?
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };

    // stdinの生成 値の読み込み開始
    ($($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)*}
    };
}

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)*}
    };
}

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<_>>()
    };

    // 文字列Vec<char>の読み込み
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    // usize1?の読み込み
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // 指定した型で読み込み
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
    };

    println!("{}", solve(n));
}

fn solve(r: usize) -> &'static str{
    if r < 1200 {
        return "ABC"
    }
    if r < 2800 {
        return "ARC";
    }
    return "AGC";
}

macro_rules! tests {
    ($($name:ident:[$( $args:expr ),*] => $output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output,super::solve($($args),*));
                }
            )*
        }
    }
}


tests! {
    //テスト名:[引数]=>expected
    test1:[1199]=>"ABC",
    test2:[1200]=>"ARC",
    test3:[4208]=>"AGC",
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll N, A, B;
  // N合計, A青, B赤

  cin >> N >> A >> B;

  ll C = A + B;
  ll L = N % C;

  if(L < A){
    cout << A*(N/C) + L << endl;
  }
  else{
    cout << A*(N/C) + A << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#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 COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N;
int main() {
    while (cin >> N) {
        long long res = 0;
        for (int i = 1; i <= N; ++i) {
            if (i % 3 != 0 && i % 5 != 0) res += i;
        }
        cout << res << endl;
    }
}

















Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int h, w; cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == -1) continue;
            int now = a[i][j];
            ans += c[now][1];
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
import sys
f = sys.stdin


def create_prime(n):
    prime = [1] * (n + 1)
    prime[:2] = [0, 0]
    for i in range(len(prime)):
        if prime[i]:
            for j in range(2 * i, len(prime), i):
                prime[j] = 0
    return prime

prime = create_prime(200000)

while True:
    n = int(f.readline())
    if n == 0:
        break
    s = 0
    for i in range(len(prime)):
        if prime[i]:
            s += i
            n -= 1
            if n == 0:
                print(s)
                break

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

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,t=0,t_=0;cin>>n;
  lvector c(n-1,0),s(n-1,0),f(n-1,0),ans(n,0);
  rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
  rep(i,n-1) {
    t=s[i]+c[i];ans[i]=t;
    for(ll j=i+1;j<n-1;++j) {
      t_=0;
      if(t>s[j]) {
        while(t>s[j]+t_) t_+=f[j];
        t=s[j]+t_;
      }
      else t=s[j];
      t=t+c[j];ans[i]=t;
    }
  }
  rep(i,n) print(ans[i]);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  int i, j;

  for(i = 0; i < 9; i++){
    for(j = 0; j < 9; j++){
      printf("%dx%d=%d\n", i+1, j+1, (i+1)*(j+1));
    }
  }
  return 0;
}

Measured memory_bytes: 524
a,b = (int(x) for x in input().split())
ans1 = a+b
ans2 = a-b
ans3 = a*b

if ans1 > ans2:
    if ans1 > ans3:
        print(ans1)
    else:
        print(ans3)

else:
    if ans2 > ans3:
        print(ans2)
    else:
        print(ans3)
        


Measured memory_bytes: 2940
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	ll n = s.size();
	string t;
	while(n > 0){
		t += "hi";
		n -= 2;
	}
	if(s == t) puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;
const ld PI = 3.14159265358979323846;

vector <vector<ll>> graph;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin >> n >> m;
	graph.resize(n+1);
	for (int z=0;z<m;z++){
		ll u,v;
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	vector <ll> visited(n+1,false);
	vector <ll> ans(n+1);
	queue <ll> que;
	visited[1] = true;
	que.push(1);
	while (!que.empty()){
		ll u = que.front();
		que.pop();
		for (ll v : graph[u]){
			if (visited[v]) continue;
			visited[v] = true;
			ans[v] = u;
			que.push(v);
		}
	}
	cout << "Yes" << endl;
	for (int z=2;z<=n;z++){
		cout << ans[z] << endl;
	}
}

Measured memory_bytes: 13656
from math import atan, degrees

a,b,x = map(float, input().split())

D = a**2 * b / 2
S = x/a

if x == a ** 2 * b:
  deg = 90
  
elif x < D:
  Z = a - 2*S/b
  rad = atan((a-Z) / b)
  deg = degrees(rad)
  
elif x > D:
  Y = 2*S/a - b
  rad = atan(a / (b-Y))
  deg = degrees(rad)
  
else:
  rad = atan(a / b)
  deg = degrees(rad)

print(90-deg)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int b[12],c=0;
		string e[2] = { "","" };
		int d[101];
		fill(d, d + 101, 0);
		for (int i = 0; i < n; i++) {
			cin >> b[i];
			e[1] += to_string(b[i]);
			d[b[i]]++;
		}
		string h = "";
		c = 0;
		while (e[0] != e[1]) {
			e[0] = e[1];
			e[1] = "";
			for (int i = 0; i < n; i++) 
				b[i] = d[b[i]];
			fill(d, d + 101, 0);
			for (int i = 0; i < n; i++) {
				d[b[i]]++;
				e[1] += to_string(b[i]);
			}
			c++;
		}
		cout << c - 1 << endl;
		for (int i = 0; i < n; i++) {
			if (i == 0)
				cout << b[i];
			else
				cout << " " << b[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        
        static void SolveA(string[] args)
        {
            int[] ni = ReadAndParseIntArr();
            int n = ni[0];
            int i = ni[1];
            int ans = n - i + 1;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140