akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            String s = in.next();
            String t = in.next();
            String ans = t + s;

            // 出力
            out.println(ans);

        }

    }
}



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


void solve(long long N, std::string S){
  long long count = 0;
  for(long long i = 0; i < N-2; i++){
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') count++;
  }

  cout << count << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
    solve(N, S);
    return 0;
}


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

int main(){
  int card[50],tmp[50];
  int n,r,p,c;

  while(cin >> n >> r,n){
    for(int i=0;i<n;i++)card[i] = n-i;

    for(int x=0;x<r;x++){
      cin >> p >> c;

      for(int i=0;i<c;i++)tmp[i] = card[p-1+i];
      for(int i=p-2;i>=0;i--)card[i+c] = card[i];
      for(int i=0;i<c;i++)card[i] = tmp[i];
    }
    cout << card[0] << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int S=0;
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
    S+=A.at(i);
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int B;
  if (S%(4*M)==0) {
    B = S/(4*M);
  }
  else {
    B = S/(4*M) + 1;
  }
  
  int C=M;
  for (int i=0; i<N; i++) {
    if (A.at(i) < B) {
      break;
    }
    C--;
  }
  if (C>0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 3616
import time
import numpy as np

# def solve(n, m, py):
"""
n, m = map(int, input().split())
py = [list(map(int, input().split())) for _ in range(m)]
"""

n, m = map(int, input().split())
py = [list(map(int, input().split())) for _ in range(m)]
p = [[] for _ in range(n)]
start = time.time()
for _p, _y in py:
    p[_p - 1].append(_y)
# print(time.time() - start)
for i in range(n):
    p[i] = np.argsort(np.argsort(p[i]))

# print(time.time() - start)
counter = [0 for _ in range(n)]
for _p, _y in py:
    # print("{:06}{:06}".format(_p, p[_p - 1].index(_y) + 1))
    # t = "{:06}{:06}".format(_p, p[_p - 1].index(_y) + 1)
    # print(counter[_y])
    t = "{:06}{:06}".format(_p, p[_p - 1][counter[_p - 1]] + 1)
    print(t)
    counter[_p - 1] += 1

Measured memory_bytes: 56616
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
       int n = scan.nextInt();
       int[] hights = new int[n];
      for(int i=0;i<n;i++){
      	hights[i] = scan.nextInt();
      }
      int check = 0;
      int ans =1;
      for(int i=1;i<n;i++){
      	for(int j=0;j<i;j++){
        	if(hights[i] >= hights[j]){
            	check++;
            }
            if(check == i){
            	ans++;
            }
        }
        check =0;
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;

	bool flag = false;
	for (int i = 0; i < S.size(); i++) {
		int tmp = S.at(S.size() - 1);
		for (int j = S.size() - 2; j >= 0; j--)
			S.at(j + 1) = S.at(j);
		S.at(0) = tmp;
		if (S == T) {
			flag = true;
			break;
		}
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def calc(x,y,cx,cy)
  (x-cx).abs+(y-cy).abs
end
io = STDIN
n=io.gets.to_i
xyh=[]
n.times do
  xyh << io.gets.split.map(&:to_i)
end
xyh_a = xyh.select{|x,y,h|h>0}
xyh_b = xyh.select{|x,y,h|h==0}
(0..100).each do |cx|
  (0..100).each do |cy|
    ar = xyh_a.map{|x,y,h|calc(x,y,cx,cy)+h}.uniq
    if ar.size == 1 &&
       ar[0]>=1 &&
       xyh_b.all?{|x,y,h|calc(x,y,cx,cy) >= ar[0]}
      puts "#{cx} #{cy} #{ar[0]}"
      exit
    end
  end
end

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

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back



using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };



void solve() {

    int n;
    cin>>n;
    vi v(n);
    for(int i=0; i<n; i++){
        int a, b;
        cin>>a>>b;
        if(a==b) v[i]=1;
        else v[i]=0;
    }
    for(int i=0; i<n-2; i++){
        if(v[i]==v[i+1]&&v[i+2]==1&&v[i]==v[i+2]){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

        
        solve();


    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

typedef pair<int, int> pint;
typedef pair<pint, pint> ppint;

/* add vars here */

ll h,w;


/* add your algorithm here */

int main() {
  cin >> h >> w;
  int odd = 0;
  vector< vector<int> > tb(h, vector<int>(w,0));
  rep(i,h)rep(j,w) {
    cin >> tb[i][j];
    if (tb[i][j] & 1) ++odd;
  }

  vector<ppint> v;
  int num = 0;
  int x = 0, y = 0;

  for (int itr = 0; itr < h*w; ++itr) {
    if (tb[x][y] & 1) ++num;

    int nx = x, ny = y;
    if (x % 2 == 0) {
      if (ny == w-1) ++nx;
      else ++ny;
    }
    else {
      if (ny == 0) ++nx;
      else --ny;
    }
    if (num & 1) if (num < odd) v.pb(ppint(pint(x,y), pint(nx,ny)));
    x = nx, y = ny;
  }

  cout << v.size() << endl;
  for (auto p : v) {
    cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
  }
}


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


int main(){
  int n,m;
  cin >> n >> m;
  int a[m];

  for (int i=0; i<m; i++){
    cin >> a[i];
    n -= a[i];

  }
  if(n<0){cout << -1 << endl;}else{
  cout << n << endl;}

}

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

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

int main(){
	string S;
	cin >> S;
	if(S=="ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;

	return 0;
}

Measured memory_bytes: 3592
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    s = input()
    if s == 'AC':
        AC += 1
    if s == 'WA':
        WA += 1
    if s == 'TLE':
        TLE += 1
    if s == 'RE':
        RE += 1
print('AC x',AC)
print('WA x',WA)
print('TLE x',TLE)
print('RE x',RE)

Measured memory_bytes: 69824
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,n,sum=0,sum1=0,m,p1,a1,b1;
    map<long long int,long long int>a;
    map<long long int,long long int>b;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        sum1=sum1+a[i];
        b[a[i]]=b[a[i]]+1;
    }
    cin>>m;
    for(i=1; i<=m; i++)
    {
        cin>>a1>>b1;
        p1=sum+b[a1];
        b[a1]=0;
        b[b1]=b[b1]+p1;
        sum1=sum1-(a1*p1);
        sum1=sum1+(p1*b1);
        cout<<sum1<<endl;
    }
    }


Measured memory_bytes: 15680
#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))
 
using namespace std;
 
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
 
inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
 
void solve() {
  int N, Q; cin >> N >> Q;
  vi32 a(N); cin >> a;
  vi64 X(Q); cin >> X;
  each(x, X) {
    i64 ans = 0;
    i64 sum = 0;
    for (int l = 0, r = 0; l < N; ) {
      while (r < N && sum + a[r] <= x) {
        sum += a[r++];
      }
      ans += r - l;
      sum -= a[l++];
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(1 <= i and i <= 9) ans++;
        else if(100 <= i and i <= 999) ans++;
        else if(10000 <= i and i <= 99999) ans++;
    }
    cout << ans << endl;
}


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

string s[1000];
int main() {
	int n;
	while (cin >> n, n) {
		int a = INT_MIN, b = INT_MAX;
		rep(i, n)cin >> s[i];
		rep(i, n) {
			if (s[i] == "x") {
				if (i & 1) {
					if (i) {
						if (s[i - 1] == "x") {
							puts("none"); goto g;
						}
						else a = max(a, stoi(s[i - 1]) + 1);
					}
					if (i < n - 1) {
						if (s[i + 1] == "x") {
							puts("none"); goto g;
						}
						else a = max(a, stoi(s[i + 1]) + 1);
					}
				}
				else {
					if (i) {
						if (s[i - 1] == "x") {
							puts("none"); goto g;
						}
						else b = min(b, stoi(s[i - 1]) - 1);
					}
					if (i < n - 1) {
						if (s[i + 1] == "x") {
							puts("none"); goto g;
						}
						else b = min(b, stoi(s[i + 1]) - 1);
					}
				}
			}
			else {
				if (i & 1) {
					if (i) {
						if (s[i - 1] != "x"&&stoi(s[i - 1]) > stoi(s[i])) {
							puts("none"); goto g;
						}
					}
					if (i < n - 1) {
						if (s[i + 1] != "x"&&stoi(s[i + 1]) > stoi(s[i])) {
							puts("none"); goto g;
						}
					}
				}
			}
		}
		if (a > b)puts("none");
		else if (a < b)puts("ambiguous");
		else printf("%d\n", a);
	g:;
	}
}

Measured memory_bytes: 3280
#include<stdio.h>
#include<string.h>

int main(void)
{
    char s1[100], s2[100];
    int taro=0, hanako=0, i, turn;
    
    scanf("%d", &turn);
    
    for(i=0; i<turn; i++){
        scanf("%s %s", s1, s2);
        if ( strcmp(s1, s2) == 0 ){
            taro++;
            hanako++;
        }
        else if ( strcmp(s1, s2) > 0 ){
            taro+=3;
        }
        else if ( strcmp(s1, s2) < 0 ){
            hanako+=3;
        }
    }
    
    printf("%d %d\n", taro, hanako);
    
    return 0;
}


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

// int gcd(int a, int b) {
//     if (a < b) swap(a, b);
//     while (b > 0) {
//         int c = a % b;
//         a = b;
//         b = c;
//     }
//     return a;
// }

// 再帰による実装
int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    // while (x % y != 0) {
    //     int z = x % y;
    //     x = y;
    //     y = z;
    // }
    printf("%d\n", gcd(x, y));
}


Measured memory_bytes: 3212
class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        // int[] keys = new int[n];
        BinaryTree binaryTree = new BinaryTree();
        for(int i=0; i<n; i++){
            String order = sc.next();
            switch(order){
                case "insert":
                    binaryTree.root = binaryTree.add(binaryTree.root, Integer.parseInt(sc.next()));
                    break;
                case "print":
                    binaryTree.print();
                    break;
                case "find":
                    binaryTree.find(binaryTree.root, Integer.parseInt(sc.next()));
                    break;
                default:
                    break;
            }
        }
        
    }

    static class Node{
        int key;
        Node left;
        Node right;

        public Node(int key){
            this.key = key;
        }

    }

    static class BinaryTree{
        Node root = null;

        Node getRoot(){
            return this.root;
        }

        void print(){
            innorder(this.root);
            System.out.println();
            preorder(this.root);
            System.out.println();
        }
        void preorder( Node node){
            if(node == null){
                return;
            }
            System.out.print(" "+node.key);
            preorder(node.left);
            preorder(node.right);
        }
        void innorder(Node node){
            if(node == null){
                return;
            }   
            innorder(node.left);
            System.out.print(" "+node.key);
            innorder(node.right);
        }


        public Node add(Node current, int key){
            if(current == null) {
                return new Node(key);
            }
            if( key >= current.key){
                current.right = add(current.right, key);
            } else {
                current.left = add(current.left, key);
            }
            return current;
        }

        public void find( Node node, int key){
            if(node == null){
                System.out.println("no");
                return ;
            }
            if(node.key == key){
                System.out.println("yes");
                return ;
            }

            if( key > node.key){
                find(node.right, key);
            } else {
                find(node.left, key);
            }

        }

    }
}




Measured memory_bytes: 189380
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    VEC(ll,A,N);
    ll x=0,k=1;
    REP(i,N){
        ll t;
        cin>>t;
        A[i]=t;
        x+=k*t;
        k*=-1;
    }
    //s(x);
    ll t=x;
    cout<<x<<" ";
    REP(i,N-1){
        t=2*(A[i]-t/2);
        cout<<t<<" ";
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		
		Scanner a = new Scanner(System.in);

		String str = a.next();
		
		int b = Integer.parseInt(str);
		
	    str = a.next();
	    
	    int c = Integer.parseInt(str); 
		System.out.println(b * c + " " + (2 * c + 2 * b));
		
	}
}

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

using ld=long double;

int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

using Event=pair<ld,int>;
const ld eps=1e-8;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> f(h);
    for(int i=0;i<h;i++) cin>>f[i];

    reverse(f.begin(),f.end());
    string top="";
    for(int i=0;i<w;i++) top+=".";    
    w++;
    h++;    
    f.push_back(top);
    for(int i=0;i<h;i++){
        f[i]+=".";
    }

    auto isRange=[&](int i,int j){
        return 0<=i && i<h && 0<=j && j<w;
    };
    
    vector<Event> event;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(f[i][j]!='#') continue;
            for(int k=0;k<4;k++){
                if(isRange(i+dh[k],j+dw[k]) && f[i+dh[k]][j+dw[k]]=='.'){
                    if(k==0){
                        event.push_back({ld(i)/ld(j+1),1});
                        event.push_back({ld(i+1)/ld(j+1),-1});
                    }
                    if(k==1){
                        event.push_back({ld(i+1)/ld(j+1),1});
                        if(j!=0) event.push_back({ld(i+1)/ld(j),-1});
                    }
                    if(k==2 && j!=0){
                        event.push_back({ld(i)/ld(j),1});
                        event.push_back({ld(i+1)/ld(j),-1});
                    }
                    if(k==3 && i!=0){
                        event.push_back({ld(i)/ld(j+1),1});
                        if(j!=0) event.push_back({ld(i)/ld(j),-1});
                    }
                }
            }
        }
    }
    sort(event.begin(),event.end());
    int idx=0;
    int cnt=0;
    int res=0;
    while(idx<event.size()){
        ld t;
        do{
            auto e=event[idx++];
            t=e.first;
            cnt+=e.second;
        }while(idx<event.size() && abs(t-event[idx].first)<eps);
        res=max(cnt,res);
    }
    if(f[0][0]=='#') res++;
    res=res/2+1;
    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 36480
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include<climits>

using namespace std;
using ll=long long;

void solve(){
  int num,k;
  cin >> num >> k;
  vector<vector<int>> xy(num,vector<int>(2));
  for(int i=0;i<num;i++)
    cin >> xy[i][0] >> xy[i][1];
  vector<int> xs(num);
  vector<int> ys(num);
  for(int i=0;i<num;i++){
    xs[i]=xy[i][0];ys[i]=xy[i][1];
  }
  sort(xs.begin(),xs.end());
  sort(ys.begin(),ys.end());

  ll res=LLONG_MAX;
  for(int sx=0;sx<num;sx++)
    for(int ex=sx;ex<num;ex++)
      for(int sy=0;sy<num;sy++)
        for(int ey=0;ey<num;ey++)
        {
          int ct=0;
          for(int i=0;i<num;i++)
            if(xs[sx]<=xy[i][0]&&xy[i][0]<=xs[ex]&&ys[sy]<=xy[i][1]&&xy[i][1]<=ys[ey])
              ct++;
          if(ct>=k)
            res=min(res,(ll)(xs[ex]-xs[sx])*(ys[ey]-ys[sy]));
        }
  cout << res << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import numpy as np
import math

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

#１の位が0以外でより小さい値のものを最後にする
dishes=np.array([A,B,C,D,E])
dishes_1=np.array(list(map(lambda x: x%10, dishes)))
# print(dishes)
# print(dishes_1)
last=0
ans=0
if np.all(dishes_1==0):
  print(A+B+C+D+E)
else:
  dishes=np.dstack([dishes, dishes_1])
  dishes=dishes[0]
  dishes=sorted(dishes, key=lambda x: x[1])
  for i in range(len(dishes)):
      if dishes[i][1]!=0:
          last=dishes[i]
          dishes=np.delete(dishes, [i], axis=0)
          break
  for j in range(len(dishes)):
      ans=ans+dishes[j][0]+((10-dishes[j][0]%10)%10)
  print(ans+last[0])


Measured memory_bytes: 12488
#include <stdio.h>
#include <stdlib.h>
#define Max(a,b) (a > b ? a : b)
#define Min(a,b) (a < b ? a : b)

int main(){
  int n,i;
  int *a;
  int max,min;
  long sum=0;
  
  scanf("%d",&n);
  a = (int *)malloc(sizeof(int) * n);

  for(i=0;i<n;i++)
    scanf("%d", &a[i]);
  
  /*init max & min*/
  max = a[0];
  min = a[0];
  
  
  /*cal max, min and sum*/
  for(i=0;i<n;i++){
    if(i < n-1){
      max = Max(max, a[i+1]);
      min = Min(min, a[i+1]);
    }
    sum += a[i];
  }
  
  printf("%d %d %ld\n", min, max, sum);
  
  free(a);
  return 0;
}

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

int main(){
  int n;
  int t[15][15];

  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	t[i][j] = -1;
      }
    }

    int x = n / 2;
    int y = n / 2 + 1;
    int now = 2;

    t[y][x] = 1;

    while(now <= n * n){
      x = x + 1;
      y = y + 1;

      while(true){
	if(n <= x) x = 0;
	if(x < 0) x = n - 1;
	if(n <= y) y = 0;
	if(y < 0) y = n - 1;

	if(t[y][x] == -1){
	  break;
	}

	x = x - 1;
	y = y + 1;
      }

      t[y][x] = now;
      now++;
    }

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	printf("%4d", t[i][j]);
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n;
	cin >> n;
	vll h(n);
	for (ll i = 0; i < n; i++) cin >> h[i];

	ll base = 0, ans = 0, x = 1;
	while (x) {
		for (ll i = 0; i < n - 1; i++) {
			if (h[i] > base && h[i + 1] <= base) ans++;
		}
		if (h[n - 1] > base) ans++;
		base++;
		for (ll i = 0; i < n; i++) {
			if (h[i] > base) break;
			if (i == n - 1) x = 0;
		}
	}
	cout << ans << endl;
}


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

int a[N];
int dp[N];

int main(){
    int n,k;
    cin>>n>>k;
    for(int i = 1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i = 2;i<=n;i++)dp[i]=1000000000;
    for(int i = 2;i<=n;i++)
    {
        for(int j = 1;j<=k&&(j+1<=i);j++)
        {

            dp[i]= min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));

        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main {
    static boolean arr[][];
    static long dp[][],mod=1000000007L;
    static int pow[];
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        arr=new boolean[n][n];
        dp=new long[n][(int)Math.pow(2, n)];
        for(int i=0;i<n;i++) {
            for(int j=0;j<n;j++) {
                if(input.nextInt()==1) {
                    arr[i][j]=true;
                }
            }
        }
        for(int i=0;i<dp.length;i++) {
            for(int j=0;j<dp[i].length;j++) {
                dp[i][j]=-1L;
            }
        }
        pow=new int[30];
        int p=1;
        for(int i=0;i<pow.length;i++) {
            pow[i]=p;
            p*=2;
        }
        System.out.println(solve(n-1,new boolean[n], 0));
    }
    public static long solve(int n,boolean taken[],int state) {
        if(n==-1) {
            return 1;
        }
        long ways=0;
        for(int i=0;i<taken.length;i++) {
            if(arr[n][i] && !taken[i]) {
                taken[i]=true;
                state+=pow[i];
                if(dp[n][state]==-1) {
                    dp[n][state]=solve(n-1,taken, state)%mod;
                }
                ways+=dp[n][state];
                ways%=mod;
                taken[i]=false;
                state-=pow[i];
            }
        }
        return ways;
    }
}


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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

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

    V<int> G[10100];
    V<int> deg(N, 0);
    for (int i = 0; i < N - 1; ++i) {
        int aa, bb;
        cin >> aa >> bb;
        aa--;
        bb--;
        G[aa].push_back(bb);
        G[bb].push_back(aa);
        deg[aa]++;
        deg[bb]++;
    }

    V<int> c(N), num(N);

    for (int i = 0; i < N; ++i) {
        cin >> c[i];
    }
    sort(c.rbegin(), c.rend());

    int p = 0, idx=0;
    for (int x=1;;x++) {
        if (p == 1)break;
        for (int i = 0; i < N; i++) {
            if (p == 1)break;
            if (deg[i] == x) {
                num[i] = c[p];
                idx=i;
                ++p;
            }
        }
    }

    ll res = 0LL;
    V<bool> visited(N, false);
    queue<int> q;
    q.push(idx);
    visited[idx] = true;

    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        for (auto to : G[cur]) {
            if (visited[to])continue;
            q.push(to);
            num[to]=c[p++];
            visited[to] = true;
            res += (ll)min(num[cur], num[to]);
        }
    }

    cout << res << endl;
    for (int i = 0; i < N; i++) {
        if (i != 0)cout << " " << num[i];
        else cout << num[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 3e5 + 7;
const int maxm = 2e5 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-10;
long long a[maxn];
int n;
multiset<long long> s;
priority_queue<long long> Q;
long long sum;
long long ans = -llINF;
long long pre[maxn], suffix[maxn];
int main(int argc, char const *argv[])
{
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; i++)
        scanf("%lld", &a[i]);

    for (int i = 1; i <= n * 2; i++) //最大的
    {
        s.insert(a[i]);
        sum += a[i];
        if (i > n)
        {
            sum -= *s.begin();
            s.erase(s.begin());
        }
        pre[i] = sum; //删到i位置
    }

    sum = 0;

    for (int i = n * 3; i >= n + 1; i--) //最小的
    {
        Q.push(a[i]);
        sum += a[i];
        if (i <= 2*n)
        {
            sum -= Q.top();
            Q.pop();
        }
        suffix[i] = sum;
    }

    for (int i = n; i <= n * 2; i++)
        ans = max(ans, pre[i] - suffix[i + 1]);

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

    return 0;
}

Measured memory_bytes: 12148
##A
n = input()
if int(n[-1]) == 3:
    print("bon")
elif int(n[-1]) == 2:
    print("hon")
elif int(n[-1]) == 4:
    print("hon")
elif int(n[-1]) == 5:
    print("hon")
elif int(n[-1]) == 7:
    print("hon")
elif int(n[-1]) == 9:
    print("hon")
else:
    print("pon")


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

int main(){
  ll n, m, k;
  cin >> n >> m >> k;
  ll a[n], b[m];
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  vector<ll> suma(n+1), sumb(m+1);
  for(int i = 1; i <= n; i++) suma[i] = suma[i-1] + a[i-1];
  for(int i = 1; i <= m; i++) sumb[i] = sumb[i-1] + b[i-1];
  ll ans = 0;
  rep(i,n+1) {
    ll res = k - suma[i];
    if(res < 0) continue;
    int pos = upper_bound(sumb.begin(),sumb.end(),res) - sumb.begin();
    ans = max(ans,(ll)i+pos-1);
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9588
#include "stdio.h"

int main(){

  int i, K, N, p, s = 0;

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

  if(N == 1 && K ==1){
    printf("1");
    return 0;
  }

  if(K == 1){
    printf("%d", N);
    return 0;
  }

  for(i = 1; i < N + 1; i++){
    for(p = 1; p < K ; p++){

      if(i + p > N){
        printf("%d", s);
        return 0;
      }
    }
    s++;
  }
}


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

using namespace std;
#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++)

int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;

  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 384
import sys

S = input()

if S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(S) == 26:
    for i in range(26):
        for j in range(ord(S[-i - 1]) + 1, 97 + 26):
            if chr(j) not in S[:-i - 1]:
                print(S[:-i - 1] + chr(j))
                sys.exit()
else:
    for i in range(97, 97 + 26):
        if chr(i) not in S:
            print(S + chr(i))
            break


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

#define MAX_N 100001

long long par[MAX_N]; // 親
long long rankuf[MAX_N]; // 木の深さ
// n要素で初期化
void init(long long n) {
	for (long long i = 0; i < n; i++) {
		par[i] = i;
    rankuf[i] = 0;
	}
}
// 木の根を求める
long long find(long long x) {
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}
// xとyの属する集合を併合
void unite(long long x, long long y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (rankuf[x] < rankuf[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (rankuf[x] == rankuf[y]) rankuf[x]++;
	}
}
// xとyが同じ集合に属するか否か
bool same(long long x, long long y) {
	return find(x) == find(y);
}

void solve(long long N, long long M, vector<long long> p, vector<long long> x, vector<long long> y){
	init(N);
	for (long long i = 0; i < M; i++) {
		unite(p[x[i]-1],p[y[i]-1]);
	}
	long long res = 0;
	for (long long i = 0; i < N; i++) {
		if (same(p[i],i+1) || p[i] == i+1) res++;
	}
	printf("%lld\n", res);
}

int main(){
	long long N;
	long long M;
	scanf("%lld",&N);
	vector<long long> p(N-1+1);
	scanf("%lld",&M);
	vector<long long> y(M-1+1);
	vector<long long> x(M-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&p[i]);
	}
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	solve(N, M, p, x, y);
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main (){
int a[3],b[3],counta=0,countb=0,countc=0,countd=0;
for (int i=0;i<3;i++){
cin >>a[i] >>b[i];
if (a[i]==1)counta++;
if (a[i]==2)countb++;
if (a[i]==3)countc++;
if (a[i]==4)countd++;
if (b[i]==1)counta++;
if (b[i]==2)countb++;
if (b[i]==3)countc++;
if (b[i]==4)countd++;
}
if (counta==3 ||countb==3 ||countc==3 ||countd==3)cout <<"NO"<<endl;
else cout <<"YES"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll fact[100001];
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k,i,j;
    cin>>n>>k;
    int h[n+1];
    for(i=1;i<n+1;i++)
    cin>>h[i];
    vector<ll>d(n+1,INT_MAX);
    d[1]=0;
    d[2]=abs(h[1]-h[2]);
    for(i=3;i<=n;i++)
    {
    	d[i]=d[i-1]+abs(h[i]-h[i-1]);
    	for(j=2;j<k+1;j++)
    	{
    		if(i-j<0)
    		break;
    		d[i]=min(d[i],d[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout<<d[n];

}

Measured memory_bytes: 1408
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

int main(void) {

	long A, B; cin >> A >> B;
	cout << max(A - 2 * B, (long)0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void ){
    int a,b,c;
    scanf( "%d%d%d" , &a, &b, &c );
    if ( a <= b && b <= c ){
        printf( "%d %d %d\n",a,b,c );
    } else if ( a <= c && c <= b ){
        printf( "%d %d %d\n",a,c,b );
    } else if ( b <= a && a <= c ){
        printf( "%d %d %d\n",b,a,c );
    } else if ( b <= c && c <= a ){
        printf( "%d %d %d\n",b,c,a );
    } else if ( c <= b && b <= a ){
        printf( "%d %d %d\n",c,b,a );
    } else {
        printf( "%d %d %d\n",c,a,b );       
    }
    return 0;
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
#define log2(x) (log(x)/log(2))
#define ln '\n'
#define bln(i,n) ((i==n-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a, b, res, mn = inf;
bool sm = true;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a >> b;
		if (a!=b) sm = false;
		res += a;
		if (a>b) chmin(mn,b);
	}
	cout << (sm ? 0 : res-mn) << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n+1,0);
  int base = 1;
  for(int i = n-1; i>=0; i--){

    a.at(i)=(a.at(i+1)+(s.at(i)-'0')*base)%2019;
    base = (base*10)%2019;
  }
  vector<int> p(2019,0);
  rep(i,n+1){
    p.at(a.at(i))++;
  }
  ll ans = 0;
  rep(i,2019){
    int m = p.at(i);
    ans+=m*(m-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4352
nu = gets.chomp.split(" ").map(&:to_i)
num = nu.sort
count = 0

count += num[2] - num[1]

if (num[2] - num[0] - count) % 2 == 0
  count += (num[1] - num[0]) / 2
else
  count += ((num[1] - num[0]) / 2) + 2
end

puts count


Measured memory_bytes: 1788
using System.Linq;
using System;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G() => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		var I = G();
		int N = I[0], K = I[1];
		I = G();
		var g = I[0];
		foreach (var a in I.Skip(1)) g = GCD(g, a);
		WriteLine(K % g == 0 && K <= I.Max() ? "POSSIBLE" : "IMPOSSIBLE");
	}
	int GCD(int n, int m) => m > 0 ? GCD(m, n % m) : n;
}


Measured memory_bytes: 21728
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ull, ull> P; //ペア　タイプでふ
constexpr ll bigNum = 1000000007;

int main(void)
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    //ここから本体
    int a, b = 0;
    cin >>a>>b;
    cout << max(a + b, max(a - b, a * b));
}


Measured memory_bytes: 256
N = int(input())
h=[int(i) for i in input().split()]

d0=0
d1= abs(h[1]-h[0])

for i in range(2, N):
    tmp = min([abs(h[i]-h[i-1])+d1, abs(h[i]-h[i-2])+d0])
    d0=d1
    d1=tmp
print(d1)


Measured memory_bytes: 13928
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <map>
#define MOD (1000000007l)

using namespace std;

int main(void) {
  long D, G;
  cin >> D >> G;
  vector<long> p(D), c(D);
  for (long i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }
  map<long, long> score_table;
  score_table[0] = 0;
  for (long d = 1; d <= D; d++) {
    map<long, long> next_score_table = score_table;
    for (long solve = 1; solve <= p[d-1]; solve++) {
      long score = d * 100 * solve;
      if (solve == p[d-1]) score += c[d-1];
      for (auto it: score_table) {
        long solve_sum = it.first + solve;
        long score_sum = it.second + score;
        if (next_score_table[solve_sum] < score_sum) next_score_table[solve_sum] = score_sum;
      }
    }
    score_table = next_score_table;
  }
  for (auto it: score_table) {
    if (it.second >= G) {
      cout << it.first << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  long long n;
  cin>>n;
  if(n%2)n*=2;
  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long x, y;
  cin >> x >> y;
  long sub, ans = 2000000000;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      if(x * pow(-1,i) <= y * pow(-1,j)){
        sub = 0;
        if(x != x * pow(-1,i))sub++;
        if(y != y * pow(-1,j))sub++;
        sub += y * pow(-1,j) - x * pow(-1,i);
        ans = min(ans, sub);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e7;
const int inf=1e9;
int main(){
	string s;cin>>s;
    int N=s.size();
	bool flag = true;
	rep(i,0,N){
		if(s[i] != s[N-1-i]) flag = false;
	}rep(i,0,(N-1)/2){
		if(s[i] != s[(N-1)/2-1-i]) flag = false;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n , k;
    cin >> n >> k;
    ll x[100001] = {};
    for ( ll i = 0 ; i < n ; i++){
        int a , b;
        cin >> a >> b;
        x[a] += b;
    }
    ll c = 0;
    for ( int i = 0 ; i < 100001 ; i++ ){
       c += x[i];
       if( c >= k ){
         cout << i;
         return 0;
       }
    }
}

Measured memory_bytes: 1024
n = int(input())
shop_list = list()
shop_dict = dict()
for i in range(n):
  s, p = input().split()
  p = int(p)
  shop_list.append(tuple([s, p]))
  shop_dict[tuple([s,p])] = i + 1
  #print(shop_dict)
shop_list = sorted(shop_list, key = lambda x:x[1], reverse = True)
#print(shop_list)
shop_list = sorted(shop_list, key = lambda x:x[0])
#print(shop_list)

for shop in shop_list:
  print(shop_dict[shop])



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    vector<ll> big(1LL << 20,0),little(1LL << 20,0);

    vector<ll> tbit(40,0);
    for(ll i = 0; i < 40; i++){
        for(ll j = 0; j < n; j++){
            if(a[j]&(1LL << i)){
                tbit[i]++;
            }
        }
    }

    for(ll i = 0; i < (1LL << 20); i++){
        for(ll j = 0; j < 20; j++){
            if(i&(1LL << j)){
                big[i] += (1LL << j)*(n-tbit[j+20]);
                little[i] += (1LL << j)*(n-tbit[j]);
            }else{
                big[i] += (1LL << j)*tbit[j+20];
                little[i] += (1LL << j)*tbit[j];
            }
        }
    }

    vector<ll> ruimax(1LL << 20,0);
    ruimax[0] = little[0];
    for(ll i = 1; i < (1LL << 20); i++){
        ruimax[i] = max(ruimax[i-1],little[i]);
    }

    ll ans = 0;

    for(ll i = 0; i < (1LL << 20); i++){
        ll t = k - (i << 20);
        if((1LL << 20) > t && t >= 0){
            ans = max(ans,(big[i] << 20) + ruimax[t]);
        }else if((1LL << 20) <= t){
            ans = max(ans,(big[i] << 20)+ ruimax[(1LL << 20) - 1]);
        }
    }

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

Measured memory_bytes: 25600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

vector<pair<int, int>> factrize(ll n)
{
	vector<pair<int, int>> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			res.back().second++;
			n /= i;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}


int main()
{
	ll n;
	cin >> n;
	auto v = factrize(n);
	int ans = 0;

	/*for (int i = 0; i < v.size(); i++) {
		printf("[%d,%d]\n", v[i].first, v[i].second);
	}*/
	
	int count = 0;
	for (int i = 0; i < v.size(); i++) {
		count = 1;
		while (v[i].second >= count) {
			v[i].second -= count;
			count++;
			ans++;
		}
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 3720
a,b = map(str, input().split())
count = 0
num = a
sub = 0
line = int(b) - int(a) + 1

for i in range(line):
	if num[0] == num[4] and num[1] == num[3]:
		count = count + 1
	sub = int(num) + 1
	num = str(sub)
	
print(count)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int x[214514];
double y[214514];
string z[214514];
int sum[214514];
signed main(){
	string a,b;
	cin>>a>>b;
	int sum=0;
	rep(0,i,3){
		if(a[i]==b[i])sum++;
	}
	c(sum)
}			

Measured memory_bytes: 2688
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ls = [0] * n
    ans = []

    for i in range(n-1, -1, -1):
        if (sum(ls[i::i+1]) % 2) != a[i]:
            ls[i] = 1
            ans.append(i+1)
    print(sum(ls))
    if ans:
        print(*ans[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 14768
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    ll dp[n];
    memset(dp,1000000,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
            }
        }
    }
    cout<<dp[n-1];
    return 0;
}









Measured memory_bytes: 1408