akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
    int n,x;
    scanf("%d%d",&n,&x);
    int l[n+1];
    for(int i=1;i<=n;i++) scanf("%d",&l[i]);
    int ans=1,sum=0;
    for(int i=1;i<=n;i++){
        sum+=l[i];
        if(sum<=x)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MX = 1'000'000 + 1;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int p[MX] = {0};
  for (int &i : a) {
    cin >> i;
    p[i]++;
  }
  int pw = 1;
  for (int i = 2; i < MX; i++) {
    int cnt = 0;
    for (int j = i; j < MX; j += i) cnt += p[j];
    if (cnt > 1) pw = 0;
  }
  if (pw) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = 0;
  for (int i = 0; i < n; i++) g = gcd(g, a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11140
#import<cstdio>
int main(){for(int n,a,c,r,t;c=r=scanf("%d",&n),n;printf("%d\n",r))for(char d[]="123546",s[9];n--;r+=*d-48)scanf("%s",s),*s%6-4?a=*s%5+*s%2*2+c&3,t=*d,*d=d[++a],d[a]=d[5],d[5]=d[++a%4+1],d[a%4+1]=t:c+=*s+3;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

int T,n,s,s2,s3,i,j,k,l,A,B,C,D;
char ans[101];
bool bz;

void swap(int &x,int &y) {int z=x;x=y;y=z;}

int main()
{
	#ifdef file
	freopen("agc020D.in","r",stdin);
	#endif
	
	scanf("%d",&T);
	for (;T;--T)
	{
		scanf("%d%d%d%d",&A,&B,&C,&D),bz=0;
		if (A<B) swap(A,B),C=(A+B)-C+1,D=(A+B)-D+1,swap(C,D),bz=1;
		s=ceil((double)A/(B+1));
		
		if (A>=B*s)
		{
			fo(i,C,D)
			ans[i-C+1]=(!(i%(s+1)))?'B':'A';
		}
		else
		{
			s2=(B*s-A)/(s*s-1);
			s3=(A-s2)+(A-s2)/s;
			fo(i,C,D)
			if (i<=s3)
			ans[i-C+1]=(!(i%(s+1)))?'B':'A';
			else
			ans[i-C+1]=(!(((A+B)-i+1)%(s+1)))?'A':'B';
		}
		
		if (!bz)
		{
			fo(i,1,D-C+1) putchar(ans[i]);
			putchar('\n');
		}
		else
		{
			fd(i,D-C+1,1) putchar(ans[i]=='A'?'B':'A');
			putchar('\n');
		}
	}
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 3764
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] A1 = new long[N];
        long ans = 0;
        long c=0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            if(A[i]!=0){
                c+=A[i];
            }else{
                ans+=c/2;
                c=0;
            }
        }
        ans+=c/2;
        System.out.println(ans);
    }
}

Measured memory_bytes: 62136
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, N: int):
    ans=max(H,W)
    print(-(-N//ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(H, W, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
a, b = map(int, input().split())

x, y = a, b
if a > b:
    while b > 0:
        r = a % b
        a = b
        b = r
    answer = (x * y)//a
elif b > a:
    while a > 0:
        r = b % a
        b = a
        a = r
    answer = (x * y)//b
else:
    answer = (x * y)//a

print(answer)

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

constexpr int mod = 1e9+7;

vector<int> g[200005];
map<int, int> match;
int pw2[200005];
long long dp[200005];

deque<pair<int,int>> foo(int c) {
  deque<pair<int,int>> ret;
  if(g[c].empty()) {
    ret.emplace_back(1,1);
    return ret;
  }


  vector<deque<pair<int,int>>> dl;
  for(int i : g[c])
    dl.push_back(foo(i));
  int mi = 0;
  for(int i=1;i<dl.size();i++) {
    if(dl[i].size() > dl[mi].size()) mi = i;
  }
  dl.back().swap(dl[mi]);
  ret = move(dl.back());
  dl.pop_back();
  int m = 0;
  for(auto & l : dl) {
    m = max(m, (int)l.size());
    for(int i=0;i<l.size();i++) {
      long long tot = (ret[i].first + ret[i].second + dp[i]) % mod;
      tot = tot * (l[i].first + l[i].second) % mod;
      int tz = 1LL * ret[i].first * l[i].first % mod;
      int to = 1LL * ret[i].first * l[i].second % mod;
      to = (to + 1LL * ret[i].second * l[i].first) % mod;
      dp[i] = (tot - tz - to + mod*2) % mod;
      ret[i] = {tz, to};
    }
  }
  for(int i=0;i<m;i++) {
    ret[i].first = (ret[i].first + dp[i])%mod;
    dp[i] = 0;
  }
  ret.emplace_front(1,1);
  return ret;
}

int main() {
  int n;
  scanf("%d",&n);
  pw2[0] = 1;
  for(int i=1;i<=n+1;i++)
    pw2[i] = pw2[i-1]*2%mod;
  for(int i=0;i<=n+1;i++)
    match[pw2[i]] = pw2[n+1-i];
  for(int i=1;i<=n;i++) {
    int x;
    scanf("%d",&x);
    g[x].push_back(i);
  }
  deque<pair<int,int>> ret = foo(0);
  int ans = 0;
  for(auto p : ret) {
    int tot = (p.first + p.second) % mod;
    int tmp = 1LL * p.second * match[tot] % mod;
    ans = (ans + tmp) % mod;
  }
  printf("%d\n",ans);
}


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

using namespace std;
using ll = long long;

int LAS(vector<int> &a) {
    int n = a.size();
    const int INF = 2e9;
    vector<int> dp(n, INF);
    for(int i = 0; i < n; i++) {
        auto itr = upper_bound(dp.begin(), dp.end(), a[i]);
        *itr = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    reverse(a.begin(), a.end());
    cout << LAS(a) << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_map>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int const MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-12;
ll INF = LLONG_MAX / 10;

int main() {
	int N, M; cin >> N >> M;
	vector<int> d(N);
	while (M--) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		d[u]++; d[v]++;
	}
	rep(u, N) if (d[u] % 2) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 640
s = input()
l = len(s)

#全部で2**(l-1)パターンある
ans = 0
for i in range(2 ** (l-1)):
    eq = s[0]
    for j in range(l-1):
        if i & (1<<j):
            eq += '+'+s[j+1]
        else:
            eq += s[j+1]
    tmp = list(map(int, eq.split('+')))
    ans += sum([int(chr) for chr in tmp])

print(ans)

Measured memory_bytes: 3064
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=[]
ans=0
for i in range(n):
    if(i<n-1):
        d.append(a[i+1]-a[i])
    else:
        d.append(a[0]+k-a[i])
d=sorted(d)
print(sum(d[0:n-1]))

Measured memory_bytes: 26060
h,w = map(int, input().split(" "))
board = [list(input()) for i in range(h)]
a=[['.' for i in range(w + 2)] for j in range(h + 2)]

for i in range(1, h + 1):
  for j in range(1, w + 1):
    a[i][j] = board[i-1][j-1]
#print(*a)
ans=[["" for i in range(w)] for j in range(h)]
for i in range(1, h+1):
  for j in range(1,w+1):
    if a[i][j] == '.':
      ans[i-1][j-1]=[a[i-1][j], a[i-1][j-1], a[i-1][j+1], a[i][j-1], a[i][j+1], a[i+1][j-1], a[i+1][j], a[i+1][j+1]].count('#')
    else:
      ans[i-1][j-1]='#'
for i in ans:
  print(*i,sep="")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  int a[n];
  for (int i=0;i<n;i++)
    scanf("%d",&a[i]);
  sort(a,a+n);
  int sum1=0;
  for (int i=0;i<k;i++)
    sum1+=a[i];
  printf("%d\n",sum1);
  return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int a, b, c, d; cin >> a >> b >> c >> d;
  	if(abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes" << endl;
  	else cout << "No" << endl;
	return 0;
}

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

int main(){
    ll n;
    cin>>n;

    string ans="";
    ll base=1;
    while(n!=0){
        if(n%(base*2)==0) ans+='0';
        else{
            ans+='1';
            n-=base;
        }
        base*=-2;
    }
    
    reverse(all(ans));
    if(ans=="") ans="0";
    cout<<ans<<endl;
}

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

int y[51];
ll dp[51][5001];
int N,A,X=0;
ll solve(int j,int t){
	if(dp[j][t]>=0)return dp[j][t];
	if(j==0 && t==N*X)return dp[j][t]=1;
	else if(j>0 && (t-y[j]<0 || t-y[j]>2*N*X))return dp[j][t]=solve(j-1,t);
	else if(j>0)return dp[j][t]=solve(j-1,t)+solve(j-1,t-y[j]);
	else return dp[j][t]=0;
}

int main(void){
	cin>>N>>A;
	rep1(i,N){
		cin>>y[i];
		y[i]-=A;
		X=max(y[i],X);
	}
	rep(i,N+1)rep(j,2*N*X+1)dp[i][j]=-1;
	cout<<solve(N,N*X)-1<<endl;
	return 0;
}


Measured memory_bytes: 2176
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        ls: [usize; n]
    }
    println!("{}", solve(n, ls));
}

fn solve(_n:usize, ls: Vec<usize>) -> &'static str {
    let max_len = ls.iter().max().unwrap();
    let sum = ls.iter().fold(0, |partial_sum, x| partial_sum + x);
    if max_len + max_len < sum {
        return "Yes";
    }
    "No"
}

#[test]
fn solve_test() {
    assert_eq!(solve(4, vec![3,8,5,1]), "Yes");
    assert_eq!(solve(4, vec![3,8,4,1]), "No");
    assert_eq!(solve(10, vec![1,8,10,5,8,12,34,100,11,3]), "No");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

const long long mod = 1e9 + 7;
long long cnt[26];
long long N;
string s;

int main()
{
    cin >> N >> s;
    for (int i = 0; i < N;i++)
    {
        cnt[s[i] - 'a']++;
    }
    long long ans = 1;
    for (int i = 0; i < 26;i++)
    {
        ans *= (cnt[i] + 1LL);
        ans %= mod;
    }
    ans = (ans - 1LL + mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

long long int solve(long long int h, long long int w){
	long long int ans = mod;
	for(long long int i = 1; i < h; i++){
		long long int tmp1 = w * (h - i);
		if(i % 2 == 0 || w % 2 == 0){
			ans = min(ans, abs(tmp1 - (i * w) / 2));
		} else {
			long long int tmp2 = (i / 2) * w;
			long long int tmp3 = (i / 2 + 1) * w;
			ans = min(ans, max(tmp1, tmp3) - min(tmp1, tmp2));
			tmp2 = i * (w / 2);
			tmp3 = i * (w / 2 + 1);
			ans = min(ans, max(tmp1, tmp3) - min(tmp1, tmp2));
		}
	}
	return ans;
}

int main()
{
	long long int h, w;
	cin >> h >> w;
	if(h % 3 == 0 || w % 3 == 0){
		cout << 0 << endl;
		return 0;
	}
	cout << min(solve(h, w), solve(w, h)) << endl;
}

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

//直角三角形の判定
bool Get_triangle(int a,int b,int c){
    if(pow(a,2)+pow(b,2) == pow(c,2))
        return true;
    else
        return false;
}

//与えられたデータに対しての直角三角形の判定
string Judge_triangle(int a,int b,int c){
    if(Get_triangle(a,b,c) || Get_triangle(b,c,a) ||Get_triangle(c,a,b)){
        return "YES";
    }
    else{
        return "NO";
    }
}

//与えられたデータが条件に合うかの判定
bool Judge_line(int x){
    if(1<=x || x<=1000 || ceil(x) == floor(x))
        return true;
    else
        return false;
}

//main
int main(){
  int N;
  int a,b,c;
  int n=0;
    
    while(1){

  cin >> N;
    
        if(N > 1000 || ceil(N) != floor(N)){
            
        }
    else
        break;
    }
    
    string x[N];

while(N > 0 && cin >> a >> b >> c){
    
    
    while(1){
        if(Judge_line(a) && Judge_line(b) && Judge_line(c)){
            x[n] = Judge_triangle(a,b,c);
            N--;
            n++;
            break;
        }
        
        else{
            break;
        }
  }
}
    
    //結果の表示
    for(int i = 0;i < n;i++)
        cout << x[i] << endl;
    
  return 0;
}


Measured memory_bytes: 3200
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

////////////////////////////////////////////////////////////////

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

	bool ans = false;
	if(S[0] == '7') ans = true;
	if(S[1] == '7') ans = true;
	if(S[2] == '7') ans = true;

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return list(map(int, input().split()))

N = int(input())
while N:
    B = [inpl() for _ in range(N)]
    ans = -1
    tmp = 1
    while tmp:
        ans += tmp
        tmp = 0
        erase = [set() for _ in range(5)]
        for i in range(N):
            for j in range(1, 4):
                if B[i][j-1] == B[i][j] == B[i][j+1]:
                    for k in range(j-1, j+2):
                        erase[k].add(i)
        B2 = list(map(list, zip(*B)))
        for j in range(5):
            for i in sorted(erase[j], reverse=True):
                tmp += B[i][j]
                del B2[j][i]
            B2[j] = [0]*len(erase[j]) + B2[j]
        B = list(map(list, zip(*B2)))
    print(ans)
    N = int(input())


Measured memory_bytes: 6008
import java.util.Scanner;

//K Poker
public class Main{

	int suit(char c){
		return c=='S'?0:c=='C'?1:c=='H'?2:3;
	}
	
	int num(char c){
		return c=='K'?13:c=='Q'?12:c=='J'?11:c=='T'?10:c=='A'?1:c-'0';
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		boolean top = true;
		while(sc.hasNext()){
			if(!top)System.out.println();
			top = false;
			int n = sc.nextInt();
			int[][] p = new int[4][14];
			for(int i=0;i<4;i++)for(int j=1;j<14;j++)p[i][j] = sc.nextInt();
			//0: no 1: one-pair 2:two-pair 3:three-cards 4:straight 5:flash 6:fullhouse 7:fourcard 8:straight-flash 9:royal
			int[] r = new int[10];
			for(int i=1;i<10;i++)r[i]=sc.nextInt();
			while(n--!=0){
				int b = 0;
				int X = 0;
				int maxS = 0;
				int maxN = 0;
				int[] suitNum = new int[4];
				int[] numNum = new int[14];
				for(int i=0;i<5;i++){
					char[] ch = sc.next().toCharArray();
					int s = suit(ch[1]);
					int x = num(ch[0]);
					b+=p[s][x];
					suitNum[s]++;
					numNum[x]++;
					maxS = Math.max(maxS, suitNum[s]);
					maxN = Math.max(maxN, numNum[x]);
				}
				if(maxN==4){
					X = 7;
				}
				else if(maxN==3){
					boolean f = true;
					for(int i=1;i<=13;i++){
						if(numNum[i]==2){
							f = false;
						}
					}
					if(f)X = 3;
					else X = 6;
				}
				else if(maxN==2){
					int c = 0;
					for(int i=1;i<=13;i++)if(numNum[i]==2)c++;
					if(c==2)X = 2;
					else X = 1;
				}
				else{
					boolean flash = false;
					for(int i=0;i<4;i++)if(suitNum[i]==5)flash = true;
					boolean straight = false;
					for(int i=1;i+4<=13;i++){
						boolean f = true;
						for(int j=0;j<5;j++){
							if(numNum[i+j]==0)f = false;
						}
						if(f){
							straight = true;break;
						}
					}
					boolean royal = numNum[1]==1&&numNum[10]==1&&numNum[11]==1&&numNum[12]==1&&numNum[13]==1;
					if(royal&&flash)X = 9;
					else if(flash&&(royal||straight))X = 8;
					else if(flash)X = 5;
					else if(straight||royal)X = 4;
				}
				System.out.println(b*r[X]);
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

bool dpx[4000][16000]={false};
bool dpy[4000][16000]={false};
int main()
{
  string S;
  cin >> S;
  int x,y;
  cin >> x >> y;
  int cnt = 0;
  int flag = 0;
  deque<int> X;
  vector<int> Y;
  REP(i,sz(S)){
    if(S[i]=='F'){
      cnt++;
    }else{
      if(flag==0){
        X.push_back(cnt);
        cnt=0;
        flag=1;
      }else{
        Y.push_back(cnt);
        cnt=0;
        flag=0;
      }
    }
  }
  if(flag==0){
    X.push_back(cnt);
  }else{
    Y.push_back(cnt);
  }
  x-=X[0];
  X.pop_front();

  // REP(i,10){
  //   REP(j,10){
  //     cout << dpx[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  dpx[0][8000]=true;
  dpy[0][8000]=true;
  REP(i,sz(X)){
    REP(j,16000){
      if(dpx[i][j]==true){
        dpx[i+1][j+X[i]]=true;
        dpx[i+1][j-X[i]]=true;
      }
    }
  }
  REP(i,sz(Y)){
    REP(j,16000){
      if(dpy[i][j]==true){
        dpy[i+1][j+Y[i]]=true;
        dpy[i+1][j-Y[i]]=true;
      }
    }
  }
  if(dpx[sz(X)][x+8000]&&dpy[sz(Y)][y+8000]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  // sort(ALL(X));
  // sort(ALL(Y));
  // reverse(ALL(X));
  // reverse(ALL(Y));
  // int sumx=0;
  // REP(i,sz(X)){
  //   if(sumx<x){
  //     sumx+=X[i];
  //   }else{
  //     sumx-=X[i];
  //   }
  // }
  // int sumy=0;
  // REP(i,sz(Y)){
  //   if(sumy<y){
  //     sumy+=Y[i];
  //   }else{
  //     sumy-=Y[i];
  //   }
  // }
  // if(sumx==x&&sumy==y){
  //   cout << "Yes" << endl;
  // }else{
  //   cout << "No" << endl;
  // }
}


Measured memory_bytes: 35384
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[n-r] % self.mod

    def H(self, n, r):
        if n == 0 and r > 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod

    def rising_factorial(self, n, r):  # 上昇階乗冪 n * (n+1) * ... * (n+r-1)
        return self.fac[n+r-1] * self.facinv[n-1] % self.mod

    def stirling_first(self, n, k):  # 第 1 種スターリング数  lru_cache を使うと O(nk)  # n 要素を k 個の巡回列に分割する場合の数
        if n == k: return 1
        if k == 0: return 0
        return (self.stirling_first(n-1, k-1) + (n-1)*self.stirling_first(n-1, k)) % self.mod

    def stirling_second(self, n, k):  # 第 2 種スターリング数 O(k + log(n))  # n 要素を区別のない k グループに分割する場合の数
        if n == k: return 1  # n==k==0 のときのため
        return self.facinv[k] * sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def balls_and_boxes_3(self, n, k):  # n 要素を区別のある k グループに分割する場合の数  O(k + log(n))
        return sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def bernoulli(self, n):  # ベルヌーイ数  lru_cache を使うと O(n**2 * log(mod))
        if n == 0: return 1
        if n % 2 and n >= 3: return 0  # 高速化
        return (- pow(n+1, self.mod-2, self.mod) * sum(self.C(n+1, k) * self.bernoulli(k) % self.mod for k in range(n))) % self.mod

    def faulhaber(self, k, n):  # べき乗和 0^k + 1^k + ... + (n-1)^k
        # bernoulli に lru_cache を使うと O(k**2 * log(mod))  bernoulli が計算済みなら O(k * log(mod))
        return pow(k+1, self.mod-2, self.mod) * sum(self.C(k+1, j) * self.bernoulli(j) % self.mod * pow(n, k-j+1, self.mod) % self.mod for j in range(k+1)) % self.mod

    def lah(self, n, k):  # n 要素を k 個の空でない順序付き集合に分割する場合の数  O(1)
        return self.C(n-1, k-1) * self.fac[n] % self.mod * self.facinv[k] % self.mod

    def bell(self, n, k):  # n 要素を k 個以下に分割する場合の数  O(k**2 + k*log(mod))
        return sum(self.stirling_second(n, j) for j in range(1, k+1)) % self.mod

mod = 10**9+7
comb = Combination(2000)
n, k = map(int, input().split())
print(comb.P(k, n))




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

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

using namespace std;

struct Edge { int dst,weight; };
typedef pair<int,int> ii;

const int MAX_V = 1000;
int V,p[MAX_V],d[MAX_V];
vector<Edge> G[MAX_V];

ii visit(int prev,int cur) {
  ii ret(0,cur);
  rep(i,(int)G[cur].size()){
    Edge e = G[cur][i];
    if( e.dst != prev && G[e.dst].size() >= 2 ) {
      ii t = visit(cur,e.dst);
      t.first += e.weight;
      if(ret.first < t.first ) ret = t;
    }
  }
  return ret;
}

int longest_path(){
  ii s = visit(-1,0);
  ii t = visit(-1,s.second);
  return t.first;
}

int coef_dfs(int cur,int prev){
  int ret = 0;
  rep(i,(int)G[cur].size()){
    int next = G[cur][i].dst;
    if( G[next].size() <= 1 || next == prev ) continue;
    ret += coef_dfs(next,cur) + G[cur][i].weight;
  }
  return ret;
}

int main(){
  while( cin >> V, V ){
    int sum = 0;
    rep(i,V) G[i].clear();
    rep(i,V-1) { cin >> p[i]; --p[i]; }
    rep(i,V-1) { cin >> d[i]; sum += d[i]; }
    rep(i,V-1) { G[i+1].push_back((Edge){p[i],d[i]}); G[p[i]].push_back((Edge){i+1,d[i]}); }
    int root = -1;
    rep(i,V) if( G[i].size() > 1 ) { root = i; break; }
    sum += coef_dfs(root,-1) * 2;
    cout << sum - longest_path() << endl;
  }
  return 0;
}

Measured memory_bytes: 1392
def d(x,y):
    return ((x[0]-y[0])**2+(x[1]-y[1])**2)**(1/2)

import itertools
ans=0
k=1
n= int(input())
xy=[list(map(int,input().split())) for i in range(n)]
l=[i for i in range(n)]
for v in itertools.permutations(l, n):
    for i in range(n-1):
        ans+=d(xy[v[i]],xy[v[i+1]])
for i in range(1,n+1):
    k*=i
print(ans/k)

Measured memory_bytes: 3064
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

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

    void solve() {
        int R = in.nextInt();
        int G = in.nextInt();
        out.println(G * 2 - R);
    }


    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}

Measured memory_bytes: 24916
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str1 = br.readLine();
    String[] str2 = str1.split(" ");
    double a, b, C, c;
    double S, L, h;

    a = Double.parseDouble(str2[0]);
    b = Double.parseDouble(str2[1]);
    C = Double.parseDouble(str2[2]);
    c = Math.toRadians(C);

    S = a * b * Math.sin(c) * 1/2;
    L = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(c));
    h = b * Math.sin (c);

    System.out.println(S);
    System.out.println(L + a + b);
    System.out.println(h);
  }
}


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

int main(){
  long long N,A,B;
  cin>>N>>A>>B;
  if(N%(A+B)<A)
    cout<<N/(A+B)*A+N%(A+B)<<endl;
  else
    cout<<N/(A+B)*A+A;
}


Measured memory_bytes: 3600
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
B = np.array(B)
ans = 0
for i in range(N):
  A = [int(x) for x in input().split()]
  A = np.array(A)
  if(sum(A*B)+C)>0:
    ans += 1
print(ans)

Measured memory_bytes: 27148
bool DBG = false;
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using ld = long double;
//using i128 = __int128_t;
//using bint = boost::multiprecision::cpp_int
//using d1024 = boost::multiprecision::number<mp::cpp_dec_float<1024>>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << (x) << (" ")
#define coutn(x) cout << (x) << ("\n")
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define dcouts(x) if(DBG) couts(x)
#define dcoutn(x) if(DBG) coutn(x);
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;



void solve(){
  int n; cin >> n;
  V<ll> a(n); cin >> a;
  V<ll> b;
  FOR(i,0,n){
    auto it = ub(ALL(b), -a[i]);
    if(it==b.end()) b.pb(-a[i]);
    else{
      *it = -a[i];
    }
  }
  coutn(b.size());
}

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

Measured memory_bytes: 2168
// 2011/12/12 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool F[30];
	for(int i=0; i<30; i++)
		F[i] = false;

	for(int i=0; i<28; i++){
		int x;
		cin >> x;
		F[x-1] = true;
	}

	for(int i=0; i<30; i++)
		if(!F[i])
			cout << i+1 << endl;

	return 0;
}

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

int main(){
	char x,y; cin>>x>>y;
	if(x>y) cout<<'>'<<endl;
	else if(x<y) cout<<'<'<<endl;
	else cout<<'='<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;
int main()
{
    string s;

    cin >> s;

    for(int i = 0;i < s.size();i += 2){
        if(s[i] == 'h' && s[i + 1] == 'i'){

        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
 
    return 0;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]
    Q = int(input())
    BC = []
    for i in range(Q):
        BC.append(list(map(int, input().split())))
    dic = Counter(A)
    ans = 0
    for k, v in dic.items():
        ans += int(k)*v
    for i in BC:
        B, C = i[0], i[1]
        ans += - B*dic[B] + C*dic[B]
        dic[C] += dic[B]
        del dic[B]
        print(ans)

resolve()

Measured memory_bytes: 102420
package main

import (
	"fmt"
)

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

	alpha := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}

	for _, v := range s {
		for ak, av := range alpha {
			if string(v) == av {
				alpha = append(alpha[:ak], alpha[ak+1:]...)
				break
			}
		}
	}

	if len(alpha) == 0 {
		fmt.Println("None")
	} else {
		fmt.Println(alpha[0])
	}
}

Measured memory_bytes: 1280
#include <stdio.h>

int main() {
 char a[2000]={0};
 int c[30]={0},b,d,f;
 b=0;
 while(scanf("%c",&a[b])!=EOF){
  if('A'<=a[b]&&'Z'>=a[b]){
   d=a[b]-'A';
   c[d]+=1;}
   else if(a[b]>='a'&&'z'>=a[b]){
   d=a[b]-'a';
   c[d]+=1;}
   b=b+1;}
   for(f=97;f<=122;f++){
     d=f-'a';
     printf("%c : %d\n",f,c[d]);
   }
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  for(int i=0;i<20;i++){
    if(N==(1<<i)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  cout<<N+1<<" 2\n";
  for(int i=0;i<(N-1)/2;i++){
    cout<<i*2+2<<" "<<i*2+3<<"\n";
    cout<<i*2+3<<" 1\n";
    cout<<N+i*2+2<<" 1\n";
    cout<<N+i*2+2<<" "<<N+i*2+3<<"\n";
  }
  if((N&1)==0){
    int d2=log2(N);
    cout<<(1<<d2)+1<<" "<<N<<"\n";
    cout<<2*N-(1<<d2)<<" "<<N*2<<"\n";
  }
}


Measured memory_bytes: 2304
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [n,a,b] <- map (read::String->Int) . words <$> getLine
  print $ sum [x|x<-[1..n], let y=(sum .map digitToInt .show)x, a<=y, y<=b]

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;cin>>N;
    string S;cin>>S;
    for(int i=0;i<N-1;i++){
        if(S[i]==S[i+1]) S[i]='0';
    }
    int cnt=0;
    
    for(int i=0;i<N;i++){
        if(S[i]!='0') cnt++;
    }
    
    cout<<cnt<<endl;
}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		
		int max = -1000000;
		int min = 1000000;
		long sum = 0;
		int tmp = 0;
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		
		for (int i = 0; i < n; i++ ) {
			tmp = Integer.parseInt(str[i]);
			if (tmp > max) {
				max = tmp;
			}
			if (tmp < min) {
				min = tmp;
			}
			sum = sum + tmp;
		}
		System.out.println(min + " " + max + " " + sum);
	}	
}

Measured memory_bytes: 28400
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = (int)1e9;

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

	int n, k, s;
	cin >> n >> k >> s;
	for (int i = 0; i < k; ++i) cout << s << ' ';
	if (s == INF) {
		for (int i = k; i < n; ++i) cout << 1 << ' ';
	} else {
		for (int i = k; i < n; ++i) cout << INF << ' ';
	}
	cout << '\n';
}


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

using namespace std;

#define int long long

int n;
int a[200001], b[200001];

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

	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);	
	if (n % 2 == 1)
	{
		int me_a = a[(n + 1) / 2], me_b = b[(n + 1) / 2];
		cout << (me_b - me_a + 1) << '\n';
	}
	else
	{
		int me_a = (a[n / 2] + a[n / 2 + 1]) / 2, me_b = (b[n / 2] + b[n / 2 + 1]) / 2;
		if ((a[n / 2] + a[n / 2 + 1]) % 2 && (b[n / 2] + b[n / 2 + 1]) % 2)
			cout << (me_b - me_a) * 2 + 1 << '\n';
		else if ((a[n / 2] + a[n / 2 + 1]) % 2)	
			cout << (me_b - me_a) * 2 << '\n';
		else if ((b[n / 2] + b[n / 2 + 1]) % 2)
			cout << (me_b - me_a) * 2 + 2 << '\n';
		else
			cout << (me_b - me_a) * 2 + 1 << '\n';				
	}
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n, q;
    cin >> n >> q;

    dsu d(n);
    REP(_, q){
        ll t, u, v;
        cin >> t >> u >> v;
        if(t == 0){
            d.merge(u, v);
        }else{
            cout << (int)(d.same(u, v)) << endl;
        }
    }
    return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e3 + 4;
ll dist[T];
bool vis[T];
vii g[T];
int n,m;

void bellman() {
    for(int i = 0; i < n; i++)
        for(int u = 1; u <= n ; u++)
            for(ii v : g[u]) {
                if(!vis[v.fi]) dist[v.fi] = dist[u]+v.se;
                vis[v.fi] = 1;
                dist[v.fi] = max(dist[v.fi],dist[u]+v.se);
            }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for(int i = 2; i <= n; i++) dist[i] = -1e18;

    for(int i = 0; i < m; i++) {
        int a,b,c; cin >> a >> b >> c;
        g[a].eb(b,c);
    }

    bellman();
    ll ans = dist[n];
    bellman();

    if(ans == dist[n]) cout << ans << endl;
    else cout << "inf" << endl;

    return 0;
}



Measured memory_bytes: 384
import copy
n = int(input())
A = list(map(str,input().split()))
B = copy.copy(A)

def BubbleSort(A,n):
    for i in range(n):
        for j in range(n-1,i,-1):
            if int(A[j][1:2])<int(A[j-1][1:2]):
                v = A[j]
                A[j] = A[j-1]
                A[j-1] = v
    return A

def SelectionSort(A,n):
    for i in range(n):
        minj = i
        for j in range(i,n):
            if int(A[j][1:2])<int(A[minj][1:2]):
                minj = j
        v = A[i]
        A[i] = A[minj]
        A[minj] = v
    return A

print(' '.join(BubbleSort(A,n)))
print('Stable')
print(' '.join(SelectionSort(B,n)))
if BubbleSort(A,n) == SelectionSort(B,n):
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 6344
#include <stdio.h>
int main(void){
    int l,n;
    int i,j,k;
    int x;
    int count[4][3][10];
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++) count[i][j][k]=0;
        }
    }
    
    scanf("%d",&n);
    for(l=1;l<=n;l++) {
        scanf("%d %d %d %d",&i,&j,&k,&x);
        count[i-1][j-1][k-1]=count[i-1][j-1][k-1]+x;
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++) {
                printf(" %d",count[i][j][k]);
            }
            printf("\n");
        }
        if(i==3) break;
        printf("####################\n");
    }
    
    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const int MAXN=100005;

int parent_color[MAXN];
int counter[MAXN];

vector<vector<int>> G(MAXN);
int max_color=1;
bool went[MAXN];

void dfs(int now,int parent,map<pii,int> &hen_color){
  if(went[now])return;
  went[now]=true;
  // cout<<now<<" ";
  if(parent!=0) {
    if(counter[parent]==0)counter[parent]++;
    if(counter[parent]==parent_color[parent])counter[parent]++;
    hen_color[pii(now,parent)]=counter[parent];
    hen_color[pii(parent,now)]=counter[parent];
    parent_color[now]=counter[parent];
    chmax(max_color,counter[parent]);
    counter[parent]++;
  }
  
  for(auto e: G[now]){
    dfs(e,now,hen_color);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  vector<pii> hen(n-1);
  rep(i,n-1){
    int a,b; cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
    hen[i]=pii(a,b);
  }
  map<pii,int> hen_color;
  dfs(1,0,hen_color);

  cout<<max_color<<endl;
  rep(i,n-1){
    cout<<hen_color[hen[i]]<<endl;
  }
}


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

int main(void) {
  int d, t, s;
  scanf("%d %d %d", &d, &t, &s);

  float res = (float) d / (float) s;
  if ((float) t < res) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
int a[100000];
int main(void){
int n, s;
scanf("%d%d", &n, &s);
for(int i = 0;i < n;++i)scanf("%d", &a[i]);
int res = n + 1, sum = 0, l = 0, r = 0;
for(;l < n;){
if(l == r)sum = a[r++];
else{
if(sum >= s)sum -= a[l++];
else if(r < n)sum += a[r++];
else break;
}
if(sum >= s && res > r - l)res = r - l;
}
if(res <= n)printf("%d\n", res);
else puts("0");
return 0;
}

Measured memory_bytes: 2216
N = int(input())
L = sorted([int(i) for i in input().split()], reverse=True)
# print(L)
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] < L[j]+L[k] and L[i] != L[j] != L[k]:
                ans += 1
print(ans)


Measured memory_bytes: 71716
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define fir first
#define sec second
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define maxd 1000000007
#define eps 1e-6
typedef long long ll;
const int N=100000;
const double pi=acos(-1.0);
int n,maxdis[200200][2];
vector<int> sq[200200];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

void dfs(int u,int fu)
{
	int len=sq[u].size();
	rep(i,0,len-1)
	{
		int v=sq[u][i];
		if (v==fu) continue;
		dfs(v,u);
		int tmp=maxdis[v][0]+1;
		if (tmp>maxdis[u][0]) {maxdis[u][1]=maxdis[u][0];maxdis[u][0]=tmp;}
		else if (tmp>maxdis[u][1]) maxdis[u][1]=tmp;
	}
}

int main()
{
	n=read();
	rep(i,1,n-1)
	{
		int u=read(),v=read();
		sq[u].push_back(v);
		sq[v].push_back(u);
	}
	dfs(1,0);
	int ans=0;
	rep(i,1,n) ans=max(ans,maxdis[i][0]+maxdis[i][1]);
	if (ans%3==1) puts("Second");else puts("First");
	return 0;
}


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

bool solve(map<int, int> &mp){
  if(mp[1] % 2 == 0 || mp[2] % 2 == 0) return false;
  for(map<int, int>::iterator it = mp.begin() ; it != mp.end() ; it++){
    if(it->first == 1 || it->first == 2) continue;
    if(it->second % 2 == 1) return false;
  }
  return true;
}

int main(){
  int from, to;
  while(cin >> from >> to){
    map<int, int> mp;
    mp[from]++;
    mp[to]++;
    
    while(cin >> from >> to, from|to){
      mp[from]++;
      mp[to]++;
    }
    cout << (solve(mp) ? "OK" : "NG") << endl;
  }
  
  return 0;
}

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

using namespace std;
int num;
int main(){
  int btm,top;
  cin >> num;
  btm = num % 100;
  top = num / 100;
  //11
  if(btm <= 12 && btm >= 1 && top >= 1 && top <= 12){
    cout << "AMBIGUOUS" << endl;
  }
  //22
  else if((btm == 0 || btm > 12) && (top == 0 || top > 12)){
    cout << "NA" << endl;
  }
  //12
  else if(top >= 1 && top <= 12 && (btm == 0 || btm > 12)){
    cout << "MMYY" << endl;
  }
  else{
    cout << "YYMM" << endl;
  }
  return 0;
}


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

int n, sum, sub, puyo[10000];


void solve(int a, int b){
	while(puyo[--a] == puyo[++b]){
		for(int i = a; i >= 0; i--){
			sum++;
			if(puyo[i] != puyo[i - 1]){
				a = i;
				break;
			}
		}
		
		for(int i = b; i < n; i++){
			sum++;
			if(puyo[i] != puyo[i + 1]){
				b = i;
				break;
			}
		}
		
		if(sum >= 4){
			sub -= sum;
		} else{
			break;
		}
		
		sum = 0;
	}
	
	return;
}


int main() {
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> puyo[i];
		}
		
		int ans = 1000000;
		
		for(int i = 1; i < n - 1; i++){
			sub = n;
			
			if(puyo[i - 1] == puyo[i + 1]){
				sum = 1;
				solve(i, i);
			} else{
				if(puyo[i - 3] == puyo[i - 2] && puyo[i - 2] == puyo[i - 1]){
					sum = 0;
					sub -= 4;
					solve(i - 3, i);
				}
				if(puyo[i + 1] == puyo[i + 2] && puyo[i + 2] == puyo[i + 3]){
					sum = 0;
					sub -= 4;
					solve(i, i + 3);
				}
			}
			
			ans = min(ans, sub);
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1200