akhauriyash/Code-Regression huggingface dataset:
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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() {

    ll R = 0;
    ll G = 0;
    ll B = 0;
    
    int N;
    string S;
    cin >> N >> S;
    for (auto x: S) {
        if (x == 'R') R++;
        else if (x == 'G') G++;
        else B++;
    }


    ll sub = 0;
    REP(i, N - 1) {
        FOR(j, i + 1, N) {
            ll k = 2 * j - i;
            if (k <= j || k > N - 1) continue;

            if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) sub++;
        }
    }

    ll ans = R * G * B - sub;
    cout << ans << endl;


#ifdef _MSC_VER
    system("PAUSE");
#endif

    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

static const int MAX = 1e6;
// static const int NIL = -1;
static const int INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> div;
    for(int in=1;in<=MAX;in*=6) {
        div.push_back(in);
    }
    for(int in=9;in<=MAX;in*=9) {
        div.push_back(in);
    }

    vector<int> dp(n+1, INF);
    dp.at(0) = 0;
    for(int in=1;in<=n;in++) {
        for(auto d:div) {
            if(in-d>=0) dp.at(in) = min(dp.at(in), dp.at(in-d)+1);
        }
    }

    cout << dp.at(n) << endl;

    return 0;
}


Measured memory_bytes: 640
import heapq
from collections import defaultdict
N, K = map(int, input().split())

sushi = defaultdict(list)
for i in range(N):
    t, d = map(int, input().split())
    sushi[t].append(d)

# 各種類で最大のもの
P = []
# Pに入らなかったもの
Q = []

for k in sushi.keys():
    # 最大のものだけ
    sushi[k].sort(reverse=True)
    P.append(sushi[k][0])
    for x in sushi[k][1:]:
        Q.append(-x)

# heapqで最小値を扱う
heapq.heapify(P)
# heapqで最大値を扱う
heapq.heapify(Q)

cur = 0
# 全種類食べることが出来る場合
if K >= len(sushi.keys()):
    max_variation = len(sushi.keys())
    # 全種類について、最大のものを食べる
    cur += sum(P)
    # まだ食べられるので、Qを大きい方から食べる
    for _ in range(K - max_variation):
        cur += -heapq.heappop(Q)
    ans = cur + max_variation**2
# 全種類食べることが出来ない場合
else:
    # 最大値が大きい方からからK種類だけPに残す
    # 選べなかったものはQに突っ込む
    while len(P) > K:
        m = heapq.heappop(P)
        heapq.heappush(Q, -m)
    max_variation = K
    cur += sum(P)
    ans = cur + max_variation**2

# max_variation-1, ..., 1種類食べるとき
for i in range(max_variation - 1, 0, -1):
    # Pのうち、最小のものは一旦諦める
    p = heapq.heappop(P)
    cur -= p

    # 諦めたものをQに入れる
    heapq.heappush(Q, -p)
    q = -heapq.heappop(Q)
    cur += q
    ans = max(ans, cur + i**2)

print(ans)


Measured memory_bytes: 102608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] xs = new double[N];
        double[] ys = new double[N];
        double l = 0;
        for (int i = 0; i < N; i++) {
            xs[i] = sc.nextInt();
            ys[i] = sc.nextInt();
//            double xy = Math.sqrt((x - preX) * (x - preX) + (y - preY) * (y - preY));
        }
        double NN = 1;
        for (double i = 1; i < N + 1; i++) {
            NN *= i;
        }
        double c = NN/N;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i == j) continue;
                double tmp = Math.sqrt((xs[i] - xs[j]) * (xs[i] - xs[j])
                        + (ys[i] - ys[j]) * (ys[i] - ys[j]));
                l += tmp * c;
            }
        }

        System.out.println(l / NN);
    }
}

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

int main(){
  int n, m, l;
  cin >> n >> m >> l;

  int A[n][m] = {};
  int B[m][l] = {};
  long long C[n][l] = {};

  for( int i = 0; i < n; i++) {
    for( int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }

  for( int j = 0; j < m; j++) {
    for( int k = 0; k < l; k++) {
      cin >> B[j][k];
    }
  }

  for( int i = 0; i < n; i++) {
    for( int j = 0; j < m; j++) {
      for( int k = 0; k < l; k++){
        C[i][k] += A[i][j] * B[j][k];
      }
    }
  }

  for( int i = 0; i < n; i++){
    for( int k = 0; k < l; k++) {
      if(k) cout << " ";
      cout << C[i][k];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3244
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=10**10
for i in range(n-k+1):
    ans=min(ans,abs(x[i])+abs(x[i+k-1]-x[i]))
    ans=min(ans,abs(x[i+k-1])+abs(x[i+k-1]-x[i]))
print(ans)

Measured memory_bytes: 14568
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int R,G,B,N;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> R >> G >> B >> N;
  int ans = 0;
  REP(i,3010) REP(j,3010) {
    int rem = N-i*R-j*G;
    if (rem >= 0 && rem % B == 0) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

            ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
int main()
{
    FAST
    int n;
    cin>>n;
   map<int,int>m;
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                for(int l=1;l<=100;l++){
                    int temp=((j*j)+(k*k)+(l*l)+(j*k)+(k*l)+(j*l));
                    m[temp]++;
                }
            }
        }
        for(int i=1;i<=n;i++)
            cout<<m[i]<<endl;

    return 0;
}


Measured memory_bytes: 5392
#include <iostream>
#include <vector>

using namespace std;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int ans = 11;
vector<vector<int>> mp;
void dfs(int i, int j, int direction, int num){
	while(mp[i+dx[direction]][j+dy[direction]] == 0){
		i += dx[direction];
		j += dy[direction];
	}
	if(mp[i+dx[direction]][j+dy[direction]] == 3){
		ans = min(num,ans);
		return;
	}
	if(mp[i+dx[direction]][j+dy[direction]] == 1 && num < 10){
		mp[i+dx[direction]][j+dy[direction]] = 0;
		for(int k = 0;k<4;k++){
			if(mp[i+dx[k]][j+dy[k]] == 1)continue;
			if(mp[i+dx[k]][j+dy[k]] == -1)continue;
			dfs(i,j,k,num+1);
		}
		mp[i+dx[direction]][j+dy[direction]] = 1;
	}
}


int main(){
	int w,h;
	while(cin>>w>>h,w){
		mp.resize(h+2,vector<int>(w+2,-1));
		int def_i,def_j;
		for(int i = 1;i < h+1;i++){
			for(int j = 1;j < w+1;j++){
				cin >> mp[i][j];
				if(mp[i][j] == 2){
					def_i = i;
					def_j = j;
				}
			}
		}
		mp[def_i][def_j] = 0;
		for(int i = 0;i < 4;i++){
			if(mp[def_i+dx[i]][def_j+dy[i]] != 0 && mp[def_i+dx[i]][def_j+dy[i]] != 3)continue;
			dfs(def_i,def_j,i,1);
		}
		if(ans == 11)cout << -1 << endl;
		else cout << ans << endl;
		ans = 11;
		mp.clear();
	}
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> mp;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, N;
  cin >> H >> W >> N;
  int count[10];
  for(int i = 0; i < 10; i++){count[i] = 0;}
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    pair<int, int> p = pair<int, int>(a, b);
    for(int dh = -1; dh < 2; dh++){
      for(int dw = -1; dw < 2;dw++){
        int h = a + dh;
        int w = b + dw;
        if (!((h > 1) && (h < H) && (w > 1) && (w < W))){continue;}
        pair<int,int> p = pair<int, int>(h,w);
        if(mp[p]){
          mp[p] += 1;
        }
        else{
          mp[p] = 1;
        }
      }
    }
  }
  for(map<pair<int,int>,int>::iterator itr = mp.begin(); itr != mp.end(); itr++){
    count[itr->second] += 1;
  }
  unsigned long long zero = H - 2;
  zero *= W - 2;
  for(int i = 1; i < 10; i++){
    zero -= count[i];
  }
  cout << zero << endl;
  for(int i = 1; i < 10; i++){
    cout << count[i] << endl;
  }
}


Measured memory_bytes: 56448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

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

    bool yymm = false;
    bool mmyy = false;
    int up = s / 100;
    int down = s % 100;
    if (1 <= up && up <= 12)
        mmyy = true;
    if (1 <= down && down <= 12)
        yymm = true;

    if (yymm && mmyy)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (yymm)
    {
        cout << "YYMM" << endl;
    }
    else if (mmyy)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int main(){

	vector<int>t;
	int n,a,b,c,d;
	cin >> n >> a >> b >> c;
	rep(i,n){
	cin >> d;
	t.push_back(d);
	}

	sort(t.begin(),t.end(),greater<int>());

	int m=c/a;
	rep(i,n){
		c+=t[i];
		if(c/(a+(i+1)*b)>m) m=c/(a+(i+1)*b);
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll solve() {
	var(int, n);
	vec(ll, a, n);
	sort(all(a));
	int c0 = n / 2 - 1, c1 = n / 2, c2 = n / 2 + 1;
	ll ans = 0;
	rep(i, 0, c0) {
		ans -= a[i] * 2;
	}
	rep(i, c2 + 1, n) {
		ans += a[i] * 2;
	}
	if (n & 1) {
		ans += - a[c0] + a[c2] + max(-a[c0] + a[c1], - a[c1] + a[c2]);
	} else {
		ans += - a[c0] + a[c1] + a[c2] * 2;
	}
	return ans;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;

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

    int count = 0;
    for(int i = 0; i < n; i++){
      int min = numbers[i];
      int minind = i;
      for(int j = i+1; j < n; j++){
        if(min > numbers[j]){
          min = numbers[j];
          minind = j;
        }
      }
      if(i == minind){continue;}
      int keep = numbers[i];
      numbers[i] = numbers[minind];
      numbers[minind] = keep;
      count++;
    }

    for(int i = 0; i < n-1; i++){
      System.out.print(numbers[i]); System.out.print(" ");
    }
    System.out.println(numbers[n-1]);
    System.out.println(count);
  }
 
  
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
//   setsu[i] = new LinkedList<Integer>();
// } 

 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 16856
#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);
    
    string str;
    cin >> str;
    vector<ll> a(str.size());
    for(int i = 0; i < str.size(); i++){
        a[i] = str[i] - '0';
    }

    ll ans = 133333333333;
    for(int i = 0; i < str.size() - 2; i++){
        ll t = 0;
        for(int j = i; j < i+3; j++){
            t *= 10;
            t += a[j];
        }
        ans = min(ans,abs(753-t));
    }

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

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


D,T,S = MI()
print('Yes' if S*T >= D else 'No')


Measured memory_bytes: 61756
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>
using namespace std;

int main(void){
    // Your code here!
    int h, w;
    
    cin >> h >> w;
    for(int i = 0; i < h + 2; i++){
        if(i == 0 || i == h + 1){
            for(int j = 0; j < w + 2; j++)
                cout << '#';
            cout << endl;
        }
        else{
            string temp;
            cin >> temp;
            cout << '#' << temp << '#' << endl;
        }
    }
    
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t,flag=0,cnt=0;
    cin>>t;
    int a[t];
    for(int j=0;j<t;j++)
    {
        cin>>a[j];
    }

    int x=0;
            while(1)
            {
                if(x==t){x=0;cnt++;}
                if(a[x]%2==0){a[x]=a[x]/2;}
                else if(a[x]%2!=0) {break;}
                x++;
            }

 cout<<cnt;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    char a[200][200],b[200][200];
    int n,m,i,j,k,max=0,sum1,sum2,sum,pi;
    while(scanf("%d",&n)==1&&n>=1)
    {
        sum1=0,sum2=0,max=0;
        getchar();
        for(i=0;i<n;i++)
        {
            scanf("%s",a[i]);
        }
        scanf("%d",&m);
        if(m<1)
            break;
        getchar();
        for(i=0;i<m;i++)
        {
            scanf("%s",b[i]);
        }
        for(i=0;i<n;i++)
        {
            sum1=0,sum2=0;
            for(j=i;j<n;j++)
            {
                pi=1;
                for(k=0;a[i][k]||a[j][k];k++)
                {
                    if(a[i][k]!=a[j][k])
                        pi=0;
                }
                if(pi)
                    sum1++;
            }
            for(j=0;j<m;j++)
            {
                pi=1;
                for(k=0;a[i][k]||b[j][k];k++)
                {
                    if(a[i][k]!=b[j][k])
                        pi=0;
                }
                if(pi)
                    sum2++;
            }
            sum=sum1-sum2;
            max=sum>max?sum:max;
        }
        printf("%d\n",max);
    }
    return 0;
}


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

int main() {
	long long s;
	cin >> s;
	int ans = 753;
	while (s >= 111) {
		ans = min(ans, (int) abs(753 - s % 1000));
		s /= 10;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
a = na()

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

l = a[0]
for i in range(n):
    l = lcm(a[i], l)
ans = 0
for i in range(n):
    ans += l // a[i]

ans %= 1000000007
print(ans)

Measured memory_bytes: 4084
#include <iostream>
#include<vector>

using namespace std;

int main()
{

    int X, N;
    vector<bool> isExist(101, false);
    cin >> X >> N;

    int Nmin = X;
    int Nmax = X;

    for (int i = 0; i < N; i++){
        int p;
        cin >> p;
        isExist[p] = true;
    }

    int Xmin = X;
    int Xmax = X;
    int dmin = 0;
    int dmax = 0;

    while(true){
        if(isExist[Xmin]){
            Xmin--;
            dmin++;
        }else{
            break;
        }
    }
    while (true)
    {
        if (isExist[Xmax])
        {
            Xmax++;
            dmax++;
        }
        else
        {
            break;
        }
    }

    if(dmax >= dmin){
        cout << Xmin << endl;
    }else{
        cout << Xmax << endl;
    }
}

Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


a, b, c = inl()


def solve():
    ans = min(
        [
            abs((a // 2) - (a - a // 2)) * b * c,
            abs((b // 2) - (b - b // 2)) * a * c,
            abs((c // 2) - (c - c // 2)) * b * a,
        ]
    )
    return ans


print(solve())


Measured memory_bytes: 9108
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll arr[n+1];
    for(int i=0;i<n;++i)
    {
        cin >> arr[i];
    }

    ll max_abs = -1;

    for(int i=0;i<n;++i)
    {
        for(int j=i+1; j<n; ++j)
        {
            max_abs = max(max_abs, abs(arr[i] - arr[j]));
        }
    }

    cout << max_abs << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(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());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd

int main() {
	ll N, X;
	cin >> N >> X;
	ll *x = new ll[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		x[i] = abs(X - x[i]);
	}
	ll gc = x[0];
	for (int i = 0; i < N; i++) {
		gc = gcd(gc, x[i]);
	}
	cout << gc;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

int N, M;
int ct[100000];
bool used[100000];
vector<vector<int>> edge;
vector <int> edge_4th;

bool f(int pos, int goal, int banned, int CT) {
	if (pos == goal && CT >= 2) {
		return true;
	}
	CT++;
	used[pos] = true;
	for (int i = 0; i < edge[pos].size(); i++) {
		if (edge[pos][i] != banned) {
			if (!used[edge[pos][i]] || (used[edge[pos][i]] && edge[pos][i] == goal && CT >= 3)) {
				if (f(edge[pos][i], goal, banned, CT))return true;
			}
		}
	}
	return false;
}

int main() {
	cin >> N >> M;
	bool isok = false;
	edge.resize(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ct[a]++, ct[b]++;
	}
	int ct6 = 0, ct4 = 0;
	for (int i = 0; i < N; i++) {
		if (ct[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
		if (ct[i] >= 6)ct6++;
		if (ct[i] >= 4)ct4++, edge_4th.push_back(i);
	}

	if (ct4 == 2) {
		if (f(edge_4th[0], edge_4th[0], edge_4th[1], 0))isok = true;
	}

	if (ct6 >= 1 || ct4 >= 3 || isok)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    ll a,b,t,ans=0;
    cin>>a>>b>>t;
    int i=1;
    while(1){
        if(i*a>t)break;
        else{
            ans+=b;
            i++;
        }
    }
    
    cout<<ans<<endl;
}
   



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/detail/standard_policies.hpp>

// common
#define endl     "\n"
#define M_PI     3.14159265358979323846

// fast input output
#define fast_io  ios_base::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL)

// fixed float field
#define fix_prec cout.setf( std::ios::fixed, std:: ios::floatfield ); cout.precision(9);

// vector
#define vi       vector<int>
#define vvi      vector<vector<int>>
#define vpii     vector<pair<int,int>>
#define pb(v,x)  v.push_back(x)

// pair
#define pii      pair<int,int>
#define mp(a,b)  make_pair(a,b)
#define F        first
#define S        second

// sort
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()

// bound
#define lb(v,x)  lower_bound(v.begin(),v.end(),x)
#define ub(v,x)  upper_bound(v.begin(),v.end(),x)

using namespace std;
//using namespace __gnu_pbds;

//typedef tree < int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
typedef long long int lli;
typedef unsigned long long int ulli;

// constants
lli const mod  = 1e9+7;
lli const modl = 1e18;

// helper functions
// calculate gcd
lli gcd(lli x, lli y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

// calculate fibonacci number
lli fib(int n)
{
    lli a,b,c,i;
    a=0,b=1;
    if(n == 0)
        return a;
    for(i=2;i<=n;i++)
    {
    	c=a+b;
    	a=b;
    	b=c;
    }
    return b;
}

// check if number if prime
bool isprime(lli n)
{
	if(n<=1)
		return false;
	else if(n==2)
		return true;
	else if(n%2==0)
		return false;
	else
	{
		int i;
		for(i=3;i*i<=n;i++)
		{
			if(n%i==0)
				return false;
		}
		return true;
	}
}

// read from and write to text file
void readwrite()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
} 

// seive
vector<lli>prime(100000+7,1);
void buildprime(lli n)
{
	lli i,j;
	prime[0]=prime[1]=0;
	for(i=2;i*i<=n;i++)
	{
		if(prime[i])
		{
			for(j=i*i;j<=n;j+=i)
				prime[j]=0;
		}
	}
}

// nCr
lli dp[1005][1005];
lli comb[1005][1005];
lli ncr(lli n,lli r)
{
	if(n==r)
		return 1;
	if(r==0)
		return 1;
	if(r==1)
		return n;
	if(dp[n][r]!=0)
		return dp[n][r];
	return dp[n][r] = (ncr(n-1,r)%mod+ncr(n-1,r-1)%mod)%mod;
}

void ncrm()
{
	comb[0][0]=1;
	for(int i=1;i<1001;i++)
	{
		comb[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			comb[i][j]=(comb[i-1][j]%mod+comb[i-1][j-1]%mod)%mod;
		}
	}
}

// binary exponentiation
lli binpowm(lli a,lli b)
{
	lli res=1;
	a%=mod;
	while(b)
	{
		if(b&1)
			res=((res%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return res%mod;
}
 
// factorial
lli fact(lli n)
{
	lli i,res=1;
	for(i=1;i<=n;i++)
		res=((res%mod)*(i%mod))%mod;
	return res%mod;
}

// driver code
void solve()
{
	lli n,ans=0;
	cin>>n;
	ans=(n*(n-1))/2;
	cout<<ans;
}

int main()
{
  fast_io;
  fix_prec;
  //readwrite();
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
    cout<<endl;     
  }
  return 0;	
}

/*
Kab Khoon khaulega tera jab sabka internship lag jayega tab
Shame on you if you do not get internship
*/

Measured memory_bytes: 3800
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;

int MAXN = 100000;
int main(){
  char st[MAXN+10];
  while(cin>>st){
    int n = strlen(st);
    int i;
    for(i=0; i<n ; i++){
      if(st[i] == 'b' && st[n-i-1] == 'd' ||
         st[i] == 'd' && st[n-i-1] == 'b' ||
         st[i] == 'p' && st[n-i-1] == 'q' ||
         st[i] == 'q' && st[n-i-1] == 'p')continue;
      break;
    }
    if(i<n)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
cout << fixed << setprecision(10);
ll n,k;
cin>>n>>k;
ll s[100005]={};
ll a,b;
ll ca=0;
for(ll i=0; i<n; i++){
cin>>a>>b;
s[a]+=b;}
for(ll i=0; i<=100000; i++){
ca+=s[i];
if(ca>=k){
cout<<i<<endl;
break;}}}


Measured memory_bytes: 4336
#include <stdio.h>
int main() {
	int H, W, i, j;
	scanf("%d %d", &H, &W);
	int max_H = H + 2;
	int max_W = W + 2;
	char pic[max_H][max_W];
	for (i = 1; i <= H; i++) {
		scanf("%s", pic[i]);
	}
	for (i = 0; i < max_H; i++) {
		printf("#");
		for (j = 0; j <= W; j++) {
			if (i == 0 || i == max_H - 1 || j == W){
				printf("#");
			} else if(j == 0) {
				printf("%s", pic[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)


let (n,x) = ParseInt2 <| Console.ReadLine()
let cs = ParseIntN <| Console.ReadLine()
let work = Array.copy cs

work.[0] <- min work.[0] x
[1..n-1] |> List.iter (fun i -> work.[i] <- work.[i] + min 0 (x - (work.[i-1] + work.[i])))

Array.zip cs work
|> Array.fold (fun acc (a,b) -> acc + (abs >> int64)(a-b)) 0L
|> Console.WriteLine


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

using namespace std;

#define int long long
#define N 100005

int n, m, p[N], a[N], b[N], c[N], cnt[N];
int ans = 0;

signed main ()
{
	ios_base::sync_with_stdio (0);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i)
	{
		cin >> p[i];
		if (i > 1)
		{
			if (p[i - 1] >= p[i])
			{
				for (int j = p[i]; j < p[i - 1]; ++j)
					cnt[j]++;
			}
			else
			{
				for (int j = p[i - 1]; j < p[i]; ++j)
					cnt[j]++;
			}
		}
	}
	
	for (int i = 1; i < n; ++i)
		cin >> a[i] >> b[i] >> c[i];
	for (int i = 1; i < n; ++i)
	{
		ans += min (a[i] * cnt[i], c[i] + b[i] * cnt[i]);
	}
		
	cout << ans << "\n";
}

Measured memory_bytes: 7016
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class B1DimensionalWorldsTale {
public:
	void solve(istream& in, ostream& out) {
        int n, m, X, Y; in >> n >> m >> X >> Y;
        vector<int> x(n), y(m);
        rep(i,n) in >> x[i];
        rep(i,m) in >> y[i];
        sort(x.begin(),x.end());
        sort(y.begin(),y.end());

        bool ok = true;
        for(int z = X + 1;z <= Y;z++){
            if(x[n-1] < z && z <= y[0]){
                ok = false;
                out << "No War" << endl;
                break;
            }
        }
        if(ok) out << "War" << endl;
	}
};

int main() {
	B1DimensionalWorldsTale solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc065a()
}

fun abc065a() {
    val (x, a, b) = readLine()!!.split(" ").map { it.toInt() }

    val answer = if (b <= a) "delicious" else if (b - a <= x) "safe" else "dangerous"

    println(answer)
}


Measured memory_bytes: 37864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline void chmin(T &a, T b){if(a>=b)a=b;}
template<class T> inline void chmax(T &a, T b){if(a<=b)a=b;}
typedef long long ll;
const int INF = 1e9;

string N;

int main(){
    cin >> N;
    int sum = 0;
    REP(i,N.size()) sum += N[i] - '0'; 
    int numN = atoi(N.c_str());
    cout << (numN % sum ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int N;
int A[200000];
int B[200000];
long long C[200000];

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i];
    B[A[i]-1] = i;
  }
  set<int> g;
  for (int i=0; i<N; i++) {
    long long s = 0;
    auto it = g.upper_bound(B[i]);
    if (it != g.end()) {
      int x = *it;
      s = (long long)(i+1) * (x-B[i]) + C[x];
    }
    else {
      s = (long long)(i+1) * (N-B[i]);
    }
    C[B[i]] = s;
    g.insert(B[i]);
  }
  long long s = 0;
  for (int i=0; i<N; i++) s += C[i];
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	private static int head = 0;// キューの先頭ポインタ
	private static int tail = 0;// キューの末尾ポイント
	private static final int MAX = 100005; // 制約のプロセス数が10万なので少し多めに。
	private static Process[] queue = new Process[MAX];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		// すべてのプロセスをキューに追加
		for (int i = 0; i < n; i++) {
			String name = sc.next();
			int time = sc.nextInt();
			Process p = new Process(name, time);
			queue[i] = p;
		}
		tail = n;
		// すべてのプロセスが完了する（＝キューが空になる）まで実行
		int elaps = 0; // 経過時間
		while (!(head == tail)) {
			Process p = dequeue();
			/*
			if (p.time > q) {
				p.time = p.time - q;
				enqueue(p);
				elaps += q;
			} else {
				elaps += p.time;
				System.out.println(p.name + " " + elaps);
			}
			*/
			int mint = Math.min(p.time, q);
			p.time -= mint;
			elaps += mint;
			if (p.time > 0) {
				enqueue(p);
			} else {
				System.out.println(p.name + " " + elaps);
			}
		}

	}

	private static void enqueue(Process p) {
		// 中身が満タンでないことを判定
		if ((tail + 1) % MAX == head) {
			System.err.println("エラー（オーバーフロー）");
		} else {
			queue[tail] = p;
			tail = (tail + 1) % MAX;
		}
	}

	private static Process dequeue() {
		// 中身が空じゃないことを判定
		Process ret = null;
		if (head == tail) {
			System.err.println("エラー（アンダーフロー）");
		} else {
			ret = queue[head];
			head = (head + 1) % MAX;
		}
		return ret;

	}

}

class Process {
	String name;
	int time;

	public Process(String name, int time) {
		this.name = name;
		this.time = time;
	}

}


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

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

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

	ll X,Y; cin >> X >> Y;
	ll ans = 0;

	while(X <= Y){
		X *= 2;
		ans++;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,cnt=0;
  cin>>N;
  string s[N];
  for(int i=0;i<N;i++) cin>>s[i];
  for(int i=0;i<N-1;i++){
    if(s[i][s[i].size()-1]!=s[i+1][0]){
      cnt++;
    }
  } 

  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(s[i]==s[j]) cnt++;
    }
  }
  
  if(cnt>0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  
}


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

int main() {
    char cards[201], subbuff1[201], subbuff2[201];
    int m, h, len, i;
    while (scanf("%s", cards) && strcmp(cards, "-")) {
        len = strlen(cards);
        scanf("%d", &m);
        for (i = 0; i < m; i++) {
            scanf("%d", &h);
            strncpy(subbuff1, cards, h);
            subbuff1[h] = '\0';
            memcpy(subbuff2, &cards[h], len - h);
            subbuff2[len - h] = '\0';
            strcpy(cards, strcat(subbuff2, subbuff1));
        }
        printf("%s\n", cards);
    }
    return 0;
}

Measured memory_bytes: 620
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] emp = new int[n];
		for(int i = 0; i < n-1; i++){
			emp[sc.nextInt() - 1] ++;
		}
		for(int i = 0; i < n; i++){
			System.out.println(emp[i]);
		}
		
	}
}

Measured memory_bytes: 61848
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;

int F(ll a, ll b) {
	int digit_a = 0, digit_b = 0;

	while (a >= 1) {
		a = a / 10;
		digit_a++;
	}

	while (b >= 1) {
		b = b / 10;
		digit_b++;
	}

	int res = digit_a > digit_b ? digit_a : digit_b;

	return res;
}

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

    int ans = 100;
    for (ll i = 1; i * i <= N; ++i) {
    	if (N % i == 0) {
    		ll div = N / i;
    		int max_digit = F(i, div);
    		if (max_digit < ans) ans = max_digit;
    	}
    }

    cout << ans << endl;
}


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

int main(int argc, char *argv[])
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    long double max_ratio = -1;
    int m = 0;
    int s = 0;
    for(int a = 0; 100*A*a <= F; ++a)
    {
        for(int b = 0; 100*B*b + 100*A*a <= F; ++b)
        {
            const int water = 100*B*b + 100*A*a;
            for(int c = 0; water + c*C <= F; ++c)
            {
                for(int d = 0; water + c*C + d*D <= F; ++d)
                {
                    const int sugar = c*C + d*D;
                    if(100*sugar > water * E) continue;
                    if(sugar + water == 0) continue;

                    long double ratio = (long double)sugar / (water + sugar);
                    if(ratio > max_ratio)
                    {
                        max_ratio = ratio;
                        m = water + sugar;
                        s = sugar;
                    }
                }
            }
        }
    }
    cout << m << ' ' << s << endl;
}


Measured memory_bytes: 256
/* ファイル名：ITP1_9_A.c	*/
/* 内容：１つの単語 W を文章 T の中から探し出し、その数を数える。	*/

/* include	*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:１つの単語 W を文章 T の中から探し出し、その数を数える。	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	char W[11];		/* 文章の中から探す単語	*/
	char T[1001];	/* 文章					*/
	
	/* 処理	*/
	char end[12] = "END_OF_TEXT";	/* 入力の終わりを表す文字列	*/
	int i;			/* ループ用変数				*/
	/* 出力	*/
	int cnt;		/* 単語の数をカウントする変数	*/
	
	cnt = 0;				/* カウントの初期化	*/
	
	scanf("%s",W);			/* 探す単語の入力	*/
	
	/* 無限ループ	*/
	while(1){
		/* Tの入力	*/
		scanf("%s",T);
		
		/* 入力の終わりの文字列が来た場合	*/
		if(strcmp(end,T) == 0){
			break;	/* 入力を終了する	*/
		}
		/* 入力の終わりの文字列ではなかった場合	*/
		else{
			/* 処理なし	*/
		}
		
		/* Tを小文字に変換*/
		for(i = 0;T[i];i++){
			T[i] = tolower(T[i]);
		}
		
		/* Tが探す単語だった場合*/
		if(strcmp(T,W) == 0){
			cnt++;
		}
		else{
			/* 処理なし	*/
		}
	}
	
	printf("%d\n",cnt);	/* 見つかった単語の数を出力	*/
	
	
	return 0;
}



Measured memory_bytes: 2104
fn main() {
    // N
    let _ = read_line::<u32>();
    // H
    let h = read_vec::<u32>();
    solve(h);
}

fn solve(h:Vec<u32>) {
    
    let mut before_small: u32 = 0; // 小さい
    let mut before_large:u32 = 0; // でかい
    let mut ans = "Yes";
    for now_h in h.into_iter() {
        if before_small > now_h {
            ans = "No";
            break;
        }else {
            if before_small == now_h {
                before_small = now_h;
            }else if before_large <= now_h {
                before_small = now_h - 1;
            }else{
                ans = "No";
                break;
            }
            before_large = now_h;
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 300300
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};


    int main()
    {
        int n;
        cin>>n;
        vector<int> a(n,0);
        int sum=0;
        REP(i,n)
        {
            cin>>a[i];
            sum+=a[i];
        }
        cout<<sum-n<<endl;
    }



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, MAX, sum;
int cost[20][20];
int f[20];

int dfs(int n){
  int dis = 0;
  int ret = 0;
  int c = 0;

  rep(i, N) if(cost[n][i] && f[i]) dis = cost[n][i];
  sum += dis;
  rep(i, N) if(cost[n][i] && !f[i]) c++;
  if(!c){ sum -= dis; return ret;}

  //  printf("%d\n", dis);
  rep(i, N){
    if(!cost[n][i] || f[i]) continue;
    f[i] = 1;
    ret = max(ret, dfs(i));
  }
  //  printf("%d\n", ret);
  return ret+dis;
}

int main(){
  int a, b, t;
  while(scanf("%d", &N) && N){
    MAX = 0, sum = 0;
    memset(cost, 0, sizeof(cost));
    memset(f, 0, sizeof(f));
    rep(i, N-1){
      scanf("%d%d%d", &a, &b, &t);--a;--b;
      cost[a][b] = cost[b][a] = t;
    }
    f[0] = 1;
    int res = dfs(0);
    printf("%d\n", 2*sum- res);
  }
  return 0;
}

Measured memory_bytes: 1188