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

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

    int H, N;
    cin >> H >> N;
    vector<int> skills(N);
    rep(i, N) cin >> skills[i];

    int sum = 0;
    for (auto num : skills) sum += num;
    if (H - sum <= 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 640
fun main() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val grid = (0 until h).map { readLine()!! }
    
    val d = listOf(0, 1, 0, -1)
    var ans = true
    
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (grid[i][j] == '.') continue
            
            var drawable = false
            for (k in 0 until 4) {
                val di = i + d[k]
                val dj = j + d[k xor 1]
                if (di in 0 until h && dj in 0 until w) {
                    if (grid[di][dj] == '#') drawable = true
                }
            }
            if (!drawable) ans = false
        }
    }
    
    println(if (ans) "Yes" else "No")
}


Measured memory_bytes: 40980
A, B = map(int, input().split())
x = 0
while int(x * 0.08) <= A or int(x * 0.1) <= B:
    x += 1
    if int(x * 0.08) == A and int(x * 0.1) == B:
        print(x)
        exit()
print(-1)


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

int main() {
  int n;
  std::cin >> n;
  if (n%10 == 3) {
    std::cout << "bon" << std::endl;
  }
  else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) {
    std::cout << "pon" << std::endl;
  }
  else {
    std::cout << "hon" << std::endl;
  }
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int b = scan.nextInt();
        int a = scan.nextInt();
        int ans=0;
        for(int i=0;i<=b;i++){
        	for(int n=0;n<=b;n++){
        		int f= a-i-n;
        		if(f<=b&&f>=0){
        			ans++;
        		}
        	}
        }
        System.out.println(ans);
	}
}

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

int main(){
    int k=0;
    int a=0;
    int b=0;
    cin >> k >> a >> b;
    bool ans= false;
    int e = b-a+1;

    //aからｂの数を配列で受け取って一つずつｋで割った余りを調べる
    vector<int> c(b-a+1);

    for(int i=0; i<e; i++){
        c.at(i) = a;
        a++;
    }

    for(int i=0; i<e; i++ ){
        if (c.at(i) % k ==0){
            ans = true;
        }

    }

    if(ans){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
vvl g,df;
vl dp;
ll m,n;
inline ll mul(ll a, ll b) {
	return (a*b)%m;
}
inline ll ad(ll a, ll b) {
	return (((a+b)%m)+m)%m;
}
void dff(int v, int p) {
	ll ac = 1;
	for(int i=0;i<g[v].size();i++) {
		if(g[v][i] == p) {continue;}
		dff(g[v][i],v);
		ac = mul(ac,dp[g[v][i]]+1);
	}
	dp[v] = ac;
	ac = 1;
	for(int i=0;i<g[v].size();i++) {
		if(g[v][i] == p) {continue;}
		df[v][i] = mul(df[v][i],ac);
		ac = mul(ac,dp[g[v][i]]+1);
	}
	ac=1;
	for(int i=g[v].size()-1;i>=0;i--) {
		if(g[v][i] == p) {continue;}
		df[v][i] = mul(df[v][i],ac);
		ac = mul(ac,dp[g[v][i]]+1);
	}
}
void dfs(int v, int p,ll mp) {
	dp[v] = mul(dp[v],mp);
	for(int i=0;i<g[v].size();i++) {
		if(g[v][i] == p) {continue;}
		dfs(g[v][i],v,ad(mul(mp,df[v][i]),1));
	}
}
int main() {
	scanf("%lld %lld\n",&n,&m);
	g.assign(n,vl());
	df.assign(n,vl());
	dp.assign(n,1);
	for(int i=0;i<n-1;i++) {
		int a,b;
		scanf("%d %d ",&a,&b);
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
		df[a].push_back(1);
		df[b].push_back(1);
	}
	dff(0,-1);

	dfs(0,-1,1);
	for(int i=0;i<dp.size();i++) {
		printf("%lld\n",dp[i]);
	}
}


Measured memory_bytes: 17664
require 'prime'

N, M = gets.chomp.split.map(&:to_i)

MOD = 10 ** 9 + 7

class Integer
  def repeated_combination(k)
    (k + self - 1).combination(k)
  end

  def combination(k)
    (self - k + 1..self).inject(&:*) / k.factorial
  end

  def factorial
    return 1 if self == 0
    (1..self).inject(&:*)
  end
end

ans = 1

M.prime_division.each do |base, k|
  ans = (ans * N.repeated_combination(k)) % MOD
end

puts ans


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int co = 0;
  int ans = 0;
  rep(i, N) {
    rep(j, N) {
      if(S.at(i) == S.at(j)) {
        co++;
      }
    }
    if(co > 1) {
      ans++;
      break;
    }
    co = 0;
  }
  if(ans == 0) {
    cout << "yes" << endl;
  }
  else {
    cout << "no" << endl;
  }
}

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

#define int int64_t
#define rep(i,a,n) for(int i=(a); i<(n); ++i)
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define re(s) reverse((s).begin(),(s).end())
#define ll long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3fLL;
const int mod = 1000000007;
using namespace std;

pair<pair<string,int>,int> x[110];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,a;
    string s;
    cin>>n;
    
    rep(i,0,n){
        cin>>s>>a;
        x[i] = make_pair(make_pair(s,-a),i);
    }

    sort(x,x+n);

    rep(i,0,n){
        cout<<x[i].second+1<<'\n';
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
	int r, d, x;
	scanf("%d%d%d", &r, &d, &x);
	for (int i = 1;i <= 10;i++)
	{
		x = r*x - d;
		printf("%d\n", x);
	}

	return 0;
}

Measured memory_bytes: 128
N = int(input())
P = list(map(int,input().split()))

ans = 0

for i in range(N-2) :
    a = P[i]
    b = P[i+1]
    c = P[i+2]
    
    Z = sorted([a,b,c])
    
    if max(Z) != b and min(Z) != b :
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ro(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
typedef vector<ll> vi;
ll n,m,x,y;
int main(){
	cin>>n>>m>>x>>y;
    vi no(n),mo(m);
    for(ll &i:no) cin>>i;
    for(ll &i:mo) cin>>i;
    sort(ro(no));
    sort(ro(mo));
    if(*min_element(ro(mo))> *max_element(ro(no))){
    	if(*min_element(ro(mo))>x && *min_element(ro(mo))<=y){
    		cout<<"No War\n";
    	}
    	else{
    		cout<<"War\n";
    	}
    }
    else{
    	cout<<"War\n";
    }
}

Measured memory_bytes: 3608
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let s: Vec<char> = iter.next().unwrap().chars().collect();
    
    let mut east = vec![0;n+1];
    let mut west = vec![0;n+1];
    let mut east_cnt = 0;
    let mut _west_cnt = 0;
    for i in 0..n {
        match s[i] {
            'E' => {
                east[i+1] = east[i] + 1;
                west[i+1] = west[i];
                east_cnt += 1;
            },
            _ => {
                west[i+1] = west[i] + 1;
                east[i+1] = east[i];
                _west_cnt += 1;
            }
        }
    }

    // dbg!(&east, &west);

    let mut ret = 1u64 << 60;
    for i in 0..n {
        let right_easts = east_cnt - east[i] - (if s[i] == 'E' {1} else {0});
        ret = std::cmp::min(west[i] + right_easts, ret);
    }
    println!("{}", ret);
}


Measured memory_bytes: 14588
#include <stdio.h>


int main(void)
{
  char num[5];
  int number, x, n=0, min=0;

  fgets(num, sizeof(num), stdin);
  sscanf(num, "%d", &number);

  for (int i = 0; i < number; i++) {
    scanf("%d", &x);

    if (x%2 == 0) {
      for (int j = x; j%2 == 0; j /= 2) {
        n++;
      }

      if (i != 0) {
        if (min > n) {
          min = n;
        }
      } else {
        min = n;
      }
      
      n = 0;
        
    } else {
      min = 0;
      break;
    }

  }

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


Measured memory_bytes: 384
/*
 * test2.cpp
 */

//include files
#include<iostream>

using namespace std;

//DEFINE MACROS
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

//DEFINE CONSTANT

//DEFINE PROTOTYPE

int main(){
  int A,B,C,X;
  cin >> A;
  cin >> B;
  cin >> C;
  X=A%B;
  for(int k = 1 ; k < 10000 ; k++){
	if((X*k)%B == C){
	  cout << "YES" <<endl;
	  return 0;
	}
	if((X*k)%B == X && k!=1){
	  cout << "NO" << endl;
	  return 0;
	}
				  
  }
  
}



Measured memory_bytes: 888
n, a, b = map(int, input().split())
x = list(map(int, input().split()))

ans = 0

dis = []
for i in range(n-1):
    # dis.append(abs(x[i+1] - x[i]))
    ans += min(a * (x[i+1] - x[i]), b)

print(ans)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		System.out.println((b / a) >= c ? c : (b / a));
	}
}

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

using namespace std;

void f(int a, int cnt, int &ans, int &k)
{
    ans += min(cnt, k) * a;
    k = max(0, k - cnt);
}

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    f(1, a, ans, k);
    f(0, b, ans, k);
    f(-1, c, ans, k);

    cout << ans;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1e3 + 3;

int n, m;
int a[N], b[N];
int dp[N][1 << 12];

int calc(int idx, int msk) {
	if (msk == (1 << n) - 1)
		return 0;
	if (idx == m)
		return OO;
	int &ret = dp[idx][msk];
	if (ret != -1)
		return ret;
	ret = calc(idx + 1, msk);
	ret = min(ret, calc(idx + 1, msk | b[idx]) + a[idx]);
	return ret;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int c, x;
		cin >> a[i] >> c;
		for (int j = 0; j < c; j++) {
			cin >> x;
			x--;
			b[i] |= 1 << x;
		}
	}
	MMS(dp, -1);
	int res = calc(0, 0);
	if (res == OO)
		res = -1;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 16384
/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
//#define mod 13
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
   ll power(ll a,ll b)//a raised to power b
   {  if(b==0)return 1;if(b==1)return a;
       ll c=power(a,b/2);
       c*=c;c%=mod;if(b%2==1)c*=a;c%=mod;
        return c;
   }
   ll mi(ll a)
   {
       return power(a,mod-2);
   }

   int main()
{   ll n;cin>>n;
    vector<ll> v(n);
      for(ll i=0;i<n;i++)cin>>v[i];
       bool ok=true;ll a=0;
        for(ll i=0;i<n;i++)
        {
            if(v[i]!=i+1)
            { a++;
               /* ll j=i+1;
                 while(j<n)
                 {
                     if(v[j]!=j+1)a++;
                     if(a>1){cout<<"NO";return 0;}
                     j++;
                 }
                 cout<<"YES";return 0;*/
            }
        }
        if(a==0||a==2)cout<<"YES";
         else cout<<"NO";


    return 0;
 }


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans +=1
print(ans)            

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    char t;
    std::cin >> t;
    int a = t - 'a';
    if(a != 25) {
        t++;
        std::cout << t << std::endl;
    } else {
        std::cout << 'a' << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

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

using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;

  vector<double> L(n), a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> L[i] >> a[i] >> b[i];
  }

  double ans = 0.0;
  for (int i = 0; i < (1 << n); i++) {
    if (bitset<32>(i).count() != m) continue;
    vector<int> v;
    for (int j = 0; j < n; j++) {
      if (!(i >> j & 1)) continue;
      v.push_back(j);
    }

    double sum = 0.0;
    for (int j = 0; j < m; j++) {
      for (int k = j + 1; k < m; k++) {
        sum += pow(L[v[j]] - L[v[k]], 2.0) + pow(a[v[j]] - a[v[k]], 2.0) + pow(b[v[j]] - b[v[k]], 2.0);
      }
    }
    ans = max(ans, sum);
  }

  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 3324
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<long long,long long> ii;
int n;
vector<ii> v;
const int pref[]={-1,9,9,3,9,9,3,9,9};
const int add[]={-1,10,11,4,13,14,5,16,17};
long long shit(vector<ii> v){
    long long ans=0;
    int top=v.back().first;
    v.back().second--;
    while (!v.empty()){
        while (v.back().second){
            if (top+v.back().first>9){
                ans+=2;
                top=top+v.back().first-9;
            }
            else{
                ans++;
                top+=v.back().first;
            }
            v.back().second--;
        }
        printf("debug shit: %d %lld\n",top,ans);
        v.pop_back();
    }
    return ans;
}
int main(){ ///firstly lets delete all 0
    scanf("%d",&n);
    long long ans=0;
    long long a,b;
    for (int x=0;x<n;x++){
        scanf("%lld%lld",&a,&b);
        if (a==0){
            ans+=b;
        }
        else{
            v.push_back(ii(a,b));
        }
    }
    reverse(v.begin(),v.end());

    //printf("%lld\n",shit(v));

    int top=v.back().first;
    long long group;
    v.back().second--;
    while (!v.empty()){
        if (v.back().first==9){
            ans+=v.back().second*2;
        }
        else{
            group=v.back().second/pref[v.back().first];
            ans+=add[v.back().first]*group;
            v.back().second-=group*pref[v.back().first];
            while (v.back().second!=0){
                if (top+v.back().first>9){
                    ans+=2;
                    top=top+v.back().first-9;
                }
                else{
                    ans++;
                    top+=v.back().first;
                }
                v.back().second--;
            }
        }
        //printf("debug good: %d %lld\n",top,ans);
        v.pop_back();
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int k;
  cin >> k;

  vector<int> R(8, -1);
  for (int i = 0; i < (int)(k); ++i) {
    int r, c;
    cin >> r >> c;
    R[r] = c;
  }

  vector<int> perm(8);
  for (int i = 0; i < (int)(8); ++i) perm[i] = i;

  auto good = [&](const vector<int>& p) {
    set<int> d1, d2;
    for (int r = 0; r < (int)(8); ++r) {
      if (R[r] != -1 && R[r] != p[r]) return false;
      d1.insert(p[r] + r);
      d2.insert(p[r] - r);
    }
    return d1.size() == 8 && d2.size() == 8;
  };

  do {
    if (good(perm)) {
      for (int i = 0; i < (int)(8); ++i) {
        for (int j = 0; j < (int)(8); ++j) cout << (perm[i] == j ? 'Q' : '.');
        cout << endl;
      }
      break;
    }
  } while (next_permutation((perm).begin(), (perm).end()));

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
using ll=long long;
struct Edge{
    int a, b, c;
};
int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> cost(n, LLONG_MIN);
    cost[0]=0;
    vector<Edge> edge(m);
    for(int i=0;i<m;++i){
        cin >> edge[i].a >> edge[i].b >> edge[i].c;
        --edge[i].a, --edge[i].b;
    }
    bool flag;
    int k;
    for(k=0;k<n;++k){
        flag=true;
        for(int i=0;i<m;++i){
            if(cost[edge[i].a]==LLONG_MIN)
                continue;
            if(cost[edge[i].b]<cost[edge[i].a]+edge[i].c){
                cost[edge[i].b]=cost[edge[i].a]+edge[i].c;
                flag=false;
            }
        }
        // for(int i=0;i<n;++i){
        //     cout << i << " " << cost[i] << endl;
        // }
        if(flag)
            break;
    }
    if(k==n && !flag){
        ll c = cost[n-1];
        for(int j=0;j<n;++j){
            for(int i=0;i<m;++i){
                if(cost[edge[i].a]==LLONG_MIN)
                    continue;
                if(cost[edge[i].b]<cost[edge[i].a]+edge[i].c){
                    cost[edge[i].b]=cost[edge[i].a]+edge[i].c;
                }
            }
        }
        if(c!=cost[n-1])
            cout << "inf";
        else
            cout << cost[n-1];
    }else{
        cout << cost[n-1];
    }
    return 0;
}

Measured memory_bytes: 256
import math
N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[abs(b[i]-a[i]) for i in range(N)]
print(sum(c))
print(math.sqrt(sum([c[i]**2 for i in range(N)])))
print((sum([c[i]**3 for i in range(N)]))**(1/3))
print(max(c))



Measured memory_bytes: 5696
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,j,n,x,k,d;
    cin>>n>>k;
    lli b[n]={0};
    for(i=0;i<k;i++){
        cin>>d;
        lli a[d];
        for(j=0;j<d;j++){
            cin>>a[j];
            b[a[j]-1]=1;
        }

    }
    sort(b,b+n);
    lli l=0;
    for(i=0;i<n;i++){
        if(b[i]==0){
            l++;
        }
        else{
            break;
        }
    }
    cout<<l;
}


Measured memory_bytes: 3616
use std::cmp::max;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let g: usize = sc.read();
    let mut p: Vec<usize> = vec![];
    let mut c: Vec<usize> = vec![];
    for _ in 0..n {
        p.push(sc.read());
        c.push(sc.read());
    }

    let total: usize = p.iter().sum();
    let mut dp = vec![0; total + 1];
    for i in 0..n {
        let point = (i + 1) * 100;
        for cur in (0..(total + 1)).rev() {
            for count in 1..(p[i] + 1) {
                if count + cur > total {
                    break;
                }
                if count == p[i] {
                    dp[cur + count] = max(dp[cur + count], dp[cur] + point * count + c[i]);
                } else {
                    dp[cur + count] = max(dp[cur + count], dp[cur] + point * count);
                }
            }
        }
    }

    for i in 0..(total + 1) {
        if dp[i] >= g {
            println!("{}", i);
            return;
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4476
num = int(input())

arr = []

for i in range(1000000):
    if num in arr:
        break
    elif num%2==0:
        arr.append(num)
        num = int(num/2)
    elif num%2==1:
        arr.append(num)
        num = num*3 + 1

print(len(arr)+1)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    output((N - 1) / 2);
    return 0;
    
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;
immutable long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto A = s[1] - 1;
    auto B = s[2] - 1;
    auto C = s[3] - 1;
    auto D = s[4] - 1;
    auto S = readln.chomp;
    bool ok1 = !S[A..min(N, C+1)].canFind("##");
    bool ok2 = !S[B..min(N, D+1)].canFind("##");

    if (C < D) {
        writeln(ok1 && ok2 ? "Yes" : "No");
    } else {
        long flip = S[B-1..min(N, D+2)].indexOf("...");
        if (flip == -1) {
            writeln("No");
            return;
        }
        writeln(ok1 && ok2 ? "Yes" : "No");
    }
}

Measured memory_bytes: 2684
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        String answer = "";
        Scanner s = new Scanner(System.in);
        long x = Long.parseLong(s.next());
        long yo = 100;
        // int a = Integer.parseInt(s.next());
        // int b = Integer.parseInt(s.next());

        for (int i = 1;;i++){
            yo *= 1.01;
            if (yo >= x) {
                answer += i;
                break;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 39076
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
p=(A[-1]//B[-1]+min(1,A[-1]%B[-1]))*B[-1]+-A[-1]
for i in range(2,N+1):
    A[-i]+=p
    p+=(A[-i]//B[-i]+min(1,A[-i]%B[-i]))*B[-i]-A[-i]
print(p)

Measured memory_bytes: 15056
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	vector<bool> D(10, true);
	rep(i, K)
	{
		int tmp = 0;
		cin >> tmp;
		D[tmp] = false;
	}


	int i;
	for(i = N;i<=99999;i++)
	{
		int tmp = i;
		bool flg = true;
		do
		{
			//下位から1桁ずつ確認
			if (!D[tmp % 10])
			{
				flg = false;
				break;
			}

		} while ((tmp = tmp / 10) > 0);

		//条件を満たす場合終了
		if (flg) break;
	}

	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ss second
#define ff first
using namespace std;
const int M = 1000000007;

int mod(int x, int m = M){
    x %= m;
    return x < 0 ? x+m : x;
}


signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s, t;
    cin>>s>>t;
    int ans = 0;

    for(int i=0; i<s.size(); i++)
        ans += (s[i] != t[i]);    

    cout<<ans<<endl;
}

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

using i64 = long long;

int main() {
#ifdef HOME
	freopen("agc09a.in", "r", stdin);
	freopen("agc09a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	vector<i64> stk;
	i64 ant, t, n;

	for (int i = 0; i < 4; ++i) {
		cin >> t;
		if (stk.empty() || stk.back() * 2 > t)
			stk.push_back(t);
		else
			stk.push_back(2 * stk.back()); }

	cin >> n; n*= 4;

	ant = 0;
	for (int i = 3; i >= 0; --i) {
		ant+= i64(stk[i]) * (n / (1 << i));
		n%= 1 << i; }

	cout << ant << endl;

	return 0; }


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

int	main()
{
  int	N, A, B;
  
  cin >> N;
  cin >> A;
  cin >> B;
  
  if (A * N <= B)
    cout << A * N << endl;
  else
    cout << B << endl;
  
  return (0);
}


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

int N, M;
ll K;
ll A[200010];
ll B[200010];

bool is_ok(int cnt_a, int mid){
  return A[cnt_a] + B[mid] <= K;
}

int binary_search(int cnt_a) {
    int left = 0; // 配列の左端(leftは条件を満たす最大のインデックス)
    int right = M+1; // 配列の右端(rightは条件を満たさない最小のインデックス)
    // 両端の差が1になるまで続ける
    while (right - left > 1){
        int mid = left + (right - left) / 2; // 区間の真ん中
        if (is_ok(cnt_a, mid)) left = mid;  // もし調べている対象が「is_okの条件」に当てはまればleftをmidまで移動
        else right = mid;  // 当てはまらなければrightをmidまで移動
    }
    return left;
}

int main(){
  cin >> N >> M >> K;
  // 0インデックスには何も読まない0という初期値をそのまま入れておく
  rep(i, N) cin >> A[i+1];
  rep(i, M) cin >> B[i+1];

  rep(i, N) A[i+1] += A[i];
  rep(i, M) B[i+1] += B[i];

  int ans = 0;
  int cnt_b;
  rep(cnt_a, N+1){
    if (A[cnt_a] > K) continue;
    cnt_b = binary_search(cnt_a);
    ans = max(ans, cnt_a + cnt_b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6668
import sys

official_house = {}
for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            official_house[(b, f, r)] = 0

n = int(sys.stdin.readline())
for line in sys.stdin:
    (b, f, r, v) = [int(i) for i in line.split()]
    official_house[(b, f, r)] += v

for b in range(1, 5):
    if b != 1:
        print("####################")
    for f in range(1, 4):
        for r in range(1, 11):
            print(" %d" % official_house[(b, f, r)], end="")
        print()

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
int dp[100004];

int solve(vector<int> &v,int k)
{
    for(int i=1;i<=k;i++)
    {
        int j=0;
        int f=1;
        while(v[j]<=i && j<v.size())
        {
            if(dp[i-v[j]]==0){
                dp[i]=1;
                f=0;
                break;
            }
            else
                j++;

        }
        if(f==1)
            dp[i]=0;


    }
    return dp[k];



}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v;

    for(int i=0;i<n;i++)
    {

        int x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    memset(dp,0,sizeof dp);
    int x=solve(v,k);
    if(x==0)
        cout<<"Second";
    if(x==1)
        cout<<"First";

    return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	int n;cin >> n;
  	long long int sum=0;
  	for(int i=1;i<=n;i++){
     	if(i%3==0||i%5==0){
        	
        }else
        	sum+=i;
    }
  	cout << sum << endl;
}

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

int main()
{
	vector<int> cnt(30);
	for (int i = 0; i < 28; i++) {
		int tmp;
		cin >> tmp;
		cnt[tmp - 1]++;
	}
	for (int i = 0; i < 30; i++) {
		if (cnt[i] == 0) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
typedef long long ll;
using namespace std;

int main() {
    int n, k, ans = 1;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        ans = min(ans*2, ans+k);
    }
    cout << ans << endl;
}

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

int main() {
	int a;
	int g = 0, n = 0;

	for (int i = 0; i < 3; i++) {
		cin >> a;
		if (a == 5)
			g++;
		else if (a == 7)
			n++;
	}

	if (g == 2 && n == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
//#include <boost/graph/adjacency_list.hpp>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define IN_V(type, name) vector<type> name; for(auto& x: name) cin >> x

int main()
{
	cout << fixed << setprecision(6);
	IN(int, n);
	//IN_V(int, als);

	int ncopy = n;
	int num = 0;
	int digit = 1;
	while (ncopy > 0) {
		if (ncopy / 10 > 0) {
			num += digit * 9;
			ncopy /= 100;
			digit *= 100;
		}
		else {
			num += (n - digit + 1);
			break;
		}
	}


	cout << num << endl;
	
	return 0;
}

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

using namespace std;

int main() {

	int x,a,b;
	
	cin >> x >> a >>  b;
	if (a - b >=0) {
		cout << "delicious" << endl;
		return 0;
	}
	else if(b-a<=x){
		cout << "safe" << endl;
		return 0;
	}
	else {
		cout << "dangerous" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
let [X, K, D] = lines[0].split(' ').map(Number)

X = Math.abs(X)
const div = Math.min(Math.floor(X / D), K)
let x = X - div * D
let k = K - div
for (let i = 0; i < k; i++) {
    x -= D
    if (x <= 0) {
        if (!((k - i) % 2)) {
            x += D
        }
        break
    }
}
console.log(Math.abs(x))

Measured memory_bytes: 29600
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
  int n;
  cin >> n;
  int v;
  vector<pair<int, int> > odd(MAX + 1); // cnt, num
  vector<pair<int, int> > even(MAX + 1); // cnt, num
  // init
  for ( int i = 0; i <= MAX; i++)odd[i] = even[i] = make_pair(0, i);

  for ( int i = 1; i <= n; i++){
    cin >> v;
    if ( i % 2 == 1){
        odd[v].first ++;
    } else {
        even[v].first ++;
    }
  }

  sort(odd.begin(), odd.end(), greater<pair<int,int>>());
  sort(even.begin(), even.end(), greater<pair<int,int>>());
  if( odd[0].second != even[0].second){
    cout << n - odd[0].first - even[0].first << endl;
  } else {
    cout << n - max(odd[0].first + even[1].first, odd[1].first + even[0].first)  << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, temp, count;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			uint64 t = mask;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			while (~map[t].first) {
				--t;
			}
			while (++t <= (mask >> 1)) {
				mkey = map[t];
				map[t].first = ~static_cast<std::uint_fast64_t>(0);
				temp = mask&hash64(mkey.first);
				while (~map[temp].first) {
					temp = mask&(temp + 1);
				}
				map[temp] = mkey;
			}
			for (t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<std::uint_fast64_t>(0);
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

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

	hashmap64<uint32> map(200001);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";

	
	return 0;
}

Measured memory_bytes: 10900
#include<iostream>
using namespace std;
int main(){
	int n,i,j;
	int a[100001];
	while(1){
		cin>>n;
		int c=0;
		int s=0;
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>a[i];
			if(a[i]<=1){
				c++;
				if(a[i]==0){
					s++;
				}
			}
		}
		if(n==1&&a[0]>=2){
			cout<<2<<endl;
		}
		else{
			if(c==n||n==1&&a[0]<=1){
				cout<<"NA"<<endl;
			}
			else{
				cout<<n-s+1<<endl;
			}
		}
	}
	return 0;
}

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

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
const int INF=1e9;

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int ans=INF;
  for(int i=0;i<=100;i++){
    int tmp=0;
    for(int j=0;j<n;j++)tmp+=(v[j]-i)*(v[j]-i);
    chmin(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

struct dish {
    ll a, b;
    dish(ll a, ll b):a(a), b(b) {}
    bool operator<(const dish& d) {
        return a + b > d.a + d.b;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<dish> D;
    ll A, B;
    rep(i, 0, N) {
        cin >> A >> B;
        D.emplace_back(A, B);
    }
    sort(all(D));
    ll ans = 0;
    rep(i, 0, N) {
        if (i % 2 == 0) {
            ans += D[i].a;
        }
        else {
            ans -= D[i].b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)

#define MAX_N 10000
#define MAX_M 600

int Q;
int M[MAX_N], D[MAX_N], h[MAX_N], m[MAX_N], n[MAX_N], t;
int K[MAX_N], L[MAX_N];
char c;

int main() {
	while (true) {
		for (int i = 0; i < MAX_N; i++) {
			M[i] = 0; D[i] = 0; h[i] = 0; m[i] = 0; n[i] = 0; K[i] = 0; L[i] = -1;
		}

		bool megami = false; 
		int zenkai = 0; 
		cin >> Q; 
		if (Q == 0) { break; }

		for (int i = 0; i < Q; i++) {
			scanf("%02d/%02d %02d:%02d %c %03d", &M[i], &D[i], &h[i], &m[i], &c, &n[i]);
			t = h[i] * 60 + m[i];
			if (c == 'I') {
				L[n[i]] = t;
			}
			if (c == 'O') {
				if (n[i] >= 1) {
					if (L[0] >= 0) {
						K[n[i]] += t - max(L[0], L[n[i]]);
					}
				}
				else {
					for (int j = 1; j < MAX_M; j++) {
						if (L[j] >= 0) {
							K[j] += t - max(L[0], L[j]);
						}
					}
				}
				L[n[i]] = -1;
			}
		}
		int maxn = 0;
		for (int i = 1; i < MAX_M; i++) {
			maxn = max(maxn, K[i]);
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 1516
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ll mod1 = 1e16 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
// freopen("in.txt", "r", stdin);
const int N = 1e5 + 5;
int t;

int main()
{
	ll a;
	while (cin >> a)
	{
		cout << a +a * a +a * a*a << endl;
	}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

// int prime[1000001];
// vector<ll> primes;

// void soe() {
//     int i,j;
//     for(i=2;i<1000001;i++) prime[i] = 1;
//     for(i=2;i<=sqrt(1000001);i++) {
//         if(prime[i] == 1) {
//             for(j=i*i;j<1000001;j+=i) {
//                 prime[j] = 0;
//             }
//         }
//     }
//     for(i=2;i<1000001;i++) {
//         if(prime[i]) primes.pb(i);
//     }
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a,b;
    cin >> a >> b;
    cout << 6-(a+b) << "\n";
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  string astr,bstr;
  cin >> a >> b;
  
  for (int i = 0; i < b; i++) { //a * b
    astr += to_string(a);
  }
    for (int i = 0; i < a; i++) { //b * a
    bstr += to_string(b);
  }
  if (astr < bstr){ cout << astr << endl;  }
  else{cout << bstr << endl;}

}

Measured memory_bytes: 256
from itertools import product
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
t1 = set([0,1,2,3])
t2= set([1,2,3])
def calc(t):
    t3 = set(t)
    if not (t3 == t1 or t3 == t2): return INF
    a, b, c = 0, 0, 0
    cnt = 0
    for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
    return abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10

ans = 10 ** 9
# 4進数の配列を生成する
# 0:未使用,1:aに使用,2:bに使用,3:cに使用
for p in product(range(4), repeat=N):
    ans = min(ans, calc(p))

print(ans)



Measured memory_bytes: 56412
package main

import (
	"fmt"
)

func main() {
	fmt.Println()
	var x int
	fmt.Scan(&x)
	fmt.Println(profit(x))
}

func profit(x int) int {
	count := 0
	for i:=float64(100);i < float64(x);{
	add := (i * 1.01) - 100
	i = float64(int(add)) +100
	count ++
	}
	return count
}


Measured memory_bytes: 1752
import std.stdio, std.conv, std.array;

void main()
{
    int N;
    readf("%d", &N);
  if(N == 25){
  	writeln("Christmas");
  }
 if(N == 24){
  	writeln("Christmas Eve");
  }
    if(N == 23){
  	writeln("Christmas Eve Eve");
  }
    if(N == 22){
  	writeln("Christmas Eve Eve Eve");
  }
    
  
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
unsigned long long a[110];

unsigned long long gcd(unsigned long long a,unsigned long long b)
{
    if(b==0)
    {
        return a;
    }
    else
    {
        return gcd(b,a%b);
    }
}
int main(void)
{
    int N;
    cin>>N;
    unsigned long long ans=1;
    for(int i=0;i<N;i++)
    {
        cin>>a[i];
        ans=ans/gcd(ans,a[i])*a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1000000], b, c;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < i; j++) {
			if (a[i] == a[j]) {
				b++;
			}
		}
		if (b == 0) {
			c++;
		}
		b = 0;
	}
	cout << c  << endl;
}


Measured memory_bytes: 3476
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Top2:
    def __init__(self,x=-1,y=-1):
        if x<y:x,y=y,x
        self.val=[x,y]
        self.s=x+y

    def __add__(self, other):
        self.val=sorted(self.val+other.val,reverse=True)[:2]
        return self

n=II()
aa=LI()
dp=[Top2(a) for a in aa]

for i in range(n):
    for j in range((1<<n)-1,-1,-1):
        if j>>i&1:continue
        dp[j|1<<i]+=dp[j]

mx=-1
for j in range(1,1<<n):
    mx=max(mx,sum(dp[j].val))
    print(mx)


Measured memory_bytes: 233088
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector< vector<bool> > G(n, vector<bool>(n, false));
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a][b] = true;
        G[b][a] = true;
    }
    vector<int> p(n);
    for (int i = 0; i < n; ++i)
        p[i] = i;
    int odp = 0;
    do
    {
        if (p[0] == 0)
        {
            bool db = true;
            for (int i = 0; i < n - 1; ++i)
                if (!G[p[i]][p[i + 1]])
                    db = false;
            if (db)
                ++odp;
        }
    } while (next_permutation(p.begin(), p.end()));
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
r, c = map(int, raw_input().split(" "))
table1 = [[0 for j in range(c)] for i in range(r)]
for i in range(r):
    table1[i] = map(int, raw_input().split(" "))

table2 = [[0 for j in range(c+1)] for i in range(r+1)]
for i in range(r):
    for j in range(c):
        table2[i][j] = table1[i][j]

for i in range(r):
    for j in range(c):
        table2[i][c] += table2[i][j]
        table2[r][j] += table2[i][j]
    table2[r][c] += table2[i][c]

ans = ""
for i in range(r+1):
    for j in range(c+1):
        ans += str(table2[i][j])
        if j!=c:
            ans += " "
    if i!=r:
        ans += "\n"

print ans

Measured memory_bytes: 6508