akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>


using namespace std;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> a(n*3);
  for(int i = 0; i < n; i++){
    cin >> a[i*3];
    a[i*3+1]=a[i*3]+1;
    a[i*3+2]=a[i*3]-1;
  }

  sort(a.begin(), a.end());
  
  int prev = a[0];
  int cnt = 1;
  int m = 0;
  for(int i = 1; i < n*3; i++){
    if(prev == a[i]){
      cnt++;
    }else{
      m = max(m, cnt);
      cnt=1;
    }
    prev = a[i];
  }
  m = max(m,cnt);
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream> // cout, endl, cin
#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<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	bool F = false;
	for (int i = 0;i < N;i++) {
		cin >> A.at(i);
	}
	for (int i = 0;i < N;i++) {
		if (A.at(i) % 2 == 0) {
			if (A.at(i) % 3 == 0 || A.at(i) % 5 == 0) {

			}
			else{
				F = true;
			}
		}
	}
	if (F) cout << "DENIED" << endl;
	else cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc159/tasks/abc159_d

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, ll> counts, comb;
    rep(i, n)
    {
        cin >> a[i];
        if(counts.find(a[i]) == counts.end())
        {
            counts[a[i]] = 0;
        }
        counts[a[i]]++;
    }
    for(auto c : counts)
    {
        auto t = c.second >= 2 ? c.second * (c.second - 1) / 2 : 0;
        comb[c.first] = t;
    }
    ll all = 0;
    for(auto c : comb)
    {
        all += c.second;
    }

    rep(i, n)
    {
        auto num = a[i];
        auto count = counts[num] - 1;
        auto nc = count >= 2 ? count * (count - 1) / 2 : 0;
        auto ans = all - comb[num] + nc;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 19876
#include<bits/stdc++.h>
using namespace std;
long long  xorx(long long  n)
{
    long long   k = ((n%(4ll)+4)%4);
    if(k == 0ll)
        return n;
    if(k == 1ll)
        return 1ll;
    if(k == 3ll)
        return 0ll;
    if(k == 2ll)
        return (n + 1ll);
}

int  main()
{

   long long  a , b;
   cin >> a >> b;
   long long  first = xorx(a-1);
   long long  second = xorx( b);
   long long  answer = (first ^ second);
   cout << answer << "\n";



return 0;}


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

from collections import Counter

n = int(input())
a = list(map(int, input().split()))

pair = [0, 0]
c = Counter(a)
for num, cnt in c.items():
    pair += [num] * (cnt // 2)

pair.sort(reverse=True)

ans = pair[0] * pair[1]
print(ans)


Measured memory_bytes: 18600
#include<stdio.h>//bubble sort(隣接交換法)//
#include<stdlib.h>

void swap(int []);
void print(int []);

#define N 5

int main(void){
	int i,time,num[N];

	for(i = 0;i < N;i++){
		scanf("%d",&num[i]);
	}
	swap(num);
	print(num);

	return 0;
}

void swap(int num[N])
{
	int temp,i,j;
	for(i = N; i > 0; i--){
		for(j = 0; j < i-1; j++){
			if(num[j] < num[j + 1]){//a>b を b<a に交換する
				temp =num[j];
				num[j] =num[j + 1];
				num[j + 1] = temp;
			}
		}
	}
}

void print(int num[N]){	
	int i;

	for(i = 0 ;i < N; i++){
		printf("%d",num[i]);
		if(i != (N - 1))/*最後の数字の後にスペースを入れないようにする*/
			printf(" ");
	}
	printf("\n");
}

Measured memory_bytes: 600
//
//  ALDS1_3_D.cpp
//  
//
//  Created by mk on 2015/12/08.
//
//

#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
    stack<int> S1;
    stack< pair<int, int> > S2;
    char ch;
    int sum = 0;
    for (int i=0; cin >> ch; i++) {
        if (ch == '\\') {
            S1.push(i);
        }else if(ch == '/' && S1.size() > 0){
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while (S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    
    vector<int> ans;
    int t = 0;
    while (S2.size() > 0) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
        cout << " ";
        t += ans[i];
        cout << ans[i];
    }
    cout << endl;
    
    return 0;
    
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, R; cin >> N >> R;
	if (N >= 10)cout << R << "\n";
	else cout << R + 100 * (10 - N) << "\n";

	return 0;
}

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

int main(){
int n,d2,d4,a;
d2=d4=0;

cin>>n;

for(int i=0;i<n;i++){
cin>>a;
if(a%2!=0)
d2++;
if(a%4==0)
d4++;
}

if(d2+d4==n){
if(d2<=d4+1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

else {
if(d4>=d2) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}


Measured memory_bytes: 384
<?php
list($N, $Y) = array_map('intval', explode(' ', fgets(STDIN)));
for ($x = $N; $x >= 0; $x--) {
    for ($y = $N - $x; $y >= 0; $y--) {
        $z = $N - $x - $y;
        if (10000 * $x + 5000 * $y + 1000 * $z === $Y) {
            print "{$x} {$y} {$z}\n";
            exit;
        }
    }
}
print "-1 -1 -1\n";

Measured memory_bytes: 4728
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        int[] a = new int[n];
        for(int i = 0; i < n; ++i){
            a[i] = sc.nextInt();
            sum += a[i];
        }
        int m = sc.nextInt();
        for(int i = 0; i < m; ++i){
            int p = sc.nextInt();
            int t = sc.nextInt();
            --p;
            int ans = sum - a[p] + t;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21204
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	string s;
	cin >> s;
	string str;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) str += s.at(i);
	}
	cout << str << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <cstring>
using namespace std;

int n, m, cnt;
int pos[20], tmpPos[20];

void copyPos(int *fromPos, int *toPos){
  for(int i = 0; i < 20; i++){
    toPos[i] = fromPos[i];
  }
}

void toC(int x);

void toA(int x){
  if(pos[x] == 0){
    return;
  }

  if(pos[x] == 2){
    //xより大きいコップを全てAに移す
    for(int i = x + 1; i < n; i++){
      toA(i);
      if(cnt > m) return;
    }

    //Bにコップxを移す
    cnt++;
    if(cnt > m) return;

    pos[x] = 1;
  }

  if(pos[x] == 1){
    //xより大きいコップを全てCに移す
    for(int i = x + 1; i < n; i++){
      toC(i);
      if(cnt > m) return;
    }

    //Aにコップxを移す
    cnt++;
    if(cnt > m) return;

    pos[x] = 0;
  }
}

void toC(int x){
  if(pos[x] == 2){
    return;
  }

  if(pos[x] == 0){
    //xより大きいコップを全てCに移す
    for(int i = x + 1; i < n; i++){
      toC(i);
      if(cnt > m) return;
    }

    //Bにコップxを移す
    cnt++;
    if(cnt > m) return;

    pos[x] = 1;
  }

  if(pos[x] == 1){
    //xより大きいコップを全てAに移す
    for(int i = x + 1; i < n; i++){
      toA(i);
      if(cnt > m) return;
    }

    //Cにコップxを移す
    cnt++;
    if(cnt > m) return;

    pos[x] = 2;
  }
}

void solve(){
  int res = m + 1;

  copyPos(pos, tmpPos);
  cnt = 0;

  for(int i = 0; i < n; i++){
    toA(i);
    if(cnt > m) break;
  }

  res = min(res, cnt);
  copyPos(tmpPos, pos);
  cnt = 0;

  for(int i = 0; i < n; i++){
    toC(i);
    if(cnt > m) break;
  }

  res = min(res, cnt);

  cout << (res == m + 1 ? -1 : res) << endl;
}

int main(){
  while(cin >> n >> m, n || m){
    for(int i = 0; i < 3; i++){
      int a;
      cin >> a;

      for(int j = 0; j < a; j++){
        int x;
        cin >> x;
        x--;
        pos[x] = i;
      }
    }

    solve();
  }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
#include <deque>
#include <vector>
using namespace std;


int a[(int)1e5 + 2];
int c, c1;

main()
{
	int n;
	
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] % 4 == 0)
			c++;
		if (a[i] % 2 != 0)
			c1++;
	}
	
	if (c1 <= c)
	{
		puts("Yes");
		return 0;
	}
	if (c + c1 == n && c1 <= c + 1)
	{
		puts("Yes");
		return 0;
	}
	puts("No");
}


Measured memory_bytes: 512
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
S = input()
ln = len(S)-1
i = 0
j = ln
ans = 0
while i < j:
    if S[i] == S[j]:
        i += 1;
        j -= 1;
    elif S[i] == 'x':
        ans += 1
        i += 1
    elif S[j] == 'x':
        ans += 1
        j -= 1
    else:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 10404
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
bool isprime(int x)
{
	for(int i=2;i*i<=x;i++) if(x%i==0) return 0;
	return 1;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int x;
 	cin >> x;
 	while(!isprime(x)) x++;
 	cout << x;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<std::pair<int, int>> segments(n);
	for (auto& p : segments) std::cin >> p.first >> p.second;
	std::sort(segments.begin(), segments.end(), [](const std::pair<int, int> a, const std::pair<int, int> b) {return a.first == b.first ? a.second < b.second : a.first < b.first; });
	const int min_right = std::min_element(segments.begin(), segments.end(), [](const std::pair<int, int> a, const std::pair<int, int> b) {return a.second < b.second; })->second;
	const int max_left = std::max_element(segments.begin(), segments.end(), [](const std::pair<int, int> a, const std::pair<int, int> b) { return a.first < b.first; })->first;
	std::vector<int> right_min; std::transform(std::next(segments.begin()), segments.end(), std::back_inserter(right_min), [](const std::pair<int, int> a) {return a.second; });
	for (auto i = 2; i <= right_min.size(); ++i) right_min[right_min.size() - i] = std::min(right_min[right_min.size() - i], right_min[right_min.size() - i + 1]);
	const auto max_segment = std::max_element(segments.begin(), segments.end(), [](const std::pair<int, int> a, const std::pair<int, int> b) {return a.second - a.first < b.second - b.first; });
	long long int max_score = max_segment->second - max_segment->first + 1 + std::max(min_right - max_left + 1, 0);
	for (auto i = 0; i + 1 < n; ++i) {
		long long int score = std::max(min_right - segments[i].first + 1, 0) + std::max(right_min[i] - max_left + 1, 0);
		max_score = std::max(max_score, score);
	}
	std::cout << max_score << '\n';
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	1<=a,b,c<=9;
	cout<<max(a,max(b,c))*10+a+b+c-max(a,max(b,c))-min(a,min(b,c))+min(a,min(b,c));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main()
{
    int N, L;
    cin >> N >> L;
    vector<string> v;
    string ret;

    string s;
    for(int i=0; i<N; i++){
        cin >> s;
        v.push_back(s);
    }

    sort(v.begin(), v.end(), less<string>() );
    for(vector<string>::iterator it = v.begin(); it != v.end(); it++){
        ret += *it;
    }
    cout << ret << endl;                                                                

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


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

    for (int i = 1; i <= b; i++)
    {
	if ((a * i) % b == c)
	{
	    printf("YES\n");

	    return 0;
	}
    }
    printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<limits>

#define ll long long int

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

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

int main(){
    ll N;
    std::cin >> N;
    ll t[N];
    for(int i=0;i<N;i++)
        std::cin >> t[i];
   
    ll ans = t[0];
    ll x;

    for(int i=1;i<N;i++){
        x = t[i];
        ans = lcm(ans, x);
    }

    std::cout << ans << std::endl;

    return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int H, A;
  std::cin >> H >> A;

  int ans = H / A + (H % A > 0 ? 1 : 0);
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');
var operands = stdin.trim().split(' ');
var stack =[];
operands.forEach(function(operand) {
  if (operand === '+') {
    stack.push(parseInt(stack.pop(), 10) + parseInt(stack.pop(), 10));
  } else if (operand === '-') {
    var n2 = parseInt(stack.pop(), 10);
    var n1 = parseInt(stack.pop(), 10);
    stack.push(n1 - n2);
  } else if (operand === '*') {
    stack.push(parseInt(stack.pop(), 10) * parseInt(stack.pop(), 10));
  } else {
    stack.push(parseInt(operand, 10));
  }
});
console.log(stack[0]);

Measured memory_bytes: 15800
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int n,m,a,b;
    in(n,m);
    vector<tuple<int,int,int>> vec(m);
    vector<pair<int,int>> ans(m);
    rep(i,m){
        in(a,b);
        vec[i]=make_tuple(a,b,i);
    }
    sort(all(vec));
    int rank=0,index;
    rep(i,m){
        if(i==0||get<0>(vec[i])!=get<0>(vec[i-1])){
            rank=1;
            index=get<2>(vec[i]);
            ans[index]=make_pair(get<0>(vec[i]),rank);
        }else{
            rank++;
            index=get<2>(vec[i]);
            ans[index]=make_pair(get<0>(vec[i]),rank);
        }
    }
    rep(i,m){
        printf("%06d%06d\n",ans[i].first,ans[i].second);
    }
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[200][200];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>h>>w;
    rep(i,h)rep(j,w)cin>>s[i][j];
    rep(i,h){
        string co="";
        rep(j,w){
            co+=s[i][j];
        }
        Cout(co);
        Cout(co);
    }
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,N) for (int i = 0; i < N; i++)

int N;
vector<long double> p;
long double dp[3000][3000];

int main() {
    scanf("%d", &N);
    p.resize(N);
    rep(i,N) scanf("%Lf", & p[i]);

    dp[0][0] = 1;

    rep(i,N)rep(j,N){
        dp[i+1][j] += dp[i][j] * (1-p[i]);
        dp[i+1][j+1] += dp[i][j] * p[i];
    }

    long double ans = 0;
    for (int j = N; 2*j >= N; j--) ans += dp[N][j];
    printf("%.9Lf\n", ans);
    return 0;
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;


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

  int n; cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  map<int, int> mp_e, mp_o;
  rep(i, n) {
    if (i % 2 == 0) mp_e[v[i]]++;
    else mp_o[v[i]]++;
  }

  vector<pair<int, int>> ve, vo;
  for (auto& p : mp_e) ve.emplace_back(p.second, p.first);
  for (auto& p : mp_o) vo.emplace_back(p.second, p.first);

  sort(ALL(ve));
  reverse(ALL(ve));
  sort(ALL(vo));
  reverse(ALL(vo));

  ll ans = 0;
  if (ve[0].second != vo[0].second) {
    ans = n - ve[0].first - vo[0].first;
  } else {
    if (ve.size() == 1 && vo.size() == 1) {
      ans = n - ve[0].first;
    } else if (ve.size() == 1) {
      ans = n - ve[0].first - vo[1].first;
    } else if (vo.size() == 1) {
      ans = n - ve[1].first - vo[0].first;
    } else {
      ans = n - ve[0].first - vo[1].first;
      chmin(ans, ll(n - vo[0].first - ve[1].first));
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  string s; cin >> s;
  int K; cin >> K;
  vector<string> vec;
  int N = s.size();
  for(int i = 1; i <= 5; i++){
    for(int j = 0; j + i <= N; j++){
      vec.push_back(s.substr(j, i));
    }
  }
  sort(vec.begin(), vec.end());
  int counter = 1;
  if(K == 1){
    cout << vec[0] << endl;
    return 0;
  }
  for(int i = 0; i < vec.size(); i++){
    if(vec[i] != vec[i + 1]) counter++;
    if(counter == K){
      cout << vec[i + 1] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> value(n);
  vector<int> cost(n);
  for(int i=0 ; i<n ; i++){
    cin >> value.at(i);
  }
   for(int i=0 ; i<n ; i++){
    cin >> cost.at(i);
  }
  
  
  
  int max=0;
  for(int i=0 ;i<n;i++){
    if(value.at(i)>cost.at(i)){
      max += value.at(i)-cost.at(i);
    }
  }
  cout << max << endl;
}
      

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

int main(){
    string S;
    cin >> S;
    if (S.size() >= 4 && S.substr(0, 4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
k=int(input())

# mod k で考える
mod=k
flag=True
for i in range(1,10**6+1):
    if i<=7:
        if mod > 7 * int(str(1) * i):
            continue
        else:
            pass
    if mod == k:
        mod = 7 * int(str(1) * i) % mod
        if mod == 0:
            print(i)
            exit()
    else:
        mod = (mod * 10 + 7) % k
        if mod == 0:
            print(i)
            exit()

print(-1)

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
	int n;
	int cnt[205] = {};
	int a[205];
	cin >> n;
	rep(i, n){
		cin >> a[i];
		while(a[i] % 2 == 0){
			a[i] /= 2;
			cnt[i]++;
		}
	}
	qsort(cnt, n, sizeof(int), asc);
	cout << cnt[0] << endl;
	
}

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

using namespace std;

typedef long long int ll;

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

  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector < string > s(n);
  for (int i = 0; i < n; i++) cin >> s[i];

  vector < char > ans;

    for (int i = 0; i < n; i++) {
      if (s[i] == "AB") {
        if (i != n - 1 && a == 1 && b == 1 && c == 0) {
          if (s[i + 1] == "BC") {
            ans.push_back('B');
            b++;
            a--;
          } else {
            ans.push_back('A');
            a++;
            b--;
          }
        } else if (b < a) {
          ans.push_back('B');

          b++;
          a--;
        } else {
          ans.push_back('A');
          a++;
          b--;
        }
      } else if (s[i] == "BC") {
        if (i != n - 1 && b == 1 && c == 1 && a == 0) {
          if (s[i + 1] == "AB") {
            ans.push_back('B');
            b++;
            c--;
          } else {
            ans.push_back('C');
            c++;
            b--;
          }
        } else if (c < b) {
          ans.push_back('C');
          c++;
          b--;
        } else {
          ans.push_back('B');
          b++;
          c--;
        }
      } else {
        if (i != n - 1 && a == 1 && c == 1 && b == 0) {
          if (s[i + 1] == "BC") {
            ans.push_back('C');
            c++;
            a--;
          } else {
            ans.push_back('A');
            a++;
            c--;
          }
        } else if (a < c) {
          ans.push_back('A');
          a++;
          c--;
        } else {
          ans.push_back('C');
          c++;
          a--;
        }
      }

      if (a < 0 || b < 0 || c < 0) {
        cout << "No\n";
        return 0;
      }
    }

    cout << "Yes\n";
    for(auto i : ans) cout << i << '\n';

}


Measured memory_bytes: 6700
n=int(input())
ans=[0]*100
if n>81:
  print('No')
else:
  for i in range(1,10):
    for j in range(i,10):
      ans[(i-1)*10+(j-1)]=i*j
  if ans.count(n)==0:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 3060
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
Luca = [2, 1]
for i in range(2, N + 1):
    Luca.append(Luca[i-1] + Luca[i-2])
print(Luca[N])


Measured memory_bytes: 9100
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

char S[MAX_N], T[MAX_N];
int sum1[MAX_N], sum2[MAX_N];
  
int main() {
  scanf("%s%s", S + 1, T + 1);
  int l1 = strlen(S + 1), l2 = strlen(T + 1);
  for (int i = 1; i <= l1; ++i)
    sum1[i] = (sum1[i - 1] + (S[i] == 'A' ? 1 : 2));
  for (int i = 1; i <= l2; ++i)
    sum2[i] = (sum2[i - 1] + (T[i] == 'A' ? 1 : 2));
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if ((sum1[b] - sum1[a - 1] + 3) % 3 == (sum2[d] - sum2[c - 1] + 3) % 3)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}


Measured memory_bytes: 1408
N=int(input())
A=input()
B=input()
C=input()
retval=0
for a,b,c in zip(A,B,C):
    if a==b and b==c:
        continue
    elif a==b or b==c or c==a:
        retval+=1
    else:
        retval+=2

print(retval)


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

int asc(const void *a, const void *b){
    long *A = (long *)a;
    long *B = (long *)b;

    if(*A > *B)
        return 1;
    if(*A < *B)
        return -1;
    return 0;
}

int main(){
    int N, K, i;
    long int h[100000], x, min=1000000000;

    scanf("%d %d", &N, &K);

    for(i=0; i<N; i++){
        scanf("%ld", &h[i]);
    }

    qsort(h, N, sizeof(long int), asc);

    for(i=0; i<N-K+1; i++){
        x = h[i+K-1] - h[i];
        if(min > x)
            min = x;
    }

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

    return 0;
}

Measured memory_bytes: 1788
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=100010;
int n,A[maxn],f[maxn],first[maxn],nxt[maxn<<1],to[maxn<<1],e;
int deg[maxn],ans;
void AddEdge(int u,int v) {
	deg[u]++;deg[v]++;
	to[++e]=v;nxt[e]=first[u];first[u]=e;
	to[++e]=u;nxt[e]=first[v];first[v]=e;
}
void dfs(int x,int fa) {
	f[x]=deg[x]==1?A[x]:2*A[x];
	for(int i=first[x];i;i=nxt[i]) if(to[i]!=fa) {
		dfs(to[i],x);
		f[x]-=f[to[i]];
		if(f[to[i]]>A[x]) ans=0;
	}
	if(f[x]<0||f[x]>A[x]) ans=0;
}
int main() {
	n=read();
	rep(i,1,n) A[i]=read();
	rep(i,2,n) AddEdge(read(),read());
	ans=1;dfs(1,0);
	if(f[1]) ans=0;
	puts(ans?"YES":"NO");
	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int ans;
  cin >> n;
  for(int i=0;i*i<=n;i++){
      ans = i*i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;


int main(){
	ll a,b,c;ll r=0;
	scanf("%lld%lld%lld",&a,&b,&c);
	ll t=min(b,c);
	r+=2*t;
	b-=t;c-=t;
	t=min(a,c);
	r+=t;
	a-=t;c-=t;
	r+=b;
	if(c)r++;
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
if n <= a:
    print(n)
elif a < n and n <= a+b:
    print(a)
else:
    s,v = divmod(n,a+b)
    if v <= a:
        print(s*a+v)
    else:
        print(s*a+a)
        


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
	string s;
	int ans = 0;

	cin >> s;

	rep(i, 3) if (s[i] == '1') ans++;

	cout << ans << endl;
	return (0);
}


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool flag = false; //true = 高橋勝ち
    while (true) {
        c -= b;
        if (c <= 0) {
            flag = true;
            break;
        }
        a -= d;
        if (a <= 0) break;
    }
    if (flag) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


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

long long gcd(long long x,long long y){
    if(x<y){
      long long t=x;
      x=y;
      y=t;
    }  
    while(y>0){
      long long r=x%y;
      x=y;
      y=r;
    }
    return x;
}

int main(){
    long long a,b;cin>>a>>b;
    long long c,d;cin>>c>>d;

    long long gcm=(c*d)/gcd(c,d);
   long long anti=(b-b/c-b/d+b/gcm)-((a-1)-(a-1)/c-(a-1)/d+(a-1)/gcm);
  cout<<anti<<endl;
}

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

int H, W;
vector<vector<int> > field;

void dfs(int y, int x) {
	field[y][x] = 0;

	for (int dy = -1; dy <= 1; dy++) {
		for (int dx = -1; dx <= 1; dx++) {
			int ny = y + dy;
			int nx = x + dx;

			if (ny < 0 || H <= ny) continue;
			if (nx < 0 || W <= nx) continue;
			if (field[ny][nx] == 0) continue;

			dfs(ny, nx);
		}
	}
}

int main(void) {

	while (cin >> W >> H) {
		if (H == 0 || W == 0) break;

		// フィールド入力
		field.assign(H, vector<int>(W, 0));
		for (int y = 0; y < H; y++) for (int x = 0; x < W; x++) cin >> field[y][x];

		// 探索
		int count = 0;
		for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				if (field[y][x] == 0) continue;
				dfs(y, x);
				count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;


int l = 1299710;

vi is_prime(l,1);
vi p;

void set_prime(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i < l; i++){
		if(is_prime[i]){
			p.pb(i);
			for(int j = i + i; j < l; j += i) is_prime[j] = 0;
		}
	}
}


int main(){
	set_prime();
	int n;
	while(cin>>n){
		if(n == 0) break;
		if(is_prime[n]){
			cout<<0<<endl;
			continue;
		}
		vi::iterator s, e;
		s=e=upper_bound(all(p),n);
		s--;
		cout<<*e-*s<<endl;
	}

}

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

int a[10];
int k;

// claudio van
int main() {
  for (int i = 0; i < 5; ++i) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &k);
  bool ok = 1;
  for (int i = 0; i < 5; ++i) {
    for (int j = 0; j < 5; ++j) {
      if (abs(a[i] - a[j]) > k) {
        ok = 0;
      }
    }
  }
  printf(ok? "Yay!" : ":(");
  printf("\n");
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  for(int i = 0;i < N; ++i) {
    int l,r;
    cin >> l >> r;
    count += r - l + 1;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
  lli n,k,s,i;
  cin>>n>>k>>s;
  for(i=1;i<=k;i++)
    cout<<s<<" ";
  for(i=1;i<=(n-k);i++)
  {
    if(s==1000000000)
    	cout<<1<<" ";
    else
      cout<<1000000000<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;


int main(){
    ll n,m;
    cin >> n >> m;
    set<ll> check;
    map<ll, map<ll, ll>> branch;
    ll l, r, d;
    rep(i,m){
        cin >> l >> r >> d;
        l--;
        r--;
        check.insert(l);
        check.insert(r);
        branch[l][r] = d;
        branch[r][l] = -d;
    }
    vll dist(n, infl);
    while (!(check.empty())){
        ll start = *check.begin();
        check.erase(start);
        if (dist[start]!=infl)
            continue;
        dist[start] = 0;
        set<ll> c;
        c.insert(start);
        while (!(c.empty())){
            ll now = *c.begin();
            c.erase(now);
            for (auto p:branch[now]){
                if (dist[p.F]==infl){
                    dist[p.F] = dist[now] + p.S;
                    c.insert(p.F);
                }
                else if (dist[p.F] != dist[now]+p.S){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    ll MIN = infl,MAX=-infl;
    rep(i,n){
        if (dist[i]!=infl){
        MIN = min(dist[i], MIN);
        MAX = max(dist[i], MAX);
    }}
    if (MAX-MIN<=1e9){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 44800
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	string s;
	while(cin>>s){
		int n[10][10]={};
		rep(i,0,10){
			n[0][i]=s[i]-'0';
		}
		rep(i,0,9){
			rep(j,0,9-i) n[i+1][j]=(n[i][j+1]+n[i][j])%10;
		}
		o(n[9][0]);
	}
}

Measured memory_bytes: 1184
D,N=list(map(int,input().split()))
if D==0:
    if N==100:
        print(101)
        exit()
    print(N)
elif D==1:
    if N==100:
        print(100*101)
        exit()
    print(100*N)
else:
    if N==100:
        print(100*100*101)
        exit()
    print(100*100*N)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;


int w, h;

int yoko[40][40];
int tate[40][40];
int visited[40][40];

int main()
{
	while (cin >> w >> h) {
		if (w == 0 && h == 0)return 0;

		int a;

	
		for (int i = 0; i < 40; i++) {
			for (int j = 0; j < 40; j++) {
				tate[i][j] = 1;
				yoko[i][j] = 1;
				visited[i][j] = 0;
			}
		}
		
		

		for (int i = 1; i < 2 * h; i++) {
			if (i % 2 == 1) {
				for (int j = 1; j <= w - 1; j++) {
					cin >> a;
					yoko[i / 2][j] = a;
				}
			}
			else {
				for (int j = 0; j < w; j++) {
					cin >> a;
					tate[i / 2][j] = a;
				}
			}
		}

		/*
		for (int i = 0; i <= h; i++) {
			for (int j = 0; j < w; j++) {
				cout << tate[i][j] << " ";
			}
			cout << endl;
		}
		cout << endl;
		for (int i = 0; i <= h; i++) {
			for (int j = 0; j <= w; j++) {
				cout << yoko[i][j] << " ";
			}
			cout << endl;
		}
		*/
		visited[1][1] = 1;

		queue<P>q;
		q.push(P(1, 1));

		while (!q.empty()) {
			P p = q.front();
			q.pop();

			int x = p.first;
			int y = p.second;

			//cout << x << " " << y << " " << visited[x][y] << endl;
			if (yoko[x-1][y-1]==0&&visited[x][y-1]==0) {
				q.push(P(x, y - 1));
				visited[x][y - 1] = visited[x][y] + 1;
			}
			if (yoko[x-1][y] == 0 && visited[x][y+1] == 0) {
				q.push(P(x, y + 1));
				visited[x][y + 1] = visited[x][y] + 1;
			}
			if (tate[x-1][y-1] == 0 && visited[x - 1][y] == 0) {
				q.push(P(x-1, y));
				visited[x-1][y] = visited[x][y] + 1;
			}
			if (tate[x][y-1] == 0 && visited[x + 1][y] == 0) {
				q.push(P(x + 1, y));
				visited[x + 1][y] = visited[x][y] + 1;
			}


			

		}



		cout << visited[h][w] << endl;

	}


	return 0;
}



Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        // 主処理
        int add = a + b;
        int diff = a - b;
        int mult = a * b;
        int result = Math.max(Math.max(add, diff), mult);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n, m, p, q, r;
		while ((n = in.nextInt()) > 0) {
			m = in.nextInt();
			p = in.nextInt() - 1;
			q = in.nextInt();
			r = in.nextInt();
			Deque<Integer> allDeque = getNewDeque();
			allDeque.add(Integer.valueOf(r));
			allDeque.add(Integer.valueOf(n - r));
			Deque<Integer> a = getNewDeque();
			Deque<Integer> c = getNewDeque();
			boolean top = true;
			boolean bottom = false;
			for (int i = 0; i < m; i++) {
				boolean atop = top, abottm, ctop, cbottom = bottom;
				int asize = in.nextInt();
				a.clear();
				while (asize >= allDeque.peekFirst().intValue()) {
					top = !top;
					final Integer first = allDeque.removeFirst();
					a.addLast(first);
					asize -= first.intValue();
				}
				if (asize != 0) {
					a.addLast(Integer.valueOf(asize));
					final Integer first = allDeque.removeFirst();
					allDeque.addFirst(Integer.valueOf(first - asize));
				}
				abottm = (a.size() % 2 == 1) ? atop : !atop;
				int csize = n - in.nextInt();
				c.clear();
				while (csize >= allDeque.peekLast().intValue()) {
					bottom = !bottom;
					final Integer last = allDeque.removeLast();
					c.addFirst(last);
					csize -= last.intValue();
				}
				if (csize != 0) {
					c.addFirst(Integer.valueOf(csize));
					final Integer last = allDeque.removeLast();
					allDeque.addLast(Integer.valueOf(last - csize));
				}
				ctop = (c.size() % 2 == 1) ? cbottom : !cbottom;
				if (atop == bottom) {
					int afirst = a.removeFirst().intValue();
					allDeque.addLast(Integer.valueOf(afirst
							+ allDeque.removeLast().intValue()));
				}
				if (cbottom == top) {
					int clast = c.removeLast().intValue();
					allDeque.addFirst(Integer.valueOf(clast
							+ allDeque.removeFirst().intValue()));
				}
				Deque<Integer> b = allDeque;
				allDeque = c;
				c = b;
				allDeque.addAll(b);
				allDeque.addAll(a);
				top = ctop;
				bottom = abottm;
			}
			while (p >= allDeque.peekFirst().intValue()) {
				final int val = allDeque.removeFirst().intValue();
				q -= val;
				p -= val;
				top = !top;
			}
			int count = (top) ? -p : 0;
			while (q >= allDeque.peekFirst().intValue()) {
				final int intValue = allDeque.removeFirst().intValue();
				q -= intValue;
				if (top)
					count += intValue;
				top = !top;
			}
			if (top) {
				count += q;
			}
			System.out.println(count);
		}
	}

	private static Deque<Integer> getNewDeque() {
		return new ArrayDeque<Integer>();
	}
}

Measured memory_bytes: 59848
#include <iostream>

using namespace std;

int main()
{
  long long N, K;
  long long ans = 0;
  cin >> N >> K;
  if(N % K < abs(N % K - K)){
    ans = (N % K);
  }
  else{
    ans = abs(N % K -K);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256