akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a, b, s;
  in2(n, k);
  b = k + 1;
  s = 0;
  if(k == 0){
    out(n * n);
    memi;
    return 0;
  }
  while(b <= n){
    a = b - k;
    s = s + a * (n / b);
    a = n % b - k + 1;
    s += max(0ll, a);
    b++;
  }
  out(s);
  memi;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll k, a, b;
    cin >> k >> a >> b;
    ll n = 0;
    while (n <= b)
    {
        if (n >= a)
        {
            cout << "OK" << endl;
            exit(0);
        }
        n += k;
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int x, maxa, max=1, i;
  int r;

  cin >> x;
  r=sqrt(x);

  for(i=2; i<=r; i++){
    maxa = 1;
    while(maxa<=x){
      maxa *= i;
  }
  if(maxa/i > max){
    max = maxa/i;
  }
}

  cout << max;

  return 0;
}


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

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.valueOf(reader.readLine());
		double[] x = new double[6];

		for (int i = 0; i < n; i++) {
			StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
			for (int j = 0; j < 6; j++) {
				x[j] = Double.parseDouble(tokenizer.nextToken());
			}
			double AB = Math.sqrt(Math.pow(x[3] - x[0], 2)
					+ Math.pow(x[4] - x[1], 2));
			if (AB <= (x[2] + x[5])) {
				if (AB < x[2] - x[5]) {
					System.out.println(2);
				} else if (AB < x[5] - x[2]) {
					System.out.println(-2);
				} else
					System.out.println(1);
			} else {
				System.out.println(0);
			}
		}
	}
}

Measured memory_bytes: 16908
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int count = 0;
		for(int i =0; i <= a; i++){
			int money = i * 500;
			if(money > x) break;
			for(int j = 0; j <= b; j++){
				if(money + j * 100 > x) break;
				for(int k = 0; k <= c; k++){
					if(money + j * 100 + k * 50 > x	)break;
					if(x == i * 500 + j * 100 + k * 50) count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23764
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        mut abc: [u64; 3],
    }
    abc.sort();
    let m = abc[2];
    abc = abc.iter().map(|&x| m - x).collect::<Vec<_>>();
    let amr: u64 = abc.iter().map(|&x| x % 2).sum();
    println!(
        "{}",
        abc.iter().map(|&x| x / 2).sum::<u64>() + (3 - amr) % 3
    );
}


Measured memory_bytes: 4352
//Name: Restore Calculation
//Level: 3
//Category: 動的計画法,DP
//Note: 

/**
 * dp[i][j] = i桁目以降のパターン数(i桁目はi-1桁目にj繰り上げる)
 * とすると、
 *   dp[i][0] = (和が9以下になる組み合わせ) × dp[i+1][0] + (和が8以下になる組み合わせ) × dp[i+1][1]
 *   dp[i][1] = (和が10以上になる組み合わせ) × dp[i+1][0] + (和が9以上になる組み合わせ) × dp[i+1][1]
 * で計算できる。
 * 既存の文字と整合性が取れるものだけを採用するように注意。
 *
 * オーダーは O(|S| D^2)。
 * ただしDは数字の種類数で、D = 10。
 */
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const long long MOD = 1000000007;
bool solve(bool first) {
    string s1, s2, sum;
    if(!(cin >> s1 >> s2 >> sum)) return false;
    if(s1 == "0") return false;

    const int S = s1.size();
    vector<vector<long long>> dp(S+1, vector<long long>(2, 0));
    dp[S][0] = 1;
    for(int i = S-1; i >= 0; --i) {
        for(int a = (i==0); a <= 9; ++a) {
            if(s1[i] != '?' && s1[i] != a+'0') continue;
            for(int b = (i==0); b <= 9; ++b) {
                if(s2[i] != '?' && s2[i] != b+'0') continue;
                const int s = (a + b) % 10;

                if(a+b <= 9) {
                    if(sum[i] == '?' || sum[i] == s+'0') {
                        dp[i][0] += dp[i+1][0];
                    }
                }
                if(a+b <= 8) {
                    if(sum[i] == '?' || sum[i] == s+1+'0') {
                        dp[i][0] += dp[i+1][1];
                    }
                }
                if(a+b >= 10) {
                    if(sum[i] == '?' || sum[i] == s+'0') {
                        dp[i][1] += dp[i+1][0];
                    }
                }
                if(a+b >= 9) {
                    if(sum[i] == '?' || sum[i] == (s+1)%10+'0') {
                        dp[i][1] += dp[i+1][1];
                    }
                }
                dp[i][0] %= MOD;
                dp[i][1] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;


int main(){
    while(1){
        double n;
        scanf("%lf",&n);
        if(n<0)break;
        int a = (int)(n * 16);
        if(a>=(1<<12) || a!=(n*16)){
            cout << "NA" << endl;
        }else{
            for(int i=11;i>=0;i--){
                if(i==3) cout << ".";
                cout << ((a>>i)&1);
            }
            cout << endl;
        }
    }

    return 0;
}

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

bool check(int num) {
  int prev = -1;
  while (num > 0) {
	int next = num % 10;
	if (prev != -1 && next != prev - 1) return false;
	prev = next;
	num /= 10;
  }
  return true;
}

int main() {
  int N; cin >> N;
  vector<int> a(N); for (int i = 0; i < N; ++i) cin >> a[i];
  int res = -1;
  for (int i = 0; i < N; ++i) {
	for (int j = i+1; j < N; ++j) {
	  int num = a[i] * a[j]; 
	  if (check(num)) res = max(res, num);
	}
  }
  cout << res << endl;
}



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

int main(){
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  
}

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

using namespace std;

const int N=1e5+10;
int n,W;
int weight[111];
long long dp[N],value[111];

int main(){
	#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);cin.tie(0);
	/*Input*/
	cin >> n >> W;
	for (int i=0;i<n;i++)
		cin >> weight[i] >> value[i];
	/*Process*/
	for (int i=0;i<n;i++){
		for (int j=W-weight[i];j>=0;j--)
			dp[j+weight[i]]=max(dp[j+weight[i]],dp[j]+value[i]);
	}

	long long ans=0;
	for (int i=0;i<=W;i++)
		ans=max(ans,dp[i]);
	cout << ans << '\n';
	//Ideas:
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::BinaryHeap;
 
fn main() {
  input! {
    n: usize,
    hs: [usize;n]
  }
  
  let mut index = hs.len() - 1;
  let mut last = hs[index];  
  while 0 < index {
    let val = hs[index];
    if last + 1 < val {
      println!("No");
      return
    } else if last + 1 == val {
      last = val - 1;
    } else {
      last = val;
    }
    index -= 1;
  }
  
  if last + 1 < hs[0] {
    println!("No");
  } else {
    println!("Yes");
  }
}

Measured memory_bytes: 3728
N = int(input())

cnt = 0
flag = False
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        flag = True
        break

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9120
#include<stdio.h>
int main(void){	
	int x,y,d,r;
	scanf("%d %d %d",&r,&d,&x);
	for (int i = 0; i < 10; i++)
	{
		y = r*x-d;
		printf("%d\n", y);
		x = y;
	}
	return 0;
}


Measured memory_bytes: 128
from bisect import bisect_left

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ret = 0
for mid in b:
    ret += bisect_left(a, mid) * (n - bisect_left(c, mid + 1))
print(ret)

Measured memory_bytes: 23328
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**18]*N
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i-j>=0:
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))

print(dp[-1])

Measured memory_bytes: 52444
#include <iostream>
#include <string.h>
#define INI 0
using namespace std;
int main (){
int count=INI;
string w,word;
cin>>w;
	while (1){
		cin>>word;
		if (word=="END_OF_TEXT"){
			cout<<count<<endl;
			return 0;
		}	
		for (int i=0;i<word.length();i++)
			word[i]=tolower(word[i]);
		if (word==w)count++;
	}
}



Measured memory_bytes: 3152
A,B=map(int,input().split())
a=A//0.08
b=B//0.1
S=sorted([b,b+1,b+2,b+3,b+4,b+5,b+6,b+7,b+8,b+9])
for s in S:
    if int(s*0.08)==A and int(s*0.1)==B:
        print(int(s))
        break
else:
    print(-1)

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

int main() {
	int n, k;
	bool d[10];

	cin >> n >> k;
	
	for (int i = 0; i < 10; i++) {
		d[i] = false;
	}
	for (int i = 0; i < k; i++) {
		int m;
		cin >> m;
		d[m] = true;
	}

	for (int i = n; ; i++) {
		int j = i;
		while (j > 0) {
			if (d[j % 10]) break;
			j /= 10;
		}
		if (j == 0) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

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

const int N = 200010;
const long long int MOD = 1000000007;

int fact[N], ifact[N];
int v[N];

void mult(int &a, int b) {
    long long p = 1LL * a * b;
    if (p >= MOD) p %= MOD;
    a = (int)p;
}

int fexp(int base, int exp) {
    if (base >= MOD) base %= MOD;
    int result = 1;
    while (exp > 0) {
        if (exp % 2 == 1) mult(result, base);
        exp >>= 1;
        mult(base, base);
    }
    return result;
}

void precalc() {
    fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = fact[i - 1];
        mult(fact[i], i);
    }

    ifact[N - 1] = fexp(fact[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; --i) {
        ifact[i] = ifact[i + 1];
        mult(ifact[i], i + 1);
    }
}

inline int nCr(int n, int r) {
    if (n < r) return 0;
    if (n == r) return 1;

    int res = fact[n];
    mult(res, ifact[r]);
    mult(res, ifact[n - r]);

    return res;
}

int main() {
    precalc();

    int h, w, a, b; 
    scanf("%d%d%d%d", &h, &w, &a, &b);
    
    for (int j = b; j < w; j++) {
        v[j - b] = nCr(h - a - 1 + j, j); 
    }

    int ans = 0;
    int n = a - 1;
    for (int j = w - b - 1; j >= 0; j--) {
        int add = nCr(n, a - 1);
        mult(add, v[j]);

        ans += add;
        if (ans >= MOD) ans -= MOD;

        ++n;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int n,k,a[100001],sta,ans=0x3f3f3f3f;
int main() {
    cin>>n>>k;
    for (int i=0; i<n; i++) {
        cin>>a[i];
        if (i!=0 and a[i-1]<=0 and 0<=a[i]) sta=i;
    }
    for (int i=k-1; i<n; i++) {
        //range is [i-k+1,i] then sta -> [i-k+1,i+1]
        int mn=min(0,a[i-k+1]),mx=max(0,a[i]);
        if (-mn<mx) {
            ans=min(ans,2*(-mn)+mx);
        }
        else {
            ans=min(ans,2*(mx)-mn);
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 4012
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		
        Scanner sc= new Scanner(System.in);
        
        int W=sc.nextInt();
        int H=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int r=sc.nextInt();
        
        if((x-r)<0||W<(x+r))
        System.out.println("No");
        
        else if((y-r)<0||H<(y+r))
        System.out.println("No");
        
        else
        System.out.println("Yes");
 
}

}


Measured memory_bytes: 26412
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(500*500) #追加

from collections import defaultdict, deque

infty = 2 ** 30

dic = defaultdict(lambda: [-1, infty])

#from sys import stdin
#stdin = open('./chapter15/sample.txt')          # 冒頭にこの1行を追加

#print(stdin.readline().rstrip())    # sample.txtから1行読み込まれる
lines = stdin.readlines()

v, e = map(int, lines[0].split())

glist = [[] for i in range(v)]
parent = [-1] * v
for i in range(e):
    s, t = map(int, lines[i+1].split())
    glist[s].append(t)
    glist[t].append(s)


t = 0
def depthFirstSearch(current, prev):
    global t
    t += 1
    dic[current][0] = t #prenum
    if dic[current][1] > t:
        dic[current][1] = t
    for y in range(len(glist[current])):
        next = glist[current][y]
        if dic[next][0] == -1:
            parent[next] = current
            depthFirstSearch(next,current)
            if dic[current][1] > dic[next][1]:
                dic[current][1] = dic[next][1]
        elif next != prev:
            if dic[current][1] > dic[next][0]:
                dic[current][1] = dic[next][0]
    return

def art_points():
    #lowest no keisan
    depthFirstSearch(0, -1)
    np = 0
    ap = set()
    for i in range(1, v):
        p = parent[i]
        if p == 0:
            np += 1
        elif dic[p][0] <= dic[i][1]:
            ap.add(p)
    if np > 1:
        ap.add(0)

    ap = sorted(list(ap))
    for i in range(len(ap)):
        print(ap[i])

art_points()







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

main() {
  int cookie[3];
  for (int i = 0; i < 3; i++) cin >> cookie[i];

  bool ok = false;
  int ans = 0;
  while (1) {
    for (int i = 0; i < 3; i++) {
      if (cookie[i] % 2) ok = true;
    }
    if (ans > 100) {
      ans = -1;
      ok = true;
    }
    if (ok) break;

    int tmp[3];
    for (int i = 0; i < 3; i++) tmp[i] = (cookie[i] + cookie[(i + 1) % 3]) / 2;
    for (int i = 0; i < 3; i++) cookie[i] = tmp[i];
    ans++;
  }
  cout << ans << endl;
}


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


	
int main(){
	int n,m;
	cin >> n >> m;
	if( n % 2 == 1 ){
		for(int i = 0 ; i < n ; i++){
			if(i) cout << " ";
			cout << (i%2?m:0);
		}
		cout << endl;
	}else{
		for(int i = 0 ; i < n ; i++){
			if(i) cout << " ";
			if( i <= n/2 ) cout << 0;
			else cout << m;
		}
		cout << endl;

	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
	string s;
	cin >> s;
	int x = 0,y=0, n = s.length();
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'A')
		{
			x = i;
			break;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'Z')
		{
			y = i;
		}
	}
	cout << y - x + 1 << endl;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <unordered_set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>
#include <atomic>
#include <thread>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define DFOR(i,s,e) int i = s;for(;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define DFORR(i,s,e) int i = s;for(;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }



const int N = 200001, inf = 10000;
int d[10][10];

void solve() {
  int h, w, v;
  cin >> h >> w;
  rep(i, 10)rep(j, 10)cin >> d[i][j];
  rep(k, 10)rep(i, 10)rep(j, 10)Min(d[i][j], d[i][k] + d[k][j]);
  int ans = 0;
  rep(i, h)rep(j, w) {
    cin >> v;
    if (v != -1) {
      ans += d[v][1];
    }
  }
  cout << ans << ln;
    
}


void init() {
  
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



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

int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    char p = tolower(s[k-1]);
    s[k-1] = p;
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

string shift_str(string str)
{
    int ascii;
    string ret;
     
    for (int i=0; i<str.length(); i++)
    {
        ascii = str[i];   
        if (!('a' <= ascii && ascii <= 'z'))
        {
            ret += ascii;
        } else {
        	ret += ((ascii - 'a') + 'A');
        }
         
    }   
    return ret;
}
//?°????????????§?????????
 
int main()
{
    string str;
    getline(cin,str);	//???????????\????????§????????????.
    cout<<shift_str(str)<<endl;
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;

int n, k;
vector<int> a;
vector<vector<int>> dp;

int solve(int x, int rem) {
  if (rem < 0) return 0;
  if (x < 0) return 1;

  int &ret = dp[x][rem];
  if (ret != -1) return ret;

  ret = solve(x, rem - 1);
  ret += solve(x-1, rem) - solve(x-1, rem - a[x] - 1);
  ret %= M;
  if (ret < 0) ret += M;
  return ret;
};

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

  cin >> n >> k;
  a.resize(n);
  dp.resize(n, vector<int> (k + 1, -1));

  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << (solve(n - 1, k) - solve(n - 1, k - 1) + M) % M << '\n';
}


Measured memory_bytes: 46924
#Replacing
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
u, count = np.unique(A,return_counts=True)
L = np.zeros(10**5,int)
for i in range(len(u)):
    L[u[i]-1] = count[i]
asum = A.sum()
for i in range(Q):
    B, C = list(map(int, input().split()))
    asum += L[B-1] * (C-B)
    L[C-1] += L[B-1]
    L[B-1] = 0
    print(asum)


Measured memory_bytes: 38660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <iomanip>

using namespace std;
int main(){
  int N;
  long long K;
  cin >> N >> K;
  long long a[N][N];
  for(int i = 0 ; i < N; i++){
     for(int j =0; j <N; j++){
        cin >> a[i][j];
     }
  }
  int mod = 1000000007;
  long long ans[N][N];
  for(int i = 0 ; i <N; i++)for(int j = 0 ; j < N; j++) ans[i][j] = (i==j?1:0);
  for(int i = 0 ; (1LL<<i) <= K ; i++){
     if((K&(1LL<<i))!=0){
        long long ans2[N][N];
        for(int x=0; x<N; x++)for(int y=0; y<N; y++) ans2[x][y] =0;
        for(int x = 0; x < N; x++){
           for(int y = 0 ; y < N; y++){
              for(int z=0; z<N; z++){
                 ans2[x][y] += (ans[x][z]*a[z][y])%mod;
                 ans2[x][y] %= mod;
              }
           }
        }
        for(int x=0; x<N; x++){
           for(int y=0; y<N; y++){
              ans[x][y] = ans2[x][y];
     //         cout << ans[x][y] << " ";
           }
     //      cout << endl;
        }
     //   cout << endl;
     }
     long long a2[N][N];
     for(int x=0; x<N; x++)for(int y=0; y<N; y++) a2[x][y] =0;
     for(int x = 0; x < N; x++){
        for(int y = 0 ; y < N; y++){
           for(int z=0; z<N; z++){
              a2[x][y] += (a[x][z]*a[z][y])%mod;
              a2[x][y] %= mod;
           }
        }
     }
     for(int x=0; x<N; x++)for(int y=0; y<N; y++) a[x][y] = a2[x][y];
  }
  long long ret = 0;
  for(int x=0;x<N;x++)for(int y=0;y<N;y++){
     ret += ans[x][y];
     ret %= mod;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
int main(){
  int d,last;
  llint i,j,g,ser,res,qu,mi;
  cin>>d>>g;
  res=0;
  qu=0;
  mi=200000;
  vint p(d);
  vint c(d);
  vint sum(d);
  
  for(i=0;i<d;i++){
    cin>>p[i]>>c[i];
    sum[i]=100*(i+1)*p[i]+c[i];
  }
  
  int pd=1;ser=0;
  
  for(i=0;i<d;i++){
   ser+=pd;pd*=2;
   }
  
  for(j=0;j<=ser;j++){
    res=0;qu=0;
   for(i=0;i<d;i++){ 
    if(j&(1<<i)){res+=sum[i];qu+=p[i];}else{last=i;}
   }
   if(res<g){
     if((sum[last]-c[last])>(g-res)){
     if((g-res)%(100*(last+1))){qu+=(((g-res)/100)/(last+1))+1;}
     else{qu+=((g-res)/100)/(last+1);}
     }else{
     continue;
     }
   }
   if(qu<mi){mi=qu;}
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int W, H, N;
    cin >> W >> H >> N;

    vector<int> x(N), y(N), a(N);
    rep(i, N) cin >> x[i] >> y[i] >> a[i];

    vector<vector<int>> S(H, vector<int>(W));

    rep(i, N)
    {
        switch (a[i])
        {
        case 1:
            rep(m, x[i])
            {
                rep(n, H)
                {
                    S[n][m] = 1;
                }
            }
            break;
        case 2:
            rep2(m, x[i], W)
            {
                rep(n, H)
                {
                    S[n][m] = 1;
                }
            }
            break;
        case 3:
            rep(m, y[i])
            {
                rep(n, W)
                {
                    S[m][n] = 1;
                }
            }
            break;
        case 4:
            rep2(m, y[i], H)
            {
                rep(n, W)
                {
                    S[m][n] = 1;
                }
            }
            break;
        default:
            break;
        }
    }
    int cnt = 0;

    rep(i, H)
    {
        rep(j, W)
        {
            if (S[i][j] == 0)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


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

int main(){
	string S, T; cin>>S>>T;
	int st[26], ts[26];//st:S->T, ts:T->S
	for(int i=0; i<26; ++i) st[i] = ts[i] = -1;
	int c;//common number
	for(c=0; c<S.size(); ++c){
		int s = S[c]-'a', t = T[c]-'a';
		if(st[s] != ts[t]) break;
		st[s] = ts[t] = c;
	}
	puts(c==S.size()? "Yes":"No");
}

Measured memory_bytes: 904
#include<stdio.h>
#include<stdlib.h>
#define N 10000

int main(){
  int i,n,*A,*B;
  int C[N+1];
  scanf("%d",&n);
  
  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);
  
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0 ; i<N+1 ; i++){
    C[i]=0;
  }
  for(i=0 ; i<n ; i++){
    C[A[i]]++;
  }
  for(i=1 ; i<N+1 ; i++){
    C[i] = C[i] + C[i-1];
  }
  for(i=n-1 ; i>=0 ; i--){
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }

  for(i=0 ; i<n ; i++){
    if(i<n-1)  printf("%d ",B[i]);
    else printf("%d\n",B[i]);
  }
  return 0;
}



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

int main() {
    int n;
    string str;
    cin >> n >> str;
    if(n % 2 == 0 && str.substr(0, str.length() / 2) == str.substr(str.length() / 2, str.length())) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

// clang-format off
#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

inline void br(ostream &os = cerr) { os << endl; }

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  string s = input<string>();
  vector<string> v({"dream", "dreamer", "erase", "eraser"});

  while (s.size()) {
    bool f = false;

    for (const auto &m : v) {
      if (s.size() >= m.size() && s.substr(s.size() - m.size(), m.size()) == m) {
        f = true;
        s.erase(s.end() - m.size(), s.end());
      }
    }

    if (!f) {
      cout << NO << endl;
      return;
    }
  }

  cout << YES << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}

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

const int maxn = 100005;
const int inf = 1e9;
int a[maxn], c[16], f[1<<16], ins[1<<16];
int n, x, y, z, ans, now;

int solve(int s) {
	if (!(s >> 1)) return 0;
	if (ins[s]) return inf;
	if (f[s] != -1) return f[s];
	f[s] = inf; ins[s] = 1;
	rep (i, 1, 15) if (s >> i & 1)
		rep (j, 1, 15) if (i != j)
			f[s] = min(f[s], solve(s ^ (1 << i) ^ (1 << j)
			^ (1 << (i ^ j)) | 1) + 1 + ((s >> (i ^ j)) & 1));
	ins[s] = 0;
	//printf("%d %d\n", s, f[s]);
	return f[s];
}

int main() {
	scanf("%d", &n);
	rep (i, 2, n) {
		scanf("%d%d%d", &x, &y, &z);
		a[x+1] ^= z; a[y+1] ^= z;
	}
	rep (i, 1, n) c[a[i]]++;
	rep (i, 1, 15) {
		ans += c[i] / 2;
		c[i] &= 1;
		now |= c[i] << i;
	}
	memset(f, -1, sizeof f);
	printf("%d\n", ans + solve(now | 1));
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  ll a, b; cin >> a >> b;
  if(a*2 >= b){
    cout << b/2 << endl;
  }
  else{
    ll ans = 0;
    ans += a;
    b -= a*2;
    ans += b/4;
    cout << ans << endl;
  }
  system("pause");
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

struct BIT {
  int n;
  vector<ll> tree;
  BIT(int n):n(n),tree(n+1) {} 
  void fill(ll val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, ll val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  // sum[0, idx]
  ll range(int idx) {
    ll sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
  // sum[a, b]
  ll range(int a, int b) {
    return range(b) - range(a - 1);
  }
};

const int SIZE = 212345;
BIT bit0(SIZE);
BIT bit1(SIZE);
// 範囲add : [l, r] それぞれに x を加える
void add(int l, int r, ll x) {
  bit0.add(l, -x*(l-1));
  bit1.add(l, x);
  bit0.add(r+1, x*r);
  bit1.add(r+1, -x);
}
// sum[0, i]
ll get(int i) {
  return bit1.range(i) * i + bit0.range(i);
}

const int MAX_N = 112345;
int a[MAX_N];

int main2() {
  bit0.fill(0);
  bit1.fill(0);

  int N = nextInt();
  int M = nextInt(); 
  REP(i, N) a[i] = nextInt() -1;

  ll ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    const int L = (a[i] <= a[i+1] ? a[i+1] - a[i] : a[i+1] - a[i] + M);
    ans += L;
    if (L >= 2) {
      if (a[i] < a[i+1]) {
        add(a[i]+2, a[i+1], 1); add(a[i+1]+1, a[i+1]+1, -(L-1));
      } else {
        if (a[i]+2 <= M-1) {
          add(a[i]+2, M-1, 1);
          add(M, M, -(M-a[i]-2));
          add(0, 0, M-a[i]-2);
          add(0, a[i+1], 1);
          add(a[i+1]+1, a[i+1]+1, -(L-1));
        } else {
          add(a[i]+2-M, a[i+1], 1);
          add(a[i+1]+1, a[i+1]+1, -(L-1));
        }
      }
      // for (int x = 0; x <= M; x++) cout << get(x) << " "; cout << endl;
    }
  }
  ll ma = 0;
  for (int x = 0; x <= M; x++) {chmax(ma, get(x));}
  ans -= ma;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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



int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n, m;
    while (scanf("%d%d", &n, &m) == 2) {
        vector<vector<int> > e(n);
        for (int i = 0; i < m; i++) {
            int u, v;
            scanf("%d%d", &u, &v);
            u--; v--;
            e[u].push_back(v);
            e[v].push_back(u);
        }

        vector<int> c(n, -1);
        int bipart;
        vector<int> cnt(2);
        int cedges = 0;
        function<void(int, int)> dfs = [&](int v, int cc) {
            if (c[v] != -1) {
                if (c[v] != cc) bipart = 0;
                return;
            }
            cnt[cc]++;
            c[v] = cc;
            for (int to : e[v]) {
                dfs(to, cc ^ 1);
                cedges++;
            }
        };
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] != -1) continue;
            bipart = 1;
            cnt[0] = cnt[1] = 0;
            dfs(i, 0);
            assert(cedges % 2 == 0);
            cedges /= 2;

            ll all = bipart ? (1LL * cnt[0] * cnt[1]) : (1LL * (cnt[0] + cnt[1]) * (cnt[0] + cnt[1] - 1) / 2);
            ans += all - cedges;
        }
        cout << ans << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 7040
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    

main = do
    n <- readInt
    print $  ((n - 1) + 1) * (n - 1) `div` 2


Measured memory_bytes: 380
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
adj = [[] for _ in range(N)]
degrees = [0 for _ in range(N)]
edges = {}
for i in range(N - 1):
    a, b = map(int, input().split()) 
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)
    degrees[a] += 1
    degrees[b] += 1
    edges[(a, b)] = i

max_degree = max(degrees)
print(max_degree)

edge_colors = [-1 for _ in range(N - 1)]
visited = [False for _ in range(N)]

def dfs(v, color):
    global max_degree
    if visited[v]:
        return
    visited[v] = True

    next_color = color + 1
    next_color %= max_degree
    for u in adj[v]:
        if visited[u]:
            continue
        if u < v:
            edge_colors[edges[(u, v)]] = next_color
        else:
            edge_colors[edges[(v, u)]] = next_color

        dfs(u, next_color)
        next_color += 1
        # if color == next_color:
        next_color %= max_degree

dfs(0, -1)
for i in range(N - 1):
    print(edge_colors[i] + 1)

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

using namespace std;

int main() {
  int64_t A, B, K;
  cin >> A >> B >> K;
  int64_t eat_A = min(A, K);
  A -= eat_A;
  K -= eat_A;
  int64_t eat_B = min(B, K);
  B -= eat_B;
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e5 + 5)
#define mod (int) (1e9 + 7)

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

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

    int a,b,c;
    cin >> a >> b >> c;
    int k,ck=0;
    cin >> k;
    
    while(a >= b)
    {
        b *= 2;
        ck++;
    }

    while(b >= c)
    {
        c *= 2;
        ck++;
    }

    if (ck <= k)
    {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}







Measured memory_bytes: 3648
#include<cstdio>
#include<string>
#include<cstring>

using namespace std;

int h,w;
char tu[105][105];

int main()
{
	scanf("%d %d",&h,&w);
	for(int i = 1;i <= h;i++){
		scanf("%s",&tu[i]);
	}
		/*for(int j = 1;j <= w;j++){
			scanf(" %c",&tu[i][j]);
		}
	}*/
	for(int i = 1;i <= h;i++){
		printf("%s\n%s\n",tu[i],tu[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int abcd;
    cin >> abcd;
    vector<int> x(4);
    rep(i,4){
        x[3-i]=abcd%10;
        abcd/=10;
    }
    if(x[0]+x[1]+x[2]+x[3]==7) printf("%d+%d+%d+%d=7\n",x[0],x[1],x[2],x[3]);
    else if(x[0]+x[1]+x[2]-x[3]==7) printf("%d+%d+%d-%d=7\n",x[0],x[1],x[2],x[3]);
    else if(x[0]+x[1]-x[2]+x[3]==7) printf("%d+%d-%d+%d=7\n",x[0],x[1],x[2],x[3]);
    else if(x[0]+x[1]-x[2]-x[3]==7) printf("%d+%d-%d-%d=7\n",x[0],x[1],x[2],x[3]);
    else if(x[0]-x[1]+x[2]+x[3]==7) printf("%d-%d+%d+%d=7\n",x[0],x[1],x[2],x[3]);
    else if(x[0]-x[1]+x[2]-x[3]==7) printf("%d-%d+%d-%d=7\n",x[0],x[1],x[2],x[3]);
    else if(x[0]-x[1]-x[2]+x[3]==7) printf("%d-%d-%d+%d=7\n",x[0],x[1],x[2],x[3]);
    else if(x[0]-x[1]-x[2]-x[3]==7) printf("%d-%d-%d-%d=7\n",x[0],x[1],x[2],x[3]);
    return 0;
}



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

inf = float("inf")
dp = [inf]*(n)
dp[0] = 0
dp[1] = abs(L[1] -L[0])
for i in range(n-2):
    dp[i+2] = min(dp[i+1] + abs(L[i+2] -L[i+1]) , dp[i] + abs(L[i+2] - L[i]))
    #print(dp)
print(dp[n-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
#define N 333333
#define rev(a) reverse(a+1,a+n+1)

int n,m;
long long t[N],s[N],l[N],r[N],f[N],g[N],h[N],q[N];

double slope(int i,int j){
	return 1.0*(g[i]-g[j])/(i-j);
}

void pop(int i){
	while (m>1&&slope(q[m],q[m-1])<i) m--;
}

void push(int i){
	while (m>1&&slope(i,q[m])>slope(q[m],q[m-1])) m--;
	q[++m]=i;
}

void calc(long long f[]){
	for (int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	q[m=1]=0;
	for (int i=1;i<=n;i++){
		pop(i);
		f[i]=max(f[i-1],g[q[m]]-1ll*i*q[m]+1ll*i*(i+1)/2-s[i]);
		g[i]=f[i]+1ll*i*(i-1)/2+s[i];
		push(i);
	}
}

void solve(int x,int y){
	if (x==0&&y==n) for (int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	if (x==y) return;
	int mid=(x+y)/2;m=0;
	for (int i=x;i<=mid;i++){
		g[i]=l[i]+1ll*i*(i-1)/2+s[i];
		push(i);
	}
	for (int i=mid+1;i<=y;i++){
		pop(i);
		h[i]=g[q[m]]-1ll*i*q[m]+1ll*i*(i+1)/2-s[i]+r[i+1];
	}
	for (int i=y-1;i>mid;i--) h[i]=max(h[i],h[i+1]);
	for (int i=mid+1;i<=y;i++) f[i]=max(f[i],h[i]);
	solve(x,mid);solve(mid+1,y);
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++) t[i]=read(),f[i]=-1e18;
	calc(l);rev(t);calc(r);rev(t);rev(r);
	solve(0,n);rev(t);rev(f);rev(l);rev(r);swap(l,r);
	solve(0,n);rev(t);rev(f);rev(l);rev(r);swap(l,r);
	for (int m=read();m;m--){
		int p=read(),x=read();
		printf("%lld\n",max(l[p-1]+r[p+1],t[p]+f[p]-x));
	}
	return 0;
}

Measured memory_bytes: 21120
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 1;
        int max = sc.nextInt();
 
        for (int i = 1; i < n; i++) {
            int h = sc.nextInt();
            if (h >= max) {
                ans++;
                max = h;
            }
        }
 
        System.out.println(ans);
 
    }
}


Measured memory_bytes: 35764
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
typedef long long ll;
typedef long double ld;
using namespace std;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

const ll inf = 1e18;
const int N = 333;
ll dist[N][N];
ll d2[N][N];
int n, m, L, q;

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

  cin >> n >> m >> L;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dist[i][j] = inf;
      d2[i][j] = inf;
    }
  }
  for (int i = 1; i <= n; i++) {
    dist[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    dist[a][b] = min(dist[a][b], (ll) c);
    dist[b][a] = min(dist[b][a], (ll) c);
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (dist[i][j] <= L) {
        d2[i][j] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    d2[i][i] = 1;
  }

  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (d2[i][j] > d2[i][k] + d2[k][j]) {
          d2[i][j] = d2[i][k] + d2[k][j];
        }
      }
    }
  }

  cin >> q;
  while (q--) {
    int s, t;
    cin >> s >> t;
    if (d2[s][t] == inf) {
      cout << -1 << endl;
    } else {
      cout << d2[s][t] - 1 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

typedef struct _CLASS {
	string name;
	double mini;
	double maxi;
} CLASS;

int main() {
	CLASS Class[11] = {
		{"light fly"	, -1.00, 48.00},
		{"fly"			, 48.00, 51.00},
		{"bantam"		, 51.00, 54.00},
		{"feather"		, 54.00, 57.00},
		{"light"		, 57.00, 60.00},
		{"light welter"	, 60.00, 64.00},
		{"welter"		, 64.00, 69.00},
		{"light middle"	, 69.00, 75.00},
		{"middle"		, 75.00, 81.00},
		{"light heavy"	, 81.00, 91.00},
		{"heavy"		, 91.00, 1000000.00},
	};
	double w;
	while (cin >> w) {
		for (int i = 0; i < 11; i++) {
			if (Class[i].mini < w && w <= Class[i].maxi) {
				cout << Class[i].name << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_H = 12;
const int MAX_W = 1005;
char s[MAX_H][MAX_W];
int cnt1[MAX_H][MAX_W];
int tempcnt[MAX_H];

int main()
{
	int H,W,K;
	cin >> H >> W >> K;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> s[i][j];
		}
	}
	/*
	rep(j,W)
	{
		if (s[0][j] == '1') cnt1[0][j] = 1;
		else cnt1[0][j] = 0;
	}
	*/
	for(int i = 1; i <= H; ++i)
	{
		rep(j,W)
		{
			if (s[i-1][j] == '1') cnt1[i][j] = cnt1[i-1][j] + 1;
			else cnt1[i][j] = cnt1[i-1][j];
		}
	}
	/*
	rep(i,H+1)
	{
		rep(j,W)
		{
			cout << cnt1[i][j] << " ";
		}
		cout << endl;
	}
	*/
	int ans = H*W;
	rep(bits,(1<<(H-1)))
	{
		int temp = 0;
		vector<int> cut;
		cut.push_back(0);
		rep(k,H-1)
		{
			if (bits & (1 << k))
			{
				cut.push_back(k+1);
				temp++;
			}
		}
		cut.push_back(H);
		/*
		rep(i,cut.size())
		{
			cout << cut[i] << " ";
		}
		cout << " cut:";
		*/
		rep(k,MAX_H)
		{
			tempcnt[k] = 0;
		}
		rep(j,W)
		{
			rep(k,cut.size()-1)
			{
				tempcnt[k] += cnt1[cut[k+1]][j] - cnt1[cut[k]][j];
			}
			bool flag = false;
			rep(k,cut.size()-1)
			{
				if (tempcnt[k] > K) flag = true;
			}
			if (flag)
			{
				if (j == 0) temp += 1e5;
				//cout << j << " ";
				temp++;
				rep(k,cut.size()-1)
				{
					tempcnt[k] = cnt1[cut[k+1]][j] - cnt1[cut[k]][j];
					if (tempcnt[k] > K) temp += 1e5;
				}
			}
		}
		//cout << temp << endl;
		ans = min(ans,temp);
	}
	cout << ans << endl;
	return 0;
}

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

}

Measured memory_bytes: 596