akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
 int n; cin >> n;
 vector<int> a(n+1);
 vector<int> b(n+1);
  REP(i,n){
	cin >> a[i+1];
  }
  FOR(i,1,n+1){
    b[a[i]] = i;
  }
  FOR(i,1,n+1){
   cout << b[i] << " "; 
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int mod=(int)(7.5+1e9);
long long f(int n){
  if(n==0)return 1;
  return n*f(n-1)%mod;
}
int main(){
  int m,n;cin>>m>>n;
  long long res;
  if(abs(m-n)>1)res=0;
  else if(m==n)res=2*f(m)*f(m)%mod;
  else res=f(m)*f(n)%mod;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1792
///
// File:  1602.cpp
// Author: ymiyamoto
//
// Created on Wed Dec 20 00:50:10 2017
//

#include <cstdint>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

string calc(vector<string> values, string op)
{
  uint32_t val;
  if (op == "+") {
    val = 0;
  } else {
    val = 1;
  }

  for (auto s : values) {
    int32_t i = stoi(s);
    if (op == "+") {
      val += i;
    } else {
      val *= i;
    }
  }

  return to_string(val);
}

void conv(stack<pair<uint32_t, string>> &s, uint32_t depth)
{
  while (s.top().first > depth) {
    vector<string> values;
    uint32_t d = s.top().first;
    while (true) {
      pair<uint32_t, string> t = s.top();
      s.pop();
      if (t.first < d) {
        s.push({t.first, calc(values, t.second)});
        break;
      } else {
        values.push_back(t.second);
      }
    }
  }
}

int32_t main()
{
  while (true) {
    int32_t n;
    cin >> n;
    if (n == 0) break;

    stack<pair<uint32_t, string>> s;
    uint32_t depth = 0;
    for (int32_t i = 0; i < n; i++) {
      string str;
      cin >> str;
      uint32_t d = str.size() - 1;

      if (depth > d) {
        conv(s, d);
      }
      s.push({d, string{str[str.size() - 1]}});
      depth = d;
    }
    conv(s, 0);

    cout << s.top().second << endl;
  }

  return 0;
}

Measured memory_bytes: 3272
/**
 *   created: 07 December 2019  18:00:06
**/
#include<bits/stdc++.h>
using namespace std;

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

#define int long long
#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


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

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int32_t main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		string s;
		cin>>s;
		int i=0,j=s.size()-1;
		int cnt=0;
		while(i<=j){
			if(s[i++]!=s[j--])
				cnt++;
		}
		cout<<cnt;
	}
	return 0;
}


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

namespace ITP1_3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            //3つの整数a,b,cを読み込み、a,bの中にcの約数がいくつあるかを求める
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            var count = 0;

            //約数　Nを割り切ることができる整数
            //cをa,bの間にある数で一つずつ割っていき、割り切れた回数を数える
            for (int i =a; i<=b; i++)
            {
                if (c % i == 0) 
                {
                    count++;
                }
                else
                { }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 18032
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int r, g;
    
    scanf("%d%d", &r, &g);
    
    printf("%d", 2*g-r);
    
    return 0;
}



Measured memory_bytes: 1696
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int a,b,c,k;
    cin >> a >> b >> c>>k;
    bool ok = false;
    for(int i = 0;i<=k;i++){
        if(a < b*pow(2,i) && b*pow(2,i) <c*pow(2,k-i)){
            ok = true;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 4112
x1,y1,x2,y2 = map(int, input(). split())
dx = (x2 - x1)
dy = (y2 - y1)


x3, y3 = x2 - dy, y2 + dx
x4, y4 = x1 - dy, y1 + dx
x3, y3, x4, y4 = int(x3), int(y3), int(x4), int(y4)
print("{0} {1} {2} {3}".format( x3, y3, x4, y4))

Measured memory_bytes: 3064
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()

using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>

using namespace std;

int ggd(int number1, int number2) {
	int m = number1;
	int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}

	while (m != n) {
		int temp = n;
		n = m - n;
		m = temp;
	}

	return m;
}

int lcm(int number1, int number2) {
	return number1 * number2 / ggd(number1, number2);
}

bool is_prime(int64_t x) {
	for (int64_t i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

int main() {

	int n;
	double sita = 0;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n) {
		scanf("%d", &a[i]);
		sita += double(1) / a[i];
	}
	printf("%.16f\n", double(1) / sita);

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

class E
{
	static long F()
	{
		return long.Parse(Console.ReadLine());
	}
	static int[] G()
	{
		return Console.ReadLine().Split().Select(int.Parse).ToArray();
	}
	public static void Main()
	{
		var N = F();
		var p = new List<long>();
		for (var i = 1L; i * i <= N; i++) if (N % i == 0) p.Add(i);
		var P = N / p.Last();
		Console.WriteLine(P.ToString().Length);
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////



	
int main() {

	ll N;
	cin >> N;
	ll M = pow(2, N);

	ll S[MAX];

	repn(i, M) cin >> S[i];
	sort(S + 1, S + M + 1, greater<ll>());

	priority_queue<ll> p[20];

	rep(i, N) { p[i].push(S[1]); }

	string ans = "Yes";

	for (int i = 2; i <= M; i++) {
		for (int j = N-1; j >= 0; j--) {

			if (!p[j].empty()) {
				ll v = p[j].top();
				if (v > S[i]) {
					p[j].pop();
					rep(k, j) { p[k].push(S[i]); }
					break;
				}
			}

			if (j == 0) { ans = "No"; }

		}


		if (ans == "No") { break; }

	}

	cout << ans;
	

	system("PAUSE");


}

Measured memory_bytes: 6896
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
int D,N,M;
int A[100010];
int main()
{
	while(true){
		scanf("%d",&D);
		if(D==0)return 0;
		scanf("%d%d",&N,&M);
		for(int i=1;i<N;i++)scanf("%d",&A[i]);
		A[N]=D;
		N++;
		sort(A,A+N);
		int ans=0;
		for(int i=0;i<M;i++){
			int K;
			scanf("%d",&K);
			int l=0;int r=N;
			while(r-l>1){
				int c=(l+r)/2;
				if(A[c]>K)r=c;
				else l=c;
			}
			int dis=min(abs(K-A[l]),abs(K-A[l+1]));
			ans+=dis;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1592
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int i;
		int GCD,LCM;
		double[] num = new double[2];
		double[] tmpNum = new double[2];
		double tmp;
		
		while(scan.hasNextInt()){
			for(i=0;i<2;i++){
				num[i] = scan.nextInt();
				tmpNum[i] = num[i];
			}
			
			
			while(num[1] != 0){
				if(num[0] < num[1]){
					tmp = num[0];
					num[0] = num[1];
					num[1] = tmp;
				}
				
				tmp = num[0] - num[1];
				num[0] = num[1];
				num[1] = tmp;
			}
			GCD = (int)num[0];
			LCM = (int)((tmpNum[0]*tmpNum[1])/GCD);
			
			System.out.println(GCD + " " + LCM);
		}
		
		scan.close();
	}
}

Measured memory_bytes: 17228
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	ll ans = 0;
	int mx = a[0];
	for(int i = 1; i < n; i++) {
		if(a[i] < mx) ans += mx - a[i];
		
		mx = max(mx, a[i]);
	}
	
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 4052
import java.util.Scanner;

public class Main {

    static int count = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        mergeSort(s, 0, n);
        printArray(s);
        System.out.println(count);
    }

    static void mergeSort(int[] s, int left, int right) {
        if (left + 1 < right) { // ??????1?????\???????´????????????¶????????£????????£??????????????????
            int mid = (left + right) / 2;
            mergeSort(s, left, mid);
            mergeSort(s, mid, right);
            merge(s, left, mid, right);
        }
    }

    private static void merge(int[] s, int left, int mid, int right) {
        int[] L = new int[mid - left + 1];
        int[] R = new int[right - mid + 1];
        for (int i = 0; i < L.length - 1; i++) {
            L[i] = s[left + i];
        }
        L[L.length - 1] = Integer.MAX_VALUE;
        for (int i = 0; i < R.length - 1; i++) {
            R[i] = s[mid + i];
        }
        R[R.length - 1] = Integer.MAX_VALUE;
        for (int i = 0, j = 0, k = left; k < right; k++) {
            count++;
            if (L[i] <= R[j]) {
                s[k] = L[i];
                i++;
            } else {
                s[k] = R[j];
                j++;
            }
        }
    }

    private static void printArray(int/*or long*/[] array) {
        if (array.length == 0) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < array.length; i++) {
            sb.append(array[i]);
            if (i != array.length - 1) {
                sb.append(" ");
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 178776
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
      int total = 0;
        if(a<=k){
         total += a;
      }else{
         total += k;
      }
      k = k-a-b;
      if(c<=k){
         total -=c;
      }else{
         if(k>0){
            total -= k;
         }else{
         }
      }
      System.out.println(total);
	}
}

    

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

int main()
{
    int alt, anch, t, i;
    while(1)
    {
        scanf("%d %d", &alt, &anch);
        if(alt == 0 && anch == 0)
            {
                break;
            }
        for(t = 0;t < alt;t++)
        {
            for(i = 0;i < anch;i++)
            {
                if((t %2 == 0 && i %2 == 0) || (t %2 == 1 && i %2 == 1))
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");

    }
    return 0;
}



Measured memory_bytes: 2040
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int main(){
	int n;
	cin >> n;
	ll ans = 0, num = 0;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(a == num + 1){
			num++;
		}else if(a > num){
			int rem = a - 1;
			ans += rem / (num + 1);
			num = max(1ll, num);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 888
h,w=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(10)]
o=[list(map(int,input().split())) for _ in range(h)]

for k in range(10):
  for i in range(10):
    for j in range(10):
      if l[i][j]>l[i][k]+l[k][j]:
        l[i][j]=l[i][k]+l[k][j]

v=[[l[j][1] if j>=0 else 0 for j in i] for i in o]
print(sum(map(sum,v)))


Measured memory_bytes: 40796
#include <stdio.h>

int main(void){

  int input, ans;

  scanf("%d", &input);
  while(input != -1){
    ans = 1150;
    if(input > 10){
      ans += input > 20 ? 1250 : 125 * (input - 10);
      if(input > 20){
	ans += input > 30 ? 1400 : 140 * (input - 20);
	if(input > 30){
	  ans += 160 * (input - 30);
	}
      }
    }
    ans = 4280 - ans;
    printf("%d\n", ans);
    scanf("%d", &input);
  }
  return 0;
}

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

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;

            s = Console.ReadLine();

            char[] cs = s.ToCharArray();
            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();
        }
    }
}

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

int main(void){
	string s;
	int pos;
	cin >> s;
	cin >> pos;

	vector<string> t;
	for(int i=0; i<s.size(); i++){
		for(int j=1; j<=5; j++){
			t.push_back(s.substr(i,j));
		}
	}
	sort(t.begin(),t.end());
	unique(t.begin(),t.end());
	cout << t[pos-1] << endl;
}

Measured memory_bytes: 1660
n, k =  map(int, input().split())
ds = list(map(int, input().split()))

nums = []
for x in range(10):
    if x in ds:
        nums.append(1)
    else:
        nums.append(0)

res = 0
for x in range(n, n*10):
    ys = list(map(int,list(str(x))))
    flag = False
    for y in ys:
        if nums[y]:
            flag = True
            break
    if flag:
        continue
    else:
        res = x
        break
print(res)

Measured memory_bytes: 3444
#include <iostream>
#include <string.h>
#include <cstring>
#include <stdlib.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i=0;i<n;i++){
        char s[10];
        cin>>s;
        if( strcmp(s,"AC") == 0 ){
            ac++;
        }
        if( strcmp(s,"TLE") == 0 ){
            tle++;
        }
        if( strcmp(s,"RE") == 0 ){
            re++;
        }
        if( strcmp(s,"WA") == 0 ){
            wa++;
        }
    }
    cout<<"AC"<<" x "<<ac<<endl;
    cout<<"WA"<<" x "<<wa<<endl;
    cout<<"TLE"<<" x "<<tle<<endl;
    cout<<"RE"<<" x "<<re<<endl;
}


Measured memory_bytes: 3228
N = int(input())
MAXP = 100010

imos = [0 for i in range(MAXP)]
for i in range(N):
    a,b = map(int,input().split())
    imos[a-1] += 1
    imos[b] -= 1
nums = [0]
for im in imos:
    nums.append(nums[-1] + im)

for i,p in enumerate(reversed(nums)):
    n = MAXP - 1 - i
    if n == 0: break
    if p >= n:
        print(n)
        exit()
print(0)

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i=0;i<N;i++){
    cin >> h[i];
  }
  int ans=h[0];
  for (int i=1;i<N;i++){
    int x=h[i]-h[i-1];
    if (x>0){
      ans+=x;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct A{char m;int n,f;}A;
A KJ[100005];
int N,i,flg=0;
void sw(A *a,A *b)
{
	A c=*a;
	*a=*b;
	*b=c;
}

int pt(int p,int r)
{
	int i,j,pos;
	A x;
	x=KJ[r];
	i=p-1;
	for(j=p;j<r;j++)
	{
		if(KJ[j].n<=x.n)
		{
			sw(&KJ[++i],&KJ[j]);
		}
	}
	sw(&KJ[i+1],&KJ[r]);
	return i+1;
}

void ko(int p,int r)
{
	int q;
	if(p<r)
	{
		q=pt(p,r);
		ko(p,q-1);
		ko(q+1,r);
	}
}


int main(){
  
	scanf("%d\n",&N);
	for(i=1;i<=N;i++){
	  
		scanf("%c %d\n",&KJ[i].m,&KJ[i].n);
		KJ[i].f=i;
	}
		
	ko(1,N);
	for(i=2;i<=N;i++)
		if(KJ[i-1].n==KJ[i].n&&KJ[i-1].f>KJ[i].f)
			flg=1;
	puts(flg?"Not stable":"Stable");
	for(i=1;i<=N;i++)
		printf("%c %d\n",KJ[i].m,KJ[i].n);
	return 0;
}



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

int main(){
  long long x,y,z,k,e;
  vector<long long>v1,v2,nv1,nv2;
  priority_queue<long long>pq1,pq2;
  cin>>x>>y>>z>>k;
  for(long long i=0;i<x;i++){
    cin>>e;v1.push_back(e);
  }
  for(long long i=0;i<y;i++){
    cin>>e;v2.push_back(e);
  }
  for(auto i:v1){
    for(auto j:v2){
      pq1.push(i+j);
    }
  }
  for(long long i=0;!pq1.empty()&&i<3000;i++){
    nv1.push_back(pq1.top());
    pq1.pop();
  }
  for(long long i=0;i<z;i++){
    cin>>e,nv2.push_back(e);
  }
  sort(nv2.begin(),nv2.end());
  for(auto i:nv1){
    for(auto j:nv2){
      pq2.push(i+j);
    }
  }
  for(long long i=0;i<k;i++){
    cout<<pq2.top()<<"\n";
    pq2.pop();
  }
  return 0;
}

Measured memory_bytes: 43392
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		HashSet<Integer> hs = new HashSet<>();
		for (int i = 0; i < k; i++) {
			hs.add(sc.nextInt());
		}
		String s = "";
		boolean b;
		while (true) {
			b = true;
			s = String.valueOf(n);
			for (int i = 0; i < s.length(); i++) {
				if (hs.contains(s.charAt(i) - '0')) {
					b = false;
					break;
				}
			}
			if (b) {
				System.out.println(s);
				break;
			} else {
				n++;
			}
		}
	}
}


Measured memory_bytes: 26836
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

INF = 10**18
dp = [INF] * (N + K)

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
        else:
            break
print(dp[N-1])


Measured memory_bytes: 52320
#include <iostream>
#include <cstring>
using namespace std;
const int mod=1e9+7;
long long n,ans,pre;
long long a[210000];
int main(void)
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    pre=a[0];
    for(int i=1;i<n;i++)
    {
        ans%=mod;
        ans=(ans+pre*a[i]%mod)%mod;
        pre=(pre+a[i])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4696
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL gcd(LL m,LL n){
    if(m<n) swap(m,n);
    while(true){
        if(n==0) break;
        LL t = n;
        n = m%n;
        m = t;
    }
    return m;
}
LL lcm(LL a,LL b){
    return (a*b)/gcd(a,b);
}


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL a,b,c,d;
    cin>>a>>b>>c>>d;
    LL lcm_cd = lcm(c,d);

    LL div_c = b/c - (a%c == 0 ?  a/c-1: a/c);
    LL div_d = b/d - (a%d == 0 ?  a/d-1: a/d);
    LL div_cd = b/lcm_cd - (a%lcm_cd == 0 ?  a/lcm_cd-1: a/lcm_cd);
    LL ans = (b - a + 1) - div_c - div_d + div_cd;

    PUTS(ans);
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

int a, b;

int main(){
    IOS;
    cin >> a >> b;
    if(a == b){
        F0R(i,a){
            cout << a;
        }
        return 0;
    }
    if(a < b){
        F0R(i,b){
            cout << a;
        }
        return 0;
    }
    if(b < a){
        F0R(i,a){
            cout << b;
        }
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define f(i,x,n) for(ll i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define debug(x) cout<<x<<"\n";
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
long long MOD=pow(10,9)+7;

int main() {
	
	int t;
	t=1;
	//cin >> t;
	while(t--){
     int n;
     cin>>n;
     cout<<(n^1);
     
}
	
	return 0;
}  
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 3616
#include <stdio.h>
#include <algorithm>

using namespace std;

struct Info{
	Info(){m_node = m_distance = 0;}
	Info(int node,int distance){
		m_node = node;
		m_distance = distance;
	}
	int m_node,m_distance;
};

class InfoQueue{
public:
	InfoQueue(){
		info = new Info[10000];
		num_of_data = head = tail = 0;
	}
	bool isEmpty(){
		return num_of_data == 0;
	}
	void enqueue(Info data){
		info[tail] = data;
		tail = (tail+1)%10000;
		num_of_data++;
	}
	Info dequeue(){
		Info ret = info[head];
		head = (head+1)%10000;
		num_of_data--;
		return ret;
	}
private:
	Info* info;
	int head,tail,num_of_data;
};


int main(){

	int n,row,col,num;
	scanf("%d",&n);

	int table[n+1][n+1];
	int check_table[n+1];

	for(int i=1;i<=n;i++){
		check_table[i] = -1;
		for(int k=1;k<=n;k++)table[i][k] = 0;
	}

	for(int i=1;i<=n;i++){
		scanf("%d %d",&row,&num);
		for(int k=1;k<=num;k++){
			scanf("%d",&col);
			table[row][col]=1;
		}
	}

	check_table[1] = 0;

	InfoQueue Q;
	Q.enqueue(Info(1,0));

	Info tmp;
	while(!Q.isEmpty()){
		tmp = Q.dequeue();
		for(int i=1;i<=n;i++){
			if(table[tmp.m_node][i]==1 && check_table[i] == -1){
				check_table[i] = tmp.m_distance+1;
				Q.enqueue(Info(i,tmp.m_distance+1));
			}
		}
	}

	for(int i=1;i<=n;i++){
		printf("%d %d\n",i,check_table[i]);
	}

    return 0;
}



Measured memory_bytes: 2832
# 2020/06/14
# AtCoder Beginner Contest 170 - C

# Input
x, n = map(int,input().split())

if n == 0:
    ans = x
else:
    p = list(map(int,input().split()))

    # Make NG List (1 is NG, 0 is OK)
    nglist = [0] * 102
    for i in range(n):
        nglist[p[i]] = 1

    # Search
    minval = 10000
    ans = -1
    for i in range(0, 102):
        wkmin = abs(x - i)
        if nglist[i] == 0 and wkmin < minval:
            minval = wkmin
            ans = i

# Output
print(ans)


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

int w,h,m[50][50];

bool in(int x,int y) {
	return 0<=x&&x<w&&0<=y&&y<h;
}

void dfs(int x,int y) {
	m[x][y]=0;
	for(int i=1;i>=-1;i--) {
		for(int j=1;j>=-1;j--) {
			int nx=x+i,ny=y+j;
			if(in(nx,ny)&&m[nx][ny]) dfs(nx,ny);
		}
	}
}

int main() {
	while(scanf("%d %d",&w,&h),w||h) {
		for(int j=0;j<h;j++) {
			for(int i=0;i<w;i++) {
				scanf("%d",&m[i][j]);
			}
		}
		int count=0;
		for(int j=0;j<h;j++) {
			for(int i=0;i<w;i++) {
				if(m[i][j]) count++,dfs(i,j);
			}
		}
		printf("%d\n",count);
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    int tak = (a+d-1)/d;
    int aoki = (c+b-1)/b;
    if(tak < aoki) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;


ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b; //あまりが0ならそれが、最大公約数
}

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;
    string a,b;
    cin >> a >> b;
    string res = "";
    REP(i,N)
    {
        res += a[i];
        res += b[i];
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}

const int MAXN = 5e5 + 1;
vector <int> tree[MAXN];

void add(int v, int val)
{
    for (int i = v; i < MAXN; i += (i & -i))
        tree[i].push_back(val);
}

int query(int v, int val)
{
    int res = 0;
    for (int i = v; i > 0; i -= (i & -i))
    {
        res += tree[i].E() - upper_bound(tree[i].B(), tree[i].E(), val);
    }
    return res;
}

signed main()
{
    hello();
    
    int n, q;
    cin >> n >> q;
    vector <int> seq(n);
    vector <int> used(n + 1, INF);
    for (int i = 0; i < n; ++i)
        cin >> seq[i];
    vector <int> nseq(n);
    for (int i = n - 1; i >= 0; --i)
    {
        nseq[i] = used[seq[i]];
        used[seq[i]] = i;
    }

    for (int i = 0; i < n; ++i)
        add(i + 1, nseq[i] + 1);
    for (int i = 0; i < MAXN; ++i)
        stable_sort(tree[i].B(), tree[i].E());

    for (int v = 0; v < q; ++v)
    {
        int l, r;
        cin >> l >> r;
        cout << query(r, r) - query(l - 1, r) << endl;
    }
}

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

const int INF = 2e9;

int main(){
    string s;
    cin >> s;
    int cnt = 1;
    rep(i,s.size()-1){
        if(s[i] != s[i+1]) cnt++;
    }
    cout << cnt - 1 << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N;
    cin >> N;

    if(N == 1) {
        printf("1.0\n");
    }
    else if(N % 2 == 0) {
        printf("0.5\n");
    }
    else {
        double cnt = static_cast<double>(N / 2 + 1);
        cnt /= static_cast<double>(N);
        printf("%.7f\n", cnt);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 10000000000000000
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii,int> piii;
#define mp make_pair
signed main(){
    int n,m;
    cin>>n>>m;
    vector<piii>edge;
    rep(i,m){
        piii temp;
        cin>>temp.first.first>>temp.first.second>>temp.second;
        --temp.first.first,--temp.first.second;
        edge.push_back(temp);
    }
    vector<int>d(n,-INF);
    d[0]=0;
    rep(v,3*n){
        for(int i=0;i<m;i++){
            int s=edge[i].first.first;
            int t=edge[i].first.second;
            int c=edge[i].second;
            if(d[s]!=-INF&&d[t]<d[s]+c){
                d[t]=d[s]+c;
                if(t==n-1&&v>n*2){
                    return puts("inf")*0;
                }
            }
        }
    }
    cout<<d[n-1]<<endl;
}


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

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


}


Measured memory_bytes: 128
n = gets.to_i

xys = []

0.upto(n - 1) do
  xys << gets.split.map(&:to_i)
end

routes = 0.upto(n - 1).to_a.permutation

distances = routes.map {|route|
  route.each_cons(2).inject(0) {|acc, (p1, p2)|
    a = xys[p1]
    b = xys[p2]
    acc + Math.sqrt((a[0] - b[0]).abs ** 2 + (a[1] - b[1]).abs ** 2)
  }
}

puts distances.inject(&:+) / distances.length

Measured memory_bytes: 3836
print 'YES' if raw_input() in ['KIHBR', 'KIHBRA', 'KIHBAR', 'KIHBARA', 'KIHABR', 'KIHABRA', 'KIHABAR', 'KIHABARA', 'AKIHBR', 'AKIHBRA', 'AKIHBAR', 'AKIHBARA', 'AKIHABR', 'AKIHABRA', 'AKIHABAR', 'AKIHABARA'] else 'NO'


Measured memory_bytes: 2572
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <stack>
#include <string>
using namespace std;
int table[10]={0,2,5,5,4,5,6,3,7,6};
int use_ok[10];
int dp[100001];
int N,M;
int main(){
	cin >> N >> M;
	for(int i=1;i<=M;i++){
		int x;
		cin >> x;
		use_ok[x]=1;
	}
	for(int i=0;i<100001;i++)dp[i]=-100000000;
		dp[0]=0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=9;j++){
			if(use_ok[j] && i-table[j]>=0)dp[i]=max(dp[i],dp[i-table[j]]+1);
		}
	}
	//for(int i=0;i<=N;i++)cout << i << " " << dp[i] << endl;

	int aa=N;
	while(aa!=0){
		for(int i=9;i>=1;i--){
			if(aa-table[i]>=0 && dp[aa-table[i]]==(dp[aa]-1) && use_ok[i] ){
				aa-=table[i];
				cout << i;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	s := make([]string, h)
	rm := make(map[int]bool, 0)
	rc := make(map[int]bool, 0)
	for i := range s {
		fmt.Scan(&s[i])
		if strings.Count(s[i], "#") > 0 {
			rm[i] = true // i行目は生き残る
			for j := 0; j < w; j++ {
				if s[i][j] == '#' {
					rc[j] = true // j列目は生き残る
				}
			}
		}
	}
	for i := 0; i < h; i++ {
		if rm[i] {
			for j := 0; j < w; j++ {
				if rc[j] {
					fmt.Print(string(s[i][j]))
				}
			}
			fmt.Println()
		}
	}
}


Measured memory_bytes: 896
#include <iostream>
#include <string>

using namespace std;

int main(){

	int A = 0, B = 0, K = 0;

	cin >> A >> B >> K;

	for (int i = A; i <= B; ++i) {
		if (i < A + K || i >= B - K + 1){
			cout << i;
			if (i != B) {
				cout << std::endl;
			}
		}
	}

	return 0;
}

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

int main(){

    //入力
    int l,r; cin >> l >> r;

    int ans = 2019;

    if(r-l >= 2019){
        cout << 0 << endl;
        return 0;
    }else{
        for(int i = l%2019; i < r-l+(l%2019); i++){
            for(int j=i+1; j<r-l+(l%2019)+1; j++){
                ans = min(ans,(i*j)%2019);
            }   
        }
    }

    //表示
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0 ; i < N; i++){
        cin >> A[i];
    }
    bool ans = true;
    for(int i = 0; i < N; i++){
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0 && A[i] % 5 != 0){
                ans = false;
            }
        }
    }
    if(ans == true){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

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


int main() {
	char s[5];
	cin >> s;
	int a = s[0] - '0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] - '0';

	if (a + b + c + d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7";
	else if (a + b + c - d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7";
	else if (a + b - c - d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7";
	else if (a - b - c - d == 7) cout << a << '-' << b << '-' << c << '-' << d << "=7";
	else if (a - b - c + d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7";
	else if (a - b + c + d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7";
	else if (a - b + c - d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7";
	else if (a + b - c + d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  int L[N];
  int cnt = 1;
  int D = 0;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  for (int i = 0; i < N; i++) {
    if (D + L[i] <= X) {
      cnt++;
    }
    D = D + L[i];
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <time.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define repi(a,b) for (int i=a;i<=b;i++)
#define repj(a,b) for (int j=a;j<=b;j++)
#define N 200005
#define oo 10000000000000000ll
#define ll long long 

int n;
int a[N];
ll pre[N],ans=oo;

ll Min(ll a,ll b)
{
	return a<b?a:b;
}

ll ABS(ll a)
{
	if (a>=0ll) return a;
	else return -a;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n;
	repi(1,n){
		cin>>a[i];
		pre[i]=pre[i-1]+a[i];
	}
	
	repi(1,n-1)
	{
		ll t1=pre[i];
		ll t2=pre[n]-pre[i];
		
		//cout<<t1<<' '<<t2<<endl;
		
		//cout<< (ABS(t1-t2)) <<endl;
		
		ans=Min(ABS(t1-t2),ans);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] s = new char[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                s[i][j] = str.charAt(j);
            }
        }
        int ans = 0;
        int dy[] = {1, -1, 0, 0};
        int dx[] = {0, 0, 1, -1};
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '#') continue;
                int[][] maze = new int[h][w];
                for (int k = 0; k < h; k++) {
                    for (int l = 0; l < w; l++) {
                        maze[k][l] = -1;
                    }
                }
                maze[i][j] = 0;
                Queue<Point> q = new ArrayDeque<>();
                q.add(new Point(i, j));
                while (q.size() > 0) {
                    Point p = q.poll();
                    int y = p.first, x = p.second;
                    for (int k = 0; k < 4; k++) {
                        int ny = y + dy[k], nx = x + dx[k];
                        if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.' && maze[ny][nx] == -1) {
                            maze[ny][nx] = maze[y][x] + 1;
                            q.add(new Point(ny, nx));
                        }
                    }
                }
                int ma = 0;
                for (int k = 0; k < h; k++) {
                    for (int l = 0; l < w; l++) {
                        ma = Math.max(ma, maze[k][l]);
                    }
                }
                ans = Math.max(ans, ma);
            }
        }
        System.out.println(ans);
    }
}

class Point {
    public int first, second;
    Point(int y, int x) {
        this.first = y;
        this.second = x;
    }
}

Measured memory_bytes: 25960
#ワシャフ
INF = 10**9

H,W = map(int,input().split())

#iからjにするのに必要な魔力量
c = [list(map(int,input().split())) for i in range(10)]

dp = [[(INF if i!=j else 0) for j in range(10)]for i in range(10)]
for k in range(0,10,1):
    for i in range(0,10,1):
        for j in range(0,10,1):
            c[i][j] = min(c[i][j],c[i][k]+c[k][j])


A = [list(map(int,input().split())) for i in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j]>-1:
            ans += c[A[i][j]][1]
print(ans)

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

const int LIMIT = 100000;

int main(int argc, const char * argv[]) {
    int isPrime[LIMIT] = {0};
    int Q;
    
    for (int i = 2; i < LIMIT; i++) {
        isPrime[i] = 1;
    }
    
    for (int i = 2; i < (int)sqrt(LIMIT); i++) {
        if (isPrime[i] == 1) {
            for (int j = 2 * i; j < LIMIT; j++) {
                if (j % i == 0) isPrime[j] = 0;
            }
        }
    }
    
    vector<int> a(LIMIT, 0);
    for (int i = 2; i < LIMIT; i++) {
        if (isPrime[i] == 1) {
            if (isPrime[(i + 1) / 2]) a[i] = 1;
        }
    }
    
    vector<int> sum(LIMIT + 1, 0);
    
    for (int i = 0; i < sum.size(); i++) {
        sum[i + 1] = sum[i] + a[i];
    }
    
    cin >> Q;
    
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << sum[r + 1] - sum[l] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
# coding: utf-8

list = []

while True:
    num = input().rstrip().split(" ")
    if (int(num[0]) == 0) and (int(num[1]) == 0):
        break
    list.append(num)

for i in range(len(list)):
    for j in range(int(list[i][0])):
        if (j == 0) or (j == (int(list[i][0])-1)):
            print("#"*int(list[i][1]))
        else:
            print("#" + "."*(int((list[i][1]))-2) + "#")
    print()

Measured memory_bytes: 7600
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
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(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#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) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
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<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 m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

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



int n, x;

signed main() {
	cin >> n >> x;
	cout << (n - gcd(n,x))*3 << endl;
}


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

int main()
{
    char c;

    for (;;) {
       scanf("%c", &c);

        if (c == '\n') {
            printf("%c",c);
            break;
        }
        else if ('a' <= c && c <= 'z') {
            printf("%c", c - 32);
        }
        else if ('A' <= c && c <= 'Z'){
            printf("%c",c+32);
        }
        else {
            printf("%c",c);
        }
    }
    
    return 0;
}


Measured memory_bytes: 3156