akhauriyash/Code-Regression huggingface dataset:
import numpy as np
n = int(input())
p = np.array(input().split(),dtype=int)
q = np.array(input().split(),dtype=int)
kaijo = [1,1,2,6,24,120,720,5040]
pn = 0
qn = 0
ans = 0
for i in range(n-1):
    pi = p[i]-1
    qi = q[i]-1
    for j in range(i):
        if p[i] > p[j]:
            pi -= 1
    for j in range(i):
        if q[i] > q[j]:
            qi -= 1
    pn += pi*kaijo[n-i-1]
    qn += qi*kaijo[n-i-1]

print(abs(pn-qn))


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

int main() {
	int n, m,a,b;
	cin >> n>>m>>a>>b;
	vector<string> map(n,string(m,'.'));
	if (n % 2) {
		for (int i = 1; i < m && a > 0; i+=2) {
			map[n - 1][i - 1] = '<';
			map[n - 1][i] = '>';
			a--;
		}
	}
	if (m % 2) {
		for (int i = 1; i < n && b > 0; i+=2) {
			map[i - 1][m - 1] = '^';
			map[i][m - 1] = 'v';
			b--;
		}
	}
	for (int i = 1; i < n; i+=2) {
		for (int j = 1; j < m; j+=2) {
			if (a > 1) {
				map[i - 1][j - 1] = map[i][j - 1] = '<';
				map[i - 1][j] = map[i][j] = '>';
				a -= 2;
			} else if (b > 1) {
				map[i - 1][j - 1] = map[i - 1][j] = '^';
				map[i][j - 1] = map[i][j] = 'v';
				b -= 2;
			}  else if (b == 1) {
				map[i - 1][j - 1] = '^';
				map[i][j - 1] = 'v';
				b--;
			} else if (a == 1) {
				map[i - 1][j - 1] = '<';
				map[i - 1][j] = '>';
				a--;
			} else {
				i = n;
				break;
			}
		}
	}
	if (n % 2 && m % 2 && a == 1 && map[n - 2][m - 2] == '.') {
		map[n - 3][m - 2] = '<';
		map[n - 3][m - 1] = '>';
		map[n - 2][m - 1] = '^';
		map[n - 1][m - 1] = 'v';
		a--;
	}
	if (a || b) {
		cout << "NO\n";
	} else {
		cout << "YES\n";
		for (int i = 0; i < n; i++) cout << map[i] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
int const N=5e5+5;
ll a[N][4];
int n;
ll memo[N][4];
//0 swim 1 catch 2 homework
ll dp(int i,int j){
 if(i==n)
    return 0;
 ll &ret=memo[i][j];
 if(ret!=-1)
    return ret;
ll path1=0;
ll path2=0;
ll path3=0;
if(j!=0)
    path1=dp(i+1,0)+a[i][0];
if(j!=1)
    path2=dp(i+1,1)+a[i][1];
if(j!=2)
    path3=dp(i+1,2)+a[i][2];
return ret=max(path1,max(path2,path3));

}
int main()
{
cin>>n;
for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
        cin>>a[i][j];
clr(memo,-1);
    cout<<dp(0,3)<<endl;


}


Measured memory_bytes: 27008
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if( (n|k) == 0 ) break;
			int[] card = new int[k+1];
			for(int i=0;i<k;i++) card[i] = sc.nextInt();
			sort(card);
			int max = 0;
			if( card[1] != 0 ) {
				int cnt = 0;
				for(int i=1;i<=k;i++) {
					if( card[i] == card[i-1] + 1 )
						cnt++;
					else cnt = 1;
					max = max(cnt, max);
				}
			}
			else {
				int[] cnt = new int[2];
				for(int i=2;i<=k;i++) {
					if( card[i] == card[i-1] + 1 ) {
						cnt[0]++;
						if(cnt[1] != 0) cnt[1]++;
					}
					else if( card[i] == card[i-1] + 2) {
						cnt[1] = cnt[0] + 2;
						cnt[0] = 1;
					}
					else {
						cnt[0] = 1;
						cnt[1] = 0;
					}
					max = max(max, max(cnt[0], cnt[1]));
				}
			}
			System.out.println(max);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
package main

import (
	"fmt"
	"math"
)

func main() {
	nums := scanNums(2)
	sum := nums[0] + nums[1]
	diff := nums[0] - nums[1]
	prod := nums[0] * nums[1]

	max := sum
	if diff > max {
		max = diff
	}
	if prod > max {
		max = prod
	}

	fmt.Println(max)
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k,d,x;
    cin>>n>>k;
    vector<ll>v;
    for(ll i=0;i<=n;i++)
    {
        v.push_back(0);
    }
    for(ll i=0;i<k;i++)
    {
        cin>>d;
        while(d)
        {
          cin>>x;
          v[x]=1;
          d--;
        }
    }
    ll c=0;
    for(ll i=1;i<=n;i++)
    {
       if(v[i]==0) c++;
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int W, H, N;
	cin >> W >> H >> N;
	int x, y, a;
	int a1 = 0, a2 = W, a3 = 0, a4 = H;
	rep(i,N){
		cin >> x >> y >> a;
		if(a == 1){
			a1 = max(a1, x);
		}
		if(a == 2){
			a2 = min(a2, x);
		}
		if(a == 3){
			a3 = max(a3, y);
		}
		if(a == 4){
			a4 = min(a4, y);
		}
	}
	cout << max((int)0, a2-a1) * max((int)0, a4-a3) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner n = new Scanner(System.in);
        int N = n.nextInt();
        int a[] = new int[N];
        int b[] = new int[N];
        int c[] = new int[N-1];
        String A[] = new String[N];
        String B[] = new String[N];
        String C[] = new String[N-1];
        int sum = 0;
        for(int i=0;i<N;i++){
            A[i] = n.next();
            a[i] = Integer.parseInt(A[i]);
        }
        for(int i=0;i<N;i++){
            B[i] = n.next();
            b[i] = Integer.parseInt(B[i]);
        }
        for(int i=0;i<N-1;i++){
            C[i] = n.next();
            c[i] = Integer.parseInt(C[i]);
        }
        for(int i=0;i<N;i++){
            sum += b[a[i]-1];
            if(i<N-1){
                if(a[i]==a[i+1]-1){
                    sum += c[a[i]-1];
                } 
            }
        }
        n.close();
        System.out.println(sum);
    }
} 

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll>A(n+1);
    vector<ll>B(n);
    REP(i,n+1){
        cin >> A[i];
    }
    REP(i,n){
        cin >> B[i];
    }
    ll cnt= 0;
    REP(i,n){
        if(A[i]>=B[i]){
            cnt+= B[i];
        }else{
            cnt+= A[i];
            ll p= B[i]-A[i];
            if(A[i+1]<=p){
                cnt+= A[i+1];
                A[i+1]=0;
            }else{
                cnt+= p;
                A[i+1]-=p;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

int main() {
	int n, k, t, u, v, l;
	scanf("%d %d %d %d %d %d", &n, &k, &t, &u, &v, &l);

	vector<bool> carrot(l, false);
	for(int i = 0; i < n; ++i) {
		int d;
		scanf("%d", &d);
		carrot[d] = true;
	}

	int cnt = 0, num = 0, rest = 0;
	for(int i = 0; i < l; ++i) {
		if(carrot[i])
			++num;

		if((num && !rest) || num > k) {
			rest = t * v;
			--num;
		}

		if(rest) {
			--rest;
			++cnt;
		}
	}

	printf("%.15lf\n", (double)cnt / v + (double)(l - cnt) / u);

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1072
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str1, str2;
	

	cin >> str1;

	str2 = str1.substr(0, 4);



	if (str2 == "YAKI") {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

  int temp_max = 0;
  for (int i=1;i<32;i++){
    for (int p=2;p<10;p++){
      int pow = std::pow(i, p);
      if((pow <= X) && (pow > temp_max)){
          temp_max = pow;
      }
    }
  }

  cout << temp_max << endl;

  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
    char S[3][101], trn = 0, crd;
    int p[3] = {0, 0, 0};
    scanf("%s\n%s\n%s", S[0], S[1], S[2]);
    while(1){
        crd = S[(int)trn][p[(int)trn]];
        if(crd == '\0'){
            printf("%c\n", 'A'+trn);
            break;
        }
        else{
            p[(int)trn]++;
            trn = crd-'a';
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        char[] s=sc.next().toCharArray(), t=sc.next().toCharArray();
        sc.close();
        int sl=s.length, tl=t.length;
        HashSet<Character> scaras=new HashSet<>();
        ArrayList<Integer> alph[]=new ArrayList[26];
        for(int a=0;a<26;a++) alph[a]=new ArrayList<>();
        for(int i=0;i<sl;i++){
            scaras.add(s[i]);
            alph[s[i]-'a'].add(i);
        }
        ArrayList<Integer> index[]=new ArrayList[tl];
        long ans=0;
        int now=-1;
        for(int j=0;j<tl;j++){
            if(!scaras.contains(t[j])){
                System.out.println(-1);
                return;
            }
            index[j]=alph[t[j]-'a'];
            int in=backBS(index[j], now);
            if(in==index[j].size()){
                ans+=sl;
                now=index[j].get(0);
            }
            else now=index[j].get(in);
        }
        ans+=now+1;
        System.out.println(ans);
    }
    public static int backBS(ArrayList<Integer> array, long key){
        int left=-1;
        int right=array.size();
        while(right-left>1){
            int mid=left+(right-left)/2;
            if(array.get(mid)>key) right=mid;
            else left=mid;
        }
        return right;
    }
}

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

using namespace std;
using ll = long long;

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

  const ll mod = 1e9 + 7;

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

  // // bits[i][j][0or1] := i番目以降の数にj桁目が0or1になる数がいくつあるか
  // vector<vector<vector<ll>>> bits(n, vector<vector<ll>>(60, vector<ll>(2)));
  //
  // for (ll i = n - 1; i >= 0; i--) {
  //   for (ll j = 0; j < 60; j++) {
  //     if (i < n - 1) {
  //       bits[i][j][0] = bits[i + 1][j][0];
  //       bits[i][j][1] = bits[i + 1][j][1];
  //     }
  //     if (a[i] & (1ll << j)) {
  //       bits[i][j][1]++;
  //     } else {
  //       bits[i][j][0]++;
  //     }
  //   }
  // }
  //
  // ll ans = 0;
  // for (ll i = 0; i < n - 1; i++) {
  //   for (ll j = 0; j < 60; j++) {
  //     if (a[i] & (1ll << j)) {
  //       ans += ((1ll << j) % mod) * bits[i + 1][j][0];
  //       ans %= mod;
  //     } else {
  //       ans += ((1ll << j) % mod) * bits[i + 1][j][1];
  //       ans %= mod;
  //     }
  //   }
  // }
  // cout << ans << endl;

  vector<ll> zero(60, 0);
  vector<ll> one(60, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      if (a[i] & (1ll << j)) {
        one[j]++;
      } else {
        zero[j]++;
      }
    }
  }

  ll ans = 0;
  for (int j = 0; j < 60; j++) {
    ans += (1ll << j) % mod * one[j] % mod * zero[j] % mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5540
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Bichrome Cells
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a;
  cin >> n >> a;
  printf("%d\n", n * n - a);
  return 0;
}


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

using namespace std;

int extgcd(int a,int b,int &x,int &y)
{
    int d=a;
    if(b)
    {
        d=extgcd(b,a%b,y,x);
        y-=a/b*x;
    }else
    {
        x=1;y=0;
    }
    return d;
}

int main()
{
    int a,b;

    while(cin>>a>>b)
    {
        int x,y;
        extgcd(a,b,x,y);
        cout<<x<<" "<<y<<endl;
    }

    return 0;
}



Measured memory_bytes: 3096
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  string s,t;
  t="CODEFESTIVAL2016";
    cin >> s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
 
int d[111], f[111];
bool visited[111];
vector<vector<int> > g(111);
int t;
void dfs(int x){
  t++;
  d[x] = t;
  visited[x] = true;
  for(auto &u : g[x]){
    if(!visited[u]){
      dfs(u);
    }
  }
  t++;
  f[x] = t;
}
 
int main(){
  int n; cin >> n;
  FOR(i,0,n){
    int u, k; cin >> u >> k;
    FOR(j,0,k){
      int v;
      cin >> v;
      g[u].push_back(v);
    }
  }
  FOR(i,0,n+1) visited[i] = false;
  t = 0;
  FOR(i,1,n+1){
    if(!visited[i]) dfs(i);
  }
 
  FOR(i,1,n+1){
    printf("%d %d %d\n", i, d[i], f[i]);
  }
  return 0;
}

Measured memory_bytes: 3272
#include<stdio.h>

int main(void)
{
  int n;
  
  while( scanf("%d",&n) ){
    int count=0;
    if(n==0 )break;
    while(n!=1){
      count++;
      if( n%2 == 0 ){
	n=n/2;
      }
      else{
	n=n*3+1;
      }
    } 
    
    printf("%d\n",count);
  }
  
  return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> a(n + 1);
    REP(i, n + 1) cin >> a[i];
    vector<int> b(n);
    REP(i, n) cin >> b[i];

    ll ans = 0;
    int tmp = 0;
    REP(i, n) {
        ans += min(a[i], b[i]);
        if (b[i] - a[i] > 0) {
            tmp = b[i] - a[i];
            ans += min(tmp, a[i + 1]);
            a[i + 1] = max(a[i + 1] - tmp, 0);
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
import sys
MOD = 10**9 + 7
list_size = 700000

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

x, y = map(int, input().split())
if (x+y)%3 != 0:
	print(0)
	sys.exit()
n = (x+y)//3
r = n - (n-x+y)//2
print(comb(n, r))

Measured memory_bytes: 58484
#include<stdio.h>
int main(void){
	int a,b,c,d,n,count=0;
	while(scanf("%d",&n)!=EOF){
		count=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(n==a+b+c+d){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}


Measured memory_bytes: 2036
N = int(input())
v = list(map(int , input().split()))
v = sorted(v)
ave = 0
for i in range(1,len(v)):
    if i == 1:
        sum = v[0] + v[1]
        ave = sum / 2
    else:
        ave = (ave + v[i]) / 2

print(ave)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    ll x, y;
    cin>>x>>y;
    int cnt = 0;
    while (x <= y) {
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

// https://qiita.com/wakimiko/items/69b86627bea0e8fe29d5
struct Edge {
    ll from; //出発点
    ll to;   //到達点
    ll cost; //移動コスト
};

ll bellmanFord(ll v, ll s, ll g, vector<Edge> &routes) {

    vector<ll> costs(v, INF);
    vector<bool> hasLoop(v, false);
    costs[s] = 0;

    for (ll i = 0; i < v - 1; i++) {
        for (ll j = 0; j < (ll) routes.size(); j++) {
            Edge e = routes[j];
            if(costs[e.from] == INF) continue;
            if (costs[e.to] > costs[e.from] + e.cost) {  //移動した後のコストが小さいと、頂点のコストを更新
                costs[e.to] = costs[e.from] + e.cost;
            }
        }
    }
    for (ll j = 0; j < v; j++) {
        for (ll i = 0; i < (ll) routes.size(); i++) {
            ll f = routes[i].from;
            ll t = routes[i].to;
            ll c = routes[i].cost;
            if (costs[f] == INF) continue;
            if (costs[f] + c < costs[t]) hasLoop[t] = true;
            if (hasLoop[f])hasLoop[t] = true;
        }
    }
    if (hasLoop[g] == true) return MINF;
    return costs[g];
}

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

    vector<Edge> routes(m);

    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c = -c;
        Edge edge = {a, b, c};
        routes[i] = edge;
    }

    ll ans = bellmanFord(n, 0, n - 1, routes);

    if (ans == MINF) {
        cout << "inf" << endl;
        return 0;
    }

    cout << -ans << endl;
}



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

class P
{
    static void Main()
    {
        //int[] wab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = int.Parse(Console.ReadLine());
        long res = 1;
        for (long i = 1; i <= a; i++) res = res * i % 1000000007;
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<pair<int, int>>>p(h, vector<pair<int, int>>(w));
    rep(i, h){
        queue<int> q;
        int cnt = 0;
        rep(j, w){
            if (s[i][j] == '.') {
                q.push(j);
            }else{
                cnt = q.size();
                rep(k, cnt) {
                    p[i][q.front()].first = cnt;
                    q.pop();
                }
            }
        }
        cnt = q.size();
        rep(k, cnt) {
            p[i][q.front()].first = cnt;
            q.pop();
        }
    }
    rep(i, w){
        queue<int> q;
        int cnt = 0;
        rep(j, h){
            if (s[j][i] == '.') {
                q.push(j);
            }else{
                cnt = q.size();
                rep(k, cnt) {
                    p[q.front()][i].second = cnt;
                    q.pop();
                }
            }
        }
        cnt = q.size();
        rep(k, cnt) {
            p[q.front()][i].second = cnt;
            q.pop();
        }
    }
    int ans = 0;
    rep(i, h){
        rep(j, w){
            //cout << '(' << p[i][j].first << ',' << p[i][j].second <<  ") ";
            if (s[i][j] == '.') {
                ans = max(ans, p[i][j].first + p[i][j].second - 1);
            }
        }
        //cout << endl;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    LL l1, l2;
    l1 = 2, l2 = 1;
    int n;
    cin>>n;
    while(--n)
    {
        l2 += l1;
        l1 = l2 - l1;
    }
    cout<<l2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200005
#define st first
#define nd second
#define pb push_back
using namespace std;
typedef long long ll;
ll n, a, b, i, j, t, x, l, r, p;
vector<pair<ll,ll> > v;
ll cautbin(ll x, ll l, ll r)
{
    while(l!=r)
    {
        ll m=(l+r+1)/2;
        if(v[m].st<=x)
            l=m;
        else r=m-1;
    }
    return l;
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
int main()
{
    fast();
    cin>>n;
    x=-5000;
    while(x*x*x*x*x<=(1LL<<62))
    {
        v.pb({x*x*x*x*x,x});
        ++x;
    }
    r=v.size()-1;
    for(i=0;i<v.size();++i)
    {
        p=cautbin(v[i].st+n,0,r);
        if(v[p].st-v[i].st==n)
        {
            cout<<v[p].nd<<' '<<v[i].nd<<'\n';
            return 0;
        }
    }
}


Measured memory_bytes: 3740
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        List<Integer> table = new ArrayList<>();
        outer: for (int i = 2; i <= 400000; i++) {
            if (i % 7 != 1 && i % 7 != 6) continue;
            for (int j = 2; j * j <= i; j++) {
                if (j % 7 != 1 && j % 7 != 6) continue;
                if (i % j == 0) continue outer;
            }
            table.add(i);
        }

        while (true) {
            int n = in.nextInt();
            if (n == 1) break;
            out.print(n + ":");
            for (int num : table) {
                if (n % num == 0) {
                    out.print(" " + num);
                }
            }
            out.println();
        }
        out.flush();
    }
}



Measured memory_bytes: 31320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC094A
{
    class Program
    {
        
            static void Main(string[] args)
            {



                var word = Console.ReadLine().Split();

            int a = int.Parse(word[0]);
            int b = int.Parse(word[1]);
            int c = int.Parse(word[2]);

            if (a > c)
                Console.WriteLine("NO");
            else if (a - c > b)
                Console.WriteLine("NO");
            else if (a + b < c)
                Console.WriteLine("NO");

            else
                Console.WriteLine("YES");


            Console.ReadKey();


            }
        }
    }


Measured memory_bytes: 11092
#include <stdio.h>

int main(){
    int x,y,t;
    while(1){
       scanf("%d %d", &x, &y);
       if ( x == 0 && y == 0) {
           break;
       }else if (x > y){
           t = x;            
           x = y; 	       
           y = t;
      }
      printf("%d %d\n",x,y); 
    }
    return 0;
}



Measured memory_bytes: 2024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
typedef long long ll;
using namespace std;
 
int main(){
  int n,a,b;
  cin >> n >> a >>b;
  
  if(n == 1) cout << "Hello World" << endl;
  else cout << a+b << endl;
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  
  for (int i  = 0; i < N; i++) {
    cin >> W.at(i);
  }
  
  vector<int> s(N);
  
  for (int T = 1; T < N; T++) {
    int S1 = 0;
    int S2 = 0;
    for (int i = 0; i < N; i++) {
      if (i <= T) {
        S1 += W.at(i);
      } else {
        S2 += W.at(i);
      }
    }
    if (S1 - S2 >= 0) {
      s.at(T) = S1 - S2;
    } else {
      s.at(T) = S2 - S1;
    }
  }
  
  sort(s.begin(), s.end());
  
  cout << s.at(1) << endl;
  
 
  
  
  
  return 0;
}

Measured memory_bytes: 256
b=[]
n=int(input())
a=list(map(int,input().split()))
for i in a:
  if i %2==0:
    b.append(i)
cnt=0
for i in b:
  if i%3==0 or i%5==0:
    cnt+=1
if cnt==len(b):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 38256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a[]=new int[3];
		a[0]=scan.nextInt();
		a[1]=scan.nextInt();
		a[2]=scan.nextInt();
		Arrays.sort(a);
		System.out.println(a[0]+a[1]);
	}
}


Measured memory_bytes: 22228
while True:
    a,b,c=input().split()
    a = int(a)
    c = int(c)
    if b=='?':
        break
    elif b=='+':
        print(a+c)
    elif b=='-':
        print(a-c)
    elif b=='*':
        print(a*c)
    elif b=='/':
        print(a//c)

Measured memory_bytes: 7540
package main

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

func main() {
	sc := NewScanner()
	S, W := sc.NextInt(), sc.NextInt()
	if S <= W {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
}

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: 1756
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
    	int N100 = N/100;//100のけた
      	int N10 = (N/10)%10;//
        int N1 = N%10;//1のけた
        if(N1 == 7 || N10 == 7 || N100 == 7){
          System.out.print("Yes");
        }else{
          System.out.print("No");
        }
    }
}

Measured memory_bytes: 35736
/*input
100 100
*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
ll n,i,j,k,m;

void solve() 
{ 

cin>>n>>m;

cout<<n*m;


}
 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
 // cin >> T;
ll h=T;
    while(T--){
 
        solve();
        cout<<endl;

     
        
        
 
    }
    
    
    return 0;
 
}


Measured memory_bytes: 3688
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

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

  rep(x,1,50001){
    int m = x*108/100;
    if (m==n){
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
diagram = gets.chomp.chars

upper_skip = ->{
  loop do
    a = diagram[0]
    return false if a == "\\"
    return true unless a
    diagram.shift
  end
}

downer_skip = ->(target_height) {
  height = index = 0
  until height == target_height
    height -= 1 if diagram.shift == "\\"
    index += 1
  end
  index
}

highest = ->{
  max_index = height = 0
  max_height = -Float::INFINITY 
  diagram.size.times do |j|
    case diagram[j]
    when "\\"
      height -= 1
    when "/"
      height += 1
      max_height, max_index = height, j if max_height < height
      return [0, j] if height.zero?
    end
  end
  [max_height, max_index]
}

calc_area = ->(from, to) {
  depth = area = 0
  from.upto(to) do
    case diagram.shift
    when "\\"
      area += depth + 1/2r
      depth += 1
    when "_"
      area += depth
    when "/"
      depth -= 1
      area += depth + 1/2r
    end
  end
  area.to_i
}


pools = []
loop do
  break if upper_skip.()
  height, last_index = highest.()
  if height.zero?
    pools << calc_area.(0, last_index)
  elsif height == -Float::INFINITY
    break
  else
    first_index = downer_skip.(height)
    pools << calc_area.(first_index, last_index)
  end
  break if diagram.size.zero?
end

if pools.empty?
  puts 0, 0
else
  puts pools.inject(&:+)
  puts pools.size.to_s + " " + pools.join(" ")
end


Measured memory_bytes: 8036
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int b[MAX];

int main() {
	int n,h;cin>>n>>h;
	int a_max=-1;
	rep(i,n) {int a;cin>>a>>b[i];a_max=max(a_max,a);}
	sort(b,b+n,greater<int>());
	int ans=0;
	rep(i,n) {
		if(b[i]>a_max&&h>0) {h-=b[i];ans++;}
		else break;
	}
	if(h>0) ans+=(h-1)/a_max+1;
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll allscore(int i, int d, vector<vector<int>>s, vector<vector<int>>t, vector<int>c) {
	ll res = 0;
	int fury = 0;
	for (int j = 0; j < d; j++) {
		if (t.at(i).at(j) == 1) {
			res += s.at(j).at(i);
			fury = 0;
		}
		else {
			fury++;
			res -= fury * c.at(i);
		}
	}
	return res;
}
ll fastscore(vector<int>bl,int date,int fury) {
	int l = -1;
	int r = bl.size();
	for (int i = date - 1; i >= 0; i--) {
		if (bl.at(i) == 1) {
			l = i;
			break;
		}
	}
	for (int i = date + 1; i < r; i++) {
		if (bl.at(i) == 1) {
			r = i;
			break;
		}
	}
	ll ans = (r - date) * (date - l) * fury;
	return ans;
}
int main() {
	//入力
	int d; cin >> d;
	vector<int>c(26);
	for (int i = 0; i < 26; i++)cin >> c.at(i);
	vector<vector<int>>s(d, vector<int>(26));
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < 26; j++)cin >> s.at(i).at(j);
	}
	vector<int>td(d);
	vector<vector<int>>t(26, vector<int>(d,0));
	for (int i = 0; i < d; i++) {
		int x;
		cin >> x;
		x--;
		td.at(i) = x;
		t.at(x).at(i)++;
	}
	
	int m;
	cin >> m;
	vector<pair<int, int>>dq(m);
	for (int i = 0; i < m; i++) {
		cin >> dq.at(i).first >> dq.at(i).second;
		dq.at(i).first--;
		dq.at(i).second--;
	}
	
	//Q.B
	vector<int>sum(26,0);
	for (int i = 0; i < 26; i++) {
		sum.at(i) = allscore(i, d, s, t, c);
	}
	ll ans = 0;
	for (int i = 0; i < 26; i++)ans += sum.at(i);
	//Q.C
	for (int i = 0; i < m; i++) {
		int day = dq.at(i).first;
		int change = dq.at(i).second;
		int before = td.at(day);
		//変更前と変更後について再計算、sumに反映
		t.at(before).at(day) = 0;
		t.at(change).at(day) = 1;
		td.at(day) = change;
		ll befs = fastscore(t.at(before), day, c.at(before)) + s.at(day).at(before);
		ll chgs = fastscore(t.at(change), day, c.at(change)) + s.at(day).at(change);
		ans = ans - befs + chgs;
		sum.at(before) -= befs;
		sum.at(change) += chgs;
		cout << ans << endl;
	}
}

Measured memory_bytes: 4152
#include <iostream>

using namespace std;

int main(void)
{
    const int Gladness_500yen = 1000;
    const int Gladness_5yen = 5;
    int X;
    int totalGladness = 0;

    cin >> X;

    //500円硬貨で両替
    int num_500yen = X / 500;
    totalGladness += num_500yen * Gladness_500yen;
    X = X % 500;

    //5円硬貨で両替
    int num_5yen = X / 5;
    totalGladness += num_5yen * Gladness_5yen;
    
    cout << totalGladness << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
broken=[False for i in range(n+1)]
const=1000000007
for i in range(m):
    a=int(input())
    broken[a]=True
n_way=[1,1]
if broken[1]:
    n_way=[1,0]
for i in range(2,n+1):
    if not broken[i] :
        n_way.append((n_way[i-1]+n_way[i-2])%const)
    else:
        n_way.append(0)
print(n_way[n])



Measured memory_bytes: 7832
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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 n;
vector<int>a;
vector<vector<int> > dp;
int rec(int l = 0,int r = n) {
    if((r-l)<=1) return 0;
    if((r-l)==2) {
        if(abs(a[l]-a[l+1])<=1) {
            return 2;
        } else {
            return 0;
        }    
    }
    if(dp[l][r] != -1)return dp[l][r];
    if(abs(a[l] - a[r-1]) <= 1 && rec(l+1,r-1) == r-l-2) {
        chmax(dp[l][r],r-l);
    }
    for(int i = l+1;i<=r-1;i++) {
        chmax(dp[l][r],rec(l,i) + rec(i,r));
    }
    return dp[l][r];
}
int main() {
    while(true) {
        cin >> n;
        if(n==0) break;
        a.resize(n);
        rep(i,n) cin >> a[i];
        dp.assign(n+2,vector<int>(n+2,-1));
        cout << rec() << endl;
    }
}


Measured memory_bytes: 3260
using System;
namespace AISing.Problems
{
    class A
    {
        static void Main()
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int l = int.Parse(inputs[0]);
            int r = int.Parse(inputs[1]);
            int d = int.Parse(inputs[2]);

            int ll = l / d;
            int rr = r / d;
            if (l % d == 0)
            {
                Console.WriteLine(rr - ll + 1);
            }
            else
            {
                Console.WriteLine(rr - ll);
            }
        }
    }
}


Measured memory_bytes: 27528
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel rui(19, 1);
vel kai(1000007, 1);
vel ink(1000007, 1);
vel par;
int root(int ser) {
	if (par[ser] == -1) { return ser; }
	int ans = root(par[ser]);
	par[ser] = ans;
	return ans;
}
bool marge(pin a) {
	int x = root(a.first);
	int y = root(a.second);
	if (x != y) {par[x] = y;}
	return x != y;
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
int nap(int n, vel napw, vel napv) {
	if (napw.size() == 0) { return 0; }
	if (napw.size() == 1) {
		return (n / napw[0])*napv[0];
	}
	if (napw.size() == 2) {
		int ans = 0;
		int lim = n / napw[0];
		rep(c0, lim+1) {
			int c1 = (n - c0 * napw[0])/napw[1];
			mmax(ans, c0*napv[0] + c1*napv[1]);
		}
		return ans;
	}
	int ans = 0;
	int ex;
	int lim = n / napw[0];
	int nlim;
	rep(c0, lim+1) {
		ex = n - c0 * napw[0];
		nlim = ex / napw[1];
		rep(c1, nlim+1) {
			int c2 = (ex - c1 * napw[1]) / napw[2];
			mmax(ans, c0*napv[0] + c1 * napv[1]+c2*napv[2]);
		}
	}
	return ans;
}
signed main() {
	int n; cin >> n;
	vvel w(2, vel(3));
	rep(i, 3) { cin >> w[0][i]; }
	rep(i, 3) { cin >> w[1][i]; }
	rep(i, 2) {
		vel napv(0), napw(0);
		rep(j, 3) {
			int now_w = w[i][j];
			int pre_w = w[(i + 1) % 2][j];
			if (now_w<pre_w) {
				napw.push_back(now_w);
				napv.push_back(pre_w - now_w);
			}
		}

		n += nap(n, napw, napv);
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 15872
S = input()
decom = []

temp = 0
for i in range(1,len(S)):
  if S[i] != S[i-1]:
    decom.append((S[i-1],temp + 1))
    temp = 0
  else:
    temp += 1
decom.append((S[-1],temp + 1))

ans = 0
for i in range(len(decom)):
  if decom[i][0] == "<":
    if i == len(decom) - 1:
      ans += decom[i][1]
    ans += (decom[i][1] * (decom[i][1] - 1)) // 2
  else:
    if i == 0 or decom[i][1] > decom[i-1][1]:
      ans += (decom[i][1] * (decom[i][1] + 1)) // 2
    else:
      ans += decom[i-1][1] + (decom[i][1] * (decom[i][1] - 1)) // 2
print(ans)


Measured memory_bytes: 22044
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 1e18
#define common cout << "Case #" << w+1 << ": "  



int main()
{
    fastio;
    string s,t;
    cin >> s >> t;
    int len=t.length(),n=s.length();
    int ans=len;
    for(int i=0;i<=n-len;i++)
    {
        string x=s.substr(i,len);
        int cnt=0;
        for(int j=0;j<len;j++)
        {
            if(x[j]!=t[j])
                cnt+=1;
        }
        ans=min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)
typedef struct edge{
    int v;              // エッジの　終点　
    LL w;               // エッジの　重み　
    edge() {}                                             
    edge(int v, LL w) : v(v), w(w) {};          
} Edge;

vector<LL> dijkstra(int n, vector<vector<Edge> >& G, int s) {   // N , G , start (ノードは0-index)
    vector<LL> d(n, LLONG_MAX/10); d[s] = 0;                    
    priority_queue<pair<LL, int> > que;                        
    que.push(make_pair(0LL, s));                                           
    while (!que.empty()) {                                  
        auto p = que.top(); que.pop();                      
        int u = p.second;                                      
        LL  dist = -p.first;                                 
        if (dist > d[u]) continue;                           
        for (Edge e : G[u]) {                                
            if (d[e.v] > d[u]+e.w) {                         
                d[e.v] = d[u] + e.w;                          
                que.push(make_pair(-d[e.v], e.v));           
            }                                                 
        }
    }
    return d;                                                
}

vector<vector<Edge>> G;
vector<bool> ch;
vector<int> dis;
vector<int> ct;
queue<pair<int,int>> que;

void bfs(){
    while(!que.empty()){
        pair<int,int> now = que.front();
        que.pop();
        for(auto t : G[now.F]){
            int to = t.v;
            if(ch[to])continue;
            dis[to] = now.F;
            ct[to] = now.S;
            que.push({to,now.S+1});
            ch[to] = true;
        }
    }
}



int main() {
    int N,M;cin >> N >> M;
    G.resize(N);
    ch.resize(N,false);
    dis.resize(N,-1);
    ct.resize(N,0);
    rep(i,M){
        int a,b;cin >> a >> b;
        a--;b--;
        G[a].emplace_back(b,1);
        G[b].emplace_back(a,1);
    }

    que.push({0,1});
    ch[0] = true;
    bfs();
    bool ok = true;
    auto v = dijkstra(N,G,0);

    rep(i,N){
        if(v[i] != ct[i])ok = false;
    }

    if(ok){
        cout << "Yes" << endl;
        for(int i = 1;i < N;i++){
            cout << dis[i]+1 << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
}   

Measured memory_bytes: 20692
#include <iostream>

using namespace std;

const int INF = 1e9;

int main(void){
  int n,k;
  while(cin>>n>>k,n||k){
    int g[101][101];
    for(int i=0;i<=100;++i){
      for(int j=0;j<=100;++j){
        g[i][j] = INF;
      }
    }
    
    for(int i=0;i<k;++i){
      int t,a,b,c,d,e;
      cin>>t;
      if(t){
        cin>>c>>d>>e;
        if(e<g[c][d]) g[c][d]=g[d][c]=e;
      }else{
      	int cost[101];
				for(int j=0;j<=100;++j) cost[j]=INF;
        cin>>a>>b;
        cost[a]=0;
        bool f;
        do{
        	f=false;
	        for(int from=1;from<=n;++from){
	          for(int to=1;to<=n;++to){
	            if(cost[from] != INF && cost[to] > cost[from] + g[from][to]){
	              cost[to] =  cost[from] + g[from][to];
	              f=true;
	            }
	          }
	        }
        }while(f);
        cout<<((cost[b]==INF)?-1:cost[b])<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1196