akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 100
using namespace std;

int main(void) {
  string S;  
  cin >> S;

  if(S == "Sunny")  cout << "Cloudy" << endl;
  if(S == "Cloudy") cout << "Rainy" << endl;
  if(S == "Rainy") cout << "Sunny" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

def gcd(x,y):
    if y > x:
        x,y = y,x
    if y == 0:
        return x
    if x%y == 0:
        return y
    else:
        return gcd(x%y,y)

L = [0]
for i in range(N):
    L.append(gcd(L[i],A[i]))
R = [0]
for i in range(N):
    R.append(gcd(R[i],A[-(i+1)]))

print(max([gcd(L[i],R[N-i-1]) for i in range(N)]))

Measured memory_bytes: 14076
# Tenka1 Programmer Beginner Contest 2019
# https://atcoder.jp/contests/tenka1-2019-beginner
# 
# 

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main(N, S, K):
    S = list(S)
    s = S[K-1]
    for i in range(N):
        if S[i] != s:
            S[i] = '*'
    S = ''.join(S)
    print(S)

N = i2n()
S = i2s()
K = i2n()
main(N, S, K)


Measured memory_bytes: 3064
H,W,K=map(int,input().split())

mat=[]
for i in range(H):
  array=[int(x) for x in input()]
  mat.append(array)
#print(mat)

answer=10**9
for i in range(2**(H-1)):
  bitarray=[]
  ii=i
  for j in range(H-1):
    bitarray.append(ii&1)
    ii>>=1
    
  #print(bitarray)
  segment_list=[]
  segment=[0]
  for k in range(len(bitarray)):
    if bitarray[k]==0:
      segment.append(k+1)
    else:
      segment_list.append(segment)
      segment=[k+1]
    
  segment_list.append(segment)
  divide_yoko=len(segment_list)-1
  #print(segment_list,divide_yoko)  
  
  white_list_segment=[0]*len(segment_list)
  sep_list=[]
  for j in range(W):
    white_list_segment_line=[0]*len(segment_list)
    for k in range(len(segment_list)):
      seg=segment_list[k]
      for s in seg:
        white_list_segment_line[k]+=mat[s][j]
        
    isLineOver=False
    if max(white_list_segment_line)>K:
      isLineOver=True
      break
    
    isOver=False
    for k in range(len(segment_list)):
      if white_list_segment[k]+white_list_segment_line[k]>K:
        isOver=True
        break

    if isOver:
      sep_list.append(j-1)
      for k in range(len(segment_list)):
        white_list_segment[k]=white_list_segment_line[k]
    else:
      for k in range(len(segment_list)):
        white_list_segment[k]+=white_list_segment_line[k]
  
  if not isLineOver:
    answer=min(answer,len(segment_list)-1+len(sep_list))
  #print(len(segment_list)-1+len(sep_list),segment_list,sep_list)
  
print(answer)

Measured memory_bytes: 49752
#include <stdio.h>

int main(void) {
    int L, R, d;
    int i;
    int count = 0;
    
    scanf("%d %d %d", &L, &R, &d);

    for(i = L; i <= R; i++) {
        if(i % d == 0) count++;
    }

    printf("%d\n", count);
    return 0;
}

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


int main(){

	int m,d,n,J,K;
	J=20;
	K=4;
	
	
	while (1) {
		cin>>m>>d;
		if (m==0) break;
		if (m==1||m==2) 
			n=(d+((m+12+1)*26)/10+(K-1)+(K-1)/4+J/4+5*J) %7;
		else
			n=(d+((m+1)*26)/10+K+K/4+J/4+5*J) %7;
		
		switch (n) {
			case 0:
				cout << "Saturday" <<endl;
				break;
			case 1:
				cout << "Sunday" <<endl;
				break;
			case 2:
				cout << "Monday" <<endl;
				break;
			case 3:
				cout << "Tuesday" <<endl;
				break;
			case 4:
				cout << "Wednesday" <<endl;
				break;
			case 5:
				cout << "Thursday" <<endl;
				break;
			case 6:
				cout << "Friday" <<endl;
				break;
			default :
				break;
		}
		
	}
		
	return 0;
}

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

int main() {
    int N; cin>>N;
    map<ll,int>mp;
    rep(i,N){
        ll a;
         cin>>a;
        mp[a]++;
    }
    vector<ll>A(2,0);
    for(auto p:mp){
        if(p.second>=4){
        A.emplace_back(p.first);
        A.emplace_back(p.first);
    }
    else if(p.second>=2){
        A.emplace_back(p.first);
    }
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    ll ans =A[0]*A[1];
    cout<<ans<<endl;
}

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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

#define MAX 302
#define MOD 998244353

int R[2][MAX][MAX][2];

void solve(int test)
{
    string s;
    int limit;
    cin >> s >> limit;
    s.push_back('0');
    int n = SIZE(s);

    CLEAR(R, 0);
    R[0][0][0][0] = 1;
    int i, j, k, l;
    FOR(i, 0, SIZE(s))
    {
        int prev = i & 1;
        int next = prev ^ 1;
        CLEAR(R[next], 0);
        FOR(j, 0, n)
            FOR(k, 0, n)
                FOR(l, 0, 2)
                    if(R[prev][j][k][l] != 0)
                    {
                        int val = R[prev][j][k][l];
                        if(s[i] == '0')
                        {
                            R[next][j][k][0] += val;
                            R[next][j][k][0] %= MOD;
                            if(l == 0 && k < n)
                            {
                                R[prev][j + 1][k + 1][l] += val;
                                R[prev][j + 1][k + 1][l] %= MOD;
                            }
                            continue;
                        }
                        if(l == 0)
                        {
                            R[next][j][k][l] += val;
                            R[next][j][k][l] %= MOD;
                        }
                        if(j > 0)
                        {
                            R[next][j - 1][k][1] += val;
                            R[next][j - 1][k][1] %= MOD;
                        }
                    }
    }

    Int res = 0;
    FOR(i, 0, n)
        if(i <= limit)
            res += R[n & 1][0][i][0];

    res %= MOD;
    cout << res << endl;
}

int main()
{
    int T = 1, t;
    //cin >> T;
    FOR(t, 0, T) solve(t);
    return 0;
}


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

int main(){
	string s;
	cin>>s;
	ll ans=0;
	if(s.find("R")!=-1)ans=1;
	if(s.find("RR")!=-1)ans=2;
	if(s.find("RRR")!=-1)ans=3;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();

		if (a > 0) {
			long temp = a;
			if (k > a) {
				a = 0;
			}
			else {
				a -= k;
			}
			k -= temp;
		}
		if (b > 0 && k > 0) {
			if (b < k){ 
				b = 0;
			}			
			else {
				b -= k;
			}
		}

		System.out.println(a + " " + b);
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
#define SUIT 4
#define RANK 13

int main(){

   int n;                           // input, n<=52
   int CardCheck[SUIT][RANK]={0};   // flag list, [suit][rank]
   int i, j;                        // loop cnt
   char suit;                      // suit num, S:0, H:1, C:2, D:3
   int suit_num;
   int rank;

   scanf("%d", &n);
   for(i=0;i<n;i++){
	   scanf(" %c %d", &suit, &rank);

	   if(suit == 'S') suit_num = 0;
	   else if(suit == 'H') suit_num = 1;
	   else if(suit == 'C') suit_num = 2;
	   else if(suit == 'D') suit_num = 3;

      CardCheck[suit_num][rank-1] = 1;
   }

   for(i=0;i<SUIT;i++){
      for(j=0;j<RANK;j++){
          if(CardCheck[i][j] == 0){
             if(i==0) printf("S");
             else if(i==1) printf("H");
             else if(i==2) printf("C");
             else if(i==3) printf("D");
             printf(" %d\n", j+1);
          }
      }
   }

   return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <algorithm>
#define mod 998244353
#define maxn 200010
#define LL long long
using namespace std;
LL fact[maxn],inv[maxn],ans,t[maxn],p;
int n,m,k,nm;
LL quick_pow(LL a,LL b){//a^b
	LL ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
void init(){
	int i;
	scanf("%d%d%d",&n,&m,&k);
	nm=n,nm=max(nm,m),fact[0]=1;
	for(i=1;i<=nm;i++)fact[i]=fact[i-1]*i%mod;//fact[i]代表i!
	inv[nm]=quick_pow(fact[nm],mod-2);
	for(i=nm-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;//inv[i]代表i!的乘法逆元
}
LL C(LL a,LL b){//组合数计算
	return fact[a]*inv[a-b]%mod*inv[b]%mod;
}
int main(){
	int i;
	init();
	ans=0,p=quick_pow(m-1,n-k-1);
	for(i=n-k;i<=n;i++){
		ans=(ans+m*p%mod*C(n-1,i-1)%mod)%mod;//C(n-1,i-1)隔板法
		p=p*(m-1)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s,t,x;
    cin>>s>>t;
    for(int i=0;i<n;i++){
        x.push_back(s[i]);
        x.push_back(t[i]);
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
	long long a = rand();
	long long b = rand();
	return a * (RAND_MAX + 1ll) + b;
}
void usaco() {
	freopen("problem.in", "r", stdin); 
	freopen("problem.out", "w", stdout);
}
// #define endl '\n'
// #define double long double
// #define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

const int MXN = 100005;
vector<int> adj[MXN];
int dist[MXN];
int par[MXN];

signed main() {

	ran(); fast();

	int n, m;
	cin >> n >> m;
	for (int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	for (int i=0; i<MXN; i++) dist[i] = INT_MAX;
	
	queue<pair<int, int>> proc;
	proc.push({1, 0});
	
	while (!proc.empty()) {
		
		auto x = proc.front(); proc.pop();
		
		int no = x.first, di = x.second;
		
		if (dist[no] < di) continue;
		dist[no] = di;
		
		for (auto x: adj[no]) {
			int ot = x;
			if (dist[ot] > di + 1) {
				dist[ot] = di + 1;
				par[ot] = no;
				proc.push({ot, di+1});
			}
		}
		
	}

	for (int i=1; i<=n; i++) {
		if (dist[i] == INT_MAX) {
			cout << "No" << endl;
			exit(0);
		}
	}

	cout << "Yes" << endl;
	for (int i=2; i<=n; i++) {
		cout << par[i] << endl;
	}

}


Measured memory_bytes: 11088
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let hw: Vec<usize> = read_vec();
    let h = hw[0];
    let w = hw[1];
    let mut cnt: Vec<u32> = vec![0; 26];
    for _ in 0..h {
        let s: String = read();
        let cv: Vec<char> = s.chars().collect();
        for c in cv {
            cnt[c as usize - 'a' as usize] += 1;
        }
    }

    if h % 2 == 0 {
        if w % 2 == 0 {
            for c in cnt {
                if c % 4 != 0 {
                    println!("No");
                    return;
                }
            }
            println!("Yes");
        } else {
            let mut tmp = 0;
            for c in cnt {
                if c % 2 != 0 {
                    println!("No");
                    return;
                } else if c % 4 != 0 {
                    tmp += 1;
                }
            }
            if tmp <= h / 2 {
                println!("Yes");
            } else {
                println!("No");
            }
        }
    } else {
        if w % 2 == 0 {
            let mut tmp = 0;
            for c in cnt {
                if c % 2 != 0 {
                    println!("No");
                    return;
                } else if c % 4 != 0 {
                    tmp += 1;
                }
            }
            if tmp <= w / 2 {
                println!("Yes");
            } else {
                println!("No");
            }
        } else {
            let mut tmp = 0;
            for i in 0..26 {
                if cnt[i] % 2 != 0 {
                    cnt[i] -= 1;
                    tmp += 1;
                }
            }
            if tmp != 1 {
                println!("No");
                return;
            }

            let mut tmp = 0;
            for c in cnt {
                if c % 4 != 0 {
                    tmp += 1;
                }
            }
            if tmp <= w / 2 + h / 2 {
                println!("Yes");
            } else {
                println!("No");
            }
        }
    }
}


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

#ifdef LOCAL

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

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, class C<A...> c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;
#else
#define debug(...) {}
#endif

const int N = 1e6;
long long infLL = 1e18;
int inf = 1e9;

int used[1000];

string zmien(string s) {
	bool changed = false;
	bool should_change = false;
	for (int i = 0; i < s.size(); i ++) {
		if (i < 0) return "-1";
		char x = s[i];
		if (used[x] || changed || should_change) {
			for (int z = (changed? 'a' : (x + 1)); z <= 'z'; z ++) {
				if (not used[z]) {
					x = z;
					break;
				}
			}
			debug(i);
			debug(x);
			debug(used[x]);
			if (used[x] || (should_change && x == s[i])) {
				if (changed) return "-1";
				used[s[i-1]] --;
				i -= 2;
				should_change = true;
				continue;
			}
			string res = "";
			for (int j = 0; j < i; j ++) {
				res += s[j];
			}
			res += x;
			return res;
		}
		used[x] ++;
	}
	if (not changed) {
		for (char i = 'a'; i <= 'z'; i ++) {
			if (not used[i]) return s + i;
		}
		for (int i = s.size() - 2; i >= 0; i --) {
			bool OK = false;
			char MIN = 'z';
			for (int j = i + 1; j < s.size(); j ++) {
				if (s[j] > s[i]) {
					OK = true;
					MIN = min(MIN, s[j]);
				}
			}
			if (not OK) continue;
			string res = "";
			for (int j = 0; j < i; j ++) res += s[j];
			res += MIN;
			return res;
		}
		return "-1";
	}
	return s;
}

int main() {
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	string res = zmien(s);
	cout << res;
}


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

int main() {
	std::string str;
	std::cin >> str;
	if ((str[0] == str[1] && str[1] == str[2]) || (str[2] == str[3] && str[1] == str[2])) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<x2+y1-y2<<' '<<y2+x2-x1<<' '<<y1-y2+x1<<' '<<x2-x1+y1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll a, b;
  cin >> a >> b;
  ll count = 0;
  for (ll i = a; i <= b; i++){
    string s = to_string(i);
    string t = s;
    reverse(all(t));
    if(s==t){
      count++;
    }
  }
  print(count);
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}



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

#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);

int main()
{int n;
	cin>>n;
	ll ans=0,t=0,m=0;
	rep(i,n){
		cin>>t;
		m=max(t,m);
		ans+=t;

	}cout<<ans-(m/2)<<endl;	
    return 0;
}

/*author  https://qiita.com/drken/items/0c88a37eec520f82b788*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


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

int main() {
    long n;
    cin >> n;
    set<long long> a;
    for(long i=0; i<n; i++) {
        long long t;
        cin >> t;
        auto itr = a.find(t);
        if (itr == a.end())
            a.insert(t);
        else
            a.erase(t);
    }
    cout << a.size() <<'\n';
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    int d, t, s;
    cin>>d>>t>>s;
    int cd = 1LL*s*t;
    if(cd >= d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0(1 by 1 too), 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t, early/late mod
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3648
s = input()
l = len(s)
h = l//2
if l%2==0:
    for i in range(1,h):
        if s[0:h-i] == s[h-i:-2*i]:
            print(len(s[:-2*i]))
            break
else:
    for i in range(1,h):
        if s[0:h-i+1] == s[h-i+1:-2*i+1]:
            print(len(s[:-2*i+1]))
            break

Measured memory_bytes: 3064
#19 ABC133B
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]

res=0
for i in range(n-1):
    for j in range(i+1,n):
        t=[(x[i][k]-x[j][k])**2 for k in range(d)]
        t=sum(t)
        if int(t**0.5)==t**0.5:
            res+=1
print(res)


Measured memory_bytes: 38384
//25
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int g[255][255]={{}};
    for(int y=0;y<n;y++){
      for(int x=0;x<n;x++){
	char c;
	cin>>c;
	g[y][x]=c=='1';
      }
    }
    int ans=0;
    int ga[255][255];
    copy(g[0],g[255],ga[0]);
    for(int y=1;y<n;y++){
      for(int x=0;x<n;x++){
	if(ga[y][x]){
	  ga[y][x]+=ga[y-1][x];
	}
      }
    }
    ans=max(ans,*max_element(ga[0],ga[255]));
    copy(g[0],g[255],ga[0]);
    for(int x=1;x<n;x++){
      for(int y=0;y<n;y++){
	if(ga[y][x]){
	  ga[y][x]+=ga[y][x-1];
	}
      }
    }
    ans=max(ans,*max_element(ga[0],ga[255]));
    copy(g[0],g[255],ga[0]);
    for(int y=1;y<n;y++){
      for(int x=1;x<n;x++){
	if(ga[y][x]){
	  ga[y][x]+=ga[y-1][x-1];
	}
      }
    }
    ans=max(ans,*max_element(ga[0],ga[255]));
    copy(g[0],g[255],ga[0]);
    for(int y=1;y<n;y++){
      for(int x=n-2;x>=0;x--){
	if(ga[y][x]){
	  ga[y][x]+=ga[y-1][x+1];
	}
      }
    }
    ans=max(ans,*max_element(ga[0],ga[255]));
    cout<<ans<<endl;
  }
  return 0;
}

    

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

map<string,int> mp;
string s[53];

int main()
{
	// freopen("input.in", "r", stdin);

	int n; cin >> n;
	int sum = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> s[i];
		int t; cin >> t;
		mp[s[i]] = t;
		sum += t;
	}
	string last;
	cin >> last;
	for(int i = 0; i < n; i++)
	{
		sum -= mp[s[i]];
		if(s[i] == last)	
			break;
	}
	cout << sum << "\n";
}

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

int main(){
	int n;
	cin >> n;
	ll b;
	vector<ll> v(n + 1 , 0);
	v[0] = 0;
	for(int i = 1; i < n + 1; i++){
		cin >> b;
		v[i] = v[i - 1] + b;
	}
	sort(v.begin(),v.end());
	ll sum = 0;
	ll t = 0;
	while(t<n){
	    if(v[t]==v[t+1]){
	      ll s=2;
	      while((t + s) <= n && v[t] == v[t+s]){
	        s++;
	      }
	      sum += s * (s - 1) / 2;
	      t += s;
	    }
	    else{
	      t++;
	    }
	  }
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n, m, l, a, k, h;
int ls[100];
int V = 20000;
int d[20000];
int s;
vector<vector<edge>> es;

void dijkstra(int s)
{
	fill(d, d + V, INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		REP(i, es[v].size())
		{
			edge e = es[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main()
{
	while (cin >> n >> m >> l >> k >> a >> h, n)
	{
		es.clear();
		m++;
		REP(i, l) cin >> ls[i];
		es.resize(n*m);
		REP(i, l)
		{
			int tmp = ls[i];
			REP(j, m-1)
			{
				es[tmp + n*j].push_back(edge{ tmp + n*j, tmp + n*(j + 1), 1 });
			}
		}

		REP(i, k)
		{
			int x, y, t;
			cin >> x >> y >> t;
			for (int j = t; j < m; j++)
			{
				es[x + n*j].push_back(edge{ x + n*j, y + n*(j-t), t });
				es[y + n*j].push_back(edge{ y + n*j, x + n*(j-t), t });
			}
		}
		dijkstra(a + (m-1)*n);
		int ans = INF;
		REP(i, m)
		{
			ans = min(ans, d[h + n*i]);
		}
		if (ans == INF) puts("Help!");
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;

char dec(char c) {
    if(isdigit(c)) {
        int d = c - '0';
        d = (d - 1 + 10) % 10;
        return '0' + d;
    }
    return c;
}

char inc(char c) {
    if(isdigit(c)) {
        int d = c - '0';
        d = (d + 1) % 10;
        return '0' + d;
    }
    return c;
}

int main() {
    int N; cin >> N;
    while(N--) {
        string op; cin >> op;
        reverse(op.begin(), op.end());
        string s; cin >> s;
        for(char c : op) {
            if(c == 'J') s = s.substr(s.length() - 1) + s.substr(0, s.length() - 1);
            if(c == 'C') s = s.substr(1) + s.substr(0, 1);
            if(c == 'E') {
                if(s.length() & 1) {
                    s = s.substr(s.length() / 2 + 1) + s.substr(s.length() / 2, 1) + s.substr(0, s.length() / 2);
                }
                else {
                    s = s.substr(s.length() / 2) + s.substr(0, s.length() / 2);
                }
            }
            if(c == 'A') reverse(s.begin(), s.end());
            if(c == 'P') for(int i = 0; i < (int)s.length(); i++) s[i] = dec(s[i]);
            if(c == 'M') for(int i = 0; i < (int)s.length(); i++) s[i] = inc(s[i]);
        }
        cout << s << endl;
    }
}

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

int main(){
  int smallb,largeb,needwater;
  cin >> largeb >> smallb >> needwater;

  int minmoney = 0;
  

  while(needwater > 0) {//必要な水が0以下になったら終了(0以上の時にループに入る)
    //1000mlのほうが安かった
    if(largeb <= smallb){
      minmoney+=largeb;
      needwater -= 1000;
      continue;
      //while文の頭に戻る
    }
    //500mlのほうが安かった
    if(largeb >= smallb*2){
      minmoney+= smallb;
      needwater -= 500;
      continue;
    }
    
    //残り1000ml未満
    if(needwater < 1000){
      if(needwater <= 500){
	minmoney += smallb;
	needwater -= 500;
	continue;
      }
    }

    //一般的な値だった
    minmoney += largeb;
    needwater -= 1000;
  }
  cout << minmoney << endl;
}



Measured memory_bytes: 3124
#include <stdio.h>

int sum ( int a , int b , int n ) {
	int i , sum = 0;
	
	for ( i = 0; i < n; i++ ) {
		a = a % b;
		if ( a < b ) a *= 10;
		sum += a / b;
	}
	return sum;
}

int main (void) {
	int a , b , n , ans;
	while ( scanf("%d %d %d",&a,&b,&n) != EOF ) {
		ans = sum(a,b,n);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	string S;
	cin >> S;
	int B = 0;
	ll ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'B') B++;
		else ans += B;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3732
a, b = map(int, input().split())
if(a in [4, 6, 9, 11]):
	print("Yes" if (b in [4, 6, 9, 11]) else "No")
elif(a in [1, 3, 5, 7, 8, 10, 12]):
	print("Yes" if (b in [1, 3, 5, 7, 8, 10, 12]) else "No")
else:
	print("No")

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

using namespace std;

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

    int alen = a.length(), blen = b.length();
    if(alen != blen){
        cout << (alen<blen ? "LESS" : "GREATER") << endl;
        return 0;
    }

    for(int i=0; i<alen; i++){
        if(a[i] != b[i]){
            cout << (a[i]<b[i] ? "LESS" : "GREATER") << endl;
            return 0;
        }
    }

    cout << "EQUAL" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N),b(N),c(N-1);
  for(int i = 0; i < N; ++i){
    cin >> a[i];
  }
  for(int i = 0; i < N; ++i){
    cin >> b[i];
  }
  for(int i = 0; i < N-1; ++i){
    cin >> c[i];
  }
  int cnt = 0;
  for(int i = 0; i < N; ++i){
    cnt += b[a[i]-1];
  }
  for(int i = 0; i < N-1; ++i){
    if(a[i+1] == a[i] + 1){
      cnt += c[a[i]-1];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
// Akshit Awasthi
#include <bits/stdc++.h>
#define int long long
#define float long double
#define ar array
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(x) x.begin(), x.end()
#define deb(...) cerr << "[" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "]\n"
#define deb2(x, y) cerr << #x << " = " << x << "\t" << #y << " = " << y << endl
#define fastio                    \
    std::ios::sync_with_stdio(0); \
    std::cin.tie(NULL);           \
    std::cout.tie(NULL)
#define mod1 1000000007
#define mod2 998244353
#define mod mod1
#define MAX 200015
using namespace std;

template <class T>
istream& operator>>(istream& stream, vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream >> v[i];
    return stream;
}
template <class T1, class T2>
istream& operator>>(istream& stream, pair<T1, T2>& p) {
    return stream >> p.first >> p.second;
}
template <class T>
ostream& operator<<(ostream& stream, const vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream << v[i] << ' ';
    stream << '\n';
    return stream;
}
template <class T1, class T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& pair) {
    return stream << pair.first << ' ' << pair.second;
}
int pow(int a, int n) {
    if (n < 0) return 0;
    int ans = 1;
    while (n) {
        if (n & 1) ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int __lcm(int a, int b) { return (a / __gcd(a, b)) * b; }
int fact(int n) { return n == 0 ? 1LL : n * fact(n - 1) % mod; }
int inverse(int x, int p = mod) { return pow(x, p - 2); }
int nck(int n, int k, int p = mod) {
    return fact(n) * inverse(fact(k), p) % p * inverse(fact(n - k)) % p;
}

vector<int> arr;

void solve(void) {
    int n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int32_t main(void) {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("error.txt", "w", stderr);
    // #endif
    fastio;
    // cout.setf(std::ios::unitbuf);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
vector<vector<pair<int, int>>> lim(305);
ll dp[305][305][305];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m) {
        int l, r, x;
        cin >> l >> r >> x;
        lim[r].push_back(make_pair(l, x));
    }
    dp[0][0][0] = 1;
    rep(i, n + 1)rep(j, n + 1)rep(k, n + 1) {
        if (i != 0 && (i == j || i== k)) continue;
        if (j != 0 && j == k) continue;
        int nx = max({i, j, k}) + 1;
        for (auto p : lim[nx - 1]) {
            int l = p.first;
            int ki = p.second;
            int cnt = 0;
            if (i >= l) cnt++;
            if (j >= l) cnt++;
            if (k >= l) cnt++;
            if (cnt != ki) dp[i][j][k] = 0;
        }
        (dp[nx][j][k] += dp[i][j][k]) %= mod;
        (dp[i][nx][k] += dp[i][j][k]) %= mod;
        (dp[i][j][nx] += dp[i][j][k]) %= mod;
    }
    ll ans = 0;
    rep(j, n)rep(k, n) {
        if (j != 0 && j == k) continue;
        (ans += dp[n][j][k]) %= mod;
    }
    rep(i, n)rep(k, n) {
        if (i != 0 && i == k) continue;
        (ans += dp[i][n][k]) %= mod;
    }
    rep(i, n)rep(j, n) {
        if (i != 0 && i == j) continue;
        (ans += dp[i][j][n]) %= mod;
    }
    //rep(i, n + 1)rep(j, n + 1)rep(k, n + 1) cout << dp[i][j][k] << endl;
    cout << ans % mod << endl;
}


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

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

using namespace std;

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

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

void solve() {
  int N; cin >> N;
  vi32 p(N); cin >> p;

  int ans = 0;
  rep(i, N) {
    if (i + 1 == p[i]) {
      if (i + 2 <= N) swap(p[i], p[i + 1]);
      ans++;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 640
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
int main(){
		int n,i;
		int b[100000],a[100000];
		long long ans=0;
		scanf("%d",&n);
		for(i=0;i<n-1;i++)scanf("%d",&b[i]);a[0]=b[0],a[n-1]=b[n-2];
		for(i=1;i<n-1;i++){
				a[i]=min(b[i],b[i-1]);
		}
		for(i=0;i<n;i++)ans+=a[i];
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int pal=1;
    string s;

    cin>>s;
        int n=s.length();
    for(int i=0;i<n;i++)
    {
    	if(s[i]!=s[n-1-i])
    	{
		pal=0;
		break;
     	}
	}
	
	if(pal)
	{
		int w=(n-1)/2;
		for(int i=0;i<w;i++)
		if(s[i]!=s[w-1-i])
		{
			pal=0;
			break;
		}
	}
	
		if(pal)
	{
		int u=(n+2)/2;
		for(int i=u;i<n;i++)
		if(s[i]!=s[n-1-i])
		{
			pal=0;
			break;
		}
	}
	
	if(pal==1)
	cout<<"Yes";
	else cout<<"No";
	
	return 0;
}
	
	
	

Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int x=Integer.parseInt(scan.next());
    		
    		if (a==x||(a+b>=x&&a<=x)) {
    			System.out.print("YES");
    		}else {
    			System.out.print("NO");
    		}
    		


    		
     
    }
    }
// end 

Measured memory_bytes: 22612
import sys
def q(a,h):
 d[a]=h
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
n=int(input())
for e in sys.stdin:
 e=e.split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,range(n))))


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

using namespace std;

typedef long long llint;

int len[3], p[3];
string s[3];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
        len[i] = s[i].size();
    }
    int curr = 0;
    while (1) {
        if (p[curr] == len[curr]) break;
        p[curr]++;
        curr = s[curr][p[curr] - 1] - 'a';
    }
    cout << (char) ('A' + curr);
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll a,b;
	cin>>a>>b;
	for(ll i=0;i<=1000000;i++){
		if(i*8/100==a&&i*10/100==b){
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 3684
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		String T = in.next();
		Map<Character, Character> ma = new HashMap<>();
		Map<Character, Character> ima = new HashMap<>();
		boolean isOk = true;
		for (int i = 0; i < S.length(); i++) {
			char s = S.charAt(i);
			char t = T.charAt(i);
			if (ma.containsKey(s)) {
				if (ma.get(s) != t) {
					isOk = false;
				}
			}
			if (ima.containsKey(t)) {
				if (ima.get(t) != s) {
					isOk = false;
				}
			}
			ma.put(s, t);
			ima.put(t, s);
		}
		System.out.println(isOk ? "Yes" : "No");
		in.close();
	}
}

Measured memory_bytes: 27296
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>
#include <iomanip>

#define rep(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define FOR(i,s,e) for(int (i) = (s); (i)<(e); (i)++)
#define vecall(itr,vec) for(auto (itr) = (vec).begin(); (itr) != (vec).end(); (itr)++) 

using namespace std;
using p = pair<int, int>;
using ll = long long;

vector<vector<int>> path;

int main() {
	int n, m;
	cin >> n >> m;
	path.resize(n);
	vector<int> ans(n,100002);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		path[a - 1].push_back(b - 1);
		path[b - 1].push_back(a - 1);
	}

	vector<int> queue;
	queue.push_back(0);
	ans[0] = 0;
	while (queue.size() != 0)
	{
		int now = queue[0];
		

		queue.erase(queue.begin());
		vecall(itr, path[now]) {
			if (ans[now] + 1 < ans[*itr]) {
				queue.push_back(*itr);
				ans[*itr] = ans[now] + 1;
			}
		}
		
	}
	string s = "Yes";
	vecall(itr, ans) {
		if (*itr == n + 1) s = "No";

	}
	int depth = 0;
	vector<int> x(n,-1);
	x[0] = 0;
	FOR(i, 1, n) {
		depth = ans[i];
		vecall(itr, path[i]) {
			if (ans[*itr] == depth - 1) {
				x[i] = *itr;
				break;
			}
		}
		if (x[i] == -1) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << s << endl;
	FOR(i, 1, n)cout << x[i] + 1 << endl;
	return 0;

}

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PII pair<int, int>

int main()
{
    FAST_IO
    int x;
    long long ans;

    cin >> x;

    ans = (long long)1000*(x/500);
    ans += ((x%500)/5)*5;

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
inp = list(map(int, input().split()))
H = inp[0]

flag = False
vv = []
vv.append(H)
sum = 0

a = 1
for count in range(1,10000000000000000000000):
    if vv[len(vv)-1] != 1:
        sum += a
        a = a*2
        vv.append(int(vv[len(vv)-1] // 2))
    else:
        sum += a
        break

print(sum)
    

Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict 
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    dd_a = defaultdict(int)
    dd_b = defaultdict(int)
    for i in range(N):
        dd_a[i-A[i]] += 1
        dd_b[A[i]+i] += 1
    ans = 0
    for i in dd_a.keys():
        ans += dd_a[i] * dd_b[i]
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 74260
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
ll dfs(ll a,ll b){
	ll c;
	if(a==b) return a;
	if(a>b) swap(ll,a,b);
	c=(b-1)/a;
	return 2*a*c+dfs(a,b-a*c);
}
int main(void)
{
	ll n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",n+dfs(x,n-x));
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int N = S.length();
	int ans = 0;
	for (int i = 0; i < N / 2; i++) if (S[i] != S[N - i - 1]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::cout<<std::fixed<<std::setprecision(5);
    int n;cin>>n;
    double a[n];
    double s=1,ans=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        s*=a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        ans+=s/a[i];
    }
    ans=s/ans;
    std::cout<<ans;
    

}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1000

int main(void){
	int i , n;
	scanf("%d",&n);
	double a[n];
	
	for(i = 0; i < n; i++){
		scanf("%lf",&a[i]);
	}
	
	double b[n+1];
	for(i = 0; i<= n; i++){
		scanf("%lf",&b[i]);
	}
	
	double c[n+1][n+1];
	double d[n+1];
	c[0][0]=b[0];
	d[0]=a[0]+b[0];
	
	for(i = 1; i <= n; i++){
		c[i][i] = b[i];
		c[i-1][i] = a[i-1]+(b[i-1]+b[i])*2;
		d[i] = d[i-1]+a[i]+b[i];
	}
	
	int j , k;
	double x,y;
	for(i = 1;i < n; i++){
		for(j = 0; j < n-i; j++){
			x = c[j][j] + c[j+1][i+j+1];
			for(k = j; k <i+j; k++){
				y = c[j][k+1]+c[k+2][i+j+1];
				if(x>y) x = y;
			}
			c[j][i+j+1] = x + d[i+j] - d[j-1] + b[i+j+1];
		}
	}
	printf("%lf\n",c[0][n]);
	return 0;
}



Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define eps 1e-6
#define ls (rt << 1)
#define rs (rt << 1 | 1)
#define lowbit(x) (x & (-x))
#define SZ(v) ((int)(v).size())
#define All(v) (v).begin(), (v).end()
#define mp(x, y) make_pair(x, y)
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
const int M = 1e5 + 10;
const int inf = 0x3f3f3f3f;
int n, k, a[N], f[N], ans[N], tot;
vector<int> G[N];
void dfs(int u, int fa)
{
    int tp = 0, pos = 0, val = 0;
    if(a[u] > f[tot]) {
        f[++ tot] = a[u];    
    }else{
        tp = 1;
        pos = lower_bound(f + 1, f + tot + 1, a[u]) - f;
        val = f[pos];
        f[pos] = a[u];
    }
    ans[u] = tot;
    for(auto &v:G[u]) {
        if(v != fa) dfs(v, u);
    }
    if(tp) {
        f[pos] = val;
    }else{
        -- tot;
    }
}
int main(){
    int u, v;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
    for(int i = 1; i < n; ++ i) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1,0);
    for(int i = 1; i <= n; ++ i) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 30592
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)

//  ch.cpp
//
//  Created by WinnieJt on 2019/3/21.
//
//  Copyright © 2019 金天. All rights reserved.

//åß∂ƒ∆Ω≈µç∫πø∑¢∞§¶

#include<bits/stdc++.h>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
typedef long long ll;
using namespace std;
string inp;
int main(void)
{
    ios::sync_with_stdio(false);
    getline(cin,inp);
    if(inp[0]==inp[(inp.length())-1])
    {
        if((inp.length())%2==0) cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    else
    {
        if((inp.length())%2==0) cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
    return 0;
}



Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	var a, b int
	fmt.Scan(&a, &b)

	var u string
	fmt.Scan(&u)

	if u == s {
		a--
	} else {
		b--
	}
	fmt.Println(a, b)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int r = 0;
    int b = 0;
    for (int i = 0; i < S.size() ; i++){
        if(S[i] == '0'){
            r += 1;
        }
        else {
            b += 1;
        }
    }
    cout << min(r,b)*2 << endl;
}

Measured memory_bytes: 512
def main():
    N,M=map(int,input().split())
    L=2**N
    dp=[10**8 for i in range(L)]
    dp[0]=0


    for _ in range(M):
        a, _ = map(int, input().split())
        key=sum([2**(int(i)-1) for i in input().split()])
        for j in range(L):
                q=j|key
                dp[q]=min(dp[j]+a,dp[q])


    ans=dp[L-1]
    print(ans if ans<10**8 else -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
ll fastpower(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y&1)
        res*=x;

        y>>=1;
        x=x*x;
    }
    return res;
}

void swap(ll &a,ll &b)
{
    a ^= b; 
    b ^= a; 
    a ^= b;
}
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b;
    c=__gcd(a,b);
    cout<<a*b/c;
    return 0;
}

Measured memory_bytes: 256