akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int N, M;
    cin >> N;
    map<string, int> s;
    while (N--)
    {
        string x;
        cin >> x;
        s[x]++;
    }
    cin >> M;
    while (M--)
    {
        string y;
        cin >> y;
        s[y]--;
    }
    
    int ans = 0;
    for (auto a: s)
    {
        ans = max(a.second, ans);
    }
    
    cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final String N = sc.next();
		sc.close();
		int nums[] = new int[String.valueOf(N).length()];
		if(nums.length == 1) {
			System.out.println(N);
			return;
		}
		
		for(int i=0; i<nums.length; i++) nums[i] = Integer.parseInt(""+N.charAt(i));
		
		for(int i=nums.length-1; i>0; i--) {
			if(nums[i] != 9) {
				nums[i] = 9;
				for(int j=i-1; j>=0; j--) {
					if(nums[j] != 0) {
						nums[j]--;
						break;
					}
					else {
						nums[j] = 9;
					}
				}
			}
		}
		
		int sum = 0;
		for(int i=0; i<nums.length; i++) sum += nums[i];
		
		System.out.println(sum);
	}
}

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

int main(){
    int n;
    int a,b;
    int i,j;
    char t;
char t1[1000];
char t2[1000];
char t3[8];
    scanf("%s",&t1);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&t3);
        if(strcmp(t3,"replace")==0){
            scanf("%d %d %s",&a,&b,&t2);
            for(j=0;j<b-a+1;j++){
                t1[a+j]=t2[j];
            }
        }
        else if(strcmp(t3,"reverse")==0){
            scanf("%d %d",&a,&b);
            for(;a<b;){
                t=t1[a];
                t1[a]=t1[b];
                t1[b]=t;
                a++;
                b--;
            }
        }
        else if(strcmp(t3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<b+1;j++){
                printf("%c",t1[j]);
            }
             printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

long long gcd(int a, int b){
  if (a%b == 0){
    return(b);
  }
  else{
    return(gcd(b, a%b));
  }
}

int main(){    
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  int sum=0,i=0;

  while(i<A && i<K){
    sum += 1;
    i++;
  }
  while(i<A+B && i<K){
    sum += 0;
    i++;
  }
  while(i<A+B+C && i<K){
    sum += -1;
    i++;
  }
  
  
  cout << sum << endl;

}
 


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
#include <cstring>
int main() {
	int n;
	std::cin >> n;
	int a = n;
	for (int i = 1;i < (n / 4) + 1;++i) {
		if ((n - 4 * i) % 3 == 0&&(n-4*i)/3<=i) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
		return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

struct BIT{
private:
    vector<ll> a;
    int n;
public:
    BIT(int sz){
        n=sz;
        a.resize(sz+1);
    }
    ll sum(int i){
        ll res=0;
        while(i>0){
            res+=a[i];
            i-=i&-i;
        }
        return res;
    }
    ll sum(int i,int j){
        return sum(j)-sum(i-1);
    }
    void add(int i,ll x){
        while(i<=n){
            a[i]+=x;
            i+=i&-i;
        }
    }
};

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    ll ans=LINF;
    int p[n]={};
    for(int i=0;i<(n+1)/2;i++){
        p[n-1-i]=1;
    }
    do{
        bool flag=true;
        vector<pair<int,int>> ev;
        vector<pair<int,int>> od;
        for(int i=0;i<n;i++){
            if(p[i]){
                if(i%2==0)ev.push_back({a[i],i});
                else ev.push_back({b[i],i});
            }
            else{
                if(i%2==0)od.push_back({b[i],i});
                else od.push_back({a[i],i});
            }
        }
        sort(ev.begin(),ev.end());
        sort(od.begin(),od.end());
        int t=-1;
        ll sum=0;
        BIT bit(n);
        for(int i=0;i<(n/2)*2;i++){
            if(i%2==0){
                if(t>ev[i/2].first){
                    flag=false;
                    break;
                }
                t=ev[i/2].first;
                sum+=abs(ev[i/2].second+bit.sum(ev[i/2].second+1,n)-i);
                bit.add(ev[i/2].second+1,1);
            }
            else{
                if(t>od[i/2].first){
                    flag=false;
                    break;
                }
                t=od[i/2].first;
                sum+=abs(od[i/2].second+bit.sum(od[i/2].second+1,n)-i);
                bit.add(od[i/2].second+1,1);
            }
        }
        if(n&1&&t>ev.back().first){
            continue;
        }
        if(flag){
            ans=min(ans,sum);
        }
    }while(next_permutation(p,p+n));
    if(ans==LINF)cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 256
(* Vicfred
 * https://atcoder.jp/contests/abc149/tasks/abc149_b
 * implementation
 * *)
Scanf.scanf "%d %d %d\n" (fun a b k ->
    if k <= a then (a - k, b)
    else if k <= a+b then (0, b - k + a)
    else (0, 0)
) |> fun (x, y) -> Printf.printf "%d %d\n" x y



Measured memory_bytes: 3820
#include<stdio.h>
int main(void){
    int a[101][101], b[101], c[101];
    int n,m;
    int i,j;
    scanf("%d %d",&n,&m);
    for(i = 0;i < n;i++){
        for(j = 0;j < m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(j = 0;j < m;j++){
        scanf("%d\n",&b[j]);
    }
    for(i = 0;i < n;i++){
        c[i] = 0;
        for(j = 0;j < m;j++){
            c[i] += a[i][j] * b[j];
        }
    }
    for(i = 0;i < n;i++) printf("%d\n",c[i]);
}


Measured memory_bytes: 2108
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n;
    std::cin >> n;
    string s;
    std::cin >> s;
    vector<ll> a(n+1,0),b(n+1,0),c(n+1,0);
    for (int i = 0; i < n; i++) {
        a[i+1] = a[i];
        b[i+1] = b[i];
        c[i+1] = c[i];
        if(s[i]=='R'){
            a[i+1]++;
        }else if(s[i]=='G'){
            b[i+1]++;
        }else if(s[i]=='B'){
            c[i+1]++;
        }
    }
    ll cnt = 0;
    for (int i = 1; i < n-1; i++) {
        if(s[i]=='R'){
            cnt += b[i]*(c[n]-c[i])+c[i]*(b[n]-b[i]);
            ll now = 1;
            while(i+now<n&&i-now>=0){
                if((s[i+now]=='G'&&s[i-now]=='B')||(s[i+now]=='B'&&s[i-now]=='G')){
                    cnt--;
                }
                now++;
            }
        }else if(s[i]=='G'){
            cnt += a[i]*(c[n]-c[i])+c[i]*(a[n]-a[i]);
            ll now = 1;
            while(i+now<n&&i-now>=0){
                if((s[i+now]=='R'&&s[i-now]=='B')||(s[i+now]=='B'&&s[i-now]=='R')){
                    cnt--;
                }
                now++;
            }
        }else if(s[i]=='B'){
            cnt += b[i]*(a[n]-a[i])+a[i]*(b[n]-b[i]);
            ll now = 1;
            while(i+now<n&&i-now>=0){
                if((s[i+now]=='G'&&s[i-now]=='R')||(s[i+now]=='R'&&s[i-now]=='G')){
                    cnt--;
                }
                now++;
            }
        }
    }
    std::cout << cnt << std::endl;
}



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

int main()
{
    vector<int> entered_cars;
    int number;

    while (cin >> number)
    {
        if(number == 0)
        {
            int& x = entered_cars.back();
            cout << x << endl;
            entered_cars.pop_back(); 
        }
        else
        {
            entered_cars.push_back(number);
        }
    }

    return 0;
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int l = 0,r = 0;
  string tmp = s;
  rep(i,n){
    if(tmp[i] == '('){
      REP(j,i + 1,n){
        if(tmp[j] == ')'){
          tmp[i] = 'x',tmp[j] = 'x';
          break;
        }
      }
    }
  }
  rep(i,n){
    if(tmp[i] == '(')r++;
    else if(tmp[i] == ')')l++;
  }
  rep(i,l)cout << '(';
  cout << s;
  rep(i,r)cout << ')';
  cout << endl;
  return 0;
}


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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll mod = 1000000007

using namespace std;

int main(){
   int r;cin >> r;
   cout << r*r << endl; 

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

#include<vector>
void LCS(string& ret,string& s,string& t)
{
	int64_t N=max((int64_t)s.size(),(int64_t)t.size());
	ret="";
	vector<vector<int64_t>> dp(N+10,vector<int64_t>(N+10,0));

	for(int64_t i=1;i<=(int64_t)s.size();i++)
	{
		for(int64_t j=1;j<=(int64_t)t.size();j++)
		{
			dp[i][j]=max({dp[i-1][j-1],dp[i-1][j],dp[i][j-1]});
			if(s[i-1]==t[j-1])
				dp[i][j]=max({dp[i-1][j-1]+1,dp[i-1][j],dp[i][j-1]});
		}
	}

	for(int64_t i=(int64_t)s.size(),j=(int64_t)t.size(),k=0;k<dp[s.size()][t.size()];k++)
	{
		while(dp[i-1][j]==dp[i][j])i--;
		while(dp[i][j-1]==dp[i][j])j--;
		ret=s[i-1]+ret;
		i--;
		j--;
	}

	return;
}

int main()
{
	string s,t,ans="";
	
	cin >> s >> t;
	LCS(ans,s,t);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 71168
using System;
using System.Linq;

namespace ITP1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            Rectangle.ExistCrcl(data);
        }
    }
    class Rectangle
    {
        static public void ExistCrcl(int[] param)
        {
            int width = param[0];
            int height = param[1];
            int x = param[2];
            int y = param[3];
            int r = param[4];
            if (x <= 0 || x >= height ||
                y <= 0 || y >= width ||
                r > x || r > y ||
                r > (width - x) || r > (height - y)) Console.WriteLine("No");
            else Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 9436
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
#include <chrono>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef tuple<ll,ll,ll> tll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=250;
//templete
int main() {
	int A,B,C;
	cin>>A>>B>>C;
	cout<<min(B/A,C)<<endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	int N, A;
	scanf("%d %d", &N, &A);
	printf("%d\n", N*N - A);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int count=0;
		for(int i=0;i<s.length()-1;i++){
			if(s.charAt(i)!=s.charAt(i+1))count++;
		}
		System.out.println(count);
	}
 
}

Measured memory_bytes: 24272
#include<bits/stdc++.h>
using namespace std;
bool f(int x ,int y)
{
	return x>y;
}
int main()
{
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	sort(v.begin(),v.end(),f);
	long long int count = 0;
	for(int j=1;j<n;j++)
	{
		count+=v[int(floor(j/2))];
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 4020
import java.util.*;
public class Main{
  static Scanner sc = new Scanner(System.in);
  static char [][] map;
  static char ch;
  static int H;
  static int W;
  static int ans;

	public static void main(String [] args){
    while(solve()){
      System.out.println(ans);
    }
	}

  static boolean solve(){
    ans = 0;
    int tmp_x, tmp_y;
    int [] dx = {0, -1, 0, 1}, dy = {1, 0, -1, 0};
    H = sc.nextInt();
    W = sc.nextInt();
    if(H == 0 && W == 0)return false;
    readMap();
    Deque <Integer> x = new ArrayDeque <Integer>();
    Deque <Integer> y = new ArrayDeque <Integer>();
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(map[i][j] == '.') continue;
        x.offer(j);
        y.offer(i);
        while(!x.isEmpty()){
          tmp_x = x.poll();
          tmp_y = y.poll();
          ch = map[tmp_y][tmp_x];
          map[tmp_y][tmp_x] = '.';
          for(int k = 0; k < dx.length; k++){
            if(!check(tmp_x + dx[k], tmp_y + dy[k]))continue;
            if(ch == '.') continue;
            else if(ch == map[tmp_y + dy[k]][tmp_x + dx[k]]){
              x.offer(tmp_x + dx[k]);
              y.offer(tmp_y + dy[k]);
            }
          }
        }
        ans++;
      }
    }
    return true;
  }

  static boolean check(int x, int y){
    if(x < 0 || W <= x || y < 0 || H <= y) return false;
    else return true;
  }

  static void readMap(){
    map = new char[H][W];
    for(int i = 0; i < H; i++){
      map[i] = sc.next().toCharArray();
    }
    return;
  }
}

Measured memory_bytes: 22300
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    while(cin>>N, N){
        vector<vector<int>> members(N);
        for(int i=0; i<N; i++){
            int M; cin >> M;
            while(M--){
                int p; cin >> p;
                members[i].push_back(--p);
            }
        }
        int K; cin >> K;
        vector<int> leaked;
        for(int i=0; i<K; i++){
            int l; cin >> l;
            leaked.push_back(--l);
        }
        int mc = 0;
        int ans = -1;
        for(int i=0; i<N; i++){
            int count = 0;
            for(int l: leaked){
                for(int m: members[i]){
                    if(l == m)
                        count++;
                }
            }
            if(count == K){
                ans = i;
                mc++;
            }
        }
        cout << (mc == 1 ? ++ans : -1) << endl;
    }
    
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vector<vi> to(n), cost(n);
    rep(i, n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;
        to[u].pb(v); cost[u].pb(w);
        to[v].pb(u); cost[v].pb(w);
    }
    vi ans(n, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int p = q.front(); q.pop();
        rep (i, to[p].size()) {
            int t = to[p][i];
            int w = cost[p][i];
            if (ans[t] != -1) continue;
            ans[t] = (ans[p] + w) % 2;
            q.push(t);
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
long long t[600000];
int h[200001];
long long query(int index,int lb,int rb,int lq,int rq)
{
	if(lb==rb||(lq==lb&&rb==rq))
		return t[index];
	int mid=(lb+rb)/2;
	if(lq>mid)
		return query(index*2+1,mid+1,rb,lq,rq);
	else if(rq<=mid)
		return query(index*2,lb,mid,lq,rq);
	else
		return max(query(index*2,lb,mid,lq,mid),query(index*2+1,mid+1,rb,mid+1,rq));
}
long long update(int index,int lb,int rb,int leaf_id,long long value)
{
	if(lb==rb&&lb==leaf_id)
		return t[index]=value;
	int mid=(lb+rb)/2;
	if(leaf_id<=mid)
		return t[index]=max(t[index],update(index*2,lb,mid,leaf_id,value));
	else
		return t[index]=max(t[index],update(index*2+1,mid+1,rb,leaf_id,value));
}
int main()
{
	int i,n,a;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		update(1,1,n,h[i],query(1,1,n,1,h[i]-1)+a);
	}
	printf("%lld",t[1]);
	return 0;
}

Measured memory_bytes: 5120
using System;

public class MainAppC
{
    static public void Main(string[] args)
    {
        var items = Console.ReadLine().Split(' ');
        var a = int.Parse(items[0]);
        var b = int.Parse(items[1]);
        var h = int.Parse(items[2]);
        var m = int.Parse(items[3]);

        var theta = 2.0 * Math.PI * m / 60.0;
        var phi = Math.PI / 6 * (h % 12 + m / 60.0);


        var alpha = Math.Abs(theta - phi);      // なす角 (0 ~ pi)

        var c = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(alpha));
        Console.WriteLine(c);
    }
}



Measured memory_bytes: 18672
STR = input().split()
N = int(STR[0])
Y = int(STR[1])

x = -1
y = -1
z = -1
flag = False

for i in range(N+1):
    for j in range(N+1-i):
        if i*10000 + j*5000 + (N-i-j)*1000 == Y:
            flag = True
            x = i
            y = j
            z = N-i-j
            break
    if flag:
        break
    
    
str1 = str(x)
str2 = str(y)
str3 = str(z)
print(str1 + " " + str2 + " "+str3)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100003;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,na[N],ans=0;
	cin>>n;
	CLR(na);
	FOR(i,1,n+1){
		cin>>a;
		++a;
		++na[a];
		na[a-1]++;
		na[a+1]++;
	}
	FOR(i,0,N){
		ans=max(ans,na[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
def solve(N, M, X, books):
    ans = 10 ** 10
    f = "{:0" + str(N) + "b}"
    for k in range(2 ** N):
        cost = 0
        bins = f.format(k)
        powers = [0 for _ in range(M)]
        for i, b in enumerate(bins):
            if b == "1":
                cost += books[i][0]
                for m in range(M):
                    powers[m] += books[i][1][m]

        if all(p >= X for p in powers):
            ans = min(ans, cost)

    if ans == 10 ** 10:
        return -1
    return ans


if __name__ == "__main__":
    N, M, X = tuple(map(int, input().split(" ")))
    books = []
    for _ in range(N):
        k = list(map(int, input().split(" ")))
        books.append((k[0], k[1:]))
    print(solve(N, M, X, books))


Measured memory_bytes: 9268
#include<stdio.h>
int cnt,m,G[101];

int insertionSort(int *A, int n, int g){
  int i;
  for (i = g ;i< n;i++){
          int v = A[i];
          int j = i - g;
          while( j >= 0 && A[j] > v){
              A[j+g] = A[j];
              j = j - g;
              cnt++;
            }
          A[j+g] = v;
        }
}



void shellSort(int *A, int n){
     cnt = 0;
     int x=0;
     while(1){
       x=x*3+1;
       if(x>n)break;
       G[m++]=x;
     }
     int i;
     for (i = 0 ;i< m;i++)insertionSort(A, n, G[m-i-1]);
}




int main(){
  int n;
  scanf("%d",&n);
  int A[n],i;
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  shellSort(A,n);
  printf("%d\n",m );
  for(i=m-1;i>=0;i--){
    if(i!=0)printf("%d ",G[i]);
    else printf("%d\n%d\n",G[i],cnt );
  }
  for(i=0;i<n;i++)printf("%d\n",A[i] );
  return 0;
}



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



int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);*/

    long long int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;

    cin>>a>>b;
    cout<<abs(a-b)+1<<"\n";


    return 0;


}


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

ll N,Q;
string s;

int main(){
  cin >> N >> Q >> s;
  
  vector<ll> l(Q),r(Q);
  rep(i,Q) cin >> l[i] >> r[i];
  
  ll size = s.size();
  
  vector<ll> a;
  
  rep(i,size - 1){
    if(s[i] == 'A' && s[i + 1] == 'C'){
		a.PB(i);
    }
  }

  rep(i,Q){
    auto itr1 = lower_bound(a.begin(), a.end(), l[i] - 1);
    auto itr2 = lower_bound(a.begin(), a.end(), r[i] - 1);
    size_t pos1 = distance(a.begin(), itr1);
    size_t pos2 = distance(a.begin(), itr2);
    cout << pos2 - pos1 << endl;
  }
    
    
  
  
}

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <sstream>

using namespace std;
int getMaxProfit(int* ary, int ary_size);

int main()
{
	string str;
	getline(cin, str);
	int num;
	stringstream num_ss(str);
	num_ss >> num;

	int counter = 0;
	int* ary = new int[num];
	for (int i = 0; i < num; i++) {
		getline(cin, str);
		stringstream tmp_ss(str);
		tmp_ss >> ary[i];
	}
	
	cout << getMaxProfit(ary, num) << endl;
	return 0;
}


int getMaxProfit(int* ary, int ary_size) {
	int max_prf = ary[1] - ary[0];
	int min_num = (ary[1] > ary[0] ? ary[0] : ary[1]);
	for (int i = 2; i < ary_size; i++) {
		int tmp = ary[i] - min_num;
		if (tmp > max_prf) {
			max_prf = tmp;
		}
		min_num = (ary[i] < min_num ? ary[i] : min_num);
	}
	return max_prf;
}

Measured memory_bytes: 3936
// 解答不能.
// 以下のソースコードを勉強する.
// pekempey氏.
// https://atcoder.jp/contests/abc141/submissions/7549213
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;
char c[5005];

int main(){
    int N;
    scanf("%d %s", &N, c);
    string S(c);
    
    // SA-IS O(n)
    vector<int> sa(N + 1); rep(i, N + 1) sa[i] = i;
    sort(range(sa), [&](int i, int j){
        return S.substr(i) < S.substr(j);
    });
    // LCP O(n)
    vector<int> lcp(N + 1);
    rep(i, N){
        int h = 0;
        while(sa[i] + h < N && sa[i + 1] + h < N && S[sa[i] + h] == S[sa[i + 1] + h]) h++;
        lcp[i] = h;
    }
    
    vector<int> ord(N);
    rep(i, N) ord[i] = i;
    // counting sort O(n)
    sort(range(ord), [&](int i, int j) { return lcp[i] > lcp[j]; });
    
    vector<int> par(N + 1); rep(i, N + 1) par[i] = i;
    vector<int> mn(N + 1), mx(N + 1);
    rep(i, N + 1) mn[i] = mx[i] = sa[i];
    auto find = [&](int x) -> int {
        while(x != par[x]) x = par[x];
        return x;
    };
    auto unite = [&](int x, int y){
        x = find(x);
        y = find(y);
        mn[x] = min(mn[x], mn[y]);
        mx[x] = max(mx[x], mx[y]);
        par[y] = x;
    };
    
    // O(n*a(n))
    int ans = 0;
    for(int i : ord){
        unite(i, i + 1);
        int r = find(i);
        ans = max(ans, min(lcp[i], mx[r] - mn[r]));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

    public static void check(String line) {
        Map<String, String> result = new HashMap<String, String>();
        for (int i = 0; i < line.length(); i++) {
            result.put(line.substring(i, i + 1), "");
        }
        if (result.size() == 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }

int main() {
    int n, X;
    cin >> n >> X;
    vec x(n);
    rep(i, n) cin >> x[i];

    vec d(n);
    rep(i, n) d[i] = abs(X - x[i]);

    lint res = 0;

    rep(i, n) res = gcd(res, d[i]);

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

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int A, B, C;
	int K;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> K;

	int n = 0;
	while (B <= A) {
		B *= 2;
		n++;
	}
	while (C <= B) {
		C *= 2;
		n++;
	}

	//LOG(n);
	//LOG(K);
	if (n <= K) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}

Measured memory_bytes: 3640
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())

ans=1
for a in A:
    if a==0:
        ans*=a
    elif ans==-1:
        pass
    else:
        ans*=a
        if 10**18<ans:
            ans=-1

if 10**18<ans:
    print -1
else:
    print ans


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

int main(){
    int n;
    cin>>n;
    string s[60];
    rep(i,n)cin>>s[i];
    string ans;
    for(char c='a';c<='z';c++){
        int small=300;
        for(int i=0;i<n;i++){
            int cnt=0;
            for(int j=0;j<s[i].size();j++){
                if(s[i][j]==c)cnt++;
            }
            small=min(small,cnt);
        }
        for(int i=0;i<small;i++)ans+=c;
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long li;

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

    auto score = [&](const li i) {
        return min(n + i, (m - 2 * i) / 2);
    };

    li l = 0, r = m / 2 + 1;
    while (r - l > 10) {
        li ml = (l * 2 + r) / 3;
        li mr = (l + r * 2) / 3;

        if (score(ml) > score(mr)) {
            r = mr;
        } else {
            l = ml;
        }
    }


    li ans = 0;
    for (li i = l; i < r; ++i) {
        ans = max(ans, score(i));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
struct mod_util {
  vector<long long> fac,finv,inv;
  int mod = -1;
  void init(int n , int mod){
    fac.resize(n);
    finv.resize(n);
    inv.resize(n);
    this->mod = mod;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[0] = 0;
    inv[1] = 1;
    for(int i=2;i<n;i++){
      fac[i] = fac[i-1] * i % mod;
      inv[i] = mod - inv[mod%i] * (mod / i) % mod;
      finv[i] = finv[i-1] * inv[i] % mod;
    }
  }

  long long nCk(int n, int k){
      assert(mod != -1);

      if(n < k)return 0;
      if(n < 0 || k < 0)return 0;

      return fac[n] * (finv[n-k] * finv[k] % mod) % mod;
  }

  long long nPk(int n, int k){
    assert(mod != -1);

    if(n < k)return 0;
    if(n < 0 || k < 0)return 0;

    return fac[n] * finv[n-k] % mod;
  }

  // a^x を modで割った余り
  int pow_mod(int a , int x , int mod){
    long long res = 1;
    long long pow = a;
    while(x > 0){
      if(x & 1){
        res *= pow;
        res %= mod;
      }

      pow *= pow;
      x >>= 1;
    }
    return (int)res;
  }
};
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  mod_util mu;
  
  int n,m;
  cin >> n >> m;
  mu.init(max(n,m)+1,MOD);
  if(n == m){
    cout << mu.nPk(n,n) * mu.nPk(m,m) % MOD * 2 % MOD << endl;
  }else if(abs(n-m)==1){
    cout << mu.nPk(n,n) * mu.nPk(m,m) % MOD  << endl;
  }else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
 
int main() {
    int n;
    while (scanf("%d", &n), n) {
        map<string, int>mp;
        string s; int Max = 0;
        int d = 0;
        for (int i = 1; i <= n; i++) {
            string c; cin >> c;
            mp[c]++;
            if (mp[c] > Max) { s = c; Max = mp[c]; }
            int sec = 0;
            for (auto&& p : mp) {
                if (p.first != s&&sec < p.second)sec = p.second;
            }
            if (sec + n - i < Max && !d)d = i;
        }
        if (!d)puts("TIE");
        else cout << s << ' ' << d << endl;
    }
}

Measured memory_bytes: 3056
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
for b in B:
    for i in range(3):
        if b in A[i]:
            A[i][A[i].index(b)]=0
            
a=[]
            
def tate(X,i,c):
    cnt=0
    for j in range(3):
        if X[j][i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)
        
def yoko(X,i,c):
    cnt=0
    for j in range(3):
        if X[i][j]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)
        
def naname(X,c):
    cnt=0
    for i in range(3):
        if X[i][i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)

def naname2(X,c):
    cnt=0
    for i in range(3):
        if X[i][2-i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)

            
for i in range(3):
    tate(A,i,a)
    yoko(A,i,a)
naname(A,a)
naname2(A,a)
    
if len(a)==0:
    print("No")
else:
    print("Yes")
    


Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt(),f=0,i,j;
		scan.close();
		for(i=0;i<=n;i++) {
			for(j=0;j<=n;j++) {
				if(4*i+7*j==n) {
					if(f==0) System.out.print("Yes");
					f=1;
				}
			}
		}
		if(f==0) System.out.print("No");
	}
}

Measured memory_bytes: 21844
N = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


res = 0
for p, e in factorization(N):
    if p == 1:
        continue
    i = 1
    E = e
    while E > 0:
        i += 1
        E = E - i
    res += i - 1

print(res)


Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 110;
int wei[MAXN], val[MAXN];
ll dp[MAXN][(int) 1e5 + 10];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, w;
	cin >> n >> w;
	rep (i, 1, n) {
		cin >> wei[i] >> val[i];
	}
	ll ans = 0;
	rep (i, 1, n) {
		rep (j, 0, w) {
			dp[i][j] = dp[i - 1][j];
			if (j >= wei[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - wei[i]] +val[i]);
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define ALL(a) a.begin(), a.end()
#define REP(i,a) for(ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i,a,b) for(ll i(a), _##i(b); i <= _##i; ++i)
using namespace std;
using ll = long long;

void solve(){
    ll n, k;
    cin >> n >> k;
    if (n <= k) cout << min(n, k - n) << "\n";
    else {
        ll m = n % k;
        if (m == 0) cout << "0\n";
        else cout << min(m, k % m) << "\n";
    }
}

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

    int T = 1;
    //cin >> T;
    FOR(i,1,T){
        solve();
    }
}


Measured memory_bytes: 384
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define nl "\n"
#define fout(x) fixed<<setprecision(x)
#define one(x) __builtin_popcountll(x)
#define F first
#define S second
#define or_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(), order_of_key()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << fout(10)<<x;}
void __print(double x) {cerr << fout(10)<<x;}
void __print(long double x) {cerr << fout(10)<<x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod=1e9+7;
const double eps=1e-9;
const double PI=acos(-1.0);

ll qpow(ll n,ll k){ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


// ****************************************************



int main()
{
    int n;
    cin>>n;
    double ans=2*PI*n;//<<endl;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 3780
<?php
$NMXY = fgets(STDIN);
$N = (int)explode(" ",$NMXY)[0];
$M = (int)explode(" ",$NMXY)[1];
$X = (int)explode(" ",$NMXY)[2];
$Y = (int)explode(" ",$NMXY)[3];
$xArray = array_map("intval",explode(" ",fgets(STDIN)));
$xMax = max($xArray);
$yArray = array_map("intval",explode(" ",fgets(STDIN)));
$yMin = min($yArray);
foreach (range($X+1,$Y) as $num){
    if($xMax < $num and $yMin >= $num){
        echo "No War";
        exit();
    }else{
    }
}
echo "War";
?>

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll Q;
    cin >> Q;
    vector<ll> B(Q);
    vector<ll> C(Q);
    rep(i, Q) cin >> B[i] >> C[i];

    vector<ll> num(100100, 0);
    ll ans = 0;
    rep(i, N){
        num[A[i]]++;
        ans += A[i];
    }

    rep(i, Q){
        ans += num[B[i]] * (C[i] - B[i]);
        num[C[i]] = num[C[i]] + num[B[i]];
        num[B[i]] = 0;
        cout << ans << endl;
    } 

    return 0;
}


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

lli n;

int main(void){
	cin >> n;
	vector<lli> a(n+2);
	vector<lli> da(n+1);
	vector<lli> dda(n);
	for(int i = 1; i <= n; i++) cin >> a[i];
	lli sum = 0;
	for(int i = 0; i <= n; i++){
		da[i] = abs(a[i+1]-a[i]);
		sum += da[i];
	}
	for(int i = 0; i <= n-1; i++){
		dda[i] = abs(a[i+2]-a[i]);
	}
	rep(i, n){
		cout << sum-da[i]-da[i+1]+dda[i] << endl;
	}

	return 0;
}


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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >  
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
 FLASH;
 int n,m,x;
 cin>>n>>m>>x;
 int arr[m];
 for(int i=0;i<m;i++)
 {
 	cin>>arr[i];
 }
 int cnt=0,cnt1=0;
 for(int i=0;i<m;i++)
 {
 if(arr[i]<x){cnt++;}
 if(arr[i]>x){cnt1++;} 
 
 }
 cout<<min(cnt,cnt1)<<endl;
}



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

int main() {
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    int ans=0;
    rep(i,n-2){
        if(p[i]<p[i+1] && p[i+1]<p[i+2]) ans++;
        else if(p[i+2]<p[i+1] && p[i+1]<p[i]) ans++;
    }
    cout<<ans<<endl;
}

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

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

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl

int N;
char tfs[3] = {'3', '5', '7'};

int dfs(string s) {
  int ans;
  if (stol(s) > N)
    return 0;
  else {
    int three, five, seven;
    three = 0;
    five = 0;
    seven = 0;
    FOR(i, 0, s.length()) {
      if (s[i] == '3') three++;
      if (s[i] == '5') five++;
      if (s[i] == '7') seven++;
    }
    ans = (three > 0 && five > 0 && seven > 0) ? 1 : 0;
  }

  for (auto c : tfs) {
    ans += dfs(s + c);
  }

  return ans;
}

int main() {
  cin >> N;
  int rep = dfs("0");
  cout << rep << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;


int main()
{
    int N;
    int height[21];
    int count = 0;
    int tmp = 0;
    cin >> N;
    for(int i=0; i<N; i++)  cin >> height[i];

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

            if(height[i] < height[j])   tmp++;
        }
        if(tmp != 0)    count ++;
        tmp = 0;
    }

    cout << N - count;

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    X= int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    pi=math.pi
    vec=[1,0]
    ca=0
    cur=[0,0]
    count=0
    count+=1
    cur[0]+=vec[0]
    cur[1]+=vec[1]
    ca=(ca+X)%360
    vec[0]=math.cos(ca/180*pi)
    vec[1]=math.sin(ca/180*pi)
    #print(ca,vec)
    while cur[0]**2+cur[1]**2>1e-8:
        count+=1
        cur[0]+=vec[0]
        cur[1]+=vec[1]
        ca=(ca+X)%360
        vec[0]=math.cos(ca/180*pi)
        vec[1]=math.sin(ca/180*pi)
        #print(ca,cur)
    print(count)






if __name__ == "__main__":
    main()

Measured memory_bytes: 73108