akhauriyash/Code-Regression huggingface dataset:
//package AtCoder;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		
			
			Scanner sc=new Scanner(System.in);
			int n=sc.nextInt();
			int k=sc.nextInt();
			int[] a=new int[n];
			for(int i=0;i<n;i++)
				a[i]=sc.nextInt();
			sc.close();
			
			if(n==1)
			{
				System.out.println(0);
				return;
			}
			int[] cost=new int[n];
			cost[0]=0;
			cost[1]=Math.abs(a[1]-a[0]);
			for(int i=2;i<n;i++)
			{
				int check=k;
				int j=i-1;
				int min=Integer.MAX_VALUE;
				while(check-->0 && j>=0)
				{
					min=Math.min(min,Math.abs(a[i]-a[j])+cost[j]);
					j--;
					//check--;
				}
				cost[i]=min;
				
			}
			

	
				System.out.println(cost[n-1]);

		

	}

}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    int K; 
    cin >> s >> K;
    set<string> ss;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; i+j <= s.size() && j <= K; j++) {
            string sub = s.substr(i,j);
            ss.insert(sub);            

            if (ss.size() > K) {
                ss.erase(prev(ss.end()));
            }
        }
    }

    string ans = *ss.rbegin();
    cout << ans << '\n';
}



Measured memory_bytes: 256
def examB():
    A = I(); B = I(); C = I(); X = I()
    ans = 0
    for i in range(min(41,A+1)):
        for j in range(B+1):
            for k in range(C+1):
                cur = 500*i + 100*j + 50*k
                if cur==X:
                    ans +=1
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 39024
def solve():
  N = int(input())
  ans = [0]*N
  for x in range(1,101):
    for y in range(1,101):
      for z in range(1,101):
        p = x*x + y*y + z*z + x*y + y*z + z*x
        if p <= N:
          ans[p-1] += 1
  return ans
print(*solve(),sep='\n')


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

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

using namespace std;

struct Edge { int dst,w; };

const int MAX = 110;
int V,E,sp,ep,iHIT;
vector<Edge> G[MAX];
int maxi[MAX];


void compute(){
  bool update = true;
  rep(i,V) maxi[i] = 0;
  vector<int> gotoMaxi,candidate;
  gotoMaxi.push_back(sp);
  while( update ) {
    update = false;
    rep(i,(int)gotoMaxi.size()) maxi[gotoMaxi[i]] = iHIT;
    gotoMaxi.clear();
    candidate.clear();

    rep(i,V*3+1) {
      rep(j,V) if( j != ep && maxi[j] ) {
	rep(k,(int)G[j].size()) {
	  Edge &e = G[j][k];
	  if( maxi[e.dst] < min(maxi[j]+e.w,iHIT) ) {
	    update = true;
	    maxi[e.dst] = min(maxi[j]+e.w,iHIT);
	    if( i == V*3 ) candidate.push_back(e.dst);
	  }
	}
      }
    }
    
    int maxValue = 0;
    rep(i,(int)candidate.size()) maxValue = max(maxValue,maxi[candidate[i]]);
    if( maxValue ) rep(i,(int)candidate.size()) if( maxValue == maxi[candidate[i]] ) gotoMaxi.push_back(candidate[i]);

    
  }

  /*
  rep(i,V) {
    cout << i << "-th : " << maxi[i] << endl;
  } puts("");
  */


  if( maxi[ep] == 0 ) puts("GAME OVER");
  else                cout << maxi[ep] << endl;

}

int main(){
  int CNT = 1;
  while( cin >> V >> E, V | E ){
    rep(i,V) G[i].clear();
    rep(i,E){
      int s,t,c;
      cin >> s >> t >> c;
      G[s].push_back((Edge){t,c});
    }
    cin >> sp >> ep >> iHIT;
    cout << "Case " << CNT++ << ": ";
    compute();
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 2e5+2;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

vector<ll> adj[maxn];

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


    ll n,k,depth=0,z;

    cin >> n >> k;

    for(ll i=1,tmp ; i<=n ; ++i)
    {
        cin >> tmp;
        adj[i].pb(tmp);
    }
    
    queue<ll> q;
    map<ll,ll> d2c,c2d;
    q.push(1);
    c2d[1] = depth;
    d2c[0] = 1;
    bool flag = true;
    ll start_depth,end_depth;

    while(flag)
    {
        z = q.front();
        q.pop();

        for(auto x : adj[z])
        {
            if(c2d.find(x)!=c2d.end()) 
            {
                end_depth = depth+1;
                start_depth = c2d[x];
                flag = false; break;
            }
            
            depth++; 
            q.push(x);

            d2c[depth] = x;
            c2d[x] = depth;
        }

    }

    if( k < start_depth)
    cout << d2c[k];
    else
    {
        k -= start_depth;

        k %= (end_depth-start_depth);

        cout << d2c[start_depth + k];
    }

    return 0;
} 

Measured memory_bytes: 39272
s = input()
list = [int(c) for c in s]
num = []
ans = 753
for i in range(len(list)-2):
	num.append((list[i] * 100) + (list[i+1] * 10) + list[i+2])
	if(num[i] >= 753):
		if(ans >= (num[i] - 753)):
			ans = num[i] - 753
	else:
		if(ans > (753 - num[i])):
			ans = 753 - num[i]
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A=sc.nextInt();
    int B=sc.nextInt();
    int C=sc.nextInt();
    int D=sc.nextInt();
  while(true){
    C=C-B;
    if (C<=0) {
      break;
    }
    A=A-D;
    if (A<=0) {
      break;
    }
  }
  if (A>0) {
    System.out.println("Yes");
  }else{
    System.out.println("No");
  }


  }
}


Measured memory_bytes: 35752
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-03-14 21:09:03 +0900
# LastModified: 2020-03-14 21:29:51 +0900
#


import os


def main():
    H,W = map(int,input().split())
    if H==1 or W==1:
        print(1)
        return
    if not H*W%2:
        print(H*W//2)
    else:
        print((H*W+1)//2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int H1, M1, H2, M2, K;

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

    cin >> H1 >> M1 >> H2 >> M2 >> K;

    if (H2 < H1) M2 += 24;

    int totalmin = (H2 - H1) * 60 + (M2 - M1);

    cout << totalmin - K;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>
#include <climits>

using namespace std;

int cnt;

void insertionSort(int *A,int n,int g){
  int v;
  for(int i=g;i<n;i++){
    v=A[i];
    int j = i - g;
    while (j>=0 && A[j] > v) {
      A[j+g] = A[j];
      j = j -g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int *A,int n){
  cnt = 0;
  int *G,g,m;


  for(m=1;m<=100;m++){
    g=((pow(3,m)-1)/2);
    if(g>n)
      break;
  }
  m--;
  printf("%d\n",m);

  G = (int *)malloc(m*sizeof(int));
  for(int i=m,c=0;i>0;i--,c++){
    G[c] = (pow(3,i)-1)/2;
  }

  for(int i=0;i<m;i++){
    printf("%d",G[i]);
    if(i<m-1)
      putchar(' ');
    else
      putchar('\n');
    insertionSort(A,n,G[i]);
  }
  printf("%d\n",cnt);
}

int main(){
  int n,*A;

  scanf("%d\n",&n);
  A = (int *)malloc(n*sizeof(int));

  for(int i=0;i<n;i++){
    scanf("%d\n",&A[i]);
  }

  shellSort(A,n);

  for(int i=0;i<n;i++){
    printf("%d\n",A[i]);
  }

}



Measured memory_bytes: 7192
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		for( int i=0; i<N; i++ ){
			char ch = S.charAt(i);
			char ccc = T.charAt(i);
			System.out.print(ch);
			System.out.print(ccc);          
		}    
	}
}


Measured memory_bytes: 21844
using System;

namespace ABC142
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            var N = decimal.Parse(input[0]);
            var K = decimal.Parse(input[1]);
            var hi = Console.ReadLine().Split(' ');

            var count = 0m;

            foreach (var item in hi)
            {
                if (decimal.Parse(item) >= K)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

#define rep(i, u) for (int i = 0; i < u; i++)

using ll = long long;
using ull = unsigned long long;

int main() {
  int x; cin >> x;
  if (x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    pair<string,int> P;
    vector<tuple<string,int,int>> V;
    string M[110];
    int A[110];
    REP(i,N){
        cin >> M[i] >> A[i];
      A[i] *= -1;
        V.emplace_back(M[i],A[i],i+1);
    }
    sort(V.begin(),V.end());
    REP(i,N){
        cout <<get<2>(V[i])<< endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL 0
#define N 44

int F[N];

int fib(int n){

  int i;

  if(n == 0 || n == 1){
    return F[n] = 1;
  }
  else if(F[n] != NIL){
    return F[n];
  }
  else{
    return F[n] = (fib(n-2))+(fib(n-1));
  }
}

int main(){

  int i, n, ans;
  
  scanf("%d",&n);
  for(i = 0; i <= n; i++) F[n] = NIL;
  ans = fib(n);

  printf("%d\n",ans);

  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define MOD 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll N;
    cin >>N;
    
    cout << (modpow(10, N, 1000000007)-2*modpow(9, N, 1000000007) +modpow(8, N, 1000000007)+MOD*2)%MOD<< endl;


    return 0;
    

}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] a = new int[n+1];//0段目からn段目のNG
    int[] b = new int[n+1];//0段目からn段目の場合の数
    int count = 0;

    for(int i=0; i<m; i++){
      a[sc.nextInt()]=-1;
    }

    b[0] = 1;
    b[1] = (a[1]==-1)?0:1;
    for(int i=2; i<=n; i++){
      if(b[i]==-1){continue;}
      b[i-2] = (a[i-2]==-1)? 0:b[i-2];
      b[i-1] = (a[i-1]==-1)? 0:b[i-1];
      b[i]= b[i-1] + b[i-2];
      b[i]=b[i]%1000000007; //i段目の場合の数
    }
    System.out.println(b[n]);


  }
}

Measured memory_bytes: 47944
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int N;
int dp[2][370][370];

struct Seg {
    Seg() {}
    Seg(int a, int b, int c) : l(a), r(b), cost(c) {}
    int l, r, cost;
    bool operator<(const Seg &s) const {
        return r < s.r;
    }
};

int main() {
    while(cin >> N, N) {
        memset(dp, -1, sizeof(dp));
        vector<Seg> segs(N);
        for(int i=0; i<N; i++) {
            int l, r, cost; cin >> l >> r >> cost;
            segs[i] = Seg{l, r, cost};
        }
        sort(segs.begin(), segs.end());

        int ans = 0, lim = 0;
        dp[0][0][0] = 0;
        for(int i=0; i<N; i++) {
            int cur = i % 2, nxt = 1 - cur;
            
            for(int j=0; j<=lim; j++) {
                int r = segs[i].r, m1 = -1, m2 = -1;
                for(int k=0; k<=lim; k++) {
                    if(k < segs[i].l) {
                        m1 = max(m1, dp[cur][k][j]);
                        m2 = max(m2, dp[cur][j][k]);
                    }

                    // do not apply
                    dp[nxt][j][k] = max(dp[nxt][j][k], dp[cur][j][k]);
                    dp[nxt][k][j] = max(dp[nxt][k][j], dp[cur][k][j]);
                }

                // use 1st room
                if(m1 != -1) {
                    dp[nxt][r][j] = max(dp[nxt][r][j], m1 + segs[i].cost);
                    ans = max(ans, dp[nxt][r][j]);
                }

                // use 2nd room
                if(m2 != -1) {
                    dp[nxt][j][r] = max(dp[nxt][j][r], m2 + segs[i].cost);
                    ans = max(ans, dp[nxt][j][r]);
                }
            }
            for(int j=0; j<=365; j++) {
                for(int k=0; k<=365; k++) {
                    dp[cur][j][k] = -1;
                }
            }
            lim = max(lim, segs[i].r);
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define vi vector<int>

int main() {

    int N;
    cin >> N;

    vi d;
    int tmp;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        d.push_back(tmp);
        sum += tmp;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += ((sum - d[i]) * d[i]);
    }

    cout << ans/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int h, w, k, a[N][N], ans;
bool badx[N], bady[N];
char c;

main () {
	cin >> h >> w >> k;
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j) {
			cin >> c;
			a[i][j] = c == '#';
		}


	vi v;
	for (int i = 1; i <= h + w; ++i)
		v.pb(i);

	for (int mask = 0; mask < (1 << sz(v)); ++mask) {
		memset(badx, 0, sizeof(badx));		
		memset(bady, 0, sizeof(bady));
		for (int i = 0; i < sz(v); ++i)
			if (mask & (1 << i)) {
				if (v[i] <= h)
					badx[v[i]] = 1;
				else
					bady[v[i] - h] = 1;
			}

		int sum = 0;
		for (int i = 1; i <= h; ++i)
			for (int j = 1; j <= w; ++j)
				if (!badx[i] && !bady[j])
					sum += a[i][j];

		if (sum == k)
			ans++;

	}

	cout << ans << endl;
}
	
        	
//check for the constants

                                                                                   	



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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MAX_N = 2e6 + 1;
int mod = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i])cnt++;
    }
    cout << cnt;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;


signed main(){
    cin>>N>>M;
    vpint lis;
    rep(i,M){
        int  a,b;
        cin>>a>>b;
        a--;b--;
        lis.pb({b,a});
    }
    sort(all(lis));
    int las=-1;
    int ans=0;
    for(auto &p:lis){
        int a,b;
        tie(b,a)=p;
        if(a<=las)continue;
        las=b-1;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int a[] = new int[n+1];
    int b[] = new int[n];
    long sb = 0;
    long sa = 0;
    
    for (int i=0; i<n+1; i++){
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    }
    for (int i=0; i<n; i++){
      b[i] = Integer.parseInt(sc.next());
    }

    for(int i=0; i<n; i++){
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    }
    
    for (int i=0; i<n+1; i++){
      sa += a[i];
    }
    
	System.out.println(sb-sa);


  }
}


Measured memory_bytes: 50984
#include <cstdio>
using namespace std;

int main()
{
  int n, y;
  scanf("%d%d", &n, &y);
  y /= 1000;

  for (int i = n; i >= 0; i--)
    for (int j = n - i; j >= 0; j--)
      for (int k = n - i - j; k >= 0; k--)
        if (i + j + k == n && 10 * i + 5 * j + 1 * k == y)
        {
          printf("%d %d %d\n", i, j, k);
          return 0;
        }

  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

L = []
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        if T[j] == S[i+j] or S[i+j] == "?":
            cnt += 1
    if cnt == len(T):
        temp = []
        for j in range(len(S)):
            if i <= j < i+len(T):
                temp.append(T[j-i])
            elif S[j] == "?":
                temp.append("a")
            else:
                temp.append(S[j])
        L.append("".join(temp))
        
if L:
    L.sort()
    print(L[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vii vector<int>
#define vll vector<long long int>
#define sii set<int>
#define sll set<long long int>
#define usi unordered_set<int, custom_hash>
#define usl unordered_set<long long int, custom_hash>
#define mii map<int, int>
#define mll map<long long int, long long int>
#define umi unordered_map<int, int, custom_hash>
#define uml unordered_map<long long int, long long int, custom_hash>
#define ski stack<int>
#define skl stack<long long int>
#define all(v) v.begin(),v.end()
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c`
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


const int N=2e5+1;
const int mod=998244353;
ll a[N], b[N], c[N];


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    
    int n, k;
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>a[i];
        b[i]=LLONG_MAX;
    }
    b[0]=0;
    for(int i=1;i<n;++i){
        for(int j=1;j<=k;++j){
            if(j<=i){
                b[i]=min(b[i], b[i-j]+abs(a[i]-a[i-j]));
            }
        }
    }

    cout<<b[n-1]<<endl;

}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left"<<endl;
	else if(a+b==c+d)cout<<"Balanced"<<endl;
	else cout<<"Right"<<endl;
	
	
	return 0;
}

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


int main(){
int N;
cin >> N;
long long Lucas[100];
Lucas[0] = 2;
Lucas[1] = 1;
for(int i=2; i<=N; i++){
  Lucas[i] = Lucas[i-1]+Lucas[i-2];
}
cout << Lucas[N] << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int a[100];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	int ans=0;
	for(int i1=0; i1<n; i1++){
		for(int i2=i1+1; i2<n; i2++){
			for(int i3=i2+1; i3<n; i3++){
				if(a[i1]!=a[i2]&&a[i2]!=a[i3]&&a[i3]!=a[i1]&&a[i1]+a[i2]>a[i3] && a[i2]+a[i3]>a[i1]&&a[i3]+a[i1]>a[i2]){
					ans++;
				}
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1608
function Main(input) {
	
    input = input.split(" ");
    
    var a = parseInt(input[0],10);
    var b = parseInt(input[1],10);
    var res;

    if(a >= 13){
        res = b;
    }
    if(a >= 6 && a <= 12){
        res = b / 2;
    }
    if(a <= 5){
        res = 0;
    }
    console.log(res);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin>>n>>m;
  if(m%2==0){
  if(2*n<=m && 4*n>=m){cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;
  }
 else {
    cout<<"No"<<endl;
 }

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <iterator>
#include <string>
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
using namespace std;
using ll = long long;

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

    vector<int> C(26);
    vector<int> satis(26, 0);
    vector<int> conts(26, 0);
    rep(i, 0, 26)
    {
        int c;
        cin >> c;

        C[i] = c;
    }

    vector<vector<int>> S(D, vector<int>(26));
    rep(i, 0, D)
    {
        rep(j, 0, 26)
        {
            int s;
            cin >> s;
            S.at(i).at(j) = s;
        }
    }

    rep(d, 1, D + 1)
    {
        int t;
        cin >> t;
        t--;

        rep(j, 0, 26)
        {
            if (j == t)
            {
                satis[j] += S.at(d - 1).at(j);
                conts[j] = d;
            }
            else
            {
                satis[j] -= C[j] * (d - conts[j]);
            }
        }

        int ans = 0;
        rep(j, 0, 26)
        {
            ans += satis[j];
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    long n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        long x;
        cin >> x;
        n -= x;
    }
    if (n >= 0) {
        cout << n << endl;
    } else{
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define maxi 10000

string lcs(string &s,string &t){
    int n=s.length();int m=t.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)dp[i][0]=0;
    for(int i=0;i<=m;i++)dp[0][i]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1])dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int l=dp[n][m];
    string ans="";
    //cout<<l;
    int i=n,j=m;
    //cout<<t<<endl;
    while(l!=0){
        if(s[i-1]==t[j-1]&&i<=n&&j<=m){
            ans.push_back(s[i-1]);i--;j--;l--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else j--;
        }
    }
    //cout<<i<<" "<<j<<endl;
    reverse(ans.begin(),ans.end());return ans;
}

int main() {
    string s,t;cin>>s>>t;
    cout<<lcs(s,t);
}


Measured memory_bytes: 38780
#include <bits/stdc++.h>
using namespace std;
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)

typedef long long int LL;
typedef pair< int, int> ii;
const int mod = 1e9 + 7;
const int mx = 1e6;
const int i27 = 1 << 27;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	int a[n], sum = 0;
	fr(i, 0, n) {
	    cin >> a[i];
	    sum += a[i];
	}
	if(sum % 10 == 0) {
	    sort(a, a + n);
	    fr(i, 0, n)
	        if(a[i] % 10) {
	            sum -= a[i];
	            break;
	        }
	}
	cout << (sum % 10 ? sum : 0);
	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    ll N, M;
    cin >> N >> M;
    vector<double> A(N);
    rep(i,0,N) cin >> A[i];
    priority_queue<double> que;
    rep(i,0,N) que.push(A[i]);
    rep(i,0,M) {
        auto a = que.top();
        que.pop();
        que.push(a / 2);
    }
    ll answer = 0;
    rep(i,0,N) {
        answer += (ll)que.top();
        que.pop();
    }
    cout << answer << endl;
    return 0;
}


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

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  for(int i=0;i<K;i++){
    if(A>=B && A>=C){
      A=2*A;
    }
    else if(B>=A && B>=C){
      B=2*B;
    }
    else{
      C=2*C;
    }
  }
  cout << A+B+C << endl;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e5+3;
const int INF = 1e9;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    //int ntest; cin >> ntest; while(ntest--)
    {
        int n; cin >> n;
        vector<int> a(n), h(n);
        fori(i,n) {
            cin >> a[i];
            h[i] = a[i]+i+1;
        }

        sort(all(h));
        LL ans = 0;
        fori(i,n) {
            int x = i+1-a[i];
            auto l = lower_bound(all(h),x);
            auto u = upper_bound(all(h),x);
            ans += u-l;
        }
        cout << ans << endl;
    }

    return 0;
}


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

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

  string s; cin >> s;
  int q; cin >> q;
  deque<char> strs;
  for(char a: s) strs.push_back(a);

  bool flip = false;
  rep(i, q) {
    int t;
    cin >> t;
    if(t == 1) {
      flip = !flip;
    } else {
      int f;
      char c;
      cin >> f;
      cin >> c;

      if(f == 1) {
        if(flip) {
          strs.push_back(c);
        } else {
          strs.push_front(c);
        }
      } else {
        if(flip) {
          strs.push_front(c);
        } else {
          strs.push_back(c);
        }
      }
    }
  }

  if(flip) {
    reverse(strs.begin(), strs.end());
  }

  string ans;
  for(char a: strs) {
    ans += a;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1368
n = int(raw_input())
  
d = [99999 for i in range(n)]
G = [0 for i in range(n)]
v = [[0 for i in range(n)] for j in range(n)]
  
def BFS(s):
  for e in range(n):
    if v[s][e] == 1:
      if d[e] > d[s] + 1:
        d[e] = d[s]+1
        BFS(e)
  
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    v[G[0]-1][G[2+j]-1] = 1
  
d[0] = 0
for s in range(n):
  BFS(s)
for s in range(n):
  if d[s] == 99999:
    d[s] = -1
for s in range(n):
  print'{0} {1}'.format(s+1, d[s])

Measured memory_bytes: 6416
N, Y = map(int, input().split())
li = [[10*a+5*b+(N - a - b), a, b, N- a-b] for a in range(N+1) for b in range(N+1-a) if 10*a+5*b+(N - a - b) == Y//1000]
if len(li) == 0:
    print('-1 -1 -1')
else:
    x = li[0]
    print('{} {} {}'.format(x[1], x[2], x[3]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
  
using namespace std;
  
const int N = 5e5 + 5;

typedef long long ll;
  
int a[N];
ll hi[N], lo[N];
ll ans[N];
  
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  string s; cin >> s;
  int n = s.length();
  vector<ll> a;
  a.push_back(2 * n);
  for (char c : s) {
    if (c == '>') a.push_back(a.back() - 1);
    else a.push_back(a.back() + 1);
  }
  ++n;
  ll l = 0, r = n, k = 1e7;
  lo[n - 1] = l;
  hi[n - 1] = r;
  for (int i = n - 2; i >= 0; --i) {
    if (a[i] < a[i + 1]) {
      lo[i] = max(lo[i + 1] - k, l);
      hi[i] = hi[i + 1] - 1;
    } else if (a[i] > a[i + 1]) {
      lo[i] = lo[i + 1] + 1;
      hi[i] = min(hi[i + 1] + k, r);
    } else {
      lo[i] = lo[i + 1];
      hi[i] = hi[i + 1];
    }
    if (lo[i] > r || hi[i] < l) {
      cout << -1 << endl;
      return 0;
    }
  }
  ans[0] = lo[0];
  for (int i = 1; i < n; ++i) {
    if (a[i] > a[i - 1]) {
      ans[i] = max(ans[i - 1] + 1, lo[i]);
    } else if (a[i] < a[i - 1]) {
      ans[i] = max(ans[i - 1] - k, lo[i]);
    } else ans[i] = ans[i - 1];
  }
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += ans[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 17552
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int m,s,h,w,n;
	scanf("%d %d %d",&h,&w,&n);
	m=h;
	if(h<w)m=w;
	if(n%m==0)s=n/m;
	else s=n/m+1;
	printf("%d",s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc165/abc165_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll x;
  cin >> x;

  ll y = 100;
  ll ans = 0;
  while (y < x) {
    y *= 1.01;
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main()
{
    int t[3];
    scanf("%d %d %d",&t[0],&t[1],&t[2]);
    int sum = t[0] + t[1] + t[2];

    int min = sum;
    for (int i = 0; i < 3; i++)
    {
        int buf = sum - t[i];
        if (min > buf)
        {
            min = buf;
        }
    }
    printf("%d",min);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define vi vector<long long>
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 500 
#define FORN(start,end) for(int i=start; i<=end; i++)
#define cout std::cout
#define cin std::cin
#define PI 4*atan(1)
using namespace std;

void printVector(vi a) {
    cout<<"\n*********DEBUG**********\n";
    FORN(i,a.size()-1) {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

void printArray(int a[], int n) {
    cout<<"\n*********DEBUG**********\n";
    FORN(i,n-1) {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findPos(vi &vecCopy,int key) {
    for(int i=0; i<vecCopy.size(); i++) {
        if(vecCopy[i]==key) {
            vecCopy[i]=-1;
            return i+1;
        }
    }
}

void bfs(vi adj[], vector<bool> &isReached, int start, int parent, vi &answer) {

    // if(isReached[start]) {
    //     return;
    // }

    // isReached[start]=true;

    // for(int i=0; i<adj[start].size(); i++) {
    //     answer[start]=parent;
    //     dfs(adj,isReached,adj[start][i],start,answer);
    // }

    list<int> queue;
    isReached[start] = true; 
    queue.push_back(start);

    while(!queue.empty()) {

        start=queue.front();
        queue.pop_front();

        for(int i=0; i<adj[start].size(); i++) {
            if(!isReached[adj[start][i]]) {
                isReached[adj[start][i]]=true;
                queue.push_back(adj[start][i]);
                answer[adj[start][i]]=start;
            }
        }
    } 

}

void solve() {

    int n,k;

    cin>>n>>k;

    vi adj[n];

    int temp1;
    int temp2;

    for(int i=0; i<k; i++) {
        cin>>temp1;
        cin>>temp2;

        temp1--;
        temp2--;

        adj[temp2].push_back(temp1);
        adj[temp1].push_back(temp2);

    }

    vi answer(n,0);
    vector<bool> isReached(n,false);

    bfs(adj,isReached,0,-1,answer);

    int fu=1;

    for(int i=0; i<n; i++) {
        if(!isReached[i]) {
            fu=-1;
            break;
        }
    }

    if(fu==-1) {
        cout<<"No\n";
    } else {
        cout<<"Yes\n";
        FORN(1,n-1) {
            cout<<answer[i]+1<<endl;
        }
    }



}
 
int32_t main() {
    // fastio;

    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
 
    int t=1;
//    cin>>t;
 
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 14768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

map<long long, int> prime_factor(long long n) {
  map<long long, int> res;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  set<int> st;
  bool flag = true;
  rep(i, n) {
    auto mp = prime_factor(a[i]);
    for (auto e : mp) {
      if (e.first == 1)
        continue;
      if (st.find(e.first) != st.end()) {
        flag = false;
        break;
      }
      st.insert(e.first);
    }
    if (!flag)
      break;
  }
  if (flag) {
    cout << "pairwise coprime\n";
    return 0;
  }
  int g = a[0];
  for (int i = 1; i < n; i++)
    g = gcd(a[i], g);
  if (g == 1)
    cout << "setwise coprime\n";
  else
    cout << "not coprime\n";
  return 0;
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
string s,t;

int main(){
	cin>>n>>m;
	cin>>s>>t;
	int q=gcd(n,m);
	for(int i=0;i<q;i++){
		if(s[(n/q)*i]!=t[(m/q)*i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<lcm(n,m)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
  int a, b, c, r = 0;

  scanf("%d %d %d", &a, &b, &c);

  for (; a <= b; a++) {
    if (c % a == 0) {
      r++;
    }
  }

  printf("%d\n", r);

  return 0;
}

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

int main(void) {
  vector<long long> input(3, 0);
  long long ans;
  cin >> input[0] >> input[1] >> input[2];
  if (input[0] % 2 == 0 || input[1] % 2 == 0 || input[2] % 2 == 0)
    ans = 0;
  else {
    sort(input.begin(), input.end());
    ans = input[0] * input[1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 100005;


int main() {
  //freopen("in.cpp","r",stdin);
  ll x,y,z;
  cin>>x>>y>>z;
  int ret=0;
  while(1){
    if(x&1)break;
    if(y&1)break;
    if(z&1)break;
    ll tx=(y+z)>>1;
    ll ty=(x+z)>>1;
    ll tz=(x+y)>>1;
    if(x==tx&&y==ty&&z==tz){
      cout<<-1<<endl;
      return 0;
    }
    x=tx,y=ty,z=tz;
    ret++;
  }
  cout<<ret<<endl;
  return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int N, M;
	ll L;
	cin >> N >> M >> L;
	vector<Vl> dist(N, Vl(N, L_INF));
	for (int i = 0; i < M; ++i) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		--a; --b;
		dist[a][b] = c;
		dist[b][a] = c;
	}


	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (dist[i][k] == L_INF || dist[k][j] == L_INF) continue;
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	vector<Vi> cost(N, Vi(N, I_INF));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (dist[i][j] <= L) cost[i][j] = 1;
		}
	}

	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (cost[i][k] == I_INF || cost[k][j] == I_INF) continue;
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
			}
		}
	}

	int Q;
	cin >> Q;
	Vi s(Q), t(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> s[i] >> t[i];
		--s[i]; --t[i];
	}

	for (int i = 0; i < Q; ++i) {
		int ansi = cost[s[i]][t[i]];
		if (ansi == I_INF) {
			cout << -1 << "\n";
		}
		else{
			cout << ansi - 1 << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> l(k),r(k);
  rep(i,k) cin >> l[i] >> r[i], ++r[i];
  vector<mint> dp(n);
  dp[0] = 1, dp[1] = -1;
  rep(i,n){
    if(i!=0) dp[i] += dp[i-1];
    rep(j,k){
      if(i+l[j]<n) dp[i+l[j]] += dp[i];
      if(i+r[j]<n) dp[i+r[j]] -= dp[i];
    }
  }
  cout << dp[n-1] << endl;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

int dx4[] = {1, -1, 0, 0};
int dy4[] = {0, 0, 1, -1};
int dx8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy8[] = {1, -1, 0, 0, 1, -1, -1, 1};

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main(){
    int N, M;
    cin >> N >> M;
    using pii = pair<int, int>;
    vector<pii> ms(M);
    rep(i, M) {
        cin >> ms[i].first >> ms[i].second;
    }
    sort(ms.begin(), ms.end(), [](const pii& l, const pii& r){
                                   return l.second < r.second;
                               });
    int ans = 0;
    int t = 0;
    rep(i, M) {
        if (t <= ms[i].first) {
            t = ms[i].second;
            ++ans;
        }
    }
    cout << ans << nl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int n;
	int ret;
	scanf("%d\n", &n);
	if(n<105) ret = 0;
	else if(n<135) ret = 1;
	else if(n<165) ret = 2;
	else if(n<189) ret = 3;
	else if(n<195) ret = 4;
	else ret = 5;
	printf("%d\n", ret);
}

Measured memory_bytes: 128