akhauriyash/Code-Regression huggingface dataset:
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  string s,t;
  cin>>s>>t;

  int n=s.length();
  int l=t.length();
  int ans=s.length();

  for(int i=0;i<=n-l;i++)
  {
    int curr=0;
    for(int j=0;j<l;j++)
    {
      if(s[i+j]!=t[j])
        curr++;
    }

    ans=min(ans,curr);
  }

  cout<<ans<<endl;

} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

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

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

  return 0;
}


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

int cnt[10][10];

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int j = i;
        while (j > 9) j /= 10;
        cnt[i % 10][j]++;
    }
    long long ans = 0;
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            ans += (long long)cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair


int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    int n;
    int ans = 0;
    scanf("%d", &n);
    while(n--)
    {
        int x;
        scanf("%d", &x);
        ans ^= (x & 1);
    }
    if (ans)
        printf("NO\n");
    else
        printf("YES\n");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;

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

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> field(h);
    rep(i,h) cin >> field[i];

    auto t = make_vec(h, w, -1); //塗り分け
    int cnt = 0;
    rep(i,h) rep(j,w)
    {
        if(t[i][j] != -1) continue;
        if(field[i][j] == '#') continue;
        queue<P> que;
        que.emplace(i, j);
        t[i][j] = cnt;

        while(!que.empty())
        {
            auto [y, x] = que.front();
            que.pop();
            rep(i,4)
            {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if(field[ny][nx] == '#') continue;
                if(t[ny][nx] != -1) continue;
                que.emplace(ny, nx);
                t[ny][nx] = cnt;
            }
        }
        cnt++;
    }

    int n = cnt+1;
    vector<vector<int>> G(n, vector<int>(0));
    rep(y,h) rep(x,w) rep2(dy,-2,3) rep2(dx,-2,3)
    {
        int ny = y + dy;
        int nx = x + dx;
        if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        int u = t[y][x];
        int v = t[ny][nx];
        if(u == v || u == -1 || v == -1) continue;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    // rep(i,n)
    // {
    //     sort(G[i].begin(), G[i].end());
    //     G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
    // }

    vector<int> dist(n, INF);
    int s = t[sy][sx], g = t[gy][gx];
    queue<int> que;
    que.emplace(s);
    dist[s] = 0;
    while(!que.empty())
    {
        auto v = que.front();
        que.pop();
        for(auto w:G[v])
        {
            if(dist[w] != INF) continue;
            que.emplace(w);
            dist[w] = dist[v] + 1;
        }
    }

    int ans = dist[g];
    if(ans == INF) ans = -1;
    cout << ans << endl;

    /*
    cout << G << endl;
    cout << dist << endl;
    cout << t << endl;
    //*/
    
    return 0;
}

Measured memory_bytes: 31784
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	vector<vector<int> > v(100, vector<int>(2, 0));
	for (int i = 0; i < 100; i++) {
		v.at(i).at(1) = i + 1;
	}

	int n;
	while (cin >> n) {
		v.at(n - 1).at(0)++;
	}

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	//cout << v.at(0).at(1) << endl;
	//cout << v.at(1).at(1) << endl;
	//cout << v.at(2).at(1) << endl;

	vector<int> v2(100);
	int max = v.at(0).at(0);
	for (int i = 0; i < 100; i++) {
		if (v.at(i).at(0) == max) {
			v2.at(i) = v.at(i).at(1);
		}
	}

	sort(v2.begin(), v2.end());
	for (int i = 0; i < 100; i++) {
		int n = v2.at(i);
		if (n) cout << n << endl;
	}
}


Measured memory_bytes: 3160
#include <iostream>

using namespace std;

int main()
{
    long long a , b , k , t1 , t2;
    cin >> a >> b;
    if ((a + b) % 2 == 0){
        cout << (a + b) / 2;
    }else{
        cout << "IMPOSSIBLE";
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

#define INF 1e18

bool dfs(int now, const vector<vector<long long int> >& adj,
         vector<long long int>& history, long long int& a, long long int& b, int odd_even = 1){
  history[now] = odd_even;
  if(odd_even == 1){ ++a; }
  else{ ++b; }
  
  for(int i = 0; i < (int)adj[now].size(); i++){
    if(history[adj[now][i]] == odd_even){ return false; }
    if(history[adj[now][i]] == 0)
      if(!dfs(adj[now][i], adj, history, a, b, -odd_even))
        return false;
  }
  
  return true;
}


int main(void){
  int v, e;
  cin >> v >> e;

  long long int input_a, input_b;
  vector<vector<long long int> > adj(v);
  for(int i = 0; i < e; i++){
    cin >> input_a >> input_b;
    --input_a;
    --input_b;
    adj[input_a].push_back(input_b);
    adj[input_b].push_back(input_a);
  }

  long long int a_sum = 0, b_sum = 0;
  vector<long long int> c_tmp;
  vector<long long int> history(v, 0);
  for(int i = 0; i < v; i++){
    if(history[i] == 0){
      long long int a = 0;
      long long int b = 0;
      if(!dfs(i, adj, history, a, b)){
        cout << -1 << endl;
        return 0;
      }
      else{
        if(a > b){ swap(a, b); }
        a_sum += a;
        b_sum += b;
        c_tmp.push_back(b - a);
      }
    }
  }
  map<long long int, int> c_map;
  for(size_t i = 0; i < c_tmp.size(); i++){ ++c_map[c_tmp[i]]; }

  vector<pair<long long int, int> > c;
  c.push_back(make_pair(0, INF));
  for(map<long long int, int>::iterator it = c_map.begin(); it != c_map.end(); ++it){ c.push_back(*it); }
  
  int n = c.size();
  vector<long long int> dp(vector<long long int>(v + 1, -INF));
  dp[0] = INF;
  for(int i = 1; i < n; i++)
    for(int j = 0; j <= v; j++)
      dp[j] = dp[j] >= 0 ? c[i].second :
        j >= c[i].first ? dp[j - c[i].first] - 1 : (int)INF * (-1);

  int minpoint = -1;
  long long int mindiff = INF;
  for(int i = 0; i <= v; i++){
    if(dp[i] >= 0){
      long long int candiate = abs((a_sum + i) - (b_sum - i));
      if(mindiff > candiate){
        mindiff = candiate;
        minpoint = i;
      }
    }
  }

  long long int ans = (a_sum + minpoint) * (b_sum - minpoint) - e;
  cout << ans << endl;
  
  return 0;
}

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

#define int long long

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);

    int n = 0;
    while(true) {
        sort(v.begin(), v.end());
        if(v[0]==v[1] && v[0]==v[2]) {
            cout << n << endl;
            return 0;
        }
        if(v[0]+2 <= v[2]) {
            n++;
            v[0] += 2;
            continue;
        } else {
            v[0]++;
            v[1]++;
            n++;
        }
    }
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
Q = [list(map(str, input().split())) for _ in range(M)]

ans = [0] * N
AC = 0
WA = 0

for P in Q:
    p = int(P[0])
    S = P[1]
    if ans[p - 1] == "END":
        continue
    if S == "WA":
        ans[p - 1] += 1
    if S == "AC":
        WA += ans[p - 1]
        AC += 1
        ans[p - 1] = "END"


print(AC, WA)


Measured memory_bytes: 98820
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
const LL INF=(LL)1e+9;
LL sz(string s){
  if(s=="") return 0;
  else if('0'<=s[0] && s[0] <='9'){
    int i=0;
    while('0'<=s[i] && s[i] <='9') ++i;
    LL re=stoi(string(s.begin(),s.begin()+i));
    if(s[i]=='('){
      int j=i;
      int tmp=1;
      do{
	++j;
	if(s[j]=='(') ++tmp;
	if(s[j]==')') --tmp;
      }while(tmp);
      return min(re*sz(string(s.begin()+i+1,s.begin()+j))+sz(string(s.begin()+j+1,s.end())),INF);
    }
    else return min(re*1+sz(string(s.begin()+i+1,s.end())),INF);
  }else{
    return min(1+sz(string(s.begin()+1,s.end())),INF);
  }
}
char solve(string s,LL n){
  if(s=="") return '0';
  else if('0'<=s[0] && s[0] <='9'){
    int i=0;
    while('0'<=s[i] && s[i] <='9') ++i;
    LL re=stoi(string(s.begin(),s.begin()+i));
    if(s[i]=='('){
      int j=i;
      int tmp=1;
      do{
	++j;
	if(s[j]=='(') ++tmp;
	if(s[j]==')') --tmp;
      }while(tmp);
      LL szp=sz(string(s.begin()+i+1,s.begin()+j));
      if(n<re*szp) return solve(string(s.begin()+i+1,s.begin()+j),n%szp);
      else return solve(string(s.begin()+j+1,s.end()),n-re*szp);
    }
    else if(n<re) return s[i];
    else return solve(string(s.begin()+i+1,s.end()),n-re);
  }else{
    if(n==0) return s[0];
    else return solve(string(s.begin()+1,s.end()),--n);
  }
}
int main(void)
{
  for(;;){
    string s;
    LL n;
    cin >> s >> n;
    if(s=="0") return 0;
    cout << solve(s,n) << endl;
  }
}

Measured memory_bytes: 3184
inf = 10**9
H, N = map(int, input().split())
AB = [[0, 0] for i in range(N)]
for i in range(N):
    AB[i][0], AB[i][1] = map(int, input().split())
AB.sort()
T = [[inf for i in range(H+1)] for j in range(N)]
for i in range(N):
    T[i][0] = 0
    if i == 0:
        for j in range(1, H+1):
            if j % AB[i][0] > 0:
                T[i][j] = AB[0][1] * (j // AB[0][0] + 1)
            else:
                T[i][j] = AB[0][1] * (j // AB[0][0])
    else:
        for j in range(1, min(AB[i][0], H+1)):
            T[i][j] = min(T[i-1][j], AB[i][1])
        for j in range(AB[i][0], H+1):
            T[i][j] = min(T[i-1][j], T[i][j - AB[i][0]]+AB[i][1])
print(T[N-1][H])

Measured memory_bytes: 125916
#include <iostream>
#include <vector>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;

    int ret = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) for (int k = 0; k < j; k++) {
        if (a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
        if (a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[k] + a[i] > a[j]) ret++;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3616
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

let rec calc_bit i n ret =
  if i = n then ret
  else
    let c = scan_int() in
    calc_bit (i+1) n (ret lor (1 lsl (c-1)))

let rec input i n arr =
  if i = n then arr
  else
    let a = scan_int() and b = scan_int() in
    let c = calc_bit 0 b 0 in
    let _ = arr.(i) <- (a, c) in
    input (i+1) n arr

let rec dp table i n m arr =
  if i = m then table.((1 lsl n) - 1)
  else
    let a, c = arr.(i) in
    let rec update_dp_table j n a c =
      if j = n then ()
      else
        let _ = table.(j lor c) <- min table.(j lor c) (table.(j) + a) in
        update_dp_table (j+1) n a c in
    let _ = update_dp_table 0 (1 lsl n) a c in
    dp table (i+1) n m arr


let max_cost = int_of_float 1e15

let () = 
  let n = scan_int() and m = scan_int() in
  let arr = Array.make m (0, 0) and dp_table = Array.make (1 lsl n) max_cost in
  let _ = dp_table.(0) <- 0 in
  let _ = input 0 m arr in
  let ret = dp dp_table 0 n m arr in
  if ret = max_cost then print_int (-1)
  else print_int ret
  

Measured memory_bytes: 3200
package main
import (
  "fmt"
  // "math"
)

func main() {
  var (
    S string
  )
  fmt.Scan(&S)

  if string(S[0]) != "A" {
    fmt.Println("WA")
    return
  }

  cCount := 0
  for i := 2; i < len(S) - 1; i++ {  
    if (string(S[i]) == "C") {
      cCount++
    }
    if (cCount > 1) {
      fmt.Println("WA")
      return
    }
    if (i == len(S) - 2 && cCount == 0) {
      fmt.Println("WA")
      return
    }
  }

  upperCount := 0
  for i := 0; i < len(S); i++ {  
    if (S[i] >= 65 && S[i] <= 90) {
      upperCount++
    }
    if (upperCount > 2) {
      fmt.Println("WA")
      return
    }
  }

  fmt.Println("AC")

}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int ans = n;
        while (true) {
            if (ans <= 0) {
                break;
            }
            ans -= 1000;
        }
        System.out.println(-ans);
    }
}


Measured memory_bytes: 35588
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    string S;
    cin >> S;

    vector<int> acgt(S.size(), 0);
    REPinit(i, 0, S.size()) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') acgt[i]++;
    }

    int tmp = 0;
    int ans = 0;
    REPinit(i, 0, S.size()) {
        if (acgt[i] == 0) {
            tmp = 0;
        }
        else {
            tmp++;
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#define MAXn 102
#define MAXm 1000010
using namespace std;

int main()
{
    char a[1001];
    scanf("%s",a);
    a[5]=a[13]=' ';
    printf("%s\n",a);
    return 0;
}

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

int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int ax = x2-x1;
	int ay = y2-y1;
	cout << (x2 - ay) << " " << (y2 + ax) << " " << (x1 - ay) << " " << (y1 + ax) << endl;
	return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
M = [int(input()) for _ in range(N)]

M.sort()

s = 0
c = 0
for m in M:
    if s + m <= X:
        s += m
        c += 1

rest = X - s
if rest > 0:
    c += rest//M[0]

print(c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string s, t;
long long res = 0;

int main() {
  cin >> s >> t;
  for (int i = 0; i < s.size(); ++i)
    if (s[i] != t[i]) ++res;

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

Measured memory_bytes: 3888
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
const int mod = 2019;

int main(void){
    int L, R;
    cin >> L >> R;
    
    if(R - L + 1 >= 2019){
        cout << 0 << endl;
        return 0;
    }
    for(int i = L; i <= R; ++i){
        if(i % mod == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    
    int ans = 2020;
    for(int i = L; i < R; ++i){
        for(ll j = i + 1; j <= R; ++j){
            ll temp = (ll)(i * j) % mod;
            ans = min(ans, (int)temp);
        }
    }
    
    cout << ans << endl;
}

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

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;


int n;
int main()
{
   	
 

    int a,b;

    cin >>a >> b;
 	int ans =0;
  	int curr = 1;

  	while(curr<b){
    		ans++;
    		curr--;
    		curr+=a;
  	}
  	
  	cout << ans << endl;


}	


Measured memory_bytes: 256
def power_func(a,n,mod):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res)%mod
    if bi[i]=='1':
      res=(res*a)%mod
  return res

def cmb(a,b,mod):
  ans=1
  for i in range(a+1-b,a+1):
    ans*=i
    ans%=mod
  for k in range(1,b+1):
    ans*=power_func(k,mod-2,mod)
    ans%=mod
    
  return ans


s=int(input())

mod=10**9+7

n=s//3

ans=0

for i in range(1,n+1):
  if i==1:
    d=1
  else:
    h=s-i*3
    d=cmb(h+i-1,i-1,mod)
  
  ans+=d
  
print(ans%mod)
  

Measured memory_bytes: 68088
n , m = map(int,input().split())
h = list(map(int,input().split()))
mit= [[h[i]] for i in range(n)]
ans = [1 for i in range(n)]
for i in range(m):
    a , b = map(int,input().split())
    if ans[a-1] == 1:
        if h[a-1] <= h[b-1]:
            ans[a-1] = 0
    if ans[b-1] == 1:
        if h[a-1] >= h[b-1]:
            ans[b-1] = 0

print(sum(ans))

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

typedef long long ll;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int L, R, d, res=0;
    std::cin >> L >> R >> d;

    for(int i = L; i <= R; ++i)
    {
        if(i % d == 0)
            res++;
    }

    print(res);
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define pos first
#define index second
#define mp make_pair
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=2e5+10;
const int mod=1e9+7;
int n,k;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else return gcd(b,a%b);
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d %d",&n,&k))
    {
        int key;
        int maxt=0;
        int flag=0;
        for(int i=1;i<=n;i++)
        {
            int t;
            scanf("%d",&t);
            maxt=max(t,maxt);
            if(t==k) flag=1;
            if(i==1) key=t;
            else key=gcd(key,t);
        }
        if(k%key==0&&k<maxt) flag=1;
        printf("%s\n",flag?"POSSIBLE":"IMPOSSIBLE");
    }
    return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
using namespace std;
const int mod = 1e9 + 7;
vector<ll>prime(1001,1);

/*vector<ll>isprime;
void calc_prime()
{
    //cout<<"in1";
    ll i,j;
    prime[0]=prime[1]=0;
    for(i=2;i*i<=1000;i++)
    {
        if(prime[i]==1)
        {
            isprime.push_back(i);
            for(j=i*i;j<=1000;j+=i)
            {
                prime[j]=0;
            }
        }
    }
}
vector<ll>dp(100001);*/
ll maxi(ll a,ll b,ll c)
{
    ll m1=max(a,b);
    ll m2=max(a,c);
    return max(m1,m2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n;
    cin>>n;
    ll ac=0,tle=0,wa=0,re=0;
    while(n)
    {
        n--;
        string s;
        cin>>s;

        if(s=="AC")
            ac++;
        else if(s=="WA")
            wa++;
        else if(s=="RE")
            re++;
        else if(s=="TLE")
            tle++;
    }
    cout<<"AC x "<<ac<<endl;cout<<"WA x "<<wa<<endl;cout<<"TLE x "<<tle<<endl;cout<<"RE x "<<re<<endl;


}

////////////////////// bit masking ///////////
/*
ll total=long (pow(2,n));
    ll mask,j,cnt=0,ans=0,maxi,mini;
    for(mask=0;mask<total;mask++)
    {
        if(mask==0||mask==1||mask==2||mask==4||mask==8)
                continue;
        cnt=0;maxi=-1000000000000;mini=1000000000000;
        for(i=0;i<n;i++)
        {

            ll f=1<<i;
            if(mask&f)
            {
                maxi=max(maxi,a[i]);
                mini=min(mini,a[i]);
                cnt+=a[i];
            }
        }
        if(cnt>=l&&cnt<=r&&(maxi-mini>=x))
            ans++;


    }
    cout<<ans;
*/
///////////////////////////////////////////////////////


Measured memory_bytes: 3648
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var in string
	var tmp int
	fmt.Scan(&in)
	n := strings.Index(in, "N")
	e := strings.Index(in, "E")
	s := strings.Index(in, "S")
	w := strings.Index(in, "W")
	if n == -1 {
		tmp++
	}
	if e == -1 {
		tmp += 3
	}
	if s == -1 {
		tmp++
	}
	if w == -1 {
		tmp += 3
	}
	if tmp == 4 {
		yesOrNo(false)
		return
	}
	yesOrNo(tmp%2 == 0)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), "")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "YES"
		fmt.Println(reply)
		return
	}
	reply = "NO"
	fmt.Println(reply)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 and M == 0) {
            break;
        }
        int r;
        cin >> r;
        constexpr int TIM = 720;
        vector<vector<int>> use(N, vector<int>(TIM + 1, 0));
        for (int i = 0; i < r; i++) {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            n--;
            t -= 540;
            if (s == 1) {
                use[n][t] = m;
            } else {
                for (int T = t - 1; T >= 0; T--) {
                    if (use[n][T] != m) {
                        use[n][T] = m;
                    } else {
                        break;
                    }
                }
            }
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; i++) {
            int ts, te, m;
            cin >> ts >> te >> m;
            ts -= 540;
            te -= 540;
            int sum = 0;
            for (int t = ts; t < te; t++) {
                bool u = false;
                for (int j = 0; j < N; j++) {
                    if (use[j][t] == m) {
                        u = true;
                        break;
                    }
                }
                if (u) {
                    sum++;
                }
            }
            cout << sum << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>

int Dp[50];

int Fibonacci(int);

int main(){
  int n,i;

  scanf("%d",&n);

  for(i = 0 ; i < 50 ; i++) Dp[i] = -1;

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

  return 0;
}

int Fibonacci(int x){
  if(x == 0 || x == 1) return Dp[x] = 1;
  if(Dp[x] != -1) return Dp[x];
  return Dp[x] = Fibonacci(x-1) + Fibonacci(x-2);
}



Measured memory_bytes: 2108
def main(N, K, A):
    i = 0   # 現在地
    lst_memo = []
    set_memo = set([])
    while i not in set_memo:
        lst_memo.append(i)
        set_memo.add(i)
        i = A[i] - 1    # pythonは一つずれる
    key = lst_memo.index(i)
    if K < key:
        print(lst_memo[K] + 1)
    else:
        roop = lst_memo[key:]
        print(roop[(K - key) % len(roop)] + 1)    # pythonは一つずれる


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Measured memory_bytes: 35668
import java.util.Scanner;

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

		//?°?????????????
		while(true){
			//H??????????????????
			int H = sc.nextInt();
			//W?¨????????????????
			int W = sc.nextInt();
			//H??¨W???0????????????
			if(H == 0 && W == 0){
				break;
			}
			//??????????????¨???
			for(int i = 1; i <= H; i++){
				//??????????????¨???
				for(int j = 1; j <= W; j++){
					//?????¶???
					if((i + j) % 2 == 0){
						//??¶??°
						System.out.print("#");
					}else{
						//?\???°
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 35340
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int R, D, X; cin >> R >> D >> X;
    rep(i, 10) {
        X = R * X - D;
        cout << X << endl;
    }
}




Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define MOD 1000000007
#define rep(i,l,r) for(ll i=l;i<r;i++)

typedef long long ll;

int main() {
    ll n, a;
    scanf("%lld",&n);
    ll min = 10000000000000000;
    rep(i, 0, 5) {
        scanf("%lld", &a);
        min = (min < a) ? min : a;
    }
    printf("%lld", (n - 1) / min + 5);

    return 0;
}

Measured memory_bytes: 2112
#include<cstdio>
int main()
{
	long long A,B,C,D;
	while(scanf("%lld %lld %lld %lld",&A,&B,&C,&D)!=EOF){
		if(A*B>=C*D)	printf("%lld\n",A*B);
		else		printf("%lld\n",C*D);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
vector<vector<bool>> seat;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size();i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3468
#include <stdio.h>
int main()
{
	int a;		/* 間違いである答え A */
	int b;		/* 間違いである答え B */

	scanf("%d", &a);
	scanf("%d", &b);

	/* 答えは1,2,3のうちのどれかであるから */
	printf("%d\n", 6 - a - b);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1;rrp(i,n-r+1,n+1){ans*=i;ans%=mod;}return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
double ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 ans=0;
 rep(i,1,n+1){
  ans+=i*(n/i+1)*(n/i)/2; 
 }
 cout<<setprecision(18)<<ans<<endl; 
return 0;}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll dp[105][4][2];

int main(){
  string n;
  cin >> n;
  int sz=n.size();
  int k;
  cin >> k;

  rep(i, sz)rep(j, k+1)rep(l, 2){
    dp[i][j][l]=0;
  }
  dp[0][0][0]=1;
  
  rep(i, sz)rep(j, k+1)rep(l, 2){
    int nsz=n[sz-i-1]-'0';
    rep(dig, 10){
      if(dp[i][j][l]>1e9)continue;
      if(dig==0 && nsz>0){
        if(dp[i+1][j][0]>1e9)continue;
        dp[i+1][j][0]+=dp[i][j][l];
      } else if(dig==0 && nsz==0){
        if(dp[i+1][j][l]>1e9)continue;
        dp[i+1][j][l]+=dp[i][j][l];
      } else if(nsz>dig && dig!=0 && j+1<=k){
        if(dp[i+1][j+1][0]>1e9)continue;
        dp[i+1][j+1][0]+=dp[i][j][l];
      } else if(nsz==dig && dig!=0 && j+1<=k){
        if(dp[i+1][j+1][l]>1e9)continue;
        dp[i+1][j+1][l]+=dp[i][j][l];
      } else if(nsz<dig && dig!=0 && j+1<=k){
        if(dp[i+1][j+1][1]>1e9)continue;
        dp[i+1][j+1][1]+=dp[i][j][l];
      }
    }

  }
  /*
  rep(i, sz)rep(j, k+1)rep(l, 2){
    int nsz=n[i]-'0';
    rep(dig, 10){
      if(dig==0 && nsz>0){
        dp[i+1][j][1]+=dp[i][j][l];
      } else if(dig==0 && nsz==0){
        dp[i+1][j][l]+=dp[i][j][l];
      } else if(nsz>dig && dig!=0 && j+1<=k){
        dp[i+1][j+1][1]+=dp[i][j][l];
      } else if(nsz==dig && dig!=0 && j+1<=k){
        dp[i+1][j+1][l]+=dp[i][j][l];
      } else if(nsz<dig && j+1<=k && l==1){
        dp[i+1][j+1][l]+=dp[i][j][l];
      }
    }
  }
  */

  cout << dp[sz][k][0] << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k,i;
  cin>>a>>b>>k;
  vector<int> d;
  for(i=1;i<=max(a,b);i++)
  {
    if(a%i==0 && b%i==0) d.push_back(i);
  }
  cout<<d[d.size()-k];
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, M;
ll A[100005];
ll S[100005];

ll solve(ll n, ll x) {
    ll ok = -1, ng = N;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (n + A[mid] >= x)
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

bool check(ll x) {
    ll cnt = 0;
    REP(i, N) {
        cnt += solve(A[i], x) + 1;
    }
    return cnt <= M;
}

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

    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N, greater<ll>());

    ll mx = A[0] + A[0] + 1, ng = 1;
    while (abs(mx - ng) > 1) {
        ll mid = (mx + ng) / 2;
        if (check(mid))
            mx = mid;
        else
            ng = mid;
    }

    memset(S, 0, sizeof(S));
    REP(i, N) {
        S[i] += A[i];
        S[i + 1] += S[i];
    }

    ll ans = 0;
    ll cnt = 0;
    REP(i, N) {
        ll index = solve(A[i], mx);
        if (index < 0)
            continue;
        ans += A[i] * (index + 1) + S[index];
        cnt += index + 1;
    }
    cout << ans + (M - cnt) * (mx - 1) << endl;

    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<cstdio>
#define ll long long int
#define pb push_back
using namespace std;
int main()
{
    ll a,b,n,i,j,k;
    vector<ll>v[60];
    map<ll,ll>m;
    set<ll>s;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>k;
        m[k]=i;
        s.insert(k);
    }
    for(auto x:s)
    {
        cout<<m[x]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 11776
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

string s[maxn];
int a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  int ret = 0;
  for(int i=0;i<n;i++){
    cin>>s[i]>>a[i];
    ret += a[i];
  }
  string t;
  cin>>t;
  for(int i=0;i<n;i++){
    ret -= a[i];
    if(t==s[i])break;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000

int main(){
  int N,x;
  cin>>N>>x;
  if(N==2){
    if(x==2){
      cout<<"Yes"<<endl;
      cout<<1<<endl;
      cout<<2<<endl;
      cout<<3<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else{
    if(x==1||x==2*N-1){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
      vector<int> ans(2*N-1);
      if(x==2){
        ans.at(N-1)=2;
        ans.at(N-2)=1;
        ans.at(N-3)=3;
        ans.at(N)=4;
        int number=5;
        for(int i=0;i<2*N-1;i++){
          if(i==N-3||i==N-2||i==N-1||i==N){
            continue;
          }
          ans.at(i)=number;
          number++;
        }
      }else{
        ans.at(N-1)=x;
        ans.at(N-2)=x+1;
        ans.at(N-3)=x-1;
        ans.at(N)=x-2;
        int number=1;
        for(int i=0;i<2*N-1;i++){
          if(i==N-3||i==N-2||i==N-1||i==N){
            continue;
          }
          while(number==x||number==x+1||number==x-1||number==x-2){
            number++;
          }
          ans.at(i)=number;
          number++;
        }
      }
      for(int i=0;i<2*N-1;i++){
        cout<<ans.at(i)<<endl;
      }
    }
  }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    int n;
    cin >> n;
    vector<string> vs{"AC","WA","TLE","RE"};
    map<string, int> mp;
    fori(i,0,n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    fori(i,0,4) {
        cout << vs[i] << " x " << mp[vs[i]] << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3652
N,Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])


Measured memory_bytes: 7748
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	int n;
	while(~scanf("%d",&n)){
	int a[200];
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	int k;
	int t;
	scanf("%d",&k);
	for(int j=0;j<k;j++){
		int x,y;
		scanf("%d%d",&x,&y);
		t=a[x-1]-y;
		printf("%d\n",sum-t);
	}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9+5;
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    int W;
    cin >> W;
    vector<int> w(n+1);
    vector<int> v(n+1);
    for (int i=1; i<=n; i++) {
        cin >> w[i];
        cin >> v[i];
    }
    ll dp[n+1][W+1];
    dp[0][0] = 0;
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=W; j++) {
            dp[i][j] = 0;
        }
    }

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=W; j++) {
            if (w[i]<=j)
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


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

int main(){
  int n,l;
  cin>>n>>l;
  string s[101];
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;i++){
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
L=[ 0 for i in range(5)] 
for i in range(3):
	a,b=map(int, raw_input().split())
	L[a]+=1
	L[b]+=1

for i in range(1,5):
	if L[i]==0 or L[i]==3:
		print "NO"
		quit()
else:
	print "YES"


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

using vi = vector<int64_t>;
using pii = pair<int64_t,int64_t>;
const int64_t INF = 1e16;

struct edge{int64_t to; int64_t cost;};
using ve = vector<edge>;

vector<ve> tree(100010, ve());
vi dist(100010, INF);

void dijkstra(int64_t s){
  // first:最短距離 second:頂点番号
  priority_queue<pii, vector<pii>, greater<pii>> q; 
  dist[s] = 0; q.push(pii(0,s));

  while(!q.empty()){
    int64_t cur_d = q.top().first;
    int64_t cur_v = q.top().second;
    q.pop();

    if(cur_d > dist[cur_v]) continue;

    for(int64_t i=0; i<tree[cur_v].size(); i++){
      edge e = tree[cur_v][i];
      if(dist[cur_v] + e.cost < dist[e.to]){
        dist[e.to] = dist[cur_v] + e.cost;
        q.push(pii(dist[e.to], e.to));
      }
    }
  }
}


int main(){
  int64_t N, Q, K; edge e; 
  cin >> N;

  for(int64_t i=0; i<N-1; i++){
    int64_t a, b, c;
    cin >> a >> b >> c;

    e.to = b-1; e.cost = c; tree[a-1].push_back(e);
    e.to = a-1; e.cost = c; tree[b-1].push_back(e);
  }

  cin >> Q >> K;

  dijkstra(K-1);

  for(int64_t i=0; i<Q; i++){
    int64_t x, y; cin >> x >> y;
    cout << dist[x-1] + dist[y-1] << endl;
  }

}
  
  

Measured memory_bytes: 11120
'use strict';

function Main(input) {
  const S1 = input.split("")
  const S2 = input.split("")
  const len = S1.length
  
  // left to right
  let ans1 = 0
  for (let i=1; i<len; i++) {
    if (S1[i] === S1[i-1]) {
      ans1++
      if (S1[i] === "0") {
        S1[i] = "1"
      } else {
        S1[i] = "0"
      }
    }
  }

  // right to left
  let ans2 = 0
  for (let i=len-1; i>-1; i--) {
    if (S2[i] === S2[i+1]) {
      ans2++
      if (S2[i] === "0") {
        S2[i] = "1"
      } else {
        S2[i] = "0"
      }
    }
  }

  console.log(Math.min(ans1, ans2))

};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 13644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc074.contest.atcoder.jp/tasks/arc074_b>
問題文============================================================
 N を 1 以上の整数とします。
 
 長さ 3N の数列 a=(a1,a2,…,a3N) があります。
 すぬけ君は、a からちょうど N 個の要素を取り除き、残った 2N 個の要素を元の順序で並べ、
 長さ 2N の数列 a' を作ろうとしています。
 このとき、a' のスコアを (a'の前半N要素の総和)−(a'の後半N要素の総和) と定義します。
 
 a' のスコアの最大値を求めてください。
=================================================================

解説=============================================================

 この問題は [1...3N]を [1...x],[x+1...3N] の二つの区間に分けた時
 
 [1...x]の中に含まれる上からN個の大きい値の総和 - [x+1...3N]の中に含まれる上からN個の小さい値の総和
 
 が最も大きくなる時の値を求めよ
 
 と言い換えることができる
 
 よって、[1...x]の上からN個の大きい値総和、および[x+1...3N]の上からN個の小さい値の総和は
 priority_queue を用いることによって効率的に求めることができるので、
 xについてその総和を保存したテーブルを作っておくことによって
 [N...2N]の全てを確認して O(3N)で解ける
 
================================================================
*/
ll solve(){
    ll N; cin >> N;
    vector<ll> a(3*N);
    for(auto &in:a) cin >> in;
    ll ret = -LINF;
    
    vector<ll> Front(3*N,0);
    priority_queue<ll,vector<ll>,greater<ll>> pq1;
    for(int i = 0; i < N;i++){
        if(i == 0){
            Front[i] = a[i]; pq1.push(a[i]);
        }else{
            Front[i] = Front[i-1] + a[i];
            pq1.push(a[i]);
        }
    }
    for(ll i = N; i < 2*N;i++){
        Front[i] = Front[i-1] + a[i];
        pq1.push(a[i]);
        Front[i] -= pq1.top(); pq1.pop();
    }
    
    vector<ll> Back(3*N,0);
    priority_queue<ll> pq2;
    for(ll i = 3*N-1; i >= 2*N;i--){
        if(i == 3*N-1){
            Back[i] = a[i]; pq2.push(a[i]);
        }else{
            Back[i] = Back[i+1] + a[i];
            pq2.push(a[i]);
        }
    }
    for(ll i = 2*N-1; i >= N;i--){
        Back[i] = Back[i+1] + a[i];
        pq2.push(a[i]);
        Back[i] -= pq2.top(); pq2.pop();
    }
    
    for(ll i = N-1; i < 2*N;i++){
        ret = max(ret,Front[i] - Back[i+1]);
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 9588
#include <stdio.h>

int main(void)
{
	double kg;
	while(scanf("%lf",&kg)!=EOF){
		if(kg<=48.00){
		printf("light fly");
		}else if(kg<=51.00){printf("fly");
		}else if(kg<=54.00){printf("bantam");
		}else if(kg<=57.00){printf("feather");
		}else if(kg<=60.00){printf("light");
		}else if(kg<=64.00){printf("light welter");
		}else if(kg<=69.00){printf("welter");
		}else if(kg<=75.00){printf("light middle");
		}else if(kg<=81.00){printf("middle");
		}else if(kg<=91.00){printf("light heavy");
		}else if(kg>91.000){printf("heavy");
		}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 616