akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int n = in.ni(), m = in.ni();
    for (int i = 0; i < n; i++) {
      graph.add(new ArrayList<>());
    }
    for (int i = 0; i < m; i++) {
      int u = in.ni() - 1, v = in.ni() - 1;
      graph.get(u).add(v);
    }
    dp = new Integer[n];
    int result = 0;
    for (int i = 0; i < n; i++) {
      result = Math.max(result, recurse(i));
    }
    out.println(result);
  }
  
  private List<List<Integer>> graph = new ArrayList<>();
  private Integer[] dp;
  
  private int recurse(int u) {
    if (dp[u] != null) return dp[u];
    
    int ans = 0;
    for (int v : graph.get(u)) {
      ans = Math.max(ans, 1 + recurse(v));
    }
    return dp[u] = ans;
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 59748
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

int gcd(int a, int b){
    while( b ){
        int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //xのn乗を計算するのにn乗を2進表記にして計算
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//答えに付加
        }
        x=(x*x)%mod;//2乗
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    int zenbu=0;
    int kidoku=0;
};

class xxIntu {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        //第1条件
        if(riLeft.z != riRight.z){
            return riLeft.z < riRight.z;//<:昇順(小さい順)、>:降順(大きい順)
        }
        //第2条件
        return riLeft.x < riRight.x;
    }
};
bool operator< (const VV &riLeft, const VV &riRight){
    return riLeft.z < riRight.z;
};
/*bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};*/



int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //ここから
    
    int N;
    cin >> N;
    long long a[100000];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    long long ans=0;
    long long amari=0;

    for(int i=0;i<N;i++){
        lldiv_t l;
        l = lldiv(amari+a[i],2);
        ans=ans+l.quot;
        if(a[i]==0){
            l = lldiv(a[i],2);
        }
        amari=l.rem;
    }
    
    cout << ans << endl;
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, 0, m) cin >> a[i];
    cout << n - m - 1 << endl;
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ab = Integer.parseInt(sc.next()+sc.next());
		int c = (int)Math.sqrt(ab);
		if(c*c == ab) System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 21844
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let n: usize = read_as_vec()[0];

    let s = read_as_string().chars().collect::<Vec<char>>();
    
    //println!("{:?}", s);
    
    //if they are all black(#)
    if s.iter().all(|ch| *ch == '#'){
        println!("0");
        return;
    }
    //if they are all white(.)
    if s.iter().all(|ch| *ch == '.'){
        println!("0");
        return;
    }

    let num_white = s.iter().filter(|ch| **ch == '.').collect::<Vec<_>>().len();
    let num_black = s.iter().filter(|ch| **ch == '#').collect::<Vec<_>>().len();
    let mut right = (num_white, num_black);
    let mut left = (0, 0);
    //initial value is the cost to change them all black
    let mut min_cost = num_white;

    for c in &s{
        if *c == '.'{
            right.0 -= 1;
            left.0 += 1;
        }else{
            right.1 -= 1;
            left.1 += 1;
        }

        min_cost = cmp::min(min_cost, left.1+right.0);
    }
    
    println!("{}", min_cost);
}




Measured memory_bytes: 8444
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
map <int ,int>mapi;
map< int,int  > ::iterator it;
int a[1005][1005],b[1005];
int main(){
	int n,i,c=0,a;
	cin>>n;
	rep(i,n){
		cin>>a;
		mapi[a]++;
	}
	for(it=mapi.begin();it!=mapi.end();it++){
		if((it->ss)%2==1){
			c++;
		}
	}
	cout<<c<<endl;
}


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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] line = Console.ReadLine().Split(' ');
		int N = int.Parse(line[0]);
		long K = long.Parse(line[1]);

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

		int ans = 0;

		//（１）K<=1000000のとき
		//ループ処理で間にあう筈
		if(K <= 1000000){
				int current = 0;
				for(int i=0; i<K; i++){
						int next = An[current] - 1;
						current = next;
				}

				ans = current + 1;
		}

		//その他の場合
		//このとき制約条件から、必ずK>N
		else{
				//規則性を探す
				/*「その村にi度目に訪れたとき、j回テレポートした時点である」
				という状態を格納するバケツ
				bucket[n,0] = i, bucket[n,1] = jとする。*/
				int[,] bucket = new int[N,2];
				int current = 0;
				bool found = false;
				int teleport = 0;
				int first = 0;

				for(int i=0; i<N; i++){
						bucket[current,0] ++;
						if(bucket[current,0] > 1){
								found = true;
								first = bucket[current,1];
								break;
						}
						else{
								bucket[current,1] = teleport;
								teleport ++;
								current = An[current] - 1;
						}
				}


				int roop = teleport - first;
				K -= (first-1);
				//何周するか数える
				long resid = K % roop;
				if(resid == 0){
						resid = roop;
				}

				int new_current = current;
				for(int i=0; i<resid-1; i++){
						int next = An[new_current] - 1;
						new_current = next;
				}
				ans = new_current + 1;

				/*
				Console.WriteLine(first);
				Console.WriteLine(current);
				Console.WriteLine(teleport);
				*/
		}


		Console.WriteLine(ans);
	}
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  print(n * n * n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int x;
    cin >> x;
    if(400 <= x && x <= 599){
        cout << 8 << endl;
        return 0;
    }
    if(600 <= x && x <= 799){
        cout << 7 << endl;
        return 0;
    }
    if(800 <= x && x <= 999){
        cout << 6 << endl;
        return 0;
    }
    if(1000 <= x && x <= 1199){
        cout << 5 << endl;
        return 0;
    }
    if(1200 <= x && x <= 1399){
        cout << 4 << endl;
        return 0;
    }
    if(1400 <= x && x <= 1599){
        cout << 3 << endl;
        return 0;
    }
    if(1600 <= x && x <= 1799){
        cout << 2 << endl;
        return 0;
    }
    if(1800 <= x && x <= 1999){
        cout << 1 << endl;
        return 0;
    }
}

Measured memory_bytes: 3672
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if (13 <= a) {
    cout << b << endl;
  } else if (6 <= a) {
    cout << (b >> 1) << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define maxn 110000

using namespace std;

int main(){
	int dp[maxn][3], a[maxn], b[maxn], c[maxn];
	int n;

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			if(i == 0){
				if(j == 0) dp[i][j] = a[i];
				if(j == 1) dp[i][j] = b[i];
				if(j == 2) dp[i][j] = c[i];
			}
			else{
				for(int k = 0; k < 3; k++){
					if(j == k) continue;
					if(j == 0){
						dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i]);
					}
					else if(j == 1){
						dp[i][j] = max(dp[i][j], dp[i - 1][k] + b[i]);
					}
					else{
						dp[i][j] = max(dp[i][j], dp[i - 1][k] + c[i]);
					}
				}
			}
		}
	}
	int aux = 0;
	aux = max(aux, dp[n - 1][0]);
	aux = max(aux, dp[n - 1][1]);
	aux = max(aux, dp[n - 1][2]);

	printf("%d\n", aux);
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;

int main(int argc, char *argv[])
{
	string s;
	int n;

	cin >> n >> s;


	if (n%2>0)
	{
		cout << "No"<<endl;
		return 0;
	}
	if (s.substr(0,n/2) == s.substr(n/2))
	{
		cout << "Yes"<<endl;
	}
	else 
	{
		cout << "No"<<endl;
	}
	return 0;
}



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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

vector<string> cand[11];
vector<int> maxl[11];
int cnt[11];    
int main() {
    int N;
    cin >> N;
    
    
    cand[1].push_back("a");
    maxl[1].push_back(0);
    //cnt[1] = 1;
    char ss[20] = "abcdefghij";
    for (int i = 2; i <= N; i++){
        rep(j, SZ(cand[i - 1])){
            string s = cand[i - 1][j];
            int mm = maxl[i - 1][j];
            //fprintf(stderr, "i = %d, mm = %d\n", i, mm);
            for (int k = 0; k <= mm + 1; k++){
                cand[i].push_back(s + ss[k]);
                maxl[i].push_back(max(mm, k));
            }
        }
    }
    //cout << SZ(cand[N]);
    //exit(1);
    rep(k, SZ(cand[N])){
        cout << cand[N][k] << endl;
    }
    return 0;
}


Measured memory_bytes: 10228
import sys
import math
from collections import deque
from itertools import combinations_with_replacement
from itertools import product
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, W, K = NMI()
    grid = [SI() for _ in range(H)]

    n = H + W
    ans = 0
    for case in range(2**n):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (case >> i) & 1:
                    if (case >> j + H) & 1:
                        if grid[i][j] == "#":
                            cnt += 1
        if cnt == K:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9428
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>
#include <iomanip>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;

using namespace std;

ll n, m, k;
ll h, w;

int main(){
    cin >> n;
    vector<ull> a(n);
    for (ll i=0; i<n; ++i){
        cin >> a[i];
    }
    ull asu=0, asq=0;
    for (ll i=0; i<n; ++i){
        asu += a[i];
        asu %= DENOM;
        asq += a[i] *a[i];
        asq %= DENOM;
    }
    ll ret = ((asu * asu) - asq) % DENOM;
    if (ret %2 ==0){
        ret /= 2;
    }else{
        ret = (ret + DENOM) / 2;
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
  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;
  }
}

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

int before, after, sum;

int calcTaxPrice(int price, int taxRate) {
    return price * (100 + taxRate) / 100;
}

int solve() {
    int max = -1;
    for (int i = 1; i <= (sum / 2); i++) {
        for (int j = i; j < sum; j++) {
            bool flg = calcTaxPrice(i, before) + calcTaxPrice(j, before) == sum;
            if (flg) {
                int temp = calcTaxPrice(i, after) + calcTaxPrice(j, after);
                max = temp > max ? temp : max;
            }
        }
    }
    return max;
}

int main () {
    while(cin >> before >> after >> sum && (sum != 0)) {
        cout << solve() << endl;
    }
}



Measured memory_bytes: 3104
#include <stdio.h>

int main(void) {
    int n, i, j;
    double tmp;
    int count[6] = {0};
    scanf("%d",&n);
    for(i = 0; i < n; i++ ) {
        scanf("%lf",&tmp);
        if(tmp >= 185) {
            count[5]++;
        } else if(tmp >= 180) {
            count[4]++;
        } else if(tmp >= 175) {
            count[3]++;
        } else if(tmp >= 170) {
            count[2]++;
        } else if(tmp >= 165) {
            count[1]++;
        } else {
            count[0]++;
        }
    }
    for(i = 1; i < 7; i++ ) {
        printf("%d:",i);
        for(j = 0; j < count[i - 1]; j++ ) {
            printf("*");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 648
N=int(input())
S=input()

x=[0]*N

c=0
for i in range(N):
	x[i] = c
	if S[i] == "W":
		c += 1

c=0
for i in range(N-1, -1, -1):
	x[i] += c
	if S[i] == "E":
		c += 1

print(min(x))


Measured memory_bytes: 15288
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.util.LinkedList;

public class Main {
	public class pair implements Comparable<pair> {
		int wt;
		int val;
		double rat;

		pair(int a, int v) {
			wt = a;
			val = v;
			rat = v / wt;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return (int) (this.rat - o.rat);
		}

	}

	public static long mod = (long) (1e9 + 7);

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int m = scn.nextInt();
		String s[] = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = scn.next();
		}
		long dp[][] = new long[n][m];
		for (int j = m - 1; j >= 0; j--) {
			if (s[n - 1].charAt(j) == '.') {
				if (j < m - 1 && dp[n - 1][j + 1] == -1) {
					dp[n - 1][j] = -1;
				} else {
					dp[n - 1][j] = 1;
				}
			} else {
				dp[n - 1][j] = -1;
			}
		}
		for (int j = n - 1; j >= 0; j--) {
			if (s[j].charAt(m - 1) == '.') {
				if (j < n - 1 && dp[j + 1][m - 1] == -1) {
					dp[j][m - 1] = -1;
				} else {
					dp[j][m - 1] = 1;
				}
			} else {
				dp[j][m - 1] = -1;
			}
		}
		for (int i = n - 2; i >= 0; i--) {
			for (int j = m - 2; j >= 0; j--) {
				if (s[i].charAt(j) == '.') {
					dp[i][j] = ((dp[i + 1][j] > 0 ? dp[i + 1][j] : 0) + (dp[i][j + 1] > 0 ? dp[i][j+1] : 0)) % mod;
				} else {
					dp[i][j] = -1;
				}
			}
		}
		System.out.println(dp[0][0]);

	}

	private static int dfs(int sr, HashSet<Integer> hset, int[] dp, ArrayList<Integer>[] g) {
		if (hset.contains(sr)) {
			return dp[sr];
		}
		hset.add(sr);
		int res = -1;
		for (int nei : g[sr]) {
			res = Math.max(res, dfs(nei, hset, dp, g));
		}
		dp[sr] = Math.max(dp[sr], res + 1);
		return dp[sr];

	}

}

Measured memory_bytes: 37284
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

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

	int A, B, C, D;
	string S;
	cin >> S;
	A = S[0] - '0';
	B = S[1] - '0';
	C = S[2] - '0';
	D = S[3] - '0';
	char x, y, z;
	char a1, a2, a3;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
			{
				int X = A;
				if (i) {
					X += B;
					x = '+';
				}
				else {
					X -= B;
					x = '-';
				}

				if (j) {
					X += C;
					y = '+';
				}
				else {
					X -= C;
					y = '-';
				}

				if (k) {
					X += D;
					z = '+';
				}
				else {
					X -= D;
					z = '-';
				}
				if (X == 7) {
					a1 = x;
					a2 = y;
					a3 = z;
				}
			}
		}
	}
	printf("%d%c%d%c%d%c%d=7\n", A, a1, B, a2, C, a3, D);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    int w;
    cin >> s >> w;
    for(int i = 0; i < s.size(); i += w){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

min = min([a,b,c,d,e], key=int)
max = max([a,b,c,d,e], key=int)

if (max - min) > k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int W,H,x,y;
	scanf("%d %d %d %d",&W,&H,&x,&y);
	double w,h;
	w = (double)W;
	h = (double)H;
	double ans = w*h/2.0;
	int ans_2 = 0;
	if(x*2 == W && y*2 == H)
	{
		ans_2 = 1;
	}
	printf("%f %d",ans,ans_2);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <math.h>
#include <complex>
using ll = long long;
using namespace std;
int const MOD = 1e9 + 7;
ll const INF = (1LL << 63) - 1;
#define rep(i, n) for (int i = 0; i < (n); i++)

using P = pair<ll, ll>;
bool operator<(const P &a, const P &b)
{
    if (a.first == b.first)
        return a.second < b.second;
    return a.first < b.first;
}

ll N, K;
vector<P> v;
int main(void)
{
    cin >> N >> K;
    rep(i, N)
    {
        ll x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    //N^4で全探索
    //区間内の点をどうカウントするか?
    //
    ll ans = INF;
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            for (int k = 0; k < N; ++k)
            {

                for (int l = 0; l < N; ++l)
                {
                    ll max_x = -INF, max_y = -INF;
                    ll min_x = INF, min_y = INF;
                    max_x = max({v[i].first, v[j].first, v[k].first, v[l].first});
                    min_x = min({v[i].first, v[j].first, v[k].first, v[l].first});

                    max_y = max({v[i].second, v[j].second, v[k].second, v[l].second});
                    min_y = min({v[i].second, v[j].second, v[k].second, v[l].second});

                    int cnt = 0;
                    for (int m = 0; m < N; ++m)
                    {
                        if (v[m].first <= max_x && min_x <= v[m].first &&
                            v[m].second <= max_y && v[m].second >= min_y)
                            cnt++;
                    }
                    if (cnt >= K)
                        ans = min(ans, (max_x - min_x) * (max_y - min_y));
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
const lint MOD = 1e9+7;

lint modpow(lint m, lint n){
  if(n == 0) return 1;
  else if(n % 2 == 0) return modpow(m * m % MOD, n/2);
  else{
    return modpow(m, n - 1) * m % MOD;
  }
}

signed main(){
	lint N, K; cin >> N >> K;
	lint ans = 0;
	vector<lint> data(K + 1, 0);
	for(lint i = K; i > 0; i--){
		lint num = modpow(K/i, N);
		for(lint j = 2 * i; j <= K; j += i){
			num = num - data[j] + MOD;
			num %= MOD;
		}
		data[i] = num;
		ans += num * i;
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4052
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
 
   string s;
   cin >> s;
   bool flg = 0;
   if((s[0]==s[1]) && (s[2]==s[3]) &&(s[0]!=s[2])) flg =1;
   else if((s[0]==s[2]) && (s[1]==s[3]) &&(s[0]!=s[1])) flg =1;
   else if((s[0]==s[3]) && (s[1]==s[2]) &&(s[0]!=s[1])) flg =1;
   
   if(flg) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}

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

struct UnionFind{
    vector<ll> par;
    vector<ll> sizes;

    UnionFind(ll n) : par(n), sizes(n, 1) {
        rep(i,n) par[i] = i;
    }

    int find(ll x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return sizes[find(x)];
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    UnionFind tree(100050);
    ll a[m], b[m];
    rep(i, m){
        cin >> a[i] >> b[i];
    }
    ll cnt = n * (n - 1) / 2;
    vector<ll> ans;
    ans.push_back(cnt);
    for (int j = m - 1; j >= 1; j--){
        if (tree.same(a[j], b[j])) ans.push_back(cnt);
        else {
            cnt -= tree.size(a[j]) * tree.size(b[j]);
            tree.unite(a[j], b[j]);
            ans.push_back(cnt);
        }
    }
    rrep(i, m) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5364
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
    int N, all = 0, S1 = 0, S2, ans = 1000000;
    scanf("%d", &N);
    int W[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &W[i]);
    } 
    for (int k = 0; k < N; k++) {
            all += W[k];
        }
    for (int i = 0; i < N; i++) {
        S1 += W[i];
        S2 = all - S1;
        if (ans > abs(S2 - S1)) {
            ans = abs(S2 - S1);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long x, y, ans;
	cin >> x >> y;
	if (x % y == 0) ans = -1;
	else {
		for (ans = x; (ans % y == 0); ans += x);
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 888
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)


    val n = sc.nextInt()

    val list = TreeSet<Int>()

    for (i in (0 until n)) {
       list.add(sc.nextInt())
    }

    val q = sc.nextInt()

    val t_list = ArrayList<Int>()
    for(i in 0 until q){
       t_list.add(sc.nextInt())
    }


    var ans = 0
    t_list.forEach{
        ans += if(list.contains(it)) 1 else 0
    }

    println(ans)

}



Measured memory_bytes: 88432
#include <stdio.h>
signed main(){
    int p,n,k,x[1005],ans=0,i,temp,min;
    scanf("%d %d",&n,&k);
    for(p=0;p<n;p++){
        scanf("%d",&x[p]);
    }
    for(p=0;p<n-1;p++){
        min=p;
        for(i=p+1;i<n;i++){
            if(x[i]<x[min]){
                min=i;
            }
        }
        if(min!=p){
            temp=x[p];
            x[p]=x[min];
            x[min]=temp;
        }
    }
    for(p=0;p<k;p++){
        ans+=x[p];
    }
    printf("%d\n",ans);
    return(0);
}

Measured memory_bytes: 1704
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,A,B;

signed main(){
	cin>>N>>A>>B;
	cout<<max(((N-1)*B+A)-((N-1)*A+B)+1,0LL)<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 55;

char str[MAXN];

int main ()
{
    scanf ("%s", &str);
    int len = strlen (str);
    for (int i = 0; i <= len - 9; i ++)
    {
        printf ("%c", str[i]);
    }
    printf ("\n");
    return 0;
}


Measured memory_bytes: 256
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
  v=q.pop()
  checked[v]=1
  for u in g[v]:
    if checked[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])


Measured memory_bytes: 56060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

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

  ll ans=1;
  rep(i,n){
    ans*=(i+1);
    ans%=MOD;
  }
  prt(ans);
}


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

int main() {

	string w;
	cin >> w;

	string res = "Yes";
	for (int i = 0; i < 26; i++) {
		int counter = 0;
		for (int j = 0; j < w.size(); j++) {
			if (w.at(j) == ('a' + i)) counter++;
		}
		if (counter % 2 == 1) res = "No";
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct _n {
  int id;              /* ?????? */
  int num;             /* ??? */
  struct _n *left;     /* ??? -- ?????±?????§ */
  struct _n *right;    /* ??? -- ?????±?????§ */
} _node;

/* ????????¢?´¢??¨????????? -- ?????°????????¨*/
void insert(_node *p1, int id, int num)
{
  _node *p2;

  if (p1->num == 0){
  	p1->num = num;
  }else if (p1->num <= num) {    /* ????????????????????§????????¨??? */
    /* ??????NULL?????????????????°????????????????????¶???????????? */
    if (p1->right == NULL) {
      p2 = malloc(sizeof(_node));
      p2->id = id;
      p2->num = num;
      p2->left = NULL;
      p2->right = NULL;
      p1->right = p2;
    } else {  /* NULL??§???????????°?????´????????????????§???? */
      insert(p1->right, id, num);
    }
  } else {
    /* ??????NULL?????????????????°????????????????????¶???????????? */
    if (p1->left == NULL) {
      p2 = malloc(sizeof(_node));
      p2->id = id;
      p2->num = num;
      p2->left = NULL;
      p2->right = NULL;
      p1->left = p2;
    } else {  /* NULL??§???????????°?????´????????????????§???? */
      insert(p1->left, id, num);
    }
  }
}

//?????????????????¢?????´?????????
void middleprint(_node *p){
	if (p != NULL)
	{
		middleprint(p->left);
		printf(" %d", p->num);
		middleprint(p->right);
	}else{
		return;
	}
}

//?????????????????¢?????´?????????
void preprint(_node *p){
	if (p != NULL)
	{
		printf(" %d", p->num);
		preprint(p->left);
		preprint(p->right);
	}else{
		return;
	}

}

int main(void)
{
	_node *start, *p1;
	int i, nx, key;
	int *x;

	//??¢?´¢??¨???????????°??\???
	scanf("%d", &nx);
	x = calloc(nx-1, sizeof(int));

	/* ?????????????????????????????? */
	start = malloc(sizeof(_node));
	start->id = 0;
	start->num = 0;
	start->left = NULL;
	start->right = NULL;
	p1 = start;

	while(nx--){
		char str[100];
    	scanf("%s", str);
    	if(!strcmp(str, "insert")){
      		scanf("%d", &x[i]);
			insert(p1, i, x[i]);
    	}else{
			middleprint(p1);
			printf("\n");
			preprint(p1);
			printf("\n");
    	}
  	}
  	
	free(x);
	free(p1);

	return 0;
}

Measured memory_bytes: 16232
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int ans = 0;
    cin >> n;
    vector<pair<string,int> > st(n);
    REP(i,n){
        cin >> st[i].fi >> st[i].se;
    }
    string x;
    cin >> x;
    bool f = false;
    REP(i,n){
        if(f){
            ans += st[i].se;
        }
        if(st[i].fi==x){
            f = true;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    string s;
    int sum = 0, ans = 0;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') sum++;
        else sum = 0;
        ans = max(ans, sum);
    }
    cout << ans << '\n';

    return 0;
}


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

ll thr[5], N;

ll ceil(ll A, ll B) {
	return (A-1)/B+1;
}

void solve() {
	cin >> N;
	ll mn = 1e18;
	for (int i = 0; i < 5; ++i)
		cin >> thr[i], mn = min(mn,thr[i]);

	cout << ceil(N,mn)+4 << '\n';

}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

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

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs (rt<<1)+1
#define PI acos(-1)
#define eps 1e-8
#define ll long long
#define fuck(x) cout<<#x<<"     "<<x<<endl;
typedef pair<int,int> pii;
const int inf=2e9;
const int maxn=1e6+10;
int d[4][2]={1,0,-1,0,0,1,0,-1};
//int lowbit(int x){return x&-x;}
//void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);}
//int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
inline ll read() {
    ll s = 0,w = 1;
    char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-') w = -1;
        ch = getchar();
    }
    while(isdigit(ch))
        s = s * 10 + ch - '0',ch = getchar();
    return s * w;
}
inline void write(ll x) {
    if(x < 0)
        putchar('-'), x = -x;
    if(x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}


int main(){
    int m,d;
    m=read();d=read();int ans=0;
    for(int i=1;i<=m;i++)
        for(int j=1;j<=d;j++){
            if((j/10)>=2&&(j%10)>=2&&(j/10)*(j%10)==i)
                ans++;
        }
    write(ans);puts("");
    return 0;
}








Measured memory_bytes: 256
N = int(input())
factor_a = []
factor_b = []
ans = N
for a in range(1, N):
    sum_a = sum([int(i) for i in str(a)])
    sum_b = sum([int(i) for i in str(N-a)])
    if sum_a + sum_b < ans:
        ans = sum_a + sum_b
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e6 + 10;
const ll mod = 1e9 + 7;
int n;
ll c[N];
string s[100];
typedef pair<string, string>pss;
map<pss, ll>d;
struct X
{
	string a, b;
	ll di;
	bool operator<(const X&b)const {
		return di > b.di;
	}
};
bool ck(string a, string b, string c) {
	if (a.empty())a = c;
	else {
		b = c;
		reverse(b.begin(), b.end());
	}
	int x = min(a.length(), b.length());
	if (a.substr(0, x) != b.substr(0, x))return false;
	return true;
}
pss merge(string a, string b, string c) {
	if (a.empty())a = c;
	else {
		b = c;
		reverse(b.begin(), b.end());
	}
	int x = min(a.length(), b.length());
	a = a.substr(x);
	b = b.substr(x);
	string rb = b;
	reverse(rb.begin(), rb.end());
	string tmp = a + rb;
	string rtmp = tmp;
	reverse(rtmp.begin(), rtmp.end());
	if (tmp == rtmp)return pss("", "");
	return pss(a, b);
}
ll bfs() {
	priority_queue<X>q;
	q.push(X{ "","",0 });
	while (!q.empty()) {
		X tp = q.top(); q.pop();
		string a = tp.a, b = tp.b; ll di = tp.di;
		if (d.count(pss(a, b)) && d[pss(a, b)] < di)continue;
		if (di > 0 && a.empty() && b.empty())return di;
		for (int i = 1; i <= n; i++) {
			if (ck(a, b, s[i])) {
				pss p = merge(a, b, s[i]);
				if (!d.count(p) || d[p] > di + c[i]) {
					d[p] = di + c[i];
					q.push(X{ p.first,p.second,d[p] });
				}
			}
		}
	}
	return -1;
}
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> s[i] >> c[i];
	printf("%lld\n", bfs());
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
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 n, k;
long long h[100010];

long long dp[100010];


int main(){
	cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> h[i];

	for (int i = 0; i < 100010; ++i) dp[i] = INF;

	dp[0] = 0;

	for (int i = 1; i < n; ++i) {
		for (int j = 1; j <= k; j++){
			if(i >= j) chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
		}
	}

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

	return 0;
}

Measured memory_bytes: 1792
import Data.Char

main = do
  (n:k:_) <- fmap (read :: String -> Int) . words <$> getLine
  (s:_) <- words <$> getLine
  putStrLn $ lower s k

lower s k = s1 ++ ((toLower s2) : s3)
  where
    s1 = take (k - 1) s
    s2 = s !! (k - 1)
    s3 = drop k s

Measured memory_bytes: 508
import java.util.*;
import java.lang.*;

public class Main{
  public static void main(String[] args) {
    try {
      Scanner scan = new Scanner(System.in);
      int a, b, c, d;
      a = Integer.parseInt(scan.next());
      b = Integer.parseInt(scan.next());
      c = Integer.parseInt(scan.next());
      d = Integer.parseInt(scan.next());

      System.out.println(Math.min(a,b)+Math.min(c,d));
    }
    catch (Exception e) {
      
    }
  }
}

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

#define int long long

signed main() {
    int n;
    cin >> n;
    int t = 0;
    for(int i=1; i<=n; ++i) {
        t += i;
        if(t>=n) {
            int u = t - n;
            for(int j=1; j<=i; ++j) {
                if(j!=u) cout << j << endl;
            }
            return 0;
        }
    }
    return 0;
}



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

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  
  int backcount = k;
  vector<int> v(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (s.at(i) == 'o') {
      v.at(backcount) = i;
      backcount--;
      i -= c;
    }
    if (backcount == 0) {
      break;
    }
    if (i < 0) {
      return 0;
    }
  }
  
  int frontcount = 1;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'o') {
      if (v.at(frontcount) == i) {
        cout << i + 1 << endl;
      }
      frontcount++;
      i += c;
    }
  }
  return 0;
}

Measured memory_bytes: 2564
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << (x) << ", "
#define de(x) cout << #x << " = " << (x) << "\n"
#define endl "\n"

//-----

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int a, b; cin >> a >> b;
	cout << max(a + b, max(a - b, a * b));

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

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

    int a = 0;
    int b = 0;
    int c = 0;
    for(int i = 0; i < 3; ++i){
        if(S[i] == 'a') ++a;
        if(S[i] == 'b') ++b;
        if(S[i] == 'c') ++c;
    }
    cout << ((a == 1 && b == 1 && c == 1) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

digits = {i: None for i in range(n)}
def main():
    string = ""
    for i in range(m):
        s, c = map(int, input().split())
        if digits[s-1] is not None and digits[s-1] != c:
            return -1
        digits[s-1] = c

    if n==1 and m==0:
        return 0

    for i, d in digits.items():
        if d is not None:
            if i==0 and d == 0:
                if n==1:
                    return 0
                return -1
            string += str(d)
        else:
            if i==0:
                string+= "1"
            else:
                string += "0"
    return int(string)

print(main())



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        while (true) {
            
            int m = scanner.nextInt();
            int f = scanner.nextInt();
            int r = scanner.nextInt();
            
            if (m==-1 && f==-1 && r==-1) {
                break;
            }
            
            /* 中間試験: m   期末試験: f   再試験: r
中間試験、期末試験のいずれかを欠席した場合成績は F。
中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
中間試験と期末試験の合計点数が 30 未満ならば成績は F。
            */
            String result = "";
            if ( m==-1 || f==-1 ) {
                result = "F";
            } else if ( 80 <= m + f ) {
                result = "A";
            } else if ( 65 <= m + f && m + f < 80 ) {
                result = "B";
            } else if ( 50 <= m + f && m + f < 65 ) {
                result = "C";
            } else if ( 30 <= m + f && m + f < 50 ) {
                result = "D";
                if ( 50 <= r ) { 
                    result = "C";
                }
            } else {
                result = "F";
            }
            System.out.println(result);
        }
        
    }
}


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

int main(){
  pair<int, int> a, b;
  int p, q,s,t;
  cin>>p>>q;
  a=make_pair(p, q);
  cin>>p>>q;
  b=make_pair(p, q);
  p=a.second-b.second+b.first;
  q=b.first-a.first+b.second;
  cout<< p <<" "<<q<<" ";
  s=a.first-b.first+p;
  t=a.second-b.second+q;
  cout<<s<<" "<<t<<endl;
}

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

using namespace std;

int main(){
 int a;
 int d[5]={0};
  
    for(int i=0;i<6;i++){
   cin >>a;
    d[a]++;
  }
  
  if(d[1]<=2&&d[2]<=2&&d[3]<=2&&d[4]<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int a = int.Parse(Console.ReadLine());

			string s = Console.ReadLine();

			if (a < 3200)
			{
				Console.WriteLine("red");

			}
			else
			{
				Console.WriteLine(s);
			}


		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 105;
const int MAXK = 100005;
const LL MOD = 1000000007;

int N, K, a[MAXN], dp[MAXK], pref[MAXK];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i];
	
	dp[0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j <= K; j++) {
			pref[j + 1] = (pref[j] + dp[j]) % MOD;
		}
		
		for (int j = 0; j <= K; j++) {
			dp[j] = (pref[j + 1] - pref[max(0, j - a[i])]) % MOD;
		}
	}
	
	cout << (dp[K] + MOD) % MOD << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,m,ts,s=0,n;

    cin>>n;
    map<ll,ll>p;

    for(int i = 0;i < n;i++)
    {
        cin>>a;
        s += a;
        p[a]++;
    }

    cin>>ts;

    while(ts--)
    {
        cin>>a>>b;
        s -= p[a]*a;
        s += p[a]*b;
        p[b] += p[a];
        p[a] -= p[a];
        cout<<s<<endl;
    }
}



Measured memory_bytes: 9368