akhauriyash/Code-Regression huggingface dataset:
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = words
printer = unlines . (:[])

solver [ns,ks,ss] = a ++ (map C.toLower c) ++ d
  where
    k = (int ks) - 1
    (a,b) = splitAt k ss
    (c,d) = splitAt 1 b

Measured memory_bytes: 508
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main
{
    public static void main(String[] args) throws IOException
    {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String line =br.readLine(); 
	String[] f = line.split(" ");
	int a=Integer.parseInt(f[0]);
	int b=Integer.parseInt(f[1]);
	if (a < b) 
	    System.out.println("a < b");
	else if (a > b) 
	    System.out.println("a > b");
	else
	    System.out.println("a == b");
    }

}

Measured memory_bytes: 24440
s = input()
t = input()

s_list = list(s)
t_list = list(t)

s_sorted = sorted(s_list)
t_sorted = sorted(t_list, reverse=True)

s_joined = ''.join(s_sorted) 
t_joined = ''.join(t_sorted) 

if s_joined < t_joined:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9056
import java.util.Scanner;

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

    long A = scanner.nextLong();
    long B = scanner.nextLong();
    long N = scanner.nextLong();

    if (N >= B) {
      System.out.println(f(A, B, B - 1));
    } else {
      System.out.println(f(A, B, N));
    }
  }

  private static long f(long A, long B, long x) {
    long f = A * x / B;
    f -= A * (x / B);
    return f;
  }
}


Measured memory_bytes: 27036
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,i,max=0,k;
  	cin>>n;
  	string s[n];
  	string t[n];
  	for(i=0;i<n;i++)
    	cin>>s[i];
  	map<string,int>h;
  	for(auto c:s)
      h[c]++;
  	
  	for(auto j:h)
    {
      if(max<j.second)
        max=j.second;
    }
  	i=0;
  	for(auto l:h)
    {
      if(max==l.second)
      {
        t[i]=l.first;
        i++;
      }
    }
 	sort(t,t+i);
      for( k=0;k<i;k++)
        cout<<t[k]<<endl;
  	return 0;
}

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

class Dice1
{
protected:
  int number[6], num;

public:
  void SetNumber(int a, int b)
  {
    number[a] = b;
  }
  void SetData()
  {
    for(int i = 0; i < 6; i++)
    {
      cin >> num;
      SetNumber(i, num);
    }
  }
  int Number(int a)
  {
      return number[a];
  }
};

class Dice2 : public Dice1
{
private:
    int temporary;

public:
  void SetTemporary(int a)
  {
    temporary = a;
  }
  int Temporary()
  {
    return temporary;
  }
  void Rotation(int a, int b, int c, int d)
  {
    a--;
    b--;
    c--;
    d--;

    SetTemporary( Number(a) );
    SetNumber( a, Number(d) );
    SetNumber( d, Number(c) );
    SetNumber( c, Number(b) );
    SetNumber( b, Temporary() );
  }

  void Prepare(int a, int b)
  {
    if( a == Number(1) )
    {
      Rotation(1, 5, 6, 2);
    }
    if( a == Number(2) )
    {
      Rotation(1, 4, 6, 3);
    }
    if( a == Number(3) )
    {
      Rotation(1, 3, 6, 4);
    }
    if( a == Number(4) )
    {
      Rotation(1, 2, 6, 5);
    }
    if( a == Number(5) )
    {
      Rotation(1, 2, 6, 5);
      Rotation(1, 2, 6, 5);
    }

    if( b == Number(2) )
    {
      Rotation(3, 2, 4, 5);
    }
    if( b == Number(3) )
    {
      Rotation(4, 2, 3, 5);
    }
    if( b == Number(4) )
    {
      Rotation(5, 3, 2, 4);
      Rotation(5, 3, 2, 4);
    }
  }
};

int main()
{
  Dice1 dice1;
  Dice2 dice2;

  dice1.SetData();
  dice2.SetData();

  int count, finalJudge = 0;

  for(int i = 0; i < 2; i++)
  {
    for(int  j = 0; j < 6; j++)
    {
      if( dice1.Number(i) == dice2.Number(j) )
      {
        count++;
      }
    }
  }
  if( count == 0 )
  {
    finalJudge++;
  }

  if( finalJudge == 0 )
  {
    dice2.Prepare( dice1.Number(0), dice1.Number(1) );

    for(int i = 0; i < 6; i++)
    {
      if( dice1.Number(i) != dice2.Number(i) )
      {
          finalJudge++;
      }
    }
  }

  if( finalJudge == 0 )
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>

int main(void)
{
	int N,a,b;
	scanf("%d",&N);
	if(65<=N && N<=90){
		printf("1\n");
	}
	else if(97<=N && N<=122){
		printf("2\n");
	}
	else {
		printf("0\n");
	}
	return 0;
}



Measured memory_bytes: 2056
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 10000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define f0(s,a,b) for(lli s=a;s<b;s++)
#define f1(s,a,b) for(lli s=a;s<=b;s++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define print(x) cout<< #x <<"=" <<x<<"\n";
#define out(x) cout<<x;
#define  Y cout<<"YES\n";
#define N cout<<"NO\n";
lli dp[3001][3001];
int main()
{
    fast
    
        memset(dp,0,sizeof(dp));
       string x ,y;
       cin>>x>>y;
       lli m=x.size();
       lli n=y.size();
       for(lli i=1;i<=m;i++)
       {
            for(lli j=1;j<=n;j++)
            {
                if(x[i-1]==y[j-1])
                dp[i][j]=1+dp[i-1][j-1];
                else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
       }
       lli r=m,c=n;
       string ans="";
       while(r>0&&c>0)
       {
           if(x[r-1]==y[c-1])
           {
               ans.pb(x[r-1]);
               r--,c--;
           }
           else
           {
                if(dp[r-1][c]>dp[r][c-1])
                {
                    r--;
                }
                else
                {
                    c--;
                }
           }
       }
       reverse(ans.begin(),ans.end());
       cout<<ans;

    
    

}
//a+b=a⊕b+2∗(a &b)
//__builtin_popcount(number)
//cout<<fixed<<setpricision(8)<<output<<"\n";

Measured memory_bytes: 70656
import numpy as np
N=int(input()) 
c=input()

#print(c.count('R'),c.count('W'))

ANS=np.zeros(N+1)
CR=np.zeros(N+1)
CW=np.zeros(N+1)

CR[0]=c.count('R')
CW[N]=c.count('W')

ANS[0]=c.count('R')
ANS[N]=c.count('W')


for i in range(1,N+1):
  if(c[i-1]=='R'):
    CR[i] = CR[i-1] - 1
    CW[i] = CW[i-1]
  else:
    CR[i] = CR[i-1]
    CW[i] = CW[i-1] + 1
  ANS[i]=max(CR[i],CW[i])

print(int(min(ANS)))
#print(CR,CW)

Measured memory_bytes: 31612
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>


using namespace std;

int n;
int a[100005];

void oku(){
	scanf("%d",&n);

	for(int i=0;i<n;i++)
		scanf("%d", a + i);

	int c = 0;
	int ans = 0;
	for(int i=0;i<n;i++)
		if(a[i] == i + 1) c++;
	  else {
		  ans += (c+1) / 2;
			c = 0;
		}

	ans += (c+1) / 2;
	cout<<ans; 
}

int main(){

oku();
return 0;}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}

inline int gc(){
	static const int BUF = 1e7;
	static char buf[BUF], *bg = buf + BUF, *ed = bg;
	
	if(bg == ed) fread(bg = buf, 1, BUF, stdin);
	return *bg++;
} 

inline int ri(){
	int x = 0, f = 1, c = gc();
	for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
	for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
	return x*f;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

struct Vertex{
	VI edges;
	
};

struct Edge{
	int from, to;
	LL w;
};

int N;
Vertex V[maxN];
int vis[maxN];
int color[maxN];
Edge E[maxN << 1];
int elen;

queue< int > Q;
void bfs() {
	vis[1] = 1;
	Q.push(1);
	
	while(!Q.empty()) {
		int tmp = Q.front();
		Q.pop();
		
		foreach(i, V[tmp].edges) {
			Edge &x = E[*i];
			if(vis[x.to]) continue;
			vis[x.to] = 1;
			if(x.w % 2 == 0) color[x.to] = color[x.from];
			else color[x.to] = !color[x.from];
			Q.push(x.to);
		}	
	}
}

int main(){
	INIT(); 
	cin >> N;
	For(i, 1, N - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		V[u].edges.PB(elen);
		E[elen].from = u;
		E[elen].to = v;
		E[elen++].w = w;
		
		V[v].edges.PB(elen);
		E[elen].from = v;
		E[elen].to = u;
		E[elen++].w = w;
	}
	
	bfs();
	For(i, 2, N) {
		if(color[i] != color[i - 1]) break;
		if(i == N) color[1] = !color[1];
	}
	
	For(i, 1, N) cout << color[i] << endl;
    return 0;
}

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

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

const int MAX_N = 1e5 + 5;
int n, m, ans;
bool mark[MAX_N];
vector <int> G[MAX_N];

void dfs (int v) {
	mark[v] = true;
	for (int u: G[v])
		if (!mark[u])
			dfs(u);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u, w;
		cin >> v >> u >> w;
		v--, u--;

		G[v].push_back(u);
		G[u].push_back(v);
	}

	for (int i = 0; i < n; i++)
		if (!mark[i]) {
			ans++;
			dfs(i);
		}

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

Measured memory_bytes: 8960
#include <iostream>
#include <math.h>

int main() {

    int l, i = 0, a[2], ans;

    while (std::cin >> l) {
        a[i] = l;
        i++;
        if (i >= 2) {
            break;
        }
    }

    ans = floor((a[0] * 3 + a[1])/2.0);
    std::cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
    int a, b;
    while(~scanf("%d%d",&a,&b)){
            printf("%d\n",(a-1)*(b-1));
        }
        return 0;
}

Measured memory_bytes: 764
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 1;
		String[] s = new String[n];
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		Arrays.sort(s);
		for (int i = 0; i < s.length - 1; i++) {
			if (!s[i].equalsIgnoreCase(s[i + 1])) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}


int main(){
  ll n,m; cin >> n >> m;
  if(n > m/2){
    cout << m/2 << endl;
  } else {
    ll x = m/2 - n;
    cout << min(n+x/2,(m-x)/2) << endl;
  }
}


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

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

    int A, B;
    cin >> A >> B;
    vector<int> ans;
    ans.push_back(A + B);
    ans.push_back(A - B);
    ans.push_back(A * B);

    cout << *max_element(ans.begin(), ans.end()) << "\n";

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;


struct SegmentTree{
    int n;
    vector<int> value;
    int SIJK;

    SegmentTree(int N){
        SIJK = 0; // compareの内容に応じて変える
        n = 1;
        while(n < N) n *= 2;
        value.assign(2 * n - 1, SIJK);
    }

    int compare(int a, int b){
        return a + b; //問題に応じて変える
    }

    void update(int i, int x){
        i += n - 1;
        value[i] += x;
        while(i > 0){
            i = (i - 1)/2; // 親のノード
            value[i] = compare(value[2 * i + 1], value[2 * i + 2]);
        }
    }

    int find(int a, int b, int k = 0, int l = 0, int r = -1){
        // [a, b) の区間に対するクエリについて
        // ノード k （区間 [l, r) 担当）が答える
        if(r < 0) r = n;
        if(r <= a || b <= l) return SIJK;
        if(a <= l && r <= b) return value[k];
        else{
            int m = (l + r) / 2;
            int tmp1 = find(a, b, 2 * k + 1, l, m);
            int tmp2 = find(a, b, 2 * k + 2, m, r);
            return compare(tmp1, tmp2);
        }
    }


};


int main(){
    int N, Q;
    cin >> N >> Q;
    SegmentTree sg(N);
    rep(i, Q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            x--;
            sg.update(x, y);
        } 
        else{
            x--;
            y--;
            cout << sg.find(x, y + 1) << endl;
        } 
    }
}


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

int main(){
	int friends[501];
	int list[2][100000];
	int n, m;
	int first, second;
	int countFriend;
	int countList;

	while(cin >> n >> m, n || m){
		fill(friends, friends+501, 0);
		countList = 0;
		countFriend = 0;

		for(int i=0; i < m; i++){
			cin >> first >> second;
			if(first == 1) friends[second] = 1;
			else if(second == 1) friends[first] = 1;
			else {
				list[0][countList] = first;
				list[1][countList] = second;
				countList++;
			}
		}

		for(int i=0; i < countList; i++){
			if(friends[list[0][i]] == 1 && friends[list[1][i]] == 0)
				friends[list[1][i]] = 2;
			else if(friends[list[1][i]] == 1 && friends[list[0][i]] == 0)
				friends[list[0][i]] = 2;
		}
		for(int i=0; i < 502; i++){
			if(friends[i] != 0) countFriend++;
		}

		cout << countFriend << endl;
	}
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)

using namespace std;

int main(){
	int N,K,i,j;
	long dp[100001]={},h[100001],minCost;

	cin >> N >> K;
	myforFL(i,1,N+1){
		cin >> h[i];
	}
	dp[2] = abs(h[2]-h[1])+dp[1];
	myforFL(i,3,N+1){
		minCost = abs(h[i]-h[i-1])+dp[i-1];
		myforFL(j,2,K+1){
			if(i - j < 1)break;
			minCost = min(abs(h[i]-h[i-j])+dp[i-j],minCost);
		}
		dp[i] = minCost;
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main() {
    char str[1200];
    int num[26];
    int i,j,x;
    
    for (i=0; i<26; i++) {
        num[i]=0;
    }
    i=0;
    while (scanf("%c", &str[i])!=EOF) {
        i++;
    }
    
    for (j=0; j<i; j++){
        if (str[j]>='A' && str[j]<='Z') {
            x=str[j]-'A';
            num[x]++;
        }else if (str[j]>='a' && str[j]<='z') {
            x=str[j]-'a';
            num[x]++;
        }
    }
    
    for(i=0; i<26; i++) {
        printf("%c : %d\n", 'a'+i, num[i]);
    }
    
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

class Solution143D {
public:
    int Solve(vector<int> vec) {
        int count = 0;
        sort(vec.begin(), vec.end());
        for (int i = 0; i < vec.size(); ++i) {
            for (int j = i + 1; j < vec.size(); ++j) {
                int ab = vec[i] + vec[j];
                auto it = lower_bound(vec.begin()+j, vec.end(), ab);
                //cout << *it << endl;
                count += it - (vec.begin()+j) - 1;
            }
        }
        return count;
    }
};

int main() {
    int n, l;
    vector<int> vec;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> l;
        vec.push_back(l);
    }
    Solution143D sol;
    auto res = sol.Solve(vec);
    cout << res << endl;
}


Measured memory_bytes: 256
//Problem B
#include<bits/stdc++.h>
using namespace std;
int rd(){
    int a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}
const int N=107;
int x,y,n,m,a[N],b[N],mx=-100,mn=100;
#define WAR {printf("War");return 0;}
int main(){
    scanf("%d%d%d%d",&n,&m,&x,&y);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),mx=max(mx,a[i]);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]),mn=min(mn,b[i]);
    if(mx+1>mn)WAR
    if(y<mx+1||mn<x+1)WAR
    printf("No War");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
hist = [''] * 6

for _ in range(n):
  h = float(input())
  
  if h < 165:
    hist[0] += '*'
  elif 165 <= h < 170:
    hist[1] += "*"
  elif 170 <= h < 175:
    hist[2] += "*"
  elif 175 <= h < 180:
    hist[3] += "*"
  elif 180 <= h < 185:
    hist[4] += "*"
  else:
    hist[5] += "*"
  
for i in range(6):
  print(str(i+1) + ':' + hist[i])
 


Measured memory_bytes: 5612
import java.util.*;
import java.io.*;

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}

//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;
static int zz=0;
static void dfs(List<Integer>[] g,int s,boolean[] b){
    if(b[s])  return;
    zz++; b[s]=true;
    for(int xx:g[s]){
        if(!b[xx]) dfs(g,xx,b);
    }
}
public static void main(String[] args) throws  IOException{
                assign();
               int[] x=int_arr();
               int n=x[0],m=x[1];
               List<Integer>[] g=new ArrayList[n+1];
               for(int i=0;i<=n;i++){g[i]=new ArrayList<>();}
                for(int i=0;i<m;i++){
                    int[] e=int_arr();
                    g[e[0]].add(e[1]);
                    g[e[1]].add(e[0]);
                }
                
                boolean[] b=new boolean[n+1];
                int res=0;
                for(int i=1;i<=n;i++){
                    if(b[i]) continue;
                    dfs(g,i,b);
                    res=Math.max(res,zz);
                    zz=0;
                }
                out.write(res+"");
                out.flush();

    }
}

Measured memory_bytes: 103948
import java.util.ArrayList;
import java.util.Scanner;

//ALDS1_4_A
public class Main {
	void run() {
		int count = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int cmp = sc.nextInt();
			for (int k = 0; k < S.length; k++) {
				if (cmp == S[k]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 40280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  ll i,j,k,n=s.size();cin>>k;
  for(i=0;i<n-1;i++){
    if(s[i]=='a') continue;
    if('z'-s[i]+1<=k){
      k-='z'-s[i]+1;
      s[i]='a';
    }
    if(k==0) break;
  }
  s[n-1]=(((s[n-1]-'a')+k)%26)+'a';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 640
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

a, b, c = list(map(int, sys.stdin.buffer.readline().split()))

ok = 4 * a * b < (c - a - b) ** 2 and (c - a - b) > 0
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    string v;
    int j = 0;
    for (int i = 0; i < n; i++) {
        v[j] = s[i];
        j++;
        v[j] = t[i];
        j++;
    }
    for (int i = 0; i < n*2; i++) {
        cout << v[i];
    }
    cout << endl;
}

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

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


Measured memory_bytes: 256
a, b, k = list(map(int, input().split()))
                                                                                                      
y = a+k if a+k < b+1 else b+1
for i in range(a, y):
  print(i)

x = b-k+1 if b > k else 0
for i in range(x, b+1):
  if i > a+k-1:
    print(i)

Measured memory_bytes: 3060
import sys
import heapq
def input(): return sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    v = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        for j in range(i, n):
            h=[0]
            heapq.heapify(h)
            count = 0
            for p in range(i-1):
                heapq.heappush(h, v[p])
                count += 1
            for m in range(j+1, n):
                heapq.heappush(h, v[m])
                count += 1
            while h[0] < 0 and count < k:
                t = heapq.heappop(h)
                count += 1
            if count <= k:
                ans = max(ans,sum(h))
    counts = n
    heapq.heapify(v)
    while h[0] < 0 and counts < k:
        t = heapq.heappop(v)
        counts += 1
    if counts <= k:
        ans = max(ans,sum(v))
    print(ans)
   
if __name__ == '__main__':
    main()

Measured memory_bytes: 9268
a = gets.chomp.to_i
n = gets.chomp.split(" ").map(&:to_i)
flag = 1
count = 0
while flag == 1 
  flag = 0
  (a-1).downto(1) do |j|
    if n[j] < n[j-1]
      n[j],n[j-1] = n[j-1],n[j]
      flag = 1
      count += 1
    end
  end
end
n[0,a-1].each do |d|
  print("#{d} ")
end
puts("#{n[a-1]}")
puts count

Measured memory_bytes: 8716
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    int n;
    cin>>n;
    vi v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(all(v));
    while(1){
        bool flag = true;
        repi(i,1,n){
            if(v[i]%v[0]!=0){
                flag = false;
                int temp = v[0];
                v[0] = v[i] % v[0];
                v[i] = temp;
                break;
            }
        }
        if(flag){
            cout << v[0] << endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
    int n, l, count = 0;
    cin >> n >> l;
    if (l >= 0){
        for (int i = 2; i <= n; i++){
            count += l + i - 1;
        }
    } else {
        for (int i = 1; i <= n; i++){
            if(i == n && l + i - 1 < 0) break;
            count += l + i - 1;
        }
    }
    cout << count << endl;
    return 0;
}

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

ll p[10000005];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i) p[j]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) ans += p[i] * i;
    cout << ans << endl;
}


Measured memory_bytes: 81704
#include <bits/stdc++.h>
using namespace std;
#define elif else if
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG(x) cout << (x) << endl

ll arr[200005] = {0};

int main()
{
    ll k, n;
    scanf("%lld %lld", &k, &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", arr + i);
    }
    ll gap = (k - arr[n - 1]) + arr[0];
    for (int i = 1; i < n; i++)
    {
        gap = max(gap, arr[i] - arr[i - 1]);
    }
    printf("%lld\n", k - gap);
    return 0;
}


Measured memory_bytes: 1792
ALL = []
for i in range(3):
    A = list(map(int,input().split()))
    ALL.append(A)

for i in range(3):
    A = [ALL[0][i],ALL[1][i],ALL[2][i]]
    ALL.append(A)

ALL.append([ALL[0][0],ALL[1][1],ALL[2][2]])
ALL.append([ALL[0][2],ALL[1][1],ALL[2][0]])

N = int(input())
c = []
for i in range(N):
    c.append(int(input()))

j = 0
for i in ALL:
    if i[0] in c and i[1] in c and i[2] in c:
        j = 1
        break

if j == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		sc.close();
		out.println((n-1)*(m-1));
	}
}


Measured memory_bytes: 21972
#include<stdio.h>
#include<map>
#include<utility>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
struct unionfind{
  int par[100010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[100010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=0;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      par[x]=y;
    }
    else{
      par[y]=x;
      if(rank[x]==rank[y]){
        rank[x]++;
      }
    }
  }
};
int main(){
  const int INF=(1<<29);
  int n,m,i,x,z[5010];
  string a,b;
  map<string,int> store;
  map<int,int> store1;
  scanf("%d\n",&n);
  unionfind tree(n);
  for(i=0;i<n;i++){
    cin >> a >> x;
    store[a]=i;
    store1[i]=x;
  }
  scanf("%d\n",&m);
  for(i=0;i<m;i++){
    cin >> a >> b;
    tree.unite(store[a],store[b]);
  }
  for(i=0;i<n;i++){
    z[i]=INF;
  }
  for(i=0;i<n;i++){
    if(z[tree.root(i)]>store1[i]){
      z[tree.root(i)]=store1[i];
    }
  }
  int ans=0;
  for(i=0;i<n;i++){
    ans=ans+z[tree.root(i)];
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 4220
N = int(input())
S = str(input())
alphabet = ['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']
return_word = []
for i in range(len(S)):
  num = alphabet.index(S[i])
  return_num = N + num
  if return_num > 25:
    return_num = return_num - 26
  return_alphabet = alphabet[return_num]
  return_word.append(return_alphabet)
final = ''
for alpha in return_word:
  final += alpha
print(final)

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

#define int long long
const int N = 1005;

int n,m,a[N],s;

signed main() {
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i], s+=a[i];
    int c=0;
    for(int i=1;i<=n;i++) if(a[i]*4*m>=s) ++c;
    cout<<(c>=m?"Yes":"No");
}


Measured memory_bytes: 256
#include <unistd.h>
#include <stdlib.h>

char    *create_array(char *s, char *new_arr, char *t, int size)
{
	int i;
	int j;

	i = -1;
	while (s[++i])
		new_arr[i] = s[i];
	free(s);
	j = 0;
	while (j < size)
		new_arr[i++] = t[j++];   
	new_arr[i] = 0;
	return (new_arr);
}

char    *get_data(char *s)
{
	int     size;
	int     sum_size;
	char    t[1000];
	char    *new_arr;

	sum_size = 0;
	while ((size = read(0, t, 1000)))
	{
		if (size == -1)
			return (NULL);
		sum_size += size;
		if (!(new_arr = (char*)malloc(sum_size + 1)))
			return (NULL);
		s = create_array(s, new_arr, t, size);
	}
	return (s);
}

void    write_num(int num)
{
	char c;

	if (num < 10)
	{
		c = num + '0';
		write(1, &c, 1);
	}
	else
	{
		write_num(num / 10);
		write_num(num % 10);
	}
}

int     get_num(char *s, int pass_flag)
{
	int i;
	int num;
	int count;
	
    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (s[i++] != 10)
			;
	num = 0;
	while ('0' <= s[i] && s[i] <= '9')
		num = num * 10 + s[i++] - '0';
	return (num);
}

void    get_nums(int *array, char *s, int count)
{
	int num;
	int i;

	i = -1;
	while (s[++i] != 10)
	{
		if (s[i] != 32)
		{
			num = 0;
			while ('0' <= s[i] && s[i] <= '9')
			{
				num = num * 10 + s[i++] - '0';
				if (!s[i])
				{
					array[count] = num;
					return ;                    
				}
			}
			array[count++] = num;
			i--;
		}
	}  
}

void    get_nums_pass(int *nums, char *tmp, int pass_flag)
{
	int i;
	int count;

    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	get_nums(nums, &tmp[i], pass_flag - 1);
}

void    get_ans(char **s, int n, int *array)
{
	int i;
	int j;
	int ans;
	
	ans = 0;
	i = -1;
	while (++i < n)
	{
	    get_nums_pass(array, s, i + 1);
	    j = -1;
	    while (++j < i)
	    {
	        if (array[i] == array[j])
	        {
	            ans--;
	            break;
	        }
	    }
	    ans++;
	}
	write_num(ans);
}

int     main(void)
{
	char    *s;
	int     n;
	int     *nums;

	s = malloc(1);
	if (!(s = get_data(s)))
	    return (-1);
	n = get_num(s, 0);
	nums = (int*)malloc(sizeof(int) * n);
	get_ans(s, n, nums);
	free(s);
	free(nums);
	return (0);
}


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

int main() {
  int n,m;
  cin >> n >> m ;
  vector<int>h(n);
  vector<bool>ok(n,true);
  rep(i,n){
    cin >> h.at(i);
  }
  rep(i,m){
    int a,b ;
    cin >> a >> b;
    a--; b--;
    if(h.at(a)<=h.at(b)) ok[a]=false;
    if(h.at(b)<=h.at(a)) ok[b]=false;
  }
  int ans=0;
  rep(i,n){
    if(ok[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 3780
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int vect_x=x2-x1;
  int vect_y=y2-y1;

  int x3,x4,y3,y4;

  x3=x2-vect_y;
  y3=y2+vect_x;
  x4=x1-vect_y;
  y4=y1+vect_x;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
#include <string>
#include <vector>
#include <array>
#include <algorithm>

int main()
{
    int X, Y, A, B, C;

    scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);

    std::vector<int> p;
    std::vector<int> q;
    std::vector<int> r;
    r.reserve(C);

    for (int i = 0; i < A; ++i)
    {
        int t;
        scanf("%d", &t);
        p.push_back(t);
    }
    std::sort(p.begin(), p.end());
    std::reverse(p.begin(), p.end());

    for (int i = 0; i < B; ++i)
    {
        int t;
        scanf("%d", &t);
        q.push_back(t);
    }
    std::sort(q.begin(), q.end());
    std::reverse(q.begin(), q.end());

    for (int i = 0; i < C; ++i)
    {
        int t;
        scanf("%d", &t);
        r.push_back(t);
    }

    for (size_t i = 0; i < X; ++i)
    {
        r.push_back(p[i]);
    }
    for (size_t i = 0; i < Y; ++i)
    {
        r.push_back(q[i]);
    }

    std::sort(r.begin(), r.end());
    std::reverse(r.begin(), r.end());

    uint64_t total = 0;
    for (size_t i = 0; i < (X + Y); ++i)
    {
        total += r[i];
    }

    printf("%lld\n", total);

    return 0;
}


Measured memory_bytes: 2672
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define NUM 200

int main()
{
   static long i,j,k,l;
   static char p[1005];
   static char s[13];
   static char ch;
   static int sum[26];
   static char r[12] = "END_OF_TEXT";
   int cnt = 0;
   char ok;
   char end = 0;
   fgets(s,13,stdin);

   while(end == 0) {
      fgets(p,1010,stdin);
      for(i=0;p[i];i++) {
         if('a' <= p[i] && p[i]<= 'z' ||
            'A' <= p[i] && p[i]<= 'Z') {
               if(p[i] == r[0]) {
                  end = 1;
                  for(j=0;r[j];j++) {
                     if(p[i+j] != r[j]) {
                        end=0;break;
                     }
                  }
                  if(end)
                     break;
               }
               if(tolower(p[i]) == tolower(s[0])) {
                  ok = 1;
                  j = i;
                  for(;s[i-j] != '\n';i++) {
                     if(tolower(p[i]) != tolower(s[i-j])) {
                        ok=0;i--; break; 
                     }
                  }
                  if('a' <= p[i] && p[i]<= 'z' ||
                     'A' <= p[i] && p[i]<= 'Z')
                     ok=0;

                  if(ok) {
                     cnt++;
                     i--;
                  }
               }
         }
         for(;;i++){
            if('a' <= p[i] && p[i]<= 'z' ||
               'A' <= p[i] && p[i]<= 'Z');
            else break;
         }
      }
   }
   cout << cnt;
   cout << endl;




   return 0;
}

Measured memory_bytes: 1124
#include <stdio.h>

int main()
{
    int A1, A2, A3, sum;
    scanf("%d %d %d", &A1, &A2, &A3);

    sum = A1 + A2 + A3;
    
    if (sum >= 22) {
        printf("bust");
    }
    else {
        printf("win");
    }
    return 0;
}

Measured memory_bytes: 1704
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
	int N;
	cin >> N;
	string ans = "Three";
	rep(i, N){
		char s;
		cin >> s;
		if(s == 'Y'){
			ans = "Four";
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	int s[3];cin>>s[0]>>s[1]>>s[2];
	sort(s,s+3);

	if(s[0]+s[2]==s[1] || s[0]+s[1]==s[2])
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5+5;
int x[maxn],l[maxn],n,ans=0;
struct edge{
    int l,r;
}e[maxn];
bool cmp(edge a,edge b){
    return a.r<b.r;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>l[i];
        e[i].l=x[i]-l[i];
        e[i].r=x[i]+l[i];
    }
    sort(e+1,e+1+n,cmp);
    int tmp=e[1].r;
    ans++;
    for(int i=2;i<=n;i++){
        if(e[i].l>=tmp){
            ans++;
            tmp=e[i].r;
        }
        else
        {
            continue;
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1920
from collections import Counter
N = int(input())
S = list(input())
S_C = Counter(S)
left_num = S_C["E"]
if S[0] == "E":
    left_num -= 1
right_num = 0
ans = left_num + right_num
for i in range(1,N):
    # リーダーが左を向いていた時、-1
    if S[i] == "E":
        left_num -= 1
    if S[i-1] == "W":
        right_num += 1
    tmp_ans = left_num + right_num
    if ans > tmp_ans:
        ans = tmp_ans
print(ans)

Measured memory_bytes: 6304
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    char c;
    std::cin >> c;
    std::cout << (
        c=='a'||c=='e'||c=='i'||c=='o'||c=='u'
        ? "vowel"
        : "consonant"
    ) << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> lines = new List<int>();
            string readLine;

            do
            {
                readLine = Console.ReadLine();
                if (readLine != null)
                {
                    lines.Add(int.Parse(readLine));
                }
            }
            while (readLine != null);

            bool[] prime = new bool[999999];
            prime[0] = true;

            int max = 0;

            foreach (int line in lines)
            {

                if (max < line) 
                {
                    max = line;
                    
                    if (line <= 0)
                    {
                        Console.WriteLine(0);
                        continue;
                    }
                    if (max <= line) { }
                    double limit = Math.Sqrt(line);

                    for (int i = 2; i <= limit; i++)
                    {
                        if (!prime[i - 1])
                        {
                            for (int j = i + 1; j <= line; j++)
                            {
                                if (!prime[j - 1] && j % i == 0)
                                {
                                    prime[j - 1] = true;
                                }
                            }
                        }
                    }
                }
                Console.WriteLine(prime.Take(line).Where(c =>  !c).Count());

            }


        }

    }
}

Measured memory_bytes: 6876
/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 100010;

int a[MAXN];
int op[MAXN];
ll suf[MAXN];
ll pre[MAXN];

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri - 1;
	pre[0] = a[0] = ri;
	for(int i = 1; i <= n; i++) {
		char opt = ge;
		while(opt != '-' && opt != '+') opt = ge;
		op[i] = opt == '-' ? -1 : 1;
		a[i] = ri, pre[i] = pre[i - 1] + (opt == '-' ? -a[i] : a[i]);
	}

	for(int i = n; i >= 1; i--) suf[i] = suf[i + 1] + a[i];

	ll res = pre[n];
	int las = n + 1;
	for(int i = n; i >= 1; i--)
		if(op[i] == -1) {
			chkmax(res, pre[i - 1] + suf[las] * 2 - suf[i]);
			las = i;
		}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2816
inpl = lambda: list(map(int,input().split()))
N, M, X, Y = inpl()
x = inpl()
y = inpl()
 
x.append(X)
y.append(Y)
xmax = max(x)
ymin = min(y)
if xmax < ymin:
  print('No War')
else:
  print('War')

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

using namespace std;

#define COUT_PRECISION 10

namespace abreto {

const int MAXN = 200200;

int N;

void main(void) {
    int p = 0, remaining = 0, ai;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> ai;
        if (ai == p + 1) {
            p++;
            remaining++;
        }
    }

    if (remaining)
        cout << (N - remaining);
    else
        cout << "-1";

    cout << '\n';
}

}

int main(void) {
    cin.sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(COUT_PRECISION);
    abreto::main();
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            int N = nint(sc);
            long[] AList = longLine(sc, N);
            long lcm = 0;
//            for (int i=0; i<AList.length; i++){
//                if (i>=1){
//                    lcm = lcm(AList[i], lcm);
//                }else {
//                    lcm = AList[0];
//                }
//            }
//            long checknum = lcm -1;
//            long result = 0;
//            for (int i=0; i<AList.length; i++){
//               result += checknum % AList[i];
//            }
//            out.println(result);
            long result = 0;
            for (int i=0; i<AList.length; i++){
               result += AList[i] -1;
            }
            out.println(result);

        }
    }
    private static long lcm(long a, long b){
        return a * b /gcd( b, a % b);
    }
    private static long gcd(long a, long b){
        if (a < b) return gcd(b ,a );
        return b == 0 ? a : gcd( b, a % b);
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

Measured memory_bytes: 26836