akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        string s,t;
        cin>>s>>t;
        int a,b;
        cin>>a>>b;
        string u;
        cin>>u;
        if(u==t)cout<<a<<" "<<b-1<<endl;
        else cout<<a-1<<" "<<b<<endl;
      }
}















Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

int main(){
    int n;
    std::cin >> n;

    int val;
    std::vector<int> cumSum(n);
    std::cin >> cumSum.at(0);
    for(int i = 1; i < n; ++i){
        std::cin >> val;
        cumSum.at(i) = cumSum.at(i - 1) + val;
    }

    std::vector<int> vari(n - 1);
    for(int i = 0; i < n - 1; ++i){
        vari.at(i) = std::abs(cumSum.at(n - 1) - 2 * cumSum.at(i));
    }

    std::cout << *std::min_element(vari.begin(), vari.end()) << std::endl;

    return 0;
}

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

int main(void) {
    string s;
    cin >> s;
    int ans = 0;
    for (int i=0; i<s.size(); i++) {
        if (s[i] == '1') ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  vector<int>v(n);
  vector<int>a(n-1);
  for(int i=0;i<n-1;i++)cin>>a[i];
  v[0]=a[0];
  for(int i=1;i<n-1;i++)
  { v[i]=min(a[i-1],a[i]);}//cout<<v[i]<<" ";}
  v[n-1]=a[n-2];
  for(int i=0;i<n;i++)
    sum+=v[i];
  //cout<<v[n-1]<<endl;
  cout<<sum;
  return 0;
}
  

Measured memory_bytes: 256
/*
AizuOnline A0154
Title
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
//grobal vars;
struct card_inf {int val;
  int cnt;} card[7];
int m;
int g;
int cc;
int minval;
//
int comp(void *x,void *y)
{
  return(((struct card_inf *)y)->val - ((struct card_inf *)x)->val);
}
void printks(struct card_inf c[7],int least_coin)
{
  int i;

  printf("---------------\n");
  for(i=0;i<m-1;i++)
    printf("|%d %d\n",card[i].val,card[i].cnt-c[i].cnt);
  printf("|%d %d\n",minval,least_coin);
}
void printks2(struct card_inf c[7])
{
  int i;
  printf("---------------\n");
  for(i=0;i<m;i++)
    printf("|%d %d\n",card[i].val,card[i].cnt-c[i].cnt);
}

void search(struct card_inf c[7],int total,int maxval)
{
  int i,j;

  struct card_inf c1[7];
#ifdef DEBUG
  printf("\nT,M %d %d::",total,maxval);  
  for(i=0;c[i].val;i++)
    printf("%d %d:",(c[i].val),(c[i].cnt));
#endif 
  for(i=0;i < m;i++)
    {
      if(c[i].val > maxval)
	continue;
      
      if(c[i].val==minval && (total % minval)==0 && c[i].cnt >= (total/minval))
	{
	  c[i].cnt--;
	  cc++;
#ifdef DEBUG
	  printf("+\n");
#endif
#ifdef PRINTKS
	  printks(c,total/minval);
#endif
	  c[i].cnt++;
	  break;
	}
      else if(c[i].val==total && c[i].cnt > 0)
	{
	  c[i].cnt--;
	  cc++;
#ifdef DEBUG
	  printf("*\n");
#endif
#ifdef PRINTKS
	  printks2(c);
#endif
	  c[i].cnt++;
	}
      else if(c[i].val<total && c[i].val <= maxval && c[i].cnt > 0 )
	{
	  memcpy(c1,c,7*2*sizeof(int));
	  c1[i].cnt--;
	  search(c1,total-c1[i].val,c[i].val);
	}
    }
 }

main()
{
  int i,nn;
  while(EOF!=scanf("%d ",&m) && m)
    {
      memset(card,0,7*2*sizeof(int));
      for(i=0;i<m;i++)
	{
	  scanf("%d %d",&(card[i].val),&(card[i].cnt));
	  //printf("%d %d\n",(card[i].val),(card[i].cnt));
	}
      qsort(card,m,sizeof(struct card_inf),(__compar_fn_t)comp);
      minval = card[m-1].val;
#ifdef DEBUG
      printf("MINV %d\n",minval);
#endif
      scanf("%d",&g);  //game kaisuu

      for(i=0;i<g;i++)
	{
	  scanf("%d",&nn);
	  cc=0;
	  search(card,nn,INT_MAX);
#ifdef DEBUG
	  printf("\n");
#endif
	  printf("%d\n",cc);
	}

    }
return(0);
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

	int n, m; cin >> n >> m;

	int res = (n - 1) * (m - 1);

	cout << res << endl;
	
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
  {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


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

int main() {
  int n, temp;
  cin >> n;
  vector<int> a{0};
  vector<bool> b{false};
  vector<bool> already{false};
  for(int i=0;i<n;i++) {
    cin >> temp;
    a.push_back(temp);
    b.push_back(false);
    already.push_back(false);
  }
  int last = 1, ans = 0;
  b.at(1) = true;
  while(!b.at(2)) {
    if (already.at(last)) {
      cout << "-1\n";
      return 0;
    }
    b.at(last) = false;
    already.at(last) = true;
    last = a.at(last);
    b.at(last) = true;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}

    

Measured memory_bytes: 892
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
var X = sc.nextInt()

fun main(args: Array<String>) {
    var min = Int.MAX_VALUE

    repeat(N) {
        val m = sc.nextInt()
        min = Math.min(min, m)
        X -= m
    }
    println(N + X / min)
}


Measured memory_bytes: 29604
// 2020-09-16 00:15:44
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
#include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
using namespace atcoder;

// clang-format on
void answer() {
  int n, q;
  cin >> n >> q;
  dsu d(n);
  rep(i, q) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      d.merge(u, v);
    } else {
      cout << d.same(u, v) << '\n';
    }
  }
}

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

Measured memory_bytes: 3740
while True:
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)
    
    if op =="+":
        result = a + b
    elif op == "-":
        result = a - b
    elif op == "*":
        result = a * b
    elif op == "/":
        result = a // b
    else:
        break
    
    print(result)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

int K, A, B;

int main() {
    cin >> K >> A >> B;
    if (A%K == 0) {
        cout << "OK" << endl;
    } else {
        if ((K * (A/K + 1)) <= B) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }

}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;


int main(){
    int a,b,x;
    cin >> a >> b >> x;
    if(x>a+b){
        cout<<"NO"<<endl;

    }else if(x<a){
        cout<<"NO"<<endl;
        
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 X; cin >> X;
    cout << (X == 7 || X == 5 || X == 3 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
const MOD = 10**9+7
// factors[f].e+n-1、において max(n)=10**5, max(factors[f].e)=log(M)=log(10**9)=21
const N = 10**5+30

let fac = [...new Array(N)].fill(0)
let ifac = [...new Array(N)].fill(0)
const mul = (a,b) => ((a>>16)*b%MOD*65536+(a&65535)*b)%MOD;

const factorization = (n) => {
    let primes= []
    for(let i=2; i*i<=n; i++) {
        let exponent = 0
        while(n%i===0) {
            n /= i
            exponent++
        }
        if(exponent) {
            primes.push({p:i, e:exponent})
        }
    }
    
    if(n!==1) {
        primes.push({p:n, e:1})
    }
    return primes
}

const mpow = (x, n) => {
    ans = 1;
    let _x = x
    while(n != 0){
        if(n & 1) ans = mul(ans,_x);
        _x = mul(_x,_x);
        n = n >> 1;
    }
    return ans;
}

const comb = (n, r) => {
    if(n == 0 && r == 0) return 1;
    if(n < r || n < 0) return 0;
    const tmp = mul(ifac[n-r],ifac[r])
    return mul(tmp,fac[n])
}

const init = () => {
    fac[0] = 1;
    ifac[0] = 1;
    for(let i=0; i<N; i++){
        fac[i+1] = mul(fac[i],(i+1));
        ifac[i+1] = mpow(fac[i+1], MOD - 2)
    }
}

const main = (arg) => {
    let [n, m] = arg.split(" ").map(Number)
    let factors = factorization(m)
    let ans = 1
    init()
    Object.keys(factors).forEach(f=>{
        let a = factors[f].e+n-1
        let b = factors[f].e
        ans = mul(ans,comb(a, b))
    })
    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37432
#include <iostream>
using namespace std;
 
int main() {
while(1){
int a[1000][3];
int n,m,ans;
cin >> n >> m >> ans;
if(n == 0){break;}
for(int i = 0;i<m;i++){
	cin>>a[i][0]>>a[i][1]>>a[i][2];
}
for(int j = 1000;j>=1;j--){
	for(int i = 0;i<m;i++){
	if(a[i][0]==j){
		if(a[i][1]==ans){ans=a[i][2];}
		else if(a[i][2]==ans){ans=a[i][1];}
	}
	}
}
cout<<ans<<endl;
}
	return 0;
}

Measured memory_bytes: 1172
#include<cstdio>
int main()
{
	int x[150]={0};
	int y[150]={0};
	int sum=0;
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	for(int i=a;i<b;i++) x[i]=1;
	for(int i=c;i<d;i++) y[i]=2;
	for(int i=0;i<=100;i++)
	{
		if(x[i]==1&&y[i]==2) sum++;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
arr = list(map(int, input().split()))

mod = 10 ** 9 + 7

res = 0
for d in range(60):
    one = sum(x % 2 == 1 for x in arr)
    res += one * (n - one) * 2 ** d
    res %= mod
    arr = [x // 2 for x in arr]

print(res)


Measured memory_bytes: 138552
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int sum = 0;
        int m = n;
        while (n > 0)
        {
            int dig = n % 10;
            sum += dig;
            n /= 10;
        }
        if (m % sum == 0)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 19796
from itertools import permutations
 
 
def warshall_floyd(d):
    # d        : nxn adjacent matrix
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
 
 
INF = float("inf")
 
n, m, r = map(int, input().split())
r_list = list(map(lambda x: int(x) - 1, input().split()))
d = [[INF] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    d[a][b] = d[b][a] = c
warshall_floyd(d)
 
ans = float("inf")
for np in permutations(r_list):
    cand = sum([d[np[i]][np[i + 1]] for i in range(r - 1)])
    ans = min(ans, cand)
 
print(ans)

Measured memory_bytes: 4636
N = int(input())
A = [int(i) for i in input().split()]

B_right = A[0::2]
B_left = list(reversed(A[1::2]))

B_left.extend(B_right)
ans = B_left

if len(A)%2 == 1:
  ans = list(reversed(ans))

print(" ".join(map(str, ans)))


Measured memory_bytes: 31812
n = int(input())
a = list(map(int, input().split()))
c = a[0]
for i in range(1,n):
    if a[i-1] < a[i]:
        a[i] -=1
    if a[i-1] > a[i]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 14396
#include <iostream>
//#include <fstream>
using namespace std;

int main(void)
{
	int A[4], B[4];
	int res[4], hit, blow;

	//ifstream fin("in.txt");
	istream& in=cin;

	while(1)
	{
		for(int i=0; i<4; i++)
			{ if( !(in >> A[i]) )return 0; }
		for(int i=0; i<4; i++)
			{ if( !(in >> B[i]) )return 0; }


		for(int i=0; i<4; i++)
			res[i] = 0;
		for(int i=0; i<4; i++)
		{
			if(A[i] == B[i])
			{
				res[i] = 1;
			}
			else
			{
				for(int j=0; j<4; j++)
					if(A[j] == B[i])res[i] = 2;
			}
		}

		hit=0; blow=0;
		for(int i=0; i<4; i++)
		{
				 if(res[i] == 1)hit++;
			else if(res[i] == 2)blow++;
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
def main() -> None:
    N = int(input())
    yen = 0
    for _ in range(N):
        x, u = input().split()
        if u == 'JPY':
            yen = yen + int(x)
        elif u == 'BTC':
            yen = yen + (float(x) * 380000.0)

    print(yen)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  ll A[N]; rep(i, N) cin >> A[i];

  map<ll, ll> A_dict;
  rep(i, N) A_dict[A[i]]++;

  vector<ll> bars;
  for(auto x: A_dict) rep(i, x.second/2) bars.push_back(x.first);
  sort(bars.begin(), bars.end()); reverse(bars.begin(), bars.end());

  ll result = 0;
  if (bars.size() >= 2) result = bars[0] * bars[1];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  string S;
  cin>>S;
  FOR(i,0,(int)S.size()-8){
    cout<<S[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
    	InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

       String[] input = br.readLine().split(" ");
       int a = Integer.parseInt(input[0]);
       int b = Integer.parseInt(input[1]);
       int c = Integer.parseInt(input[2]);
       int cum = 0;
       for(int x = a; x <= b ; x++){
    	   int ans = c % x;
    	   if(ans == 0){
    		   cum += 1;
    	   }
       }
       System.out.println(cum);
    }
}

Measured memory_bytes: 24416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		if(S.equals("Sunny")) {
			System.out.println("Cloudy");
		}else if(S.equals("Cloudy")) {
			System.out.println("Rainy");
		}else {
			System.out.println("Sunny");
		}
	}

}

Measured memory_bytes: 21716
#include <iostream>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)

using namespace std;

typedef int64_t ll;

const ll MOD = 1000000007;
const int MAX_N = 2010;

int ns, nt;
int s[MAX_N], t[MAX_N];
ll cum[MAX_N][MAX_N];

int main()
{
	cin >> ns >> nt;
	REP(i, ns) cin >> s[i];
	REP(j, nt) cin >> t[j];

	REP(i, MAX_N)
		cum[1][i] = cum[i][1] = 1;

	REP(i, ns)
		REP(j, nt)
	{
		ll dp = 0;
		if (s[i] == t[j])
			dp = cum[i + 1][j + 1];

		cum[i + 2][j + 2] = dp + cum[i + 1][j + 2] + cum[i + 2][j + 1] - cum[i + 1][j + 1];
		cum[i + 2][j + 2] = (cum[i + 2][j + 2] + MOD) % MOD;
	}

	cout << cum[ns + 1][nt + 1] << endl;
}


Measured memory_bytes: 31744
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	A, B, C, D := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()

	for {
		C -= B
		if C <= 0 {
			fmt.Println("Yes")
			break
		}
		A -= D
		if A <= 0 {
			fmt.Println("No")
			break
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1760
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
//int dx[] = { 1, 0 };
//int dy[] = { 0, 1 };
#define mod7 1e9+7;
#define mod9 1e9+9;

//int nextInt(){
//	int a;	cin >> a;return a;
//}
//string next(){
//	string s;cin >> s;return s;
//}
//char nextChar(){
//	char c;cin >> c;return c;
//}

unsigned long long strtoint(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve(){
	int n;
	cin >> n;
	int num[252525];
	int left = 100000,right = left + 1;
	rep(i,n){
		int a;
		cin >> a;
		if(i%2 == 0){
			num[left] = a;
			left--;
		}else{
			num[right] = a;
			right++;
		}
	}
	if(n % 2 == 1) {
		REP(i, left + 1, right) {
			cout << num[i] << " ";
		}
	}else{
		for(int i = right-1;i > left;i--){
			cout << num[i] << " ";
		}
	}
	cout << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 3452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var strs = Console.ReadLine().Split(' ').ToArray();
            var nums = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            if (Console.ReadLine() == strs[0]) nums[0]--;
            else nums[1]--;

            Console.WriteLine($"{nums[0]} {nums[1]}");

        }
    }
}

Measured memory_bytes: 28328
import java.util.*;
public class Main { 
	public static void main(String arts[]) { 
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		String s =sc.next();
		int ans = 0;
		for(int i = 1; i <= n-2; i++){
			int count = 0;
			for(char c = 'a' ; c <= 'z'; c++){
				//全部の文字見つけてやるよ
				int finds1 = 0;
				int finds2 = 0;
				//string1
				for(int j = 0 ; j < i ; j ++){
					if(s.charAt(j) == c){
						finds1=1;
						break;
					}
				}
				for(int j = i ; j < n; j++){
					if(s.charAt(j) ==c){
						finds2 = 1;
						break;
					}
				}
				if(finds1==1&&finds2==1){
					count ++;
				}
			}
			if(count > ans){
				ans = count;
			}
		}
		System.out.println(ans);
	} 
} 




Measured memory_bytes: 21972
#include<iostream>

#define rep(i,j) for(i=0;i<(j);i++)
#define rep_to_(i,j,k) for(i=j;i<=(k);i++)

#define MAXLEN 150
using namespace std;

int main(){
  int h,w;
  while(true){
    cin >> h>>w;
    if(h==0 && w==0)break;
    int len;
    len=h*h+w*w;

    int hi,wj,min=150*150*2,ah,aw,hp,wp,poh,lenp;

    rep_to_(hi,1,MAXLEN){
      poh=hi*hi;

      rep_to_(wj,hi+1,MAXLEN){
        lenp=poh+wj*wj;
        if(lenp>len && min>lenp){
          min=lenp;
          ah=hi;
          aw=wj;
          break;
        }
        else if(lenp==len && hi>h){
          min=lenp;
          ah=hi;
          aw=wj;
          goto OUT;
        }
      }
    }
  OUT:cout << ah<<" "<<aw<<endl;
  }
}

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

using namespace std;

int main(void){
    string S;
    int a, b;
    cin >> a >> b;
    cin >> S;
    
    if(S.size() != a + b + 1){
        cout << "No" << endl;
        return 0;
    }
    if(S[a] != '-'){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < S.size();i++){
        if(i == a)
            continue;
        if(S[i] < '0' || S[i] > '9'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    string s;
    cin >> s;
    string ans = "";
    for(ll i = 0; i < s.size(); i++){
        if(s[i] == '0')ans += "0";
        if(s[i] == '1')ans += "1";
        if(s[i] == 'B' && ans.size())ans.pop_back();        
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
testimonies = [[] for i in range(n)]
for idx1 in range(n):
    count = int(input())
    for idx2 in range(count):
        x,y = map(int, input().split())
        testimonies[idx1].append((x-1, y))

output = 0
for combination in range(2 ** n):
    consistent = True
    for index in range(n):
        if (combination >> index) & 1 == 0:
            continue
        for x,y in testimonies[index]:
            if (combination >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        output = max(output, bin(combination)[2:].count("1"))
print(output)

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int mypow(int n, int p) {
    if (p == 0) return 1;
    else if (p & 1) {
        return n * mypow(n, p - 1);
    } else {
        int half = mypow(n, p >> 1);
        return half * half;
    }
}

int main() {
    int x;
    cin >> x;
    int ans = 1;
    for (int j = 1; j <= x; ++j) {
        for (int i = 2; i <= x; ++i) {
            int tmp = mypow(j, i);
            if (tmp <= x) ans = max(tmp, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

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

int main (){
    int N,M;
    cin >> N >> M;
    LL ans=1800*M+100*N;
    for(int i=0;i<M;i++){
        ans*=2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
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]

def main():
    a,b=MI()
    for ans in range(1,2000):
        if ans*2//25==a and ans//10==b:break
    if ans==1999:print(-1)
    else:print(ans)

main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
typedef long long ll;

int main()
{
	char str[105];
	ll k;

	scanf("%s", str);
	scanf("%lld", &k);
	
	ll i = 0;
	while (i < k - 1 && i < strlen(str) - 1 && str[i] == '1') {
		i++;
	}

	printf("%c\n", str[i]);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	int n;
	cin>>n;
	ll a[n],tot=0;
	fr(i,0,n,1) cin>>a[i];
	fr(i,0,n,1) tot+=a[i];
	ll ans=0;
	fr(i,0,n,1){
		tot-=a[i];
		ans=(ans + (a[i]*(tot%mod))%mod)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5204
#include<iostream>
#include<queue>
#include<set>
#include<string.h>
#include<algorithm>
using namespace std;
set<int> s;

int main()
{
	int n;
	cin>>n;
	int num;
	for(int i=0;i<n;i++)
	{
		cin>>num;
		set<int>::iterator it=s.find(num);
		if(it!=s.end())s.erase(it);
		else s.insert(num);

	}
	cout<<s.size();

	//system("pause");
}



Measured memory_bytes: 4864
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cnt = 0 #モンスターの数
i = 0 

for _ in range(N):
    if A[i] + A[i+1] > B[i]: #今の村＋次の村が勇者の討伐可能数より多い
        cnt += B[i]
        if A[i] < B[i]: #次の村も討伐できる場合、次の村を一定程度減らす
            A[i+1] = A[i+1] + A[i] - B[i]
    elif A[i]+A[i+1]<=B[i]:
        cnt += A[i] + A[i+1]
        A[i+1] = 0
    i += 1
print(cnt)

Measured memory_bytes: 18476
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)) {
		if(ch=='-') o=-1;
		ch=getchar();
	}
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n;

int main() {
	cin>>n;ll f0=0,f1=-1e18,f2=-1e18;
	for(int i=1;i<=n;i++) {
		int x=gi();f0+=x;f1-=x;f2+=x;
		if(x<0) f2=max(f2,f1),f1=max(f1,f0);
		f1=max(f1,f2);f0=max(f0,f1);
	}
	cout<<f0;
	return 0;
}


Measured memory_bytes: 256
import sys
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())

#これO(1)で解けそう。

# スピードが同じ or 逃げる方のスピードが速いと無理
if V <= W:
    print("NO")
    sys.exit()



# 鬼の方がスピードが速い場合で場合訳
distance_AB = abs(A-B)
speed_AB = abs(V-W)

if speed_AB * T >= distance_AB:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9060
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	int R;

	cin >> N;
	cin >> R;

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		int val = 100 * (10 - N);
		R = R + val;
		cout << R << endl;
	}

	return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100009];
ll n,x,result,ans;
ll v[100009];
ll frog(ll pos,ll k)
{
   if (pos >= 0 && pos <n-1)
    {
        if (dp[pos]!= -1)
            return dp[pos];
      ll  int ret = INT_MAX;
        for(int i=1; i<=k ; i++)
        {

            ans = frog(i + pos,k ) + abs(v[pos]-v[pos+i]);
           // cout<<ans<<endl;
                ret = min(ret,ans );
        }
        return dp[pos] = ret;
    }
    else if(pos==n-1)
        return 0;
    else
        return INT_MAX;
}

int main()
{
    ll k;
    cin>>n>>k;
    memset(dp,-1,sizeof(dp));
    for(ll i=0; i<n; i++)
    {
        cin>>v[i];

    }
    cout<<frog(0,k)<<endl;
}



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

class UnionFind {
public:
	vector<int> par;

	void init(int sz) {
		par.resize(sz, -1);
	}
	int root(int pos) {
		if (par[pos] == -1) return pos;
		par[pos] = root(par[pos]);
		return par[pos];
	}
	void unite(int u, int v) {
		u = root(u); v = root(v);
		if (u == v) return;
		par[u] = v;
	}
	bool same(int u, int v) {
		if (root(u) == root(v)) return true;
		return false;
	}
};

int N, C[1 << 18];
int M, A[1 << 18], B[1 << 18], col[1 << 18];
bool E[1 << 18], ID[1 << 18];
UnionFind Z;

vector<pair<int, int>> X[1 << 18];
vector<pair<int, int>> Y[1 << 18];

void dfs(int pos, int dep) {
	col[pos] = dep;
	for (pair<int, int> to : Y[pos]) {
		if (col[to.first] != -1) continue;
		dfs(to.first, dep ^ to.second);
	}
}

int main() {
	cin >> N >> M; Z.init(N + 2);
	for (int i = 1; i <= N; i++) cin >> C[i];

	queue<int> Q;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		if (C[A[i]] == C[B[i]]) {
			if (Z.same(A[i], B[i]) == false) {
				Z.unite(A[i], B[i]);
				E[i] = true;
			}
			ID[A[i]] = true; ID[B[i]] = true;
		}
		if (C[A[i]] < C[B[i]]) X[A[i]].push_back(make_pair(B[i], i));
		if (C[B[i]] < C[A[i]]) X[B[i]].push_back(make_pair(A[i], i));
	}
	for (int i = 1; i <= N; i++) {
		if (ID[i] == true) Q.push(i);
	}

	// Step #1: チェック
	while (!Q.empty()) {
		int pos = Q.front(); Q.pop();
		for (pair<int, int> to : X[pos]) {
			if (ID[to.first] == true) continue;
			ID[to.first] = true;
			E[to.second] = true;
			Q.push(to.first);
		}
	}
	for (int i = 1; i <= N; i++) {
		if (ID[i] == false) { cout << "-1" << endl; return 0; }
	}

	// Step #2: 辺を貼る
	for (int i = 1; i <= M; i++) {
		if (E[i] == false) continue;
		
		int cost = 0;
		if (C[A[i]] == C[B[i]]) cost = 1;
		Y[A[i]].push_back(make_pair(B[i], cost));
		Y[B[i]].push_back(make_pair(A[i], cost));
	}

	for (int i = 1; i <= N; i++) col[i] = -1;
	for (int i = 1; i <= N; i++) {
		if (col[i] != -1) continue;
		dfs(i, 0);
	}

	// 出力
	for (int i = 1; i <= N; i++) {
		if (col[i] == 0) cout << "B";
		else cout << "W";
	}
	cout << endl;
	for (int i = 1; i <= M; i++) {
		if (E[i] == false) cout << "1000000000" << endl;
		else if (C[A[i]] == C[B[i]]) cout << C[A[i]] << endl;
		else cout << abs(C[A[i]] - C[B[i]]) << endl;
	}
	return 0;
}

Measured memory_bytes: 26996
#include<stdio.h>
int main(){
  char s[10];
  int x[30]={};
  int i;
  while(1){
    scanf("%c",&s[0]);
    if(s[0]=='\n')break;
    x[s[0]-'a']=1;
  }
  for(i=0;i<26;i++){
    if(x[i]==0){
      printf("%c\n",'a'+i);
      return 0;
    }
  }
  puts("None");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL n,a;
LL I = 0,J = 0,K = 0;
double dp[305][305][305];
char vis[305][305][305] = {0};

double dfs(LL c1,LL c2,LL c3){
	if(c1 == 0 && c2 == 0 && c3 == 0) return 0;
	if(vis[c1][c2][c3]) return dp[c1][c2][c3];
	LL s = c1 + c2 + c3;
	double ret = (double)n / (double)s;
	if(c1) ret += dfs(c1 - 1,c2,c3) * (double)c1 / (double)s;
	if(c2) ret += dfs(c1 + 1,c2 - 1,c3) * (double)c2 / (double)s;
	if(c3) ret += dfs(c1,c2 + 1,c3 - 1) * (double)c3 / (double)s;
	dp[c1][c2][c3] = ret;
	vis[c1][c2][c3] = 1;
	return ret;
}

int main(){
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++){
		scanf("%lld",&a);
		if(a == 1) I ++;
		if(a == 2) J ++;
		if(a == 3) K ++;
	}
	dfs(I,J,K);
	printf("%.10lf\n",dp[I][J][K]);
	return 0;
}

Measured memory_bytes: 246016
# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(input())
A = list(map(int, input().split()))
#print('A', A)

def remove_dup(A):
    B = []
    current = None
    for a in A:
        if current != a:
            B.append(a)
            current = a
    return B

# 同じ数字が続いたら除去
B = remove_dup(A)
#print('B', B)

sign = None
num = 0
for i in range(len(B)-1):
    diff = B[i+1] - B[i]
    if sign is None:
        if diff > 0:
            sign = 1
        else:
            sign = -1
    else:
        if sign == 1 and diff < 0 or sign == -1 and diff > 0:
            sign = None
            num += 1
print(num + 1)

Measured memory_bytes: 15020
#include <cstdio>
int main(){
    int n, x, answer = 0;
    
    while (1){
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= n; j++){
                for (int k = 1; k <= n; k++){
                    if (i == j || j == k || k == i) continue;
                    if (i + j + k == x) answer += 1;
                }
            }
        }
        printf("%d\n", answer / 6);
        answer = 0;
    }
    return 0;
}

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

typedef long long ll;

int main(){
	//Code here bby
  int n, d, res;
  cin>>n>>d;
  res = 0;
  while(n--){
    ll x, y;
    cin>>x>>y;
    double dist = sqrt((x*x) + (y*y));
    if(dist <= d){
      res++;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll x[n], l[n];
    rep(i, n){
        cin >> x[i] >> l[i];
    }

    pair<ll, ll> p[n];
    rep(i, n){
        p[i] = {x[i] + l[i], x[i] - l[i]};
    }

    sort(p, p + n);

    ll ans = 0;
    ll pos = -1e18;

    rep(i, n){
        ll start = p[i].second;
        ll end = p[i].first;

        if(pos <= start){
            ans++;
            pos = end;
        }
    }

    cout << ans << endl;
    
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

ll T1, T2, A1, A2, B1, B2;

bool check(ll cnt) {
    return ((A1-B1) * T1 >= ((B1-A1) * T1 + (B2-A2) * T2) * cnt);
}

bool twice(ll cnt) {
    return false;
}

void solve() {
    if (T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
        cout << "infinity" << endl;
        return;
    }
    if (T1 * A1 + T2 * A2 > T1 * B1 + T2 * B2) {
        swap(A1, B1);
        swap(A2, B2);
    }
    // 平均速度はBの方が早い
    if (B1 > A1) { // Bが常に前にいる
        cout << 0 << endl;
        return;
    }

    ll C1 = (B1 - A1); // C1 < 0
    ll C2 = (B2 - A2); // C2 > 0
    ll diff = C1 * T1 + C2 * T2;
    assert (C1 < 0);
    assert (C2 > 0);
    assert (diff > 0);
    // diff * n + C1 <= 0 を満たすnの最大値
    ll n = (-C1)*T1/diff;
    ll ans = 2*n+1;
    // nがdiff * n + C1 = 0 を満たすなら、最後のintervalの接触は1回だけ
    if (diff * n + C1 * T1 == 0) ans--;
    cout << ans << endl;
}

int main() {
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    solve();
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.ArrayList;


class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	private int[] visited;
	private int[] dist;
	
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		visited = new int[totalVertex];
		dist = new int[totalVertex];
		for(int i = 0; i< totalVertex; i++) {
			dist[i] = -1;
		}
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		for(int i = 0; i < totalVertex; i++) {
			System.out.println(i + 1 + " " + dist[i]);
		}
	}
	
	public void BFS() {
		ArrayList<Integer> arr = new ArrayList<Integer>();
		arr.add(0);
	    dist[0] = 0;
	    while(arr.size() > 0) {
	        //first-in, first-visit; if queue is used, use its dequeue() function
	        int v = arr.remove(0); 
	        visited[v] = 1;
	        LinkedList<Integer> nextTo = adjList.get(v);
	        for(int i = 0; i < nextTo.size(); i ++) {
	            int v1 = nextTo.get(i);
	            if((visited[v1] == 0) && (arr.contains(v1) == false)) {
	            	arr.add(v1);
	                dist[v1] = dist[v] + 1;
	                visited[v1] = 1;
	            }
	        }
	    }
		
		
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.BFS();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 28140
// 2009ツアツジツアツ地ツ凝ヲツ予ツ選 A : Cubist Artwork
#include <iostream>
#include <fstream>
#include <string.h>

using namespace std;

int main(){
	int w, d, t;
	int h1[21], h2[21];
	while(cin >> w >> d, w){
		memset(h1, 0, sizeof(h1));
		memset(h2, 0, sizeof(h2));
		for(int i=0;i<w;i++){ cin >> t; h1[t]++; }
		for(int i=0;i<d;i++){ cin >> t; h2[t]++; }
		int ans = 0;
		for(int i=0;i<=20;i++){
			ans += i*max(h1[i],h2[i]);
		}
		cout << ans << endl;
	}
}

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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template<typename T>
void chmin(T& s,T t){
    s=min(s,t);
}
template<typename T>
void chmax(T& s,T t){
    s=max(s,t);
}


int main(){
    int a,b,c;cin>>a>>b>>c;
    if(a+b==c||a+c==b||a==b+c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
     
    return 0;
}


Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V

a#b = abs$a-b

main = do
    [n,k] <- map read.words<$>getLine
    hr <- V.unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine
    print $ f n k hr

f n k h=dp V.! (n-1) where
    dp = V.generate n m
    m 0 = 0
    m i = V.minimum $ V.zipWith (+) (V.slice s l dp) $ V.map (# (h V.! i)) $ V.slice s l h
        where
            s = max 0 (i-k)
            l = i-s

Measured memory_bytes: 23932
// Problem : A - A?C
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

int main() {
  std::string s;
  std::cin >> s;
  if (s == "ABC") puts("ARC"); else puts("ABC");
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

struct edge{int to, cost;};
const int MAX_M = 2e5 + 5, INF = 1e5;
int N, M, d[MAX_M * 3];
vector<edge> G[MAX_M * 3];
map<P, int> f;

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> pq;
    fill(d, d+MAX_M*3, INF); d[s] = 0;
    pq.push(P(0, s));

    while(pq.size()){
        P p = pq.top(); pq.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(auto e : G[v]){
            if(d[v]+e.cost<d[e.to]){
                d[e.to] = d[v] + e.cost;
                pq.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> N >> M;
    f[P(1, 0)] = 0; f[P(N, 0)] = 1;
    int cnt = 2;
    for(int i=0;i<M;i++){
        int p, q, c; cin >> p >> q >> c;
        
        auto it1 = f.find(P(p, c)), it2 = f.find(P(q, c));
        if(it1 == f.end()) f[P(p, c)] = cnt++;
        if(it2 == f.end()) f[P(q, c)] = cnt++;
        edge e1; e1.to = f[P(q, c)]; e1.cost = 0;
        edge e2; e2.to = f[P(p, c)]; e2.cost = 0;
        G[f[P(p, c)]].push_back(e1); G[f[P(q, c)]].push_back(e2);
        
        auto it3 = f.find(P(p, 0)), it4 = f.find(P(q, 0));
        if(it3 == f.end()) f[P(p, 0)] = cnt++;
        if(it4 == f.end()) f[P(q, 0)] = cnt++;
        edge e3; e3.to = f[P(p, 0)]; e3.cost = 0;
        edge e4; e4.to = f[P(q, 0)]; e4.cost = 0;
        G[f[P(p, c)]].push_back(e3); G[f[P(q, c)]].push_back(e4);

        edge e5; e5.to = f[P(p, c)]; e5.cost = 1;
        edge e6; e6.to = f[P(q, c)]; e6.cost = 1;
        G[f[P(p, 0)]].push_back(e5); G[f[P(q, 0)]].push_back(e6);
    }

    dijkstra(f[P(1, 0)]);
    
    if(d[f[P(N, 0)]] == INF) cout << -1 << endl;
    else cout << d[f[P(N, 0)]] << endl;

    return 0;
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                int n;

                if (!int.TryParse(line, out n))
                    break;

                if (n == 0)
                    break;

                int[] s = Console.ReadLine().Split(' ')
                                .Select(x => int.Parse(x))
                                .ToArray();

                double avg = s.Average();
                double v = s.Select(x => Math.Pow((x - avg), 2))
                    .Sum() / s.Length;

                Console.WriteLine("{0:f8}", Math.Sqrt(v));
            }

        }
    }
}

Measured memory_bytes: 9872
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := intScanner(), intScanner(), intScanner()
	if a+b+c-max([]int{a, b, c}) == max([]int{a, b, c}) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772