akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <string>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void tenka1_2018_a(vector<vector<string>> v) {

    string s = v[0][0];

    if (s.size() != 2) {
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
}

int main() {

    vector<vector < string>> vec_arr_result;
    //    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata();

    tenka1_2018_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}

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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(a>0 and 	c>0){
		c-=b;
		if(c>0) a-=d;
	}
	if(a>0) cout <<"Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int modPow(long long a, long long n, long long p) {
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin >> k;
    ll a=7;
    rep(i,1000000){
        if(a%k==0){
            cout<<i+1<<endl;
            return 0;
        }
        a+=modPow(10,i+1,k)*7;
        a%=k;
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    int now=1,ans=0;
    rep(i,N){
        if (A[i]!=now) ++ans;
        else ++now;
    }
    if (ans==N) cout << -1 << endl;
    else cout << ans << endl;
}

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

int main(){
	int N, M, i, ans = 0, penaruty = 0;
	scanf("%d%d", &N, &M);
	vector<int> WA_count(N, 0), was_AC(N, 0);
	for(i = 0; i < M; i++){
		int p;
		string s;
		scanf("%d", &p);
		cin >> s;
		p--;
		if(s[0] == 'A'){
			if(was_AC[p] == 0){
				was_AC[p] = 1;
				ans++;
				penaruty += WA_count[p];
			}
		}
		else{
			WA_count[p]++;
		}
	}
	printf("%d %d\n", ans, penaruty);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(void) {
	int n, m, k[31];
	int fav[31] = {};
	int a[31][31];
	int count = 0;
	cin >> n >> m;
	
	for (int i = 0;i < n;i++)
	{
		cin >> k[i];
		for (int j = 0;j < k[i];j++)
		{
			cin >> a[i][j];
			fav[a[i][j]-1]++;
		}
	}

	for (int i = 0;i < m;i++)
	{
		if (fav[i] == n)
			count++;
	}

	cout << count << endl;
	
	return 0;
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s, t, u ;
  cin >> s >> t >> u ;
  int ns, nt, nu ;
  
  ns = s.size() ;
  nt = t.size() ;
  nu = u.size() ;
  
  if(s.at(ns-1)==t.at(0) && t.at(nt-1)==u.at(0)){
    cout <<"YES"<<endl ;
  }
  else{
    cout <<"NO"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    long N = sc.nextInt();
    int K = sc.nextInt();
    int[][] m = new int[11][5];
    for (int i = 0; i < 11; i++) {
      for (int j = 0; j < 5; j++) {
        for (int k = 0; k < 3; k++) {
          for (int l = 0; l < 3; l++) {
            m[i][j] += (i + k) * 7 + j + l + 1;
          }
        }
        m[i][j] %= 11;
      }
    }
    long ans = 0;
    if (N >= 13) {
      long rep = (N - 2) / 11;
      for (int i = 0; i < 11; i++) {
        for (int j = 0; j < 5; j++) {
          if (m[i][j] == K) ++ans;
        }
      }
      ans *= rep;
    }
    if (N >= 3) {
      for (int i = 0; i < (N - 2) % 11; i++) {
        for (int j = 0; j < 5; j++) {
          if (m[i][j] == K) ++ans;
        }
      }
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 9808
n = int(input())
A = list(map(int, input().split()))
A.sort()


# print(A)
# t = 0
# for k in range(1, n):
#     # print("A[0:{}]={}".format(k, A[:k]))
#     # print("{} <? {}".format(2 * sum(A[:k]), A[k]))
#     if 2 * sum(A[:k]) < A[k]:
#         t = max(t, k)

t = 0
value = A[0]
for k in range(1, n):
    # print("A[0:{}]={}".format(k, A[:k]))
    # print("{} <? {}".format(2 * sum(A[:k]), A[k]))
    if 2 * value < A[k]:
        t = max(t, k)
    value += A[k]


print(n - t)



Measured memory_bytes: 63856
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  string S;
  cin >> S;
  ll total = 0;
  for(auto c:S){
    total = (total + (c - '0')) % 9;
  }
  if (total == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  int ac,wa,tle,re;
  ac =0;
  wa = 0;
  tle =0;
  re =0;
  int n;
  cin>>n;

  string a = "AC";
  string w = "WA";
  string t = "TLE";
  string r = "RE";
  string tem;
  for(int i=0;i<n;i++){
    cin>>tem;
    if(tem == a) ac++;
    if(tem == w) wa++;
    if(tem == t) tle++;
    if(tem == r) re++;
  }

  cout<<a<<" " << "x" << " " <<ac <<endl;
  cout<<w<<" " << "x" << " " <<wa <<endl;
  cout<<t<<" " << "x" << " " << tle <<endl;
  cout<<r<<" " << "x" <<  " " <<re <<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=2e5+5;
char ss[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",ss);
    int cnt=0;
    for(int i=0;i<n;i++)
        cnt+=(ss[i]=='R');
    int ans=0;
    for(int i=0;i<cnt;i++)
        ans+=(ss[i]=='W');
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1928
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        double N = sc.nextDouble();
        double roop = Math.sqrt(N);
      	double x = 1;
        double y;
      	double count = 0;
        while(x <= roop){
          if(N % x == 0){
            y = N / x;
            if(x + y - 2 < count || count == 0){
              count = x + y - 2.0;
            }
          }
          x += 1;
        }
		 System.out.println(Math.round(count));            
    }
}

Measured memory_bytes: 37340
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

if A + B + C + D == 7:
  print(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
elif A - B - C - D == 7:
  print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
elif A + B - C - D == 7:
  print(S[0] + '+' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
elif A - B + C + D == 7:
  print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
elif A - B - C + D == 7:
  print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
elif A - B + C - D == 7:
  print(S[0] + '-' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
elif A + B - C + D == 7:
  print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
elif A + B + C - D == 7:
  print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')

Measured memory_bytes: 3064
h,w,k=map(int,input().split())
lis=[[0 for i in range(6)]for j in range(6)]
for i in range(h):
  tmp=input()
  for j in range(w):
    if(tmp[j]=="#"):
      lis[i][j]=1

ans=0
for i in range(2**h):
  for j in range(2**w):
    tmp=0
    hoge="{:0>{}b}".format(i, 6)[::-1]
    huga="{:0>{}b}".format(j, 6)[::-1]
    for a in range(6):
      for b in range(6):
        if(hoge[a]=="0" and huga[b]=="0"):
          if(lis[a][b]==1):
            tmp+=1
            
    if(tmp==k):
      ans+=1
      #print(hoge,huga)
      
print(ans)
            
          
        

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int t = 0;
  for (char c : s) {
    if (c == '*') {
      cout << t << '\n';
      return 0;
    }
    if (c == '(') {
      ++t;
    } else {
      --t;
    }
  }
}



Measured memory_bytes: 3224
S = list(input())
T = list(input())

index = len(S)
ans = []
isMatch = True

# 後ろから判定
while index - len(T) >= 0:
  obj = S[index - len(T):index]
  # 切り出した文字列がTと一致し得るか判定
  for i in range(len(obj)):
    if not obj[i] == "?" and not obj[i] == T[i]:
      isMatch = False
  
  # T文字列で埋める
  if isMatch:
    ans.append(S[0:index-len(T)] + T + S[index:])

  isMatch = True
  index = index - 1

if ans == []:
  print("UNRESTORABLE")
else:
  ans = sorted(ans)[0]
  for i in range(len(ans)):
    if ans[i] == "?":
      ans[i] = "a"
  print("".join(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<vector<int>> data(H, vector<int> (W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(B > i){
        if(A > j)data.at(i).at(j) = 1;
        else data.at(i).at(j) = 0;
      } else {
        if(A > j)data.at(i).at(j) = 0;
        else data.at(i).at(j) = 1;
      }
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << data.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

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

    int x, i;
    for (int i = 0; i < 5; ++i) {
        cin >> x;
        if (x == 0)
            cout << i+1;
    }

    return 0;
}


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

int factorial(int n){
    if(n == 0) return 1;
    return n*factorial(n-1);
}

int nanbanme(vector<int> A){
    int N = A.size();
    if(N == 1) return 1;
    int front = A.at(0);
    int number = 1;
    for(int i = 1; i < N; i++){
        if(A.at(i) < front) number++;
    }
    vector<int> B(N-1);
    for(int i =0; i < N-1; i++){
        B.at(i) = A.at(i+1);
    }
    return (number-1)*factorial(N - 1) + nanbanme(B);
}

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i =0; i < N; i++){
        cin >> p.at(i);
    }
    vector<int> q(N);
    for(int i =0; i < N; i++){
        cin >> q.at(i);
    }
    cout << abs(nanbanme(p) - nanbanme(q)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  ll zero=0;
  bool flg=true;
  REP(i,n) {
    cin >> a[i];
    if(a[i]==0) zero++;
  }
  if(zero!=0) {
    cout << "0" << endl;
  } else {
    ll ans=1;
    REP(i,n) {
      if(a[i]<=1000000000000000000/ans) {
        ans*=a[i];
      } else {
        flg=false;
        break;
      }
    }
    if(flg) {
      cout << ans << endl;
    } else {
      cout << "-1" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4048
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

    int ureshisa = 0;

    ureshisa += (X / 500) * 1000;
    X %= 500;
    ureshisa += (X / 5) * 5;

    cout << ureshisa << endl;

    return 0;
}

Measured memory_bytes: 888
function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var S = splited[0][0];
  var last_s = S.slice(-1);
  if (last_s == 's') {
    console.log(S+'es');
  } else {
    console.log(S+'s');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29680
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, k;
    cin >> n >> k;
    long long a[n], b[n], c[1000000];
    for (long long i = 0; i < 1000000; i++) c[i] = 0;
    for (long long i = 0; i < n; i++) 
    {
        cin >> a[i] >> b[i];
        c[a[i]] += b[i];
    }
    for (long long i = 0; i < 1000000; i++)
    {
        k -= c[i];
        if (k <= 0)
        {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 12976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i] && a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
                    ans++;
            }
        }
    }
    cout<<ans;
}

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

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
A=[]
fp =0
bp =0
n=int(raw_input())
while n: 
    cmd = raw_input()
    if cmd[0] == 'i':
        A.append(int(cmd[7:]))
        fp += 1
    elif cmd[6] == ' ':
        try:
            i = A[::-1].index(int(cmd[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif cmd[6] == 'F':
        A.pop()
        fp -=1
    elif cmd[6] == 'L':
        bp +=1
    n -=1
 
for k in A[bp:fp+1][::-1]:
    print int(k),

Measured memory_bytes: 42220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int length = sc.nextInt();
		int width = sc.nextInt();

		int area = length * width;
		int perimeter = length * 2 + width * 2;

		System.out.println(area + " " + perimeter);

	}

}


Measured memory_bytes: 26072
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func readInt() int {
	s.Scan()
	num, _ := strconv.Atoi(s.Text())
	return num
}

func readInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = readInt()
	}
	return sl
}

func init() {
	s.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	a := readInts(n)
	b := map[int]int{}

	var ans int
	for i, a := range a {
		if _, ok := b[i-a]; ok {
			ans += b[i-a]
		}
		if _, ok := b[i+a]; !ok {
			b[i+a] = 0
		}
		b[i+a]++
	}

	fmt.Println(ans)
}


Measured memory_bytes: 14780
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


// エラトステネスの篩
// [0,n) の範囲の i について、primes[i] != 0 ⇔ i は素数
vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // 素数のみをvectorに格納する場合は以下の行を追加 (0 である要素を全削除)
    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

vector<int> primes;

int solve(int N, int P) {
    vector<int> cans;
    for (size_t i = 0; i < primes.size(); i++) {
        if (primes[i] > N) {
            for (size_t j = i; j < i + 100; j++) {
                for (size_t k = j; k < i + 100; k++) {
                    cans.push_back(primes[j] + primes[k]);
                }
            }
            break;
        }
    }
    sort(cans.begin(), cans.end());
    return cans[P-1];
}

int main(){
    primes = erat(1000000);
    int N, P;
    vector<int> ans;
    while (1) {
        cin >> N >> P;
        if (N == -1 && P == -1) break;
        ans.push_back(solve(N, P));
    }
    for (auto &i: ans) {
        cout << i << endl;
    }
}





Measured memory_bytes: 6540
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.length() / 2; i++)
	{
		int j = s.length() - 1 - i;
		char c = s[i];
		s[i] = s[j];
		s[j] = c;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int a,b,c;cin>>a>>b>>c;

    cout<<a*b/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
long long a[4];
int main() {
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	for (int i = 1; i <= 3; i++)a[i] = min(a[i], a[i - 1] * 2);
	long long n; cin >> n;
	cout << a[3] * (n / 2) + a[2] * (n % 2) << endl;
	return 0;
}

Measured memory_bytes: 764
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	int R[N];pii qes[N];
	void main()
	{
		int n=qread(),m=qread();fo(i,1,m) R[i]=qread();R[m+1]=INF;
		int q=qread();fo(i,1,q) qes[i].FR=qread(),qes[i].SE=qread();
		int curq=1;pii low={0,0},upp={n,n};
		fo(i,1,m+1)
		{
			while(curq<=q and qes[curq].FR<R[i])
			{
				int wt=qes[curq].SE,ans;
				if(wt<=low.FR) ans=low.SE; else if(wt>=upp.FR) ans=upp.SE; else ans=low.SE+wt-low.FR;
				ans+=(i&1?-1:1)*(qes[curq].FR-R[i-1]);
				write2(max(0,min(n,ans)));curq++;
			}
			low.SE+=(i&1?-1:1)*(R[i]-R[i-1]);chmin(low.SE,n);
			while(low.FR+1<=n and low.SE<0) low.SE++,low.FR++;chmax(low.SE,0);
			upp.SE+=(i&1?-1:1)*(R[i]-R[i-1]);chmax(upp.SE,0);
			while(upp.FR-1>=0 and upp.SE>n) upp.SE--,upp.FR--;chmin(upp.SE,n);
		}
 	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 6144
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    set<int> A;
    for (int i=0; i<N; ++i) {
        int a;
        cin >> a;
        auto itr = A.find(a);
        if (itr == A.end())
            A.insert(a);
        else
            A.erase(a);
    }
    cout << A.size() << endl;
}


Measured memory_bytes: 8164
N = int(input())
A = sorted(list(map(int,input().split())))
m = min(A)
def gcd(a, b):
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a%b
    return b
g = A[0]
for i in range(N):
    g = gcd(g, A[i])
print(min(g,m))

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

int main()
{
  string n;
  cin >> n;
  int i;
  for(i = 0; i < 3; i++)
  {
    if(n.at(i) == '9')
    {
      n.at(i) = '1';
    }
    else if(n.at(i) == '1')
    {
      n.at(i) = '9';
    }
  }
  cout << n << endl;
}

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

int main(){
  int n; cin >> n;
  int p[55];
  for (int i = 0; i < n; i++){
    cin >> p[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++){
    if (p[i] != i + 1){
      cnt++;
      if (cnt >= 3){
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int z;

  while(cin >> z){
    if(z == 0) break;

    int max = 0;

    for(int i = 0; i < z; i++){
      for(int j = 0; j < z; j++){
	if(i*i*i+j*j*j <= z*z*z && max < i*i*i+j*j*j) max = i*i*i+j*j*j;
      }
    }

    cout << z*z*z-max << endl;
  }
  return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

class BIT
{
public:
	vector<int> bit;
	int M;

	BIT(int M) :
		bit(vector<int>(M + 1, 0)), M(M) {}

	int sum(int i) {
		if (!i) return 0;
		return bit[i] + sum(i - (i&-i));
	}

	void add(int i, int x) {
		if (i > M) return;
		bit[i] += x;
		add(i + (i&-i), x);
	}
};

class range
{
public:
	range(int l, int r, int q)
	: l(l), r(r), q(q)
	{
	}

	auto as_tuple() const
	{
		return tie(r, q, l);
	}
	bool operator<(const range &other) const
	{
		return as_tuple() < other.as_tuple();
	}
	int l, r, q;
};

int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;

	vector<range> v;
	for (int i = 0; i < M; ++i) {
		int l, r;
		cin >> l >> r;
		v.emplace_back(l, r, -1);
	}
	for (int i = 0; i < Q; ++i) {
		int l, r;
		cin >> l >> r;
		v.emplace_back(l, r, i);
	}
	sort(v.begin(), v.end());

	vector<int> ans(Q);

	BIT bit(M + 10);
	for (const auto &x : v) {
		if (x.q == -1) {
			bit.add(x.l, 1);
		}
		else {
			ans[x.q] = bit.sum(x.r) - bit.sum(x.l - 1);
		}
	}

	for (auto x : ans) {
		cout << x << endl;
	}
}



Measured memory_bytes: 8048
S = input()
high = int(S[0:2])
low = int(S[2:4])

if 1<= high <= 12:
    if 1<= low <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
if high < 1 or high > 12:
    if 1<= low <= 12:
        print("YYMM")
    else:
        print("NA")



Measured memory_bytes: 9164
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<fstream>
#include<cmath>
#include<cctype>
#include<stack>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
ll n,m,aa[5],x,y,z,w,ans=1ll<<60;
double s;
inline void solve(ll a,ll b,ll c){
	aa[1]=a*c;
	aa[2]=(b-a)/2*c;
	aa[3]=n*m-aa[1]-aa[2];
	sort(aa+1,aa+4);
	ans=min(ans,aa[3]-aa[1]);
	aa[1]=a*c;
	aa[2]=c/2*(b-a);
	aa[3]=n*m-aa[1]-aa[2];
	sort(aa+1,aa+4);
	ans=min(ans,aa[3]-aa[1]);
}
int main(){
	cin>>n>>m;
	if(n%3==0 || m%3==0){
		puts("0");
		return 0;
	}
	x=n/3;
	s=n*m*1.0/3;
	solve(x+1,n,m);
	solve(x,n,m);
	x=m/3;
	solve(x,m,n);
	solve(x+1,m,n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;
const ll mod=1e9+7;


int main(){
    ll x,y;
    cin >> x >> y;
    y--;
    if(y && x*y%(y+1)!=0){
        cout << x*y << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	ll n;
	cin >> n;
	ll h, h_pre;
	ll ans;
	cin >> ans;
	h_pre = ans;
	for (int i = 1; i < n; i++){
		cin >> h;
		if (h_pre < h){
			ans += h-h_pre;
		}
		h_pre = h;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 3;
    //判別式
    if(a == b){count--;}
    if(a == c){count--;}
    if(b == c){count--;}
    if(a == b && a == c){count++;}
    //出力
    System.out.println(count);
 }
}

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    fast;
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
     cin>>arr[i];
    map< int,int > mp;
    mp[n-arr[n]]++;
    int cnt=0;
    for(int i=n-1;i>0;i--)
    {
        cnt+=mp[i+arr[i]];
        mp[i-arr[i]]++;
    }
    cout<<cnt<<"\n";
      return 0;
}

Measured memory_bytes: 27876
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, a[1000], b[1000];
vector<int> vec;
int cnt[1000010], cnt2[1000010];
int ans = 1;

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n * m; i++) {
		if (2 <= cnt[i]) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 1; i <= n * m; i++) {
		cnt[i] += cnt[i - 1];
	}
	for (int j = 0; j < m; j++) {
		cin >> b[j];
		cnt2[b[j]]++;
	}
	for (int i = 1; i <= n * m; i++) {
		if (2 < cnt2[i]) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 1; i <= n * m; i++) {
		cnt2[i] += cnt2[i - 1];
	}
	for (int i = n * m; i >= 1; i--) {
		if (cnt[i] - cnt[i - 1] && cnt2[i] - cnt2[i - 1])ans *= 1;
		else if (cnt[i] - cnt[i - 1]) {
			ans *= cnt2[n*m] - cnt2[i - 1];
			ans %= mod;
		}
		else if (cnt2[i] - cnt2[i - 1]) {
			ans *= cnt[n*m] - cnt[i - 1];
			ans %= mod;
		}
		else {
			ans *= (cnt[n*m] - cnt[i - 1])*(cnt2[n*m] - cnt2[i - 1]) - (n*m - i);
			ans %= mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 15872
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			final int m = sc.nextInt();
			
			int before = sc.nextInt();
			int m_max = 0;
			int max = 0;
			for(int j = 1; j < m; j++){
				int cur = sc.nextInt();
				
				if(cur - before > 0){
					if(max < (cur - before)){
						max = cur - before;
					}
				}else{
					if(m_max > (cur - before)){
						m_max = cur - before;
					}
				}
				
				before = cur;
			}
			
			System.out.println(max + " " + (-m_max));
		}
	}
}

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

struct Queue {
  int front, end, length, maxLength;
  int *arr
};

struct Queue *init(int maxLength) {
  struct Queue *new = malloc(sizeof(struct Queue));
  new->maxLength = maxLength;
  new->front = new->length = 0;
  new->end = maxLength - 1;
  new->arr = malloc(maxLength * sizeof(int));
  return new;
}

void enQ(struct Queue *q, int val) {
  if (q->maxLength == q->length) {
    printf("queue is full!\n");
    return;
  }

  q->end = (q->end + 1) % q->maxLength;
  q->arr[q->end] = val;
  //printf("enqueued %d\n", val);
  q->length++;
}

int deQ(struct Queue *q) {
  if (!q->length) {
    //printf("queue is empty!\n");
    return 0;
  }

  int val = q->arr[q->front];
  //printf("dequeued %d\n", val);
  q->front = (q->front + 1) % q->maxLength;
  q->length--;

  return val;
}

int main() {
  int n, quantum, i;

  scanf("%d %d", &n, &quantum);
  struct Queue *q = init(n + 1);

  int times[n + 1];
  char names[n + 1][10];

  for (i = 1; i < n + 1; i++) {
    scanf("%s %d", &names[i], &times[i]);
    enQ(q, i);
  }

  int curProcess, t = 0;

  while (1) {
    curProcess = deQ(q);

    if (!curProcess)
      break;

    if (times[curProcess] > 0) {
      for (i = 0; i < quantum; i++) {
        times[curProcess]--;
        t++;
        if (times[curProcess] <= 0) {
          printf("%s %d\n", names[curProcess], t);
          break;
        }
      }

      enQ(q, curProcess);
    }
  }
}



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

int main()
{
    int N;
    int cnt[105] = {};
    cin >> N;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        cnt[A]++;
    }
    int ans = 0;
    for(int i = 0; i < 105; i++) {
        ans += cnt[i] > 0;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  vector<int > a(5,0);
  REP(i,5) cin >> a[i];
  vector<int > b(5,0);
  int tmp;
  int mintmp = 9;
  int c = 0;
  int ind = 0;
  REP(i,5){
    tmp = a[i]%10;
    if(tmp != 0){
      b[i] = a[i] - tmp + 10;
      if(tmp <= mintmp){
	ind = i;
	mintmp = tmp;
      }
      c ++;
    }else{
      b[i] = a[i];
    }
  } 
  if(c == 0){
    cout << a[0] + a[1] + a[2] + a[3] + a[4] << endl;
  }else{
    // cout << ind << " "<<mintmp <<endl;
    // REP(i,5){
    //   cout << b[i] <<endl;
    // }
    // cout << b[0] + b[1] + b[2] + b[3] + b[4]<< endl;
    cout << b[0] + b[1] + b[2] + b[3] + b[4] - b[ind] + a[ind] << endl;
  }

}


Measured memory_bytes: 256
def bfs(x0, y0, maze, dis):
    from collections import deque
    max_x = len(maze[0])
    max_y = len(maze)

    dis[y0][x0] = 0
    dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]

    q = deque()
    q.append([x0, y0, dis[y0][x0]])

    while len(q) > 0:
        x, y, d = q.popleft()

        for dx, dy in dxy:
            nx = x + dx
            ny = y + dy

            if 0 > nx or max_x <= nx or 0 > ny or max_y <= ny:
                continue
            if maze[ny][nx] == "#":
                continue
            if dis[ny][nx] != -1:
                continue

            dis[ny][nx] = d + 1
            q.append([nx, ny, dis[ny][nx]])

    return


h, w = map(int, input().split())

s = [[] for _ in range(h)]

for i in range(h):
    s[i] = input()

ans = 0
for i in range(h):
    for j in range(w):
        dis = [[-1] * w for _ in range(h)]

        if s[i][j] != "#":
            bfs(j, i, s, dis)

        d = 0

        for k in range(h):
            for l in range(w):
                d = max(d, dis[k][l])

        ans = max(ans, d)

print(ans)

Measured memory_bytes: 45660
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){

    string s, t;
    cin >> s >> t;

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

    if(s<t) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main(){
    ll N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    ll num_area = 1;
    vector<ll> v;
    v.push_back(1);
    
    for(ll i = 1; i < N; i++){
        if(S[i] != S[i-1]){
            num_area++;
            v.push_back(1);
        }
        else v[num_area-1]++;
    }
    
    ll size = v.size();
    ll ans = 0;
    ll tmp = 0;
    ll quantity = K;
    bool handstandind = false;
    if(S[0] == '1') handstandind = true;
    
    for(ll i = 0; i < size; i++){
        if(handstandind){
            tmp += v[i];
        }
        else{
            if(quantity > 0){
                quantity--;
                tmp += v[i];
            }
            else if(quantity == 0){
                tmp -= v[i - 2*K];
                tmp += v[i];
                if(0 <= i - 2*K - 1) tmp -= v[i - 2*K - 1];
            }
        }
        handstandind = !handstandind;
        ans = max(ans,tmp);
    }

    cout << ans << "\n";
    return 0;
} 


Measured memory_bytes: 1528
S= input()
"""
serval 
ssrra
sssa

"""

N = len(S)
"""
pre = set()
suf = set()
i=0
while not (len((suf&pre)) and 2*i>N):
    suf.add(S[i])
    pre.add(S[-i-1])
    print(i,suf,pre, S[i+1:-i-2])
    if S[i+1:-i-2]==S[i+1]*len(S[i+1:-i-2]) and S[i-1] in suf&pre:
        print("break")
        break
    i+=1
print(i)

"""
min_val = 999999
for i in range(26):
    char = chr(ord("a")+i)
    min_val = min(min_val , max(map(len,S.split(char))))



print(min_val)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;
class UnionFind {
public:
  vector<int> d;
  UnionFind(int n): d(n,-1){}

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
  if(d[x]<0) return x;
  return d[x] = root(d[x]);
}

bool unite(int x, int y) { // xとyの木を併合
  x = root(x); //xの根をrx
  y = root(y); //yの根をry
  if (x == y) return false; //xとyの根が同じ(=同じ木にある)時はそのまま
  if(d[x]>d[y]) swap(x,y);
  d[x]+=d[y];
  d[y]=x;
  return true;
}

bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
  int rx = root(x);
  int ry = root(y);
  return rx == ry;
}

int size(int x){ return -d[root(x)];}
};

signed _main(){
  int N,M,ans=0; cin >> N >> M;
  v<P> Graph(M);
  rep(i,M){
    int a,b; cin >> a >> b;
    a--;b--;
    Graph[i].first = a;
    Graph[i].second = b;
  }
  rep(i,M){
    int index=0;
    UnionFind uf(N);
    rep(j,M){
      if(i==j) continue;
      uf.unite(Graph[j].first,Graph[j].second);
      index=Graph[j].first;
    }
    if(uf.size(index)!=N) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int time,cnt,h_s,h_f,ans;
    while(1){
        ans=0;
        cin >> time;
        if(time == 0){
            break;
        }
        cin >> cnt;
        for(int i=0;i<cnt;i++){
            cin >> h_s >> h_f;
            ans += h_f - h_s;
        }
        if(ans >= time){
            cout << "OK" << endl;
        }
        else{
            cout << time - ans << endl;
        }
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  long long k = -10;
  long long ans = 0;
  for(int i = 0;i<n;i++)
  {
    long long a;
    cin >> a;
    k = max(k,a);
    ans+=k-a;
  }


  cout <<ans <<endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 string S;
 cin>>S;

 int ans=INF;
 for(int i=0;i<S.size()-2;i++){
   int a=S.at(i)-'0';
   int b=S.at(i+1)-'0';
   int c=S.at(i+2)-'0';
   int X=100*a+10*b+c;
   ans=min(ans,abs(X-753));
 }
 cout<<ans<<endl;
 return 0;}

Measured memory_bytes: 256