akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 for(;;){
  int n=ir.nextInt();
  if(n==0) return;
  int K=ir.nextInt();
  int s=ir.nextInt();
  int[][][] dp=new int[K+1][n+1][s+1];
  for(int i=0;i<=n;i++) dp[K][i][s]=1;
  for(int i=K-1;i>=0;i--){
   for(int j=0;j<=n;j++){
    for(int k=0;k<=s;k++){
     for(int l=j+1;l<=n;l++){
      if(l+k>s) break;
      dp[i][j][k]+=dp[i+1][l][k+l];
     }
    }
   }
  }
  out.println(dp[0][0][0]);
 }
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

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

 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }

 public long[] nextLongArray(int n){
  long[] a=new long[n];
  for(int i=0;i<n;i++) a[i]=nextLong();
  return a;
 }

 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 27684
#include<cstdio>
#include<algorithm>
#include<cstring>
const int MAXN = 100000;
const int MAXK = 1000;
int x[MAXN + 5], y[MAXN + 5], c[MAXN + 5];
int y1[10 * MAXK + 5];
int main() 
{
	int N,K,Max=0,cnt = 0;
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++) 
	{
		char ch;
		scanf("%d%d %c",&x[i],&y[i],&ch);
		x[i]%=(2*K);
		y[i]%=(2*K);
		if(ch=='W' ) c[i] = 1;
		else c[i]=0;
	}
	for(int i=0;i<=K;i++) {
		cnt = 0;
		memset(y1,0,sizeof(y1));
		for(int j=1;j<=N;j++) {
			bool p = ( i <= x[j] && x[j] < i+K );
			bool q = ( 0 <= y[j] && y[j] < K );
			if( p ^ q == c[j] )
			{
				cnt++;
				y1[y[j]] ++;
			}
			else 
			{
				y1[y[j]] --;
			}
		}
		for(int j=0;j<=K;j++) 
		{
			Max=std::max(Max,std::max(cnt,N-cnt));
			if( j != K )
				cnt = cnt - y1[j] - y1[K+j];
		}
	}
	printf("%d\n",Max);
}


Measured memory_bytes: 1408
def solve():
    N = int(input())
    A = list(map(int, input().split()))

    S = 0

    p = 0
    for a in A:
        S += abs(a - p)
        p = a
    S += abs(p)

    A = [0] + A
    A.append(0)
    for n in range(1, N+1):
        pre = A[n] - A[n-1]
        ne = A[n+1] - A[n]
        if pre * ne < 0:
            print(S - (abs(min(abs(ne), abs(pre))) * 2))
        else:
            print(S)


if __name__ == "__main__":
    solve()




Measured memory_bytes: 14044
#include <iostream>
#include <vector>
#include <cstring>

#define LL long long
using namespace std;
#define MAXN 60
#define MAXA 60

int N, M, S;

struct edge
{
    int v, a, b;
};
vector<edge> G[MAXN];
int C[MAXN], D[MAXN];
LL dp[MAXN][MAXA * MAXN];
LL ans;

inline void add(int u, int v, int a, int b)
{
    G[u].push_back({v, a, b});
    G[v].push_back({u, a, b});
}
int main()
{
    scanf("%d%d%d", &N, &M, &S);
    int u, v, a, b;
    for (int i = 1; i <= M; i++)
    {
        scanf("%d%d%d%d", &u, &v, &a, &b);
        add(u, v, a, b);
    }
    for (int i = 1; i <= N; i++)
    {
        scanf("%d%d", &C[i], &D[i]);
    }

    memset(dp, 0x3f, sizeof(dp));
    if (S > 2500)
        S = 2500;
    dp[1][S] = 0;
    for (int t = 1; t <=2*M; t++)
    {
        for (int i = 1; i <= N; i++)
        {
            for (int k = 0; k < G[i].size(); k++)
            {
                for (int j = 0; j <= 2500; j++)
                {
                    if (j + G[i][k].a <= 2500)
                        dp[i][j] = min(dp[i][j], dp[G[i][k].v][j + G[i][k].a] + G[i][k].b);
                }
            }

            for (int j = 0; j <= 2500; j++)
            {
                if (j >= C[i])
                    dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + D[i]);
            }
        }
    }
    for (int i = 2; i <= N; i++)
    {
        // 0x3f3f3f3f is small should be 1e16
        ans = 1e18;
        for(int j=0; j<=2500; j++) {
            if(ans>dp[i][j]) {
                ans = dp[i][j];
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int judge(int* num,int kosu) {
	for (int i = 0; i < kosu; i++)
	{
		if (num[i] % 2 == 0) continue;
		else return 1;
	}
	return 0;
}

int main(void) {
	int kaisu = 0,kosu;
	scanf("%d", &kosu);
	int num[200];
	for (int i = 0; i < kosu; i++)
	{
		scanf("%d", &num[i]);
	}
	while (1)
	{
		if (judge(num,kosu) == 1) break;
		kaisu++;
		for (int i = 0; i < kosu; i++)
		{
			num[i] /= 2;
		}
	}
	printf("%d",kaisu);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>
#include<queue>
#include<bitset>

using namespace std;

int main() {
	int N;
	string s = "ACL";

	cin >> N;

	for (int i = 0; i < N; ++i) {
		cout << s;
	}

	cout << endl;

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	swap(a,b);swap(a,c);
	cout << a<<" "<<b<<" "<<c;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3568
import math

n, m = map(int, input().split())

l = []
for i in range(1, int(math.sqrt(m))+1):
    if m % i == 0:
        l.append(i)
        l.append(m//i)
l.sort()

for i in l:
    if i >= n:
        print(m//i)
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(ll i=a;i<b;++i)
#define dloop(i,a,b) for(ll i=a;i>=b;--i)
#define all(a) a.begin(),a.end()
#define lar 1000000007
#define pq priority_queue 
#define pll pair<ll,ll>
#define ss second
#define ff first
#define pb push_back
#define ppb pop_back
#define umap unordered_map
#define ub upper_bound
#define lb lower_bound
#define br "\n"
#define sp " "
const int N=1e5;

void solve(){
	string s,t;
  cin>>s>>t;
  ll ans = 1e16;
  ll n=s.length();
  ll m=t.length();
  for(ll i=0;i+m-1<n;i++)
  {
    ll temp=0;
  	loop(j,0,m)
    {
    	if(s[i+j]!=t[j])
          temp++;
    }
    ans = min(ans,temp);
  }
  cout<<ans<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    (1..3500).forEach { a ->
        (1..3500).forEach { b ->
            val deno = 4 * a * b - n * a - n * b
            if (deno == 0L) return@forEach
            val c = n * a * b / deno
            if (0 < c && n * a * b % deno == 0L) {
                print("$a $b $c")
                return
            }
        }
    }
}

Measured memory_bytes: 33688
#include <iostream>

using namespace std;
int circle[100002] = {};
string s;

void func(int i){
    // sheep : 1  wolf : -1
    if((s[i-1] == 'o' && circle[i-1] == 1) ||(s[i-1] == 'x' && circle[i-1] == -1))circle[i] = circle[i-2];
    else{circle[i] = -circle[i-2];}
}

int main(){
    int n;
    cin >> n;
    cin >> s;
    s = s + s[0];
    circle[0] = 1;circle[1] = 1;
    for(int i = 2;i <= n+1; i++){
        func(i);
    }
    if(circle[0] == circle[n] && circle[1]==circle[n+1]){
        for(int i = 0; i < n; i++){
            if(circle[i]==1)cout << 'S';
            else cout << 'W';
        }
        cout << endl;
        return 0;
    }

    circle[0] = 1;circle[1] = -1;
    for(int i = 2;i <= n+1; i++){
        func(i);
    }
    if(circle[0] == circle[n] && circle[1]==circle[n+1]){
        for(int i = 0; i < n; i++){
            if(circle[i]==1)cout << 'S';
            else cout << 'W';
        }
        cout << endl;
        return 0;
    }

    circle[0] = -1;circle[1] = -1;
    for(int i = 2;i <= n+1; i++){
        func(i);
    }
    if(circle[0] == circle[n] && circle[1]==circle[n+1]){
        for(int i = 0; i < n; i++){
            if(circle[i]==1)cout << 'S';
            else cout << 'W';
        }
        cout << endl;
        return 0;
    }

    circle[0] = -1;circle[1] = 1;
    for(int i = 2;i <= n+1; i++){
        func(i);
    }
    if(circle[0] == circle[n] && circle[1]==circle[n+1]){
        for(int i = 0; i < n; i++){
            if(circle[i]==1)cout << 'S';
            else cout << 'W';
        }
        cout << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 936
using System;
using System.Linq;

namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int[] dts = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int d = dts[0];
            int t = dts[1];
            int s = dts[2];
            if (d <= t * s)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 28128
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def score(td):
  t_list = [v[0] for v in td]
  d_list = [v[1] for v in td]
  ut = len(set(t_list))
  score_ut = ut**2
  score_d = sum(d_list)
  return score_ut + score_d
  
def solve():
  N, K = LI()
  td = []
  for i in range(N):
    t, d = LI()
    td.append([t, d])

  from operator import itemgetter
  td.sort(key=itemgetter(1), reverse=True)

  # おいしさtopK
  cand = td[:K]
  
  # cand のネタ保持数dict
  import collections
  c = collections.Counter([v[0] for v in cand])
  m = len(c.keys())
  
  # 持ってないネタのtop1リスト
  rest_top1 = {}
  for v in td:
    if v[0] not in c:
      if v[0] not in rest_top1:
      	rest_top1[v[0]] = v[1]
      else:
        if rest_top1[v[0]] < v[1]:
          rest_top1[v[0]] = v[1]
          
  # スコア降順
  rest_o = sorted([v for k, v in rest_top1.items()], reverse=True)
  current_score = score(cand)
  scores = [current_score]
  if len(rest_o) == 0:
    print(current_score)
    return
  # おいしく無い順に持ってないもののtop1と入れ替え
  nget = 0
  for i in range(1, K):
    target = cand[-i]
    if c[target[0]] == 1:
      continue # 一つしか持ってないなら入れ替えない
    
    # スコアの差分を作る
    # netaボーナス
    dscore_neta = (m+nget+1)**2 - (m+nget)**2 
    # おいしさボーナス
    dscore_d = -target[1] + rest_o[nget]
    current_score += dscore_neta
    current_score += dscore_d
    
    scores.append(current_score)
    # 状態更新
    nget += 1
    c[target[0]] -= 1
    
    # 全部取ったらおわり
    if nget == len(rest_o):
      break
  print(max(scores))
solve()

Measured memory_bytes: 30368
#include <iostream>
#include <cmath>

int main(void)
{

    int m = 0, n = 0;
    std::cin >> n >> m;

    long long unit = 1900 * m + 100 * (n - m); 
    
    
    std::cout << (1900 * m + 100 * (n - m) << m) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    rep(i, 0, N)
    {
        ans += (i % 2 == 0 ? a[i] : -a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int n;
int ans;
int a[19][19];

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) a[i][j] = 2;
    for(int i = 0; i < n; i++)
    {
        int t1;
        scanf("%d", &t1);
        while(t1--)
        {
            int t2, t3;
            scanf("%d%d", &t2, &t3);
            t2--;
            a[i][t2] = t3;
        }
    }
    for(int i = 0; i < (1 << n); i++)
    {
        int j, cnt = 0;
        for(j = 0; j < n; j++)
        {
            if(!(i & (1 << j))) continue;
            for(int k = 0; k < n; k++)
            {
                if(a[j][k] == 1 && !(i & (1 << k)))
                {
                    j = 100;
                    break;
                }
                else if(a[j][k] == 0 && (i & (1 << k)))
                {
                    j = 100;
                    break;
                }
            }
        }
        if(j == n)
        {
            ans = max(ans, __builtin_popcount(i));
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long x = in.nextLong();
            long y = in.nextLong();

            if (x % y == 0) {
                out.println(-1);
                return;
            }

            out.println((y - 1) * x);
        }

    }
}



Measured memory_bytes: 23636
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;

map<pair<int, int>, int> ansMap;
int ar[200005];
int br[200005];

int root(int* c, int x) {
	if (c[x] == x) {
		return x;
	}
	
	return c[x] = root(c, c[x]);
}

void unite(int* c, int x, int y) {
	int rootX = root(c, x);
	int rootY = root(c, y);
	if (rootX != rootY) {
        c[rootX] = rootY;
	}
}

int main(){

    int N, K, L;
    int out;
    cin >> N >> K >> L;

    for (int i = 0; i < N; i++) {
    	ar[i] = i;
    	br[i] = i;
    }

    int p, q;
    while (K--) {
    	cin >> p >> q;
    	p--;
    	q--;
    	unite(ar, p, q);
    }

    int r, s;
    while (L--) {
    	cin >> r >> s;
    	r--;
    	s--;
    	unite(br, r, s);
    }

    pair<int, int> pArray[N];
    for (int i = 0; i < N; i++) {
    	pair<int, int> p(root(ar, i), root(br, i));
    	pArray[i] = p;
    	ansMap[p]++;
    }


    for (int i = 0; i < N; i++) {
    	cout << ansMap[pArray[i]] << " ";
    }

}


Measured memory_bytes: 15104
#[allow(unused_imports)]
use std::cmp;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
fn main() {
  input! {
    n: Chars,
  }
  if n.iter().all(|&c| c != '7') {
    println!("No");
  } else {
    println!("Yes");
  }
}


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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


void prnt(char c, int n){
  REP(i, n) cout << c;
}

int main(){
  int sx, sy, tx, ty;
  scanf("%d%d%d%d",&sx, &sy, &tx, &ty);
  int dx = tx - sx;
  int dy = ty - sy;
  prnt('U', dy);
  prnt('R', dx);
  prnt('D', dy);
  prnt('L', dx + 1);
  prnt('U', dy + 1);
  prnt('R', dx + 1);
  printf("DR");
  prnt('D', dy + 1);
  prnt('L', dx + 1);
  puts("U");
  return 0;
}

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

int main(){
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int d1 = j%10;
            int d10 = j/10;
            if(d1 >= 2 && d10 >= 2 && i == d1*d10) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long 
#define MAXN 300005
#define INF 2147483647
using namespace std;

int n, k, ans=INF, num[35][5];
int mp[505][505], c[35][35];
 
int main()
{
	scanf("%d%d", &n, &k);
	for(int i=1; i<=k; i++) for(int j=1; j<=k; j++) scanf("%d", &c[i][j]);
	for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) scanf("%d", &mp[i][j]);
	for(int x=1; x<=k; x++)
	{
		for(int i=1; i<=n; i++)
		{
			for(int j=1; j<=n; j++) num[x][(i+j)%3]+=c[mp[i][j]][x];		
		}
	}
	for(int i=1; i<=k; i++)
	{
		for(int j=1; j<=k; j++)
		{
			for(int l=1; l<=k; l++)
			{
				if(i!=j && j!=l && l!=i) ans=min(ans, num[i][0]+num[j][1]+num[l][2]);
			}
		}
	}
	printf("%d\n", ans);
} 

Measured memory_bytes: 1280
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	cat A, B, V, W, T;
	cin >> A >> V >> B >> W >> T;
	cout << ((W >= V || abs(B-A) > T*(V-W)) ? "NO\n" : "YES\n");
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  int n;
  cin>>n;
  vector<ll>a(n);
  ll sum=0;
  rep(i,n){cin>>a[i];sum=sum+a[i];}
  ll sun=a[0];
  ll ara=sum-sun;
  ll ans=abs(sun-ara);
  Rep(i,1,n-1){
    sun=sun+a[i];
    ara=sum-sun;
    ll tmp=abs(sun-ara);
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
    
    
  return 0;
}


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

int32_t main()
{
  int a,b,c,k;cin>>a>>b>>c>>k;
  int ans=0;
  ans+=min(a,k);
  k=k-min(a,k);
  k=k-b;
  if(k>0)
  {
    ans-=min(c,k);
  }
  cout<<ans<<endl;
}
  

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

int main(void)
{
    ll n, ans=0, sum=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    rep(i,n){
        sum -= a[i];
        ans += ((a[i]%mod)*(sum%mod))%mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4800
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            
            if(h == 0 && w == 0){
                break;
            }
            
            for(int i = 0;i < h; i++){
                for(int j = 0; j < w; j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 59956
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int t = Integer.parseInt(sc.next());
		
		Map<Integer, Integer> map = new HashMap<Integer,Integer>();
		
		for(int i = 0; i < n; i++) {
			int c = Integer.parseInt(sc.next());
			int time = Integer.parseInt(sc.next());
			
			if(time <= t) {
				map.put(c, time);
			}
		}
		
		int min = Integer.MAX_VALUE;
		
		for(Map.Entry<Integer, Integer> entry : map.entrySet()) {
			min = Math.min(entry.getKey(), min);
		}
		
		System.out.println(min == Integer.MAX_VALUE ? "TLE" : min);
		
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
int H,W,N;
int sum[210][210];
 
int dfs(int y,int x,int yy,int xx,int n){
    if(n==1)return sum[yy][xx]-sum[yy][x]-sum[y][xx]+sum[y][x];
    int ret=0;
    reps(yyy,y+1,yy)reps(nn,1,n)chmax(ret,min(dfs(y,x,yyy,xx,nn),dfs(yyy,x,yy,xx,n-nn)));
    reps(xxx,x+1,xx)reps(nn,1,n)chmax(ret,min(dfs(y,x,yy,xxx,nn),dfs(y,xxx,yy,xx,n-nn)));
    return ret;
}
 
signed main(){
    cin>>H>>W>>N;
    rep(i,H)rep(j,W){
        cin>>sum[i+1][j+1];
        sum[i+1][j+1]+=sum[i][j+1]+sum[i+1][j]-sum[i][j];
    }
    
    int ans=dfs(0,0,H,W,N);
    if(N==4){
        reps(i,1,H-1)reps(j,1,W-1)reps(k,i+1,H)reps(l,j+1,W){
            chmax(ans,min(min(sum[i][l],sum[k][W]-sum[k][l]),min(sum[H][W]-sum[H][j]-sum[k][W]+sum[k][j],sum[H][j]-sum[i][j])));
            chmax(ans,min(min(sum[k][j],sum[H][l]-sum[k][l]),min(sum[H][W]-sum[H][l]-sum[i][W]+sum[i][l],sum[i][W]-sum[i][j])));
        }
    }
    cout<<ans<<endl;
}

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

struct NODE { int key; NODE *pa, *ri, *le; };
NODE *NIL, *root;

void insert(int k)
{
	NODE *z, *x = root, *y = NIL;

	z = new NODE;
	z->key = k;
	z->le = NIL;
	z->ri = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
			x = x->le;
		else
			x = x->ri;
	}

	z->pa = y;

	if (y == NIL)
		root = z;
	else
	{
		if (z->key < y->key)
			y->le = z;
		else
			y->ri = z;
	}
}

void preorder(NODE *u)
{
	if (u == NIL)return;
	cout << " " << u->key;
	preorder(u->le);
	preorder(u->ri);
}

void inorder(NODE *u)
{
	if (u == NIL)return;
	inorder(u->le);
	cout << " " << u->key;
	inorder(u->ri);
}

int main()
{
	string str;
	int i, n, k;
	cin >> n;
	
	for (i = 0; i < n; i++)
	{
		cin >> str;
		if (str[0] == 'i')
		{
			cin >> k;
			insert(k);
		}
		else  if (str[0] == 'p')
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}
	return 0;
}


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

namespace Program
{
    public class ABC054D
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static public void Main(string[] args)
        {
            var N = Console_.NextInt();
            var Ma = Console_.NextInt();
            var Mb = Console_.NextInt();
            var dp = new int[N + 1][][];
            for (int i = 0; i < N + 1; ++i)
            {
                dp[i] = new int[40 * 10 + 1][];
                for (int j = 0; j < 40 * 10 + 1; ++j)
                {
                    dp[i][j] = new int[40 * 10 + 1];
                    for (int k = 0; k < 40 * 10 + 1; ++k)
                    {
                        dp[i][j][k] = 1000000000;
                    }
                }
            }
            dp[0][0][0] = 0;
            for (int i = 1; i <= N; ++i)
            {
                var a = Console_.NextInt();
                var b = Console_.NextInt();
                var c = Console_.NextInt();

                for (int j = 0; j <= 40 * 10 - a; ++j)
                {
                    for (int k = 0; k <= 40 * 10 - b; ++k)
                    {
                        dp[i][j][k] = Math.Min(dp[i - 1][j][k], dp[i][j][k]);
                        dp[i][j + a][k + b] = Math.Min(dp[i][j + a][k + b], dp[i - 1][j][k] + c);
                    }
                }
            }
            var ax = Ma;
            var bx = Mb;
            var maxMulti = Math.Min(40 * 10 / Ma, 40 * 10 / Mb);
            var min = 1000000000;
            for (int i = 1; i < maxMulti; ++i)
            {
                if (dp[N][i * ax][i * bx] < min)
                {
                    min = dp[N][i * ax][i * bx];
                }
            }

            Console.WriteLine(min == 1000000000 ? -1 : min);
        }
    }
}


Measured memory_bytes: 44484
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main () {
    int n ;
    cin >> n ;
    vector<int> d(n) ;
    rep(i, n) cin >> d[i] ;
    sort(d.begin(),d.end()) ;
    int ub = n / 2 ;
    int lb = ub - 1 ;
    cout << d[ub] - d[lb] << endl ;
}





Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int lli;

int main(void)
{
	lli n, a, b, res = 0;
	scanf("%lld%lld%lld", &n, &a, &b);
	lli X[n+1];

	for(lli i = 0;i < n;i++)
	{
		scanf("%lld", &X[i]);
		if(i)
		{
			res += min((X[i]-X[i-1])*a, b);
		}
	}
	printf("%lld\n", res);
}

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

int main()
{
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      cin >> c[i][j];
  bool res = false;
  for (int i = 0; i <= c[0][0]; i++)
  {
    int a0 = i;
    int b0 = c[0][0] - a0;
    for (int j = 0; j <= c[1][1]; j++)
    {
      int a1 = j;
      int b1 = c[1][1] - a1;
      for (int k = 0; k <= c[2][2]; k++)
      {
        int a2 = k;
        int b2 = c[2][2] - k;
        if (   a0 + b1 == c[0][1]
            && a0 + b2 == c[0][2]
            && a1 + b0 == c[1][0]
            && a1 + b2 == c[1][2]
            && a2 + b1 == c[2][1]
            && a2 + b0 == c[2][0])
        { res = true; break;}
      }
    }
  }
  cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
using namespace std;
int main() {
  string s;
  cin >> s >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans += (s.substr(i, 3) == "ABC");
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    L = list(map(int, input().split()))

    m = max(L)
    if m < sum(L) - m:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a,b,c;cin>>a>>b>>c;
    if (b-a == c-b) cout<<"YES"<<endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
using std::stack;

char s[2000];
int Atoms[30*30];

int getAtom(int x){
    int Atom = (s[x] - 'A' + 1) * 28;
    if('a'<=s[x+1] && s[x+1]<='z'){
        Atom += (s[x+1] - 'a' + 1);
    }
    return Atom;
}

int getNum(int x){
    int Num = 1;
    if('0'<=s[x] && s[x]<='9'){
        Num = s[x]-'0';
    }
    else return Num;
    if('0'<=s[x+1] && s[x+1]<='9'){
        Num = Num*10 + s[x+1]-'0';
    }
    return Num;
}

int solve(){
    scanf("%s", s);
    if(s[0]=='0') return 0;
    stack<int> S;
    int tmp = 0;
    for(int i=0;s[i]!='\0';i++){
        if(s[i] == '('){
            S.push(tmp);
            tmp = 0;
        }
        if(s[i] == ')'){
            int Num = getNum(i+1);
            tmp *= Num;
            tmp += S.top(); S.pop();
        }
        if('A' <= s[i] && s[i] <= 'Z'){
            int Atom = getAtom(i);
            if(Atoms[Atom]==0){
                puts("UNKNOWN");
                return 1;
            }
            if('a'<=s[i+1] && s[i+1]<='z') i++;
            int Num = getNum(i+1);
            tmp += Atoms[Atom] * Num;
        }
    }
    printf("%d\n", tmp);
    return 1;
}

int main(){
    while(true){
        int val;
        scanf("%s", s);
        if(s[0]=='E' && s[1]=='N' &&s[2]=='D'){
            break;
        }
        scanf("%d", &val);
        Atoms[getAtom(0)] = val;
    }
    //puts("READ DONE");
    while(solve());
    return 0;
}

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

int main(){
    bool tf = false;
    int a,b;
    
    for(;;){
        int flg = 0;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        
        if(tf) puts("");
        else tf = true;
        
        for( ; a <= b ; a++){
            if(!(a%4)){
                if(!(a%100)){
                    if(!(a%400)){
                        flg = 1;
                        cout << a << endl;
                    }
                }
                else{
                    flg = 1;
                    cout << a << endl;
                }
            }
        }
        if(!flg) cout << "NA" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
import sys

T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())

if A1 < B1:
    A1, B1 = B1, A1
    A2, B2 = B2, A2

if A1 * T1 + A2 * T2 > B1 * T1 + B2 * T2:
    print(0)
    sys.exit()

if A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2:
    print('infinity')
    sys.exit()

N = (T1 * (A1 - B1) - 1) // (T1 * (B1 - A1) + T2 * (B2 - A2)) + 1

ans = N * 2 - 1

if N * (T1 * (B1 - A1) + T2 * (B2 - A2)) == T1 * (A1 - B1):
    ans += 1

print(ans)

Measured memory_bytes: 9228
#include<stdio.h>
#include<map>
using namespace std;
typedef long long ll;
const ll mod=1000000000000000031ll,b=1000000000000000003ll,rb=821428571428571454ll;
ll mul(ll a,ll b){return(__int128)a*b%mod;}
ll ad(ll a,ll b){return(a+b)%mod;}
char s[250010];
ll p[250010],st[250010];
map<ll,int>m;
int main(){
	int n,i;
	ll ans;
	scanf("%d%s",&n,s+1);
	p[0]=1;
	for(i=1;i<=n;i++){
		p[i]=p[i-1];
		st[i]=st[i-1];
		switch(s[i]){
			case'+':st[i]=ad(st[i],p[i]);break;
			case'-':st[i]=ad(st[i],mod-p[i]);break;
			case'>':p[i]=mul(p[i],b);break;
			case'<':p[i]=mul(p[i],rb);break;
		}
	}
	ans=0;
	for(i=n;i>0;i--){
		m[st[i]]++;
		ans+=m[ad(mul(st[n],p[i-1]),st[i-1])];
	}
	printf("%lld",ans);
}

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

int main() {
	int a,b,c;
	bool f = false;
	cin >> a >> b >> c;
	if(a == 7 && b == 5 && c == 5) f = true;
	else if(a == 5 && b == 7 && c == 5) f =true;
	else if(a == 5 && b == 5 && c == 7) f =true;
	if(f) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define int ll
const int N=200001;
int n,a[N],h[N],dp[N];
#define all(x) x.begin(),x.end()
struct segment{
	int seg[200001*4]={0};
	int pull(int x,int y){
		return max(seg[x],seg[y]);
	}
	void update(int id,int l,int r,int i,int v){
		if(l==r){
			seg[id]=max(seg[id],v);
			return;
		}
		int m=(l+r)/2;
		if(i<=m)update(id*2+1,l,m,i,v);
		else update(id*2+2,m+1,r,i,v);
		seg[id]=pull(id*2+1,id*2+2);
	}
	int query(int id,int l,int r,int ql,int qr){
		if(qr<l||r<ql)return 0;
		if(ql<=r&&r<=qr)return seg[id];
		int m=(l+r)/2;
		return max(query(id*2+1,l,m,ql,qr),query(id*2+2,m+1,r,ql,qr));
	}	
	
}seg;
void bi(){
	vector<int> tmp(h,h+n);
	sort(all(tmp));
	tmp.resize(unique(all(tmp))-tmp.begin());
	for(int i=0;i<n;i++){
		h[i]=upper_bound(all(tmp),h[i])-tmp.begin()-1;
	}
}
signed main(){
	ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>h[i];
	for(int i=0;i<n;i++)cin>>a[i];
	bi();
	dp[0]=a[0];
	seg.update(0,0,n-1,h[0],a[0]);	
	int ans=a[0];
	for(int i=1;i<n;i++){
		dp[i]=seg.query(0,0,n-1,0,h[i]-1)+a[i];
		seg.update(0,0,n-1,h[i],dp[i]);
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 12416
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;

int main()
{
    int a,b;
    int v,w;
    int t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    long long int  l=abs(a-b);
    int  v1=v-w;
    if(v1<=0)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        if(l*1.0/v1<=t)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
    int x,happy=0;
    cin>>x;
    happy+=(x/500)*1000+((x%500)/5)*5;
    cout<<happy<<endl;
}

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



int main(void){
    int n;
    cin >> n;
    int p[n];
    rep(i,n){
        int x;
        cin >> x;
        p[i] = x;
    }
    int sum = 0;
    rep(i,n-2){
        if(p[i]<p[i+1] && p[i+1] < p[i+2]){
            sum++;
        }
      	if(p[i+2]<p[i+1] && p[i+1] < p[i]){
            sum++;
        }
      	
    }
    cout << sum << endl;
    
    return 0;
}


















Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    vi data(3); F0R(i, 3) cin >> data[i];

    sort(all(data));
    if (data[0] == data[1] || data[1] == data[2]) {
        if (data[0] != data[2]) {
            cout << "Yes" << endl; return 0;
        }
    }
    cout << "No" << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A.at(i);
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    int alice = 0, bob = 0;
    for(int i = 0; i < n; i += 2) alice += A.at(i);
    for(int i = 1; i < n; i += 2) bob += A.at(i);

    cout << alice - bob << endl;
}


Measured memory_bytes: 3572
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

LL dp[100001], h[100001];
const LL inf = 1e9 + 10;


int main()
{
    fast();

    

    LL t,n,i,j,k,x,y,c;
    cin >> n >> k;
    MEM(dp, inf);
    gall(h, n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    rep(i, 2, n, 1){
        rep(j, 1, k + 1, 1){
            if(i - j < 0)break;
            else{
                dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
            }
        }
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
 
char s[1000][1001];
int d[1000][1000],cnt[1000][1000];
int main(){
    int h,w;scanf("%d%d",&h,&w);
    rep(i,h)scanf("%s",s[i]);
    int Max=0;
    queue<P>que;
    rep(i,h)rep(j,w){
        if(s[i][j]=='.')continue;
        for(int k=-1;k<=1;k++){
            for(int l=-1;l<=1;l++){
                int x=i+k,y=j+l;
                if(0<=x&&x<h&&0<=y&&y<w&&s[x][y]=='.')cnt[i][j]++;
            }
        }
        if(cnt[i][j]>=s[i][j]-'0'){
            d[i][j]=Max=1;que.push(P(i,j));
        }
    }
    while(!que.empty()){
        P p=que.front();que.pop();
        for(int i=-1;i<=1;i++)for(int j=-1;j<=1;j++){
            int x=p.first+i,y=p.second+j;
            if(0<=x&&x<h&&0<=y&&y<w&&s[x][y]!='.'&&!d[x][y]){
                if(++cnt[x][y]>=s[x][y]-'0'){
                    d[x][y]=Max=d[p.first][p.second]+1;que.push(P(x,y));
                }
            }
        }
    }
    printf("%d\n",Max);
}

Measured memory_bytes: 11960
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def glm(a,b):
  #print(a,b,gcd(a,b))
  return a*b//gcd(a,b)
from functools import reduce
def glm_multi(iterable):
  return reduce(glm,iterable,1)
def main():
  n=int(input())
  nums=list(map(int,input().split()))
  g=glm_multi(nums)
  #print(g)
  return sum(g//num for num in nums)%(10**9+7)
print(main())

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

n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n - i - j) == y:
            print("{} {} {}".format(i, j, n-i-j))
            exit()
print('-1 -1 -1')

Measured memory_bytes: 2940
#include<stdio.h>

struct tranp{
  char gara;
  int atai;
};

void bbsort(struct tranp C[], int);
void selsort(struct tranp C[], int);
void pr(struct tranp C[], int);


int main(){
  int i=0,j=0;
  struct tranp C[100];
  struct tranp CC[100];
  int N=0;
  int count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c%d",&C[i].gara,&C[i].atai);
  }
  for(i=0;i<N;i++){
      CC[i]=C[i];
  }
  bbsort(C,N);
  selsort(CC,N);
  pr(C,N);
  printf("Stable\n");
  pr(CC,N);
  for(i=0;i<N;i++){
    if(C[i].gara!=CC[i].gara){
      printf("Not stable\n");
      break;
    }
  }
  if(i==N)printf("Stable\n");
  return 0;
}
void bbsort(struct tranp A[],int N){
  int i=0,j=0;
  struct tranp temp;
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(A[j].atai<A[j-1].atai){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
      }
    }
  }
}
void selsort(struct tranp A[], int N){
  int i=0,j=0;
  struct tranp temp;
  int min=0;
  for(i=0;i<=N-1;i++){
    min=i;
    for(j=i;j<=N-1;j++){
      if(A[j].atai<A[min].atai){
	min=j;
      }
    }
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
  }
}
void pr(struct tranp A[],int N){
  int i=0;
  /*if(N>1){
    for(i=0;i<N;i++){
      if(i<N-1){
	printf("%c%d ",A[i].gara,A[i].atai);
      }
      if(i==N-1){
	printf("%c%d",A[i].gara,A[i].atai);
      }
    }
    printf("\n");
  }
  else {
    for(i=0;i<N;i++){
      printf("%c%d",A[i].gara,A[i].atai);
    }
    printf("\n");
    }
  */
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%c%d",A[i].gara,A[i].atai);
  }
  printf("\n");   
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long
#define int long long

#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
  string s,t,ans;
  cin>>s>>t;

  int a=sz(s);
  int b=sz(t);

  set<int> k;

  int dp[a+1][b+1];
  rep(i,0,a+1)
  {
    rep(j,0,b+1)
    {
        if(i==(int)0 || j==(int)0) {dp[i][j]=0;}
        else if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        //cout<<dp[i][j]<<" ";
    }
    //cout<<endl;
  }
  
  int i=a,j=b;
  while(i>=1 && j>=1 )
  {
    if(s[i-1]==t[j-1])
    {

        ans.pb(s[i-1]);
        i--;
        j--;
    }
    else if(dp[i][j]==dp[i-1][j]) i--;
    else j--;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans;



}

Measured memory_bytes: 70656
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramC a = new ProgramC();
            a.main();//実行する

        }

    }
    //ABC178
    class ProgramA
    {
        public void main()
        {
            //入力
            string s = Console.ReadLine();
            //30以上ならYes、それ以外はNoを出力
            if(s[s.Length  -1] == 's')
                Console.WriteLine(s + "es");
            else
                Console.WriteLine(s + "s");


        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力
            int n = int.Parse(Console.ReadLine());
            int[] zorome = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                if (int.Parse(s[0]) == int.Parse(s[1]))
                    zorome[i] = 1;
                else
                    zorome[i] = 0;
            }
            int count = 0;
            for(int i = 0;i < n;i++)
            {
                if (zorome[i] == 1)
                    count++;
                else
                    count = 0;

                if (count == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }

            }
            
            Console.WriteLine("No");

        }
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            long n = long.Parse(Console.ReadLine());

            long count = 0;
            for(int i = 1;i < n;i++)
            {
                count += (n - 1) / i;
            }

            Console.WriteLine(count);

        }

    }

    class ProgramD
    {
        public void main()
        {

        }
            
    }

    class ProgramE
    {

        public void main()
        {

        }


    }

}






Measured memory_bytes: 27496